internal MessageDialog(MetroWindow parentWindow, MetroDialogSettings settings) : base(parentWindow, settings) { InitializeComponent(); PART_MessageScrollViewer.Height = DialogSettings.MaximumBodyHeight; }
/// <summary> /// Initializes a new MahApps.Metro.Controls.BaseMetroDialog. /// </summary> /// <param name="owningWindow">The window that is the parent of the dialog.</param> /// <param name="settings">The settings for the message dialog.</param> protected BaseMetroDialog(MetroWindow owningWindow, MetroDialogSettings settings) { DialogSettings = settings ?? owningWindow.MetroDialogOptions; OwningWindow = owningWindow; Initialize(); }
internal LoginDialog(MetroWindow parentWindow, LoginDialogSettings settings) : base(parentWindow, settings) { InitializeComponent(); Username = settings.InitialUsername; UsernameWatermark = settings.UsernameWatermark; PasswordWatermark = settings.PasswordWatermark; NegativeButtonButtonVisibility = settings.NegativeButtonVisibility; }
//private const string PART_AffirmativeButton = "PART_AffirmativeButton"; //private const string PART_NegativeButton = "PART_NegativeButton"; //private Button AffirmativeButton = null; //private Button NegativeButton = null; //static MessageDialog() //{ // //DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageDialog), new FrameworkPropertyMetadata(typeof(MessageDialog))); //} internal ProgressDialog(MetroWindow parentWindow, MetroDialogSettings settings) : base(parentWindow, settings) { InitializeComponent(); try { ProgressBarForeground = this.FindResource("AccentColorBrush") as Brush; //Выбо цвета для шариков } catch (Exception) { } }
/// <summary> /// Initializes a new MahApps.Metro.Controls.BaseMetroDialog. /// </summary> /// <param name="owningWindow">The window that is the parent of the dialog.</param> public BaseMetroDialog(MetroWindow owningWindow) { switch (owningWindow.MetroDialogOptions.ColorScheme) { case MetroDialogColorScheme.Theme: this.SetResourceReference(BackgroundProperty, "WhiteColorBrush"); break; case MetroDialogColorScheme.Accented: this.SetResourceReference(BackgroundProperty, "AccentColorBrush"); this.SetResourceReference(ForegroundProperty, "WhiteColorBrush"); break; } }
internal LoginDialog(MetroWindow parentWindow, LoginDialogSettings settings) : base(parentWindow, settings) { InitializeComponent(); Username = settings.InitialUsername; Password = settings.InitialPassword; UsernameWatermark = settings.UsernameWatermark; PasswordWatermark = settings.PasswordWatermark; NegativeButtonButtonVisibility = settings.NegativeButtonVisibility; ShouldHideUsername = settings.ShouldHideUsername; RememberCheckBoxVisibility = settings.RememberCheckBoxVisibility; RememberCheckBoxText = settings.RememberCheckBoxText; }
//private const string PART_AffirmativeButton = "PART_AffirmativeButton"; //private const string PART_NegativeButton = "PART_NegativeButton"; //private Button AffirmativeButton = null; //private Button NegativeButton = null; //static MessageDialog() //{ // //DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageDialog), new FrameworkPropertyMetadata(typeof(MessageDialog))); //} internal ProgressDialog(MetroWindow parentWindow, MetroDialogSettings settings) : base(parentWindow, settings) { InitializeComponent(); if (parentWindow.MetroDialogOptions.ColorScheme == MetroDialogColorScheme.Theme) { try { ProgressBarForeground = this.FindResource("AccentColorBrush") as Brush; } catch (Exception) { } } else ProgressBarForeground = Brushes.White; }
/// <summary> /// Initializes a new MahApps.Metro.Controls.BaseMetroDialog. /// </summary> /// <param name="owningWindow">The window that is the parent of the dialog.</param> public BaseMetroDialog(MetroWindow owningWindow, MetroDialogSettings settings) { DialogSettings = settings == null ? owningWindow.MetroDialogOptions : settings; switch (DialogSettings.ColorScheme) { case MetroDialogColorScheme.Theme: this.SetResourceReference(BackgroundProperty, "WhiteColorBrush"); break; case MetroDialogColorScheme.Accented: this.SetResourceReference(BackgroundProperty, "AccentColorBrush"); this.SetResourceReference(ForegroundProperty, "IdealForegroundColorBrush"); break; } OwningWindow = owningWindow; }
internal LoginDialog(MetroWindow parentWindow, LoginDialogSettings settings) : base(parentWindow, settings) { InitializeComponent(); Username = settings.InitialUsername; UsernameWatermark = settings.UsernameWatermark; PasswordWatermark = settings.PasswordWatermark; NegativeButtonButtonVisibility = settings.NegativeButtonVisibility; if (settings.EnablePasswordPreview) { object resource = Application.Current.FindResource("Win8MetroPasswordBox"); if (resource != null && resource.GetType() == typeof(Style)) { PART_TextBox2.Style = (Style)resource; } } }
public static SizeChangedEventHandler SetupAndOpenDialog(MetroWindow window, BaseMetroDialog dialog) { dialog.SetValue(Panel.ZIndexProperty, (int)window.overlayBox.GetValue(Panel.ZIndexProperty) + 1); dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; SizeChangedEventHandler sizeHandler = (sender, args) => { dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; }; window.SizeChanged += sizeHandler; window.metroDialogContainer.Children.Add(dialog); //add the dialog to the container dialog.OnShown(); return sizeHandler; }
public void LogInfo(string what, string source, LogSeverity severity) { switch (severity) { case LogSeverity.Info: break; case LogSeverity.Warning: MetroWindow window = Application.Current.MainWindow as MetroWindow; MetroDialogSettings settings = new MetroDialogSettings(); settings.AnimateHide = false; settings.AnimateShow = false; window.ShowMessageAsync(source, what, MessageDialogStyle.Affirmative, settings); break; case LogSeverity.Error: MessageBox.Show(what, source, MessageBoxButton.OK, MessageBoxImage.Error); break; default: throw new ArgumentOutOfRangeException(nameof(severity), severity, null); } Debug.WriteLine($"[{source}] {what}"); }
public async Task <JryEntity> CommitAsync(MetroWindow window) { if (JryEntity.IsExtensionInvalid(this.Extension)) { await window.ShowMessageAsync("error", "invalid extension."); return(null); } if (JryEntity.IsResolutionInvalid(this.Resolution)) { await window.ShowMessageAsync("error", "invalid resolution."); return(null); } var entity = this.GetCommitObject(); this.WriteToObject(entity); var provider = JryVideoCore.Current.CurrentDataCenter.VideoManager.GetEntityManager(this.Video); if (this.Action == ObjectChangedAction.Create) { entity.BuildMetaData(); if (provider.IsExists(entity)) { await window.ShowMessageAsync("error", "had same entity."); return(null); } } return(await base.CommitAsync(provider, entity)); }
/// <summary> /// Via Mahapps windows dialogs, present feedback to the user that the use can only accept. /// </summary> /// <param name="title"> /// The large title to display to the user in the dialog. /// </param> /// <param name="message"> /// The message content to display to the user in the dialog. /// </param> /// <param name="acceptButtonText"> /// The text to display in the acceptance/acknowledgement button. /// </param> protected async Task <MessageDialogResult> DisplayDialogToUser(string title, string message, string acceptButtonText = "Ok") { MetroDialogSettings mds = new MetroDialogSettings(); mds.AffirmativeButtonText = acceptButtonText; if (m_parentWindow == null) { m_parentWindow = this.TryFindParent <BaseWindow>(); } if (m_parentWindow != null) { var result = await DialogManager.ShowMessageAsync(m_parentWindow, title, message, MessageDialogStyle.Affirmative, mds); return(result); } else { Debug.WriteLine("In BaseView.DisplayDialogToUser(...) - Could not find parent window."); m_logger.Error("In BaseView.DisplayDialogToUser(...) - Could not find parent window."); return(MessageDialogResult.Affirmative); } }
/// <summary> /// Show the required dialog. /// </summary> /// <param name="viewModel">The view model ascociated with the view.</param> public async Task ShowDialog(DialogViewModel viewModel) { // Locate the ascociated view. var viewType = ViewLocator.LocateTypeForModelType(viewModel.GetType(), null, null); var dialog = (BaseMetroDialog)Activator.CreateInstance(viewType); if (dialog == null) { throw new InvalidOperationException( String.Format("The view {0} belonging to view model {1} " + "does not inherit from {2}", viewType, viewModel.GetType(), typeof(BaseMetroDialog))); } dialog.DataContext = viewModel; // Show the metro window. MetroWindow firstMetroWindow = Application.Current.Windows.OfType <MetroWindow>().First(); await firstMetroWindow.ShowMetroDialogAsync(dialog); await viewModel.Task; await firstMetroWindow.HideMetroDialogAsync(dialog); }
private static void RemoveDialog(this MetroWindow window, BaseMetroDialog dialog) { if (window.metroActiveDialogContainer.Children.Contains(dialog)) { window.metroActiveDialogContainer.Children.Remove(dialog); //remove the dialog from the container // if there's an inactive dialog, bring it to the front var dlg = window.metroInactiveDialogContainer.Children.Cast <UIElement>().LastOrDefault(); if (dlg != null) { window.metroInactiveDialogContainer.Children.Remove(dlg); window.metroActiveDialogContainer.Children.Add(dlg); } } else { window.metroInactiveDialogContainer.Children.Remove(dialog); } if (window.metroActiveDialogContainer.Children.Count == 0) { window.RestoreFocus(); } }
protected override Window EnsureWindow(object model, object view, bool isDialog) { var window = view as MetroWindow; if (window == null) { window = new MetroWindow { Content = view, }; window.SetValue(View.IsGeneratedProperty, true); window.Resources.MergedDictionaries.Add(this.themeManager.GetThemeResources()); var owner = this.InferOwnerOf(window); if (owner != null) { window.WindowStartupLocation = WindowStartupLocation.CenterOwner; window.ShowInTaskbar = false; window.Owner = owner; } else { window.WindowStartupLocation = WindowStartupLocation.CenterScreen; } } else { var owner2 = this.InferOwnerOf(window); if (owner2 != null && isDialog) { window.ShowInTaskbar = false; window.Owner = owner2; } } return(window); }
/// <summary> /// Sets the light or dark theme for a form. Call before /// InitializeComponents(). /// /// We only support the dark theme now so this no longer relevant /// but left in place in case we decide to support other themes. /// </summary> /// <param name="theme"></param> /// <param name="window"></param> public static void SetTheme(Themes theme = Themes.Default, MetroWindow window = null) { if (theme == Themes.Default) { theme = mmApp.Configuration.ApplicationTheme; } if (theme == Themes.Light) { // get the current app style (theme and accent) from the application // you can then use the current theme and custom accent instead set a new theme Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current); // now set the Green accent and light theme ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("MahLight"), ThemeManager.GetAppTheme("BaseLight")); // or appStyle.Item1 } else { // get the current app style (theme and accent) from the application // you can then use the current theme and custom accent instead set a new theme Tuple <AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current); // now set the highlight accent and dark theme ThemeManager.ChangeAppStyle(Application.Current, ThemeManager.GetAccent("Blue"), ThemeManager.GetAppTheme("BaseDark")); // or appStyle.Item1 } if (window != null) { SetThemeWindowOverride(window); } }
public static async Task <bool> ShowEditGameDialog(this MetroWindow window, GameStats game) { if (game == null) { return(false); } var dialog = new AddGameDialog(game); await window.ShowMetroDialogAsync(dialog, new MetroDialogSettings { AffirmativeButtonText = "save", NegativeButtonText = "cancel" }); var result = await dialog.WaitForButtonPressAsync(); await window.HideMetroDialogAsync(dialog); if (result == null) { return(false); } if (Config.Instance.HearthStatsAutoUploadNewGames && HearthStatsAPI.IsLoggedIn) { var deck = DeckList.Instance.Decks.FirstOrDefault(d => d.DeckId == game.DeckId); if (deck != null) { if (game.GameMode == GameMode.Arena) { HearthStatsManager.UpdateArenaMatchAsync(game, deck, true, true); } else { HearthStatsManager.UpdateMatchAsync(game, deck.GetVersion(game.PlayerDeckVersion), true, true); } } } DeckStatsList.Save(); Core.MainWindow.DeckPickerList.UpdateDecks(); return(true); }
/// <summary> /// Overrides specific theme colors in the window header /// </summary> /// <param name="window"></param> public static void SetThemeWindowOverride(MetroWindow window) { if (mmApp.Configuration.ApplicationTheme == Themes.Dark) { if (window != null) { window.WindowTitleBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#333333")); window.NonActiveWindowTitleBrush = (Brush)window.FindResource("WhiteBrush"); var brush = App.Current.Resources["MenuSeparatorBorderBrush"] as SolidColorBrush; App.Current.Resources["MenuSeparatorBorderBrush"] = (SolidColorBrush) new BrushConverter().ConvertFrom("#333333"); brush = App.Current.Resources["MenuSeparatorBorderBrush"] as SolidColorBrush; } } //else //{ // if (window != null) // { // // Need to fix this to show the accent color when switching // //window.WindowTitleBrush = (Brush)window.FindResource("WhiteBrush"); // //window.NonActiveWindowTitleBrush = (Brush)window.FindResource("WhiteBrush"); // } //} }
/// <summary> /// Ejecuta la acción que realizá la importación de un tablero al proyecto actual /// </summary> /// <param name="window">La ventana metro activa.</param> public static async void ImportTablero(this MetroWindow window, Project prj, Action <object> TableroLoaded = null) { var controller = await window.ShowProgressAsync("Abriendo por favor espere...", "Abriendo tablero"); controller.SetCancelable(false); controller.SetIndeterminate(); window.ImportTableroTr(prj, ((async(object result) => { Object[] rData = result as Object[]; Boolean succed = (Boolean)rData[0]; String msg = (string)rData[1]; if (msg.Length > 0) { TabalimApp.CurrentTablero = (Tablero)rData[2]; if (!TabalimApp.CurrentProject.Tableros.ContainsKey(TabalimApp.CurrentTablero.Id)) { TabalimApp.CurrentProject.Tableros.Add(TabalimApp.CurrentTablero.Id, TabalimApp.CurrentTablero); } await window.ShowMessageAsync(succed ? "Tablero Cargado" : "Error", msg); TableroLoaded?.Invoke(TabalimApp.CurrentTablero); } await controller.CloseAsync(); }))); }
/// <summary> /// Save all log entries /// </summary> public async void SaveLog() { NumSaveOperations++; Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog(); saveFileDialog.Title = "Save log"; saveFileDialog.DefaultExt = ".log"; saveFileDialog.Filter = "Log file (*.log)|*.log|Text file (*.txt)|*.txt"; saveFileDialog.InitialDirectory = System.IO.Path.GetDirectoryName(_lastLogPath); saveFileDialog.FileName = System.IO.Path.GetFileName(_lastLogPath); if (saveFileDialog.ShowDialog().Value) { StringBuilder logString = new StringBuilder("Date/Time | Type | Message " + Environment.NewLine + "------------------- | ------- | ---------------------------------" + Environment.NewLine); LogEvent[] logEvents = new LogEvent[listView_Log.Items.Count]; listView_Log.Items.CopyTo(logEvents, 0); await Task.Run(() => { foreach (LogEvent logEvent in logEvents) { logString.Append(logEvent.LogTime.ToString() + " | " + String.Format("{0,-7}", logEvent.LogType.ToString()) + " | " + logEvent.LogMessage + Environment.NewLine); } System.IO.File.WriteAllText(saveFileDialog.FileName, logString.ToString()); }); _lastLogPath = saveFileDialog.FileName; MetroWindow parentWindow = FindParent <MetroWindow>(this); await parentWindow.ShowMessageAsync("Log saved", "Log was successfully saved to" + Environment.NewLine + "\"" + saveFileDialog.FileName + "\"", MessageDialogStyle.Affirmative); } NumSaveOperations--; }
public static async Task <bool> UpdateBackground(MetroWindow window, string path) { //if the csgo folder isn't valid, don't bother var isValid = await CheckMyCsgoDir(window); if (!isValid.Value) { return(false); } var videoPath = $"{Regedit.MyCsgoFolderPath}{Format(Exe, "panorama", "videos")}"; if (!Directory.GetFiles(videoPath).Contains($"{videoPath}{Format($"{Name}.{FilT}.tmp")}")) { //Save the original files File.Copy($"{videoPath}{Format($"{Name}.{FilT}")}", $"{videoPath}{Format($"{Name}.{FilT}.tmp")}"); File.Copy($"{videoPath}{Format($"{Name}720.{FilT}")}", $"{videoPath}{Format($"{Name}720.{FilT}.tmp")}"); File.Copy($"{videoPath}{Format($"{Name}540.{FilT}")}", $"{videoPath}{Format($"{Name}540.{FilT}.tmp")}"); } //Update the background and overwrite the old ones File.Copy(path, $"{videoPath}{Format($"{Name}.{FilT}")}", true); File.Copy(path, $"{videoPath}{Format($"{Name}720.{FilT}")}", true); File.Copy(path, $"{videoPath}{Format($"{Name}540.{FilT}")}", true); return(true); }
private static void ShowControlInNewWindow(UIElement control, Window mainWindow) { var dialogWindowGrid = new Grid(); dialogWindowGrid.Children.Add(control); var dialogWindow = new MetroWindow { Content = dialogWindowGrid, ShowInTaskbar = false, ShowMinButton = false, IsMinButtonEnabled = false, ShowSystemMenuOnRightClick = false, WindowStartupLocation = WindowStartupLocation.CenterOwner, ResizeMode = ResizeMode.CanResizeWithGrip, Owner = mainWindow, MinHeight = 200, MinWidth = 300, Height = 400, Width = 600, }; dialogWindow.ShowDialog(); dialogWindowGrid.Children.Remove(control); }
private async void OnGetPosts(MetroWindow metroWindow) { if (string.IsNullOrWhiteSpace(Settings.Instance.GWBBlogUrl) || (string.IsNullOrWhiteSpace(Settings.Instance.GWBUserName) && string.IsNullOrWhiteSpace(Settings.Instance.GWBPassword))) { var settingsFlyout = metroWindow.Flyouts.Items[0] as Flyout; if (settingsFlyout == null) { return; } settingsFlyout.DataContext = new SettingsViewModel(); settingsFlyout.IsOpen = true; return; } ProgressDialogController progressController = await _dialogCoordinator.ShowProgressAsync(this, AppContext.Instance.ApplicationName, "Getting blog posts..."); progressController.SetIndeterminate(); //Connect to GWB var response = await GWBService.Instance.GetAllBlogPostsAsync(progressController); await progressController.CloseAsync(); if (response.Exception != null) { await _dialogCoordinator.ShowMessageAsync(this, AppContext.Instance.ApplicationName, response.Exception.Message); } else { var blog = response.Data; BlogTitle = blog.Title.ToUpper(); BlogUrl = blog.RootUrl; BlogPosts = blog.Posts.ToObservableCollection(); } }
private static SizeChangedEventHandler SetupAndOpenDialog(MetroWindow window, BaseMetroDialog dialog) { dialog.SetValue(Panel.ZIndexProperty, (int)window.overlayBox.GetValue(Panel.ZIndexProperty) + 1); dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; SizeChangedEventHandler sizeHandler = null; //an event handler for auto resizing an open dialog. sizeHandler = new SizeChangedEventHandler((sender, args) => { dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; }); window.SizeChanged += sizeHandler; //window.overlayBox.Visibility = Visibility.Visible; //activate the overlay effect window.metroDialogContainer.Children.Add(dialog); //add the dialog to the container dialog.OnShown(); return(sizeHandler); }
private async void BtnEdit_Click(object sender, RoutedEventArgs e) { metroWindow = Window.GetWindow(this) as MetroWindow; var settings = new MetroDialogSettings { ColorScheme = MetroDialogColorScheme.Theme, AnimateShow = true, }; await metroWindow.ShowMetroDialogAsync(_customDialog, settings); //todo show new values after save end edit //if (!string.IsNullOrWhiteSpace(TextBoxPosition.Text)) //{ // //var value = ElectionService.GetPosition(_position); // //set faculty text textbox from here // await ElectionConfigurationService.UpdatePosition(new Position { Id = Id, PositionName = TextBoxPosition.Text }); //} //set TextBoxPosition IsEnabled = "true" after updating set TextBoxPosition IsEnabled = "False" _addPositionDialogControl.TextBoxPosition.Text = TextBoxPosition.Text; _addPositionDialogControl.TextBoxFaculty.Text = TextBoxFaculty.Text; }
public void AttachView(object view, object context = null) { window = view as MetroWindow; }
public MetroWindowInstance(MetroWindow metroWindow) { _win = metroWindow; Sync(); }
public static bool Validar(MetroWindow janela) { Mbox.JanelaPrincipal = JanelaPrincipal; var TbOk = ValidarTextBox(ValidaUtil.FindVisualChildren <TextBox>(janela)); if (!TbOk) { return(false); } var TbPass = ValidarPassword(ValidaUtil.FindVisualChildren <PasswordBox>(janela)); if (!TbPass) { return(false); } var TbCpf = ValidarCpf(ValidaUtil.FindVisualChildren <MaskedTextBox>(janela)); if (!TbCpf) { return(false); } var TbCnpj = ValidarCnpj(ValidaUtil.FindVisualChildren <MaskedTextBox>(janela)); if (!TbCnpj) { return(false); } var TbData = ValidarData(ValidaUtil.FindVisualChildren <MaskedTextBox>(janela)); if (!TbData) { return(false); } var tbHorario = ValidarHoras(ValidaUtil.FindVisualChildren <MaskedTextBox>(janela)); if (!tbHorario) { return(false); } var tbCombo = ValidarComboBox(ValidaUtil.FindVisualChildren <ComboBox>(janela)); if (!tbCombo) { return(false); } var tbDate = ValidarDatePicker(ValidaUtil.FindVisualChildren <DatePicker>(janela)); if (!tbDate) { return(false); } return(true); }
public static async Task <MessageDialogResult> ShowDeleteMultipleGameStatsMessage(this MetroWindow window, int count) => await window.ShowMessageAsync(LocUtil.Get(LocDeleteGameStatsMultiTitle), $"{LocUtil.Get(LocDeleteGameStatsMultiText)} ({count})." + Environment.NewLine + Environment.NewLine + LocUtil.Get(LocDeleteGameStatsSure), AffirmativeAndNegative, new Settings { AffirmativeButtonText = LocUtil.Get(LocDeleteGameStatsButtonDelete), NegativeButtonText = LocUtil.Get(LocDeleteGameStatsButtonCancel) });
void UpdateMainWindowDpi(MetroWindow window) { if (window == Application.Current.MainWindow) MainWindowDpi = window.WindowDpi; }
internal LoginDialog(MetroWindow parentWindow) : this(parentWindow, null) { }
private static SizeChangedEventHandler SetupAndOpenDialog(MetroWindow window, string title, BaseMetroDialog dialog) { dialog.SetValue(Panel.ZIndexProperty, (int)window.overlayBox.GetValue(Panel.ZIndexProperty) + 1); dialog.MinHeight = window.ActualHeight / 4.0; dialog.Title = title; SizeChangedEventHandler sizeHandler = null; //an event handler for auto resizing an open dialog. sizeHandler = new SizeChangedEventHandler((sender, args) => { dialog.MinHeight = window.ActualHeight / 4.0; }); window.SizeChanged += sizeHandler; //window.overlayBox.Visibility = Visibility.Visible; //activate the overlay effect window.messageDialogContainer.Children.Add(dialog); //add the dialog to the container dialog.OnShown(); if (window.TextBlockStyle != null && !dialog.Resources.Contains(typeof(TextBlock))) { dialog.Resources.Add(typeof(TextBlock), window.TextBlockStyle); } return sizeHandler; }
internal ProgressDialog(MetroWindow parentWindow) : this(parentWindow, null) { }
internal MessageDialog(MetroWindow parentWindow) : this(parentWindow, null) { }
public CustomDialog(MetroWindow parentWindow) : this(parentWindow, null) { }
public CustomDialog(MetroWindow parentWindow, MetroDialogSettings settings) : base(parentWindow, settings) { }
internal void Initialize(MetroWindow window) => toolBarService.InitializeToolBar(toolBar, new Guid(ToolBarConstants.APP_TB_GUID), window);
internal InputDialog(MetroWindow parentWindow) : this(parentWindow, null) { }
/// <summary> /// Initializes a new MahApps.Metro.Controls.BaseMetroDialog. /// </summary> /// <param name="owningWindow">The window that is the parent of the dialog.</param> /// <param name="settings">The settings for the message dialog.</param> protected BaseMetroDialog(MetroWindow owningWindow, MetroDialogSettings settings) { this.Initialize(owningWindow, settings); }
//private const string PART_AffirmativeButton = "PART_AffirmativeButton"; //private const string PART_NegativeButton = "PART_NegativeButton"; //private Button AffirmativeButton = null; //private Button NegativeButton = null; //static MessageDialog() //{ // //DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageDialog), new FrameworkPropertyMetadata(typeof(MessageDialog))); //} internal MessageDialog(MetroWindow parentWindow) : base(parentWindow) { InitializeComponent(); }
internal ExceptionDialog(MetroWindow parentWindow) : this(parentWindow, null) { }
internal ProgressDialog(MetroWindow parentWindow, MetroDialogSettings settings) : base(parentWindow, settings) { this.InitializeComponent(); }
internal InputDialog(MetroWindow parentWindow, MetroDialogSettings settings) : base(parentWindow, settings) { InitializeComponent(); }
public ChangePasswordDialog(MetroWindow parentWindow) : this(parentWindow, null) { }
public static async Task ShowMessage(this MetroWindow window, string title, string message) => await window.ShowMessageAsync(title, message);
/// <summary> /// Initializes a new <see cref="BaseMetroDialog"/>. /// </summary> /// <param name="owningWindow">The window that is the parent of the dialog.</param> /// <param name="settings">The settings for the message dialog.</param> protected BaseMetroDialog(MetroWindow owningWindow, MetroDialogSettings settings) { this.Initialize(owningWindow, settings); }
private static Task HandleOverlayOnHide(MetroDialogSettings settings, MetroWindow window) { return (settings == null || settings.AnimateHide ? window.HideOverlayAsync() : Task.Factory.StartNew(() => window.Dispatcher.Invoke(new Action(window.HideOverlay)))); }
private static Task HandleOverlayOnShow(MetroDialogSettings settings, MetroWindow window) { return (settings == null || settings.UseAnimations ? window.ShowOverlayAsync() : Task.Factory.StartNew(() => window.Dispatcher.Invoke(new Action(() => window.ShowOverlay())))); }
public static async Task <MessageDialogResult> ShowMissingCardsMessage(this MetroWindow window, Deck deck, bool exportDialog) { if (!deck.MissingCards.Any()) { return(await window.ShowMessageAsync("No missing cards", "No cards were missing when you last exported this deck. (or you have not recently exported this deck)", Affirmative, new Settings { AffirmativeButtonText = "OK" })); } var message = "You are missing the following cards:\n"; var totalDust = 0; var sets = new List <string>(); foreach (var card in deck.MissingCards) { message += "\n• " + card.LocalizedName; if (card.Count == 2) { message += " x2"; } if (card.Set == HearthDbConverter.SetConverter(CardSet.NAXX)) { sets.Add("and the Naxxramas DLC "); } else if (card.Set == HearthDbConverter.SetConverter(CardSet.PROMO)) { sets.Add("and Promotion cards "); } else if (card.Set == HearthDbConverter.SetConverter(CardSet.HOF)) { sets.Add("and the Hall of Fame cards "); } else if (card.Set == HearthDbConverter.SetConverter(CardSet.BRM)) { sets.Add("and the Blackrock Mountain DLC "); } else if (card.Set == HearthDbConverter.SetConverter(CardSet.LOE)) { sets.Add("and the League of Explorers DLC "); } else if (card.Set == HearthDbConverter.SetConverter(CardSet.KARA)) { sets.Add("and the One Night in Karazhan DLC "); } else { totalDust += card.DustCost * card.Count; } } message += $"\n\nYou need {totalDust} dust {string.Join("", sets.Distinct())}to craft the missing cards."; var style = exportDialog ? AffirmativeAndNegative : Affirmative; var settings = new Settings { AffirmativeButtonText = "OK" }; if (exportDialog) { settings.AffirmativeButtonText = "Export"; settings.NegativeButtonText = "Cancel"; message += "\n\nExport anyway? (this will not craft the cards)"; } return(await window.ShowMessageAsync("Missing cards", message, style, settings)); }
private static SizeChangedEventHandler SetupAndOpenDialog(MetroWindow window, BaseMetroDialog dialog) { dialog.SetValue(Panel.ZIndexProperty, (int)window.overlayBox.GetValue(Panel.ZIndexProperty) + 1); dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; SizeChangedEventHandler sizeHandler = null; //an event handler for auto resizing an open dialog. sizeHandler = new SizeChangedEventHandler((sender, args) => { dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; }); window.SizeChanged += sizeHandler; //window.overlayBox.Visibility = Visibility.Visible; //activate the overlay effect window.metroDialogContainer.Children.Add(dialog); //add the dialog to the container dialog.OnShown(); return sizeHandler; }
public FullScreenCommand(IAppWindow appWindow) : base(MetroWindow.FullScreenCommand) { this.window = (MetroWindow)appWindow.MainWindow; }
private static Window SetupExternalDialogWindow(BaseMetroDialog dialog) { MetroWindow win = new MetroWindow(); win.ShowInTaskbar = false; win.ShowActivated = true; win.Topmost = true; win.ResizeMode = ResizeMode.NoResize; win.WindowStyle = WindowStyle.None; win.WindowStartupLocation = WindowStartupLocation.CenterScreen; win.ShowTitleBar = false; win.ShowCloseButton = false; win.WindowTransitionsEnabled = false; win.Background = dialog.Background; try { win.GlowBrush = win.TryFindResource("AccentColorBrush") as SolidColorBrush; } catch (Exception) { } win.Width = SystemParameters.PrimaryScreenWidth; win.MinHeight = SystemParameters.PrimaryScreenHeight / 4.0; win.SizeToContent = SizeToContent.Height; GlowWindowBehavior glowWindow = new GlowWindowBehavior(); glowWindow.Attach(win); dialog.ParentDialogWindow = win; //THIS IS ONLY, I REPEAT, ONLY SET FOR EXTERNAL DIALOGS! win.Content = dialog; EventHandler closedHandler = null; closedHandler = (sender, args) => { win.Closed -= closedHandler; dialog.ParentDialogWindow = null; win.Content = null; }; win.Closed += closedHandler; return win; }
//private const string PART_AffirmativeButton = "PART_AffirmativeButton"; //private const string PART_NegativeButton = "PART_NegativeButton"; //private Button AffirmativeButton = null; //private Button NegativeButton = null; //static MessageDialog() //{ // //DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageDialog), new FrameworkPropertyMetadata(typeof(MessageDialog))); //} internal ProgressDialog(MetroWindow parentWindow) : base(parentWindow) { InitializeComponent(); }
public void AttachWindow(MetroWindow window) { _win = window; }
private IntPtr HwndHook(IntPtr hWnd, int message, IntPtr wParam, IntPtr lParam, ref bool handled) { IntPtr returnval = IntPtr.Zero; switch (message) { case Constants.WM_NCCALCSIZE: /* Hides the border */ handled = true; break; case Constants.WM_NCPAINT: { if (!ShouldHaveBorder()) { MetroWindow w = AssociatedObject as MetroWindow; if (!(w != null && w.GlowBrush != null)) { var val = 2; UnsafeNativeMethods.DwmSetWindowAttribute(_mHWND, 2, ref val, 4); var m = new MARGINS { bottomHeight = 1, leftWidth = 1, rightWidth = 1, topHeight = 1 }; UnsafeNativeMethods.DwmExtendFrameIntoClientArea(_mHWND, ref m); } if (Border != null) { Border.BorderThickness = new Thickness(0); } } else { AddBorder(); } handled = true; } break; case Constants.WM_NCACTIVATE: { /* As per http://msdn.microsoft.com/en-us/library/ms632633(VS.85).aspx , "-1" lParam * "does not repaint the nonclient area to reflect the state change." */ returnval = UnsafeNativeMethods.DefWindowProc(hWnd, message, wParam, new IntPtr(-1)); if (!ShouldHaveBorder()) { if (wParam == IntPtr.Zero) { AddBorder(); } else { RemoveBorder(); } } handled = true; } break; case Constants.WM_GETMINMAXINFO: /* http://blogs.msdn.com/b/llobo/archive/2006/08/01/maximizing-window-_2800_with-windowstyle_3d00_none_2900_-considering-taskbar.aspx */ WmGetMinMaxInfo(hWnd, lParam); /* Setting handled to false enables the application to process it's own Min/Max requirements, * as mentioned by jason.bullard (comment from September 22, 2011) on http://gallery.expression.microsoft.com/ZuneWindowBehavior/ */ handled = false; break; case Constants.WM_NCHITTEST: // don't process the message on windows that can't be resized var resizeMode = AssociatedObject.ResizeMode; if (resizeMode == ResizeMode.CanMinimize || resizeMode == ResizeMode.NoResize || AssociatedObject.WindowState == WindowState.Maximized) { break; } // get X & Y out of the message var screenPoint = new Point(UnsafeNativeMethods.GET_X_LPARAM(lParam), UnsafeNativeMethods.GET_Y_LPARAM(lParam)); // convert to window coordinates var windowPoint = AssociatedObject.PointFromScreen(screenPoint); var windowSize = AssociatedObject.RenderSize; var windowRect = new Rect(windowSize); windowRect.Inflate(-6, -6); // don't process the message if the mouse is outside the 6px resize border if (windowRect.Contains(windowPoint)) { break; } var windowHeight = (int)windowSize.Height; var windowWidth = (int)windowSize.Width; // create the rectangles where resize arrows are shown var topLeft = new Rect(0, 0, 6, 6); var top = new Rect(6, 0, windowWidth - 12, 6); var topRight = new Rect(windowWidth - 6, 0, 6, 6); var left = new Rect(0, 6, 6, windowHeight - 12); var right = new Rect(windowWidth - 6, 6, 6, windowHeight - 12); var bottomLeft = new Rect(0, windowHeight - 6, 6, 6); var bottom = new Rect(6, windowHeight - 6, windowWidth - 12, 6); var bottomRight = new Rect(windowWidth - 6, windowHeight - 6, 6, 6); // check if the mouse is within one of the rectangles if (topLeft.Contains(windowPoint)) { returnval = (IntPtr)Constants.HTTOPLEFT; } else if (top.Contains(windowPoint)) { returnval = (IntPtr)Constants.HTTOP; } else if (topRight.Contains(windowPoint)) { returnval = (IntPtr)Constants.HTTOPRIGHT; } else if (left.Contains(windowPoint)) { returnval = (IntPtr)Constants.HTLEFT; } else if (right.Contains(windowPoint)) { returnval = (IntPtr)Constants.HTRIGHT; } else if (bottomLeft.Contains(windowPoint)) { returnval = (IntPtr)Constants.HTBOTTOMLEFT; } else if (bottom.Contains(windowPoint)) { returnval = (IntPtr)Constants.HTBOTTOM; } else if (bottomRight.Contains(windowPoint)) { returnval = (IntPtr)Constants.HTBOTTOMRIGHT; } if (returnval != IntPtr.Zero) { handled = true; } break; case Constants.WM_INITMENU: var window = AssociatedObject as MetroWindow; if (window != null) { if (!window.ShowMaxRestoreButton) { UnsafeNativeMethods.EnableMenuItem(UnsafeNativeMethods.GetSystemMenu(hWnd, false), Constants.SC_MAXIMIZE, Constants.MF_GRAYED | Constants.MF_BYCOMMAND); } else if (window.WindowState == WindowState.Maximized) { UnsafeNativeMethods.EnableMenuItem(UnsafeNativeMethods.GetSystemMenu(hWnd, false), Constants.SC_MAXIMIZE, Constants.MF_GRAYED | Constants.MF_BYCOMMAND); UnsafeNativeMethods.EnableMenuItem(UnsafeNativeMethods.GetSystemMenu(hWnd, false), Constants.SC_RESTORE, Constants.MF_ENABLED | Constants.MF_BYCOMMAND); UnsafeNativeMethods.EnableMenuItem(UnsafeNativeMethods.GetSystemMenu(hWnd, false), Constants.SC_MOVE, Constants.MF_GRAYED | Constants.MF_BYCOMMAND); } else { UnsafeNativeMethods.EnableMenuItem(UnsafeNativeMethods.GetSystemMenu(hWnd, false), Constants.SC_MAXIMIZE, Constants.MF_ENABLED | Constants.MF_BYCOMMAND); UnsafeNativeMethods.EnableMenuItem(UnsafeNativeMethods.GetSystemMenu(hWnd, false), Constants.SC_RESTORE, Constants.MF_GRAYED | Constants.MF_BYCOMMAND); UnsafeNativeMethods.EnableMenuItem(UnsafeNativeMethods.GetSystemMenu(hWnd, false), Constants.SC_MOVE, Constants.MF_ENABLED | Constants.MF_BYCOMMAND); } if (!window.ShowMinButton) { UnsafeNativeMethods.EnableMenuItem(UnsafeNativeMethods.GetSystemMenu(hWnd, false), Constants.SC_MINIMIZE, Constants.MF_GRAYED | Constants.MF_BYCOMMAND); } if (AssociatedObject.ResizeMode == ResizeMode.NoResize || window.WindowState == WindowState.Maximized) { UnsafeNativeMethods.EnableMenuItem(UnsafeNativeMethods.GetSystemMenu(hWnd, false), Constants.SC_SIZE, Constants.MF_GRAYED | Constants.MF_BYCOMMAND); } } break; } return(returnval); }
private static SizeChangedEventHandler SetupAndOpenDialog(MetroWindow window, dynamic d) { if ((d as BaseMetroDialog) != null) { BaseMetroDialog dialog = (d as BaseMetroDialog); dialog.SetValue(Panel.ZIndexProperty, (int)window.overlayBox.GetValue(Panel.ZIndexProperty) + 1); dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; SizeChangedEventHandler sizeHandler = null; //an event handler for auto resizing an open dialog. sizeHandler = new SizeChangedEventHandler((sender, args) => { dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; }); window.SizeChanged += sizeHandler; window.metroDialogContainer.Children.Add(dialog); dialog.OnShown(); return sizeHandler; } else { WaitBaseMetroDialog dialog = (d as WaitBaseMetroDialog); dialog.SetValue(Panel.ZIndexProperty, (int)window.overlayBox.GetValue(Panel.ZIndexProperty) + 1); dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; SizeChangedEventHandler sizeHandler = null; //an event handler for auto resizing an open dialog. sizeHandler = new SizeChangedEventHandler((sender, args) => { dialog.MinHeight = window.ActualHeight / 4.0; dialog.MaxHeight = window.ActualHeight; }); window.SizeChanged += sizeHandler; window.metroDialogContainer.Children.Add(dialog); dialog.OnShown(); return sizeHandler; } }