protected override Window EnsureWindow(object model, object view, bool isDialog) { Window window = view as BaseWindow; if (window == null) { if (isDialog) { window = new BaseDialogWindow { Content = view, SizeToContent = SizeToContent.WidthAndHeight }; } else { window = new BaseWindow { Content = view, SizeToContent = SizeToContent.Manual }; } window.SetValue(View.IsGeneratedProperty, true); } else { Window owner2 = InferOwnerOf(window); if (owner2 != null && isDialog) { window.Owner = owner2; } } return(window); }
public static T OpenDialog <T>(BaseDialogViewModel <T> viewModel) { IDialogWindow window = new BaseDialogWindow(); window.DataContext = viewModel; window.ShowDialog(); return(viewModel.DialogResult); }
/// <summary> /// Selects a base window depending on the view, model and dialog options /// </summary> /// <param name="model">The model</param> /// <param name="view">The view</param> /// <param name="isDialog">Whether it's a dialog</param> /// <returns>The proper window</returns> protected override Window EnsureWindow(object model, object view, bool isDialog) { Window window = view as BaseWindow; if (window == null) { if (isDialog) { if (model.GetType() == typeof(LoaderViewModel)) { window = new SplashDialogWindow { Content = view, SizeToContent = SizeToContent.WidthAndHeight }; } else if (model.GetType() == typeof(MetroMessageBoxViewModel)) { window = new BaseMessageDialogWindow { Content = view, SizeToContent = SizeToContent.WidthAndHeight }; } else { window = new BaseDialogWindow { Content = view, SizeToContent = SizeToContent.WidthAndHeight }; } } else { window = new BaseWindow { Content = view, ResizeMode = ResizeMode.CanResizeWithGrip, SizeToContent = SizeToContent.Height }; } window.SetValue(View.IsGeneratedProperty, true); } else { Window owner = InferOwnerOf(window); if (owner != null && isDialog) { window.Owner = owner; } } return(window); }
/// <summary> /// Selects a base window depending on the view, model and dialog options /// </summary> /// <param name="model">The model</param> /// <param name="view">The view</param> /// <param name="isDialog">Whether it's a dialog</param> /// <returns>The proper window</returns> protected override Window EnsureWindow(object model, object view, bool isDialog) { var window = view as Window; if (window == null) { if (isDialog) { window = new BaseDialogWindow { Content = view, WindowStartupLocation = WindowStartupLocation.CenterOwner, SizeToContent = SizeToContent.WidthAndHeight }; } else { window = new BaseWindow { Content = view, SizeToContent = SizeToContent.Manual, WindowStartupLocation = WindowStartupLocation.CenterScreen, ResizeMode = ResizeMode.CanResizeWithGrip }; ((BaseWindow)window).LeftWindowCommands .SetBinding(FrameworkElement.DataContextProperty, new Binding { Path = new PropertyPath(nameof(FrameworkElement.DataContext)), Source = view, Mode = BindingMode.OneWay }); var windowName = view.GetType().FullName ?? string.Empty; if (_store != null) { var isMainWindows = windowName.EndsWith(@".ShellView", StringComparison.OrdinalIgnoreCase) && Application.Current.Windows.Count == 1; window.AttachPositionHandler(_store, windowName, isMainWindows); } } window.SetValue(View.IsGeneratedProperty, true); } var owner = InferOwnerOf(window); if (owner != null && isDialog) { window.Owner = owner; } return(window); }
protected override Window EnsureWindow(object model, object view, bool isDialog) { Window window = view as BaseWindow; if (window == null) { if (isDialog) { var dialogMessage = view as MetroMessageBoxView; if (dialogMessage == null) { //normal Dialog window = new BaseDialogWindow { Content = view, SizeToContent = SizeToContent.WidthAndHeight }; } else { window = new BaseMessageDialogWindow { Content = view, SizeToContent = SizeToContent.WidthAndHeight, ShowTitleBar = false, ShowCloseButton = false, ResizeMode = ResizeMode.NoResize, WindowStyle = WindowStyle.None, WindowState = WindowState.Normal }; } } else { window = new BaseWindow { Content = view, ResizeMode = ResizeMode.CanResizeWithGrip, SizeToContent = SizeToContent.Height }; } window.SetValue(View.IsGeneratedProperty, true); } else { var owner = InferOwnerOf(window); if (owner != null && isDialog) { window.Owner = owner; } } return(window); }
public void ShowAboutWindow() { var baseDialogViewModel = new BaseDialogViewModel(Properties.strings.About); var aboutViewModel = new AboutViewModel(Properties.strings.About); baseDialogViewModel.CurrentViewModel = aboutViewModel; var baseDialog = new BaseDialogWindow { DataContext = baseDialogViewModel }; aboutViewModel.CloseRequest += baseDialog.OnCloseDialog; var result = baseDialog.ShowDialog(); }
public void ShowError(Exception exception, string message, string title = "") { var exceptionViewer = new ExceptionViewer(message, exception); var baseDialogWindow = new BaseDialogWindow { Title = string.IsNullOrEmpty(title) ? "Error" : title, Content = exceptionViewer, WindowStartupLocation = WindowStartupLocation.CenterScreen, ResizeMode = ResizeMode.NoResize, IsMinButtonEnabled = false }; baseDialogWindow.ShowDialog(); }
public INewTabHost <Window> GetNewHost(IInterTabClient interTabClient, object partition, TabablzControl source) { /*var tabs = new TabablzControl * { * InterTabController = new InterTabController * { * InterTabClient = this, * Partition = MainPartition * } * }; * * var window = new BaseDialogWindow * { * Title = Application.Current?.MainWindow?.Title, * Content = tabs, * DataContext = vm * }; * * ViewModelBinder.Bind(vm, tabs, null); * * return new NewTabHost<Window>(window, tabs);*/ var vm = IoC.Get <IDocumentSet>(); var view = new DocumentSetView(); var older = (ITabablzControlHolder)view; older.TabsControl.InterTabController = new InterTabController { InterTabClient = this, Partition = MainPartition }; var window = new BaseDialogWindow { Content = view, DataContext = vm }; window.SetBinding(Window.TitleProperty, new Binding { Source = vm, Path = new PropertyPath(nameof(IDocumentSet.DisplayName)) }); ViewModelBinder.Bind(vm, view, null); return(new NewTabHost <Window>(window, older.TabsControl)); }
public void ShowSettingsWindow() { var baseDialogViewModel = new BaseDialogViewModel(Properties.strings.Settings); var settingsViewModel = new SettingsViewModel(Properties.strings.Settings); baseDialogViewModel.CurrentViewModel = settingsViewModel; var baseDialog = new BaseDialogWindow { DataContext = baseDialogViewModel }; settingsViewModel.DialogResultFalseRequest += baseDialog.OnDialogResultFalse; settingsViewModel.DialogResultTrueRequest += baseDialog.OnDialogResultTrue; var result = baseDialog.ShowDialog(); }
public void ShowReportErrorWindow() { var baseDialogViewModel = new BaseDialogViewModel(Properties.strings.ReportError); var reportErrorViewModel = new ReportErrorViewModel(Properties.strings.ReportError); baseDialogViewModel.CurrentViewModel = reportErrorViewModel; var baseDialog = new BaseDialogWindow { DataContext = baseDialogViewModel }; reportErrorViewModel.DialogResultFalseRequest += baseDialog.OnDialogResultFalse; reportErrorViewModel.DialogResultTrueRequest += baseDialog.OnDialogResultTrue; var result = baseDialog.ShowDialog(); }
/// <summary> /// Selects a base window depending on the view, model and dialog options /// </summary> /// <param name="model">The model</param> /// <param name="view">The view</param> /// <param name="isDialog">Whether it's a dialog</param> /// <returns>The proper window</returns> protected override Window EnsureWindow(object model, object view, bool isDialog) { Window window = view as BaseWindow; if (window == null) { if (isDialog) { window = new BaseDialogWindow { Content = view, WindowStartupLocation = WindowStartupLocation.CenterOwner, SizeToContent = SizeToContent.WidthAndHeight }; } else { window = new BaseWindow { Content = view, SizeToContent = SizeToContent.Manual, WindowStartupLocation = WindowStartupLocation.CenterScreen, ResizeMode = ResizeMode.CanResizeWithGrip }; ((BaseWindow)window).LeftWindowCommands .SetBinding(FrameworkElement.DataContextProperty, new Binding { Path = new PropertyPath(nameof(FrameworkElement.DataContext)), Source = view, Mode = BindingMode.OneWay }); var windowName = view.GetType().FullName; window.AttachPositionHandler(windowName); } window.SetValue(View.IsGeneratedProperty, true); } var owner = InferOwnerOf(window); if (owner != null && isDialog) { window.Owner = owner; } return(window); }
public void ShowError(Exception exception, string message, string title = "") { var exceptionViewer = new ExceptionViewer(message, exception); var baseDialogWindow = new BaseDialogWindow { Title = string.IsNullOrEmpty(title) ? "Error" : title, Content = exceptionViewer, WindowStartupLocation = WindowStartupLocation.CenterScreen, ResizeMode = ResizeMode.CanResizeWithGrip, MinHeight = 400, MinWidth = 500, ShowMinButton = false, ShowMaxRestoreButton = false }; baseDialogWindow.ShowDialog(); }
public static void ShowError(Exception exception, string message, string caption = "") { var exceptionViewer = new ExceptionViewer(message, exception); var baseDialogWindow = new BaseDialogWindow { Title = string.IsNullOrEmpty(caption) ? "Error" : caption, Content = exceptionViewer, WindowStartupLocation = WindowStartupLocation.CenterScreen, ResizeMode = ResizeMode.CanResizeWithGrip, MinHeight = 400, MinWidth = 500, ShowMinButton = false, ShowMaxRestoreButton = false, ShowInTaskbar = false }; baseDialogWindow.ShowDialog(); // MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Error); }
public void ShowError(Exception exception, string message, string caption = "") { if (_errorNotified) { return; } _errorNotified = true; var exceptionViewer = new ExceptionViewer(message, exception); var baseDialogWindow = new BaseDialogWindow { Title = string.IsNullOrEmpty(caption) ? "Error" : caption, Content = exceptionViewer, WindowStartupLocation = WindowStartupLocation.CenterScreen, ResizeMode = ResizeMode.NoResize, IsMinButtonEnabled = false }; baseDialogWindow.ShowDialog(); // MessageBox.Show(message, caption, MessageBoxButton.OK, MessageBoxImage.Error); }
protected override Window EnsureWindow(object model, object view, bool isDialog) { Window window = view as BaseWindow; if (window == null) { if (isDialog) { window = new BaseDialogWindow { Content = view, SizeToContent = SizeToContent.WidthAndHeight }; } else { window = new BaseWindow { Content = view, ResizeMode = ResizeMode.NoResize, SizeToContent = SizeToContent.Manual }; window.Closing += WindowOnClosing; window.Activated += Window_Activated; } window.SetValue(View.IsGeneratedProperty, true); } else { var owner = InferOwnerOf(window); if (owner != null && isDialog) { window.Owner = owner; } } return(window); }
/// <summary> /// Selects a base window depending on the view, model and dialog options /// </summary> /// <param name="model">The model</param> /// <param name="view">The view</param> /// <param name="isDialog">Whether it's a dialog</param> /// <returns>The proper window</returns> protected override Window EnsureWindow(object model, object view, bool isDialog) { Window window = view as BaseWindow; if (window == null) { if (isDialog) { window = new BaseDialogWindow { Content = view, SizeToContent = SizeToContent.WidthAndHeight }; } else { var baseWindow = AppBootstrapper.Container.Resolve <BaseWindow>(); baseWindow.Content = view; baseWindow.SizeToContent = SizeToContent.Manual; baseWindow.WindowState = WindowState.Normal; window = baseWindow; } window.SetValue(View.IsGeneratedProperty, true); } else { Window owner = InferOwnerOf(window); if (owner != null && isDialog) { window.Owner = owner; } } return(window); }