Exemple #1
0
 public WindowBaseView(WindowBaseViewModel model)
 {
     _model = model;
     _model.Surface = this;
     DataContext = _model;
     InitializeComponent();
 }
Exemple #2
0
		public static void ShowWindow(WindowBaseViewModel windowBaseViewModel)
		{
			if (!FindWindowIdentity(windowBaseViewModel))
			{
				var windowBaseView = new WindowBaseView(windowBaseViewModel);
				PrepareWindow(windowBaseViewModel);
				windowBaseView.Show();
			}
		}
Exemple #3
0
 public static void ShowWindow(WindowBaseViewModel model)
 {
     if (!FindWindowIdentity(model))
     {
         WindowBaseView win = new WindowBaseView(model);
         PrepareWindow(model);
         win.Show();
     }
 }
		public WindowBaseView(WindowBaseViewModel model)
		{
			ContentRendered += new EventHandler(WindowBaseView_ContentRendered);
			if (model != null)
			{
				_model = model;
				_model.SetSurface(this);
				DataContext = _model;
			}
			InitializeComponent();
			Loaded += (s, e) => MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
		}
Exemple #5
0
		public static bool ShowModalWindow(WindowBaseViewModel windowBaseViewModel)
		{
			try
			{
				WindowBaseView win = new WindowBaseView(windowBaseViewModel);
				PrepareWindow(windowBaseViewModel);
				bool? result = win.ShowDialog();
				return result.HasValue ? result.Value : false;
			}
			catch (Exception e)
			{
				Logger.Error(e, "DialogService.ShowModalWindow");
			}
			return false;
		}
Exemple #6
0
		static bool FindWindowIdentity(WindowBaseViewModel windowBaseViewModel)
		{
			var identityModel = windowBaseViewModel as IWindowIdentity;
			if (identityModel != null)
			{
				WindowBaseViewModel openedWindow = (WindowBaseViewModel)_openedWindows.FirstOrDefault(x => x.Guid == identityModel.Guid);
				if (openedWindow != null && openedWindow.Surface != null)
				{
					openedWindow.Surface.Activate();
					return true;
				}
				windowBaseViewModel.Closed += (s, e) => _openedWindows.Remove((IWindowIdentity)s);
				_openedWindows.Add(identityModel);
			}
			return false;
		}
Exemple #7
0
 public static bool ShowModalWindow(WindowBaseViewModel model, bool allowsTransparency = true)
 {
     try
     {
         WindowBaseView win = new WindowBaseView(model);
         win.AllowsTransparency = allowsTransparency;
         PrepareWindow(model);
         bool? result = win.ShowDialog();
         return result.HasValue ? result.Value : false;
     }
     catch (Exception e)
     {
         Logger.Error(e, "Исключение при вызове DialogService.ShowModalWindow");
         throw;
     }
 }
Exemple #8
0
		public void ShowWindow(WindowBaseViewModel windowBaseViewModel)
		{
			if (OnShow != null)
				OnShow(windowBaseViewModel);
		}
Exemple #9
0
		public bool ShowModalWindow(WindowBaseViewModel windowBaseViewModel)
		{
			if (OnShowModal != null)
				OnShowModal(windowBaseViewModel);
			return windowBaseViewModel.CloseResult == null ? false : windowBaseViewModel.CloseResult.Value;
		}
Exemple #10
0
		static void SetWindowProperty(WindowBaseViewModel windowBaseViewModel)
		{
			windowBaseViewModel.Surface.Owner = GetActiveWindow();
			windowBaseViewModel.Surface.ShowInTaskbar = windowBaseViewModel.Surface.Owner == null;
			windowBaseViewModel.Surface.WindowStartupLocation = windowBaseViewModel.Surface.Owner == null ? WindowStartupLocation.CenterScreen : WindowStartupLocation.CenterOwner;
		}
Exemple #11
0
		static void PrepareWindow(WindowBaseViewModel model)
		{
			SetWindowProperty(model);
		}
Exemple #12
0
		public void ShowWindow(WindowBaseViewModel windowBaseViewModel)
		{
			DialogService.ShowWindow(windowBaseViewModel);
		}
Exemple #13
0
		public bool ShowModalWindow(WindowBaseViewModel windowBaseViewModel)
		{
			return DialogService.ShowModalWindow(windowBaseViewModel);
		}
Exemple #14
0
 private static void PrepareWindow(WindowBaseViewModel model)
 {
     SetWindowProperty(model);
     UpdateWindowSize(model);
 }
Exemple #15
0
 private static void UpdateWindowSize(WindowBaseViewModel model)
 {
     string key = model.GetType().AssemblyQualifiedName;
     var isSaveSize = model.GetType().GetCustomAttributes(typeof(SaveSizeAttribute), true).Length > 0;
     if (isSaveSize && Properties.Settings.Default.WindowSizeState.ContainsKey(key))
     {
         Rect rect = Rect.Parse(Properties.Settings.Default.WindowSizeState[key]);
         model.Surface.Top = rect.X;
         model.Surface.Left = rect.Y;
         model.Surface.Width = rect.Width;
         model.Surface.Height = rect.Height;
         model.Closed += SaveWindowSize;
     }
 }