using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;
using System.Drawing;
using SPC.Kiosk.Base;
using SPC.Kiosk.Common;
using System.Windows.Threading;
using SPC.Kiosk.Popup.Model;
using SPC.Kiosk.Popup.ViewModel;
namespace SPC.Kiosk.Popup
{
///
/// CallEmployee.xaml에 대한 상호 작용 논리
///
public partial class MiniPopup : Window
{
#region [ Members ]
private int ScreenNo { get; set; } = 0;
private VmMiniPopup ViewModel { get; set; }
private M_MiniPopup GetMiniPopup { get; set; }
#endregion Members
#region [ Ctor ]
///
/// Ctor
///
public MiniPopup(M_MiniPopup _getMiniPopup)
{
GetMiniPopup = _getMiniPopup;
InitializeComponent();
this.ContentRendered += MiniPopup_ContentRendered;
this.Loaded += MiniPopup_Loaded;
this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left;
this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top;
this.Width = Screen.AllScreens[ScreenNo].Bounds.Width;
this.Height = Screen.AllScreens[ScreenNo].Bounds.Height;
}
#endregion Ctor
#region [ Methods ]
private void OpenWindow()
{
var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase
, OpenCloseAnimationType.FullSizeUp
, this.FrameBase.Height
, 0.5
, 0.2);
if (OpenAnimations != null)
{
OpenAnimations.Begin();
}
}
private void CloseWindow()
{
var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase
, OpenCloseAnimationType.FullSizeDown
, this.FrameBase.Height
, 0.5
, 0.2);
if (CloseAnimation != null)
{
CloseAnimation.Completed += CloseAnimation_Completed;
CloseAnimation.Begin();
}
}
#endregion Methods
#region [ Event Handlers ]
private void CloseAnimation_Completed(object sender, EventArgs e)
{
this.ContentRendered -= MiniPopup_ContentRendered;
this.Loaded -= MiniPopup_Loaded;
this.ViewModel.Dispose();
this.Close();
}
private void MiniPopup_ContentRendered(object sender, EventArgs e)
{
this.FrameBase.Width = 800;
this.FrameBase.Height = 540;
OpenWindow();
}
private void MiniPopup_Loaded(object sender, RoutedEventArgs e)
{
if (this.DataContext is VmMiniPopup viewModel)
{
ViewModel = viewModel;
ViewModel.PropertyChanged += ViewModel_PropertyChanged;
ViewModel.MiniPopup = GetMiniPopup;
ViewModel.IsTimeoutPopup = false;
}
this.FrameBase.Width = 0;
this.FrameBase.Height = 0;
}
private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
switch (e.PropertyName)
{
case "CanWindowClose":
if (this.ViewModel.CanWindowClose)
{
CloseWindow();
}
break;
case "SubMessageText":
if (string.IsNullOrEmpty(ViewModel.SubMessageText.GetLanguageData(ViewModel.ShowLanguageType)))
{
Message2.Visibility = Visibility.Collapsed;
}
else
{
Message2.Visibility = Visibility.Visible;
}
break;
}
}
#endregion Event Handlers
}
}