Esempio n. 1
0
        private static Window SetupExternalDialogWindow(BaseMetroDialog dialog)
        {
            var win = new MetroWindow
            {
                ShowInTaskbar            = false,
                ShowActivated            = true,
                Topmost                  = true,
                ResizeMode               = ResizeMode.NoResize,
                WindowStyle              = WindowStyle.None,
                WindowStartupLocation    = WindowStartupLocation.CenterScreen,
                ShowTitleBar             = false,
                ShowCloseButton          = false,
                WindowTransitionsEnabled = false
            };

            try
            {
                win.Resources.MergedDictionaries.Add(new ResourceDictionary {
                    Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml")
                });
                win.Resources.MergedDictionaries.Add(new ResourceDictionary {
                    Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml")
                });
                win.Resources.MergedDictionaries.Add(new ResourceDictionary {
                    Source = new Uri("pack://application:,,,/MahApps.Metro;component/Styles/Colors.xaml")
                });
                win.SetResourceReference(MetroWindow.GlowBrushProperty, "AccentColorBrush");
            }
            catch (Exception) { }

            win.Width         = SystemParameters.PrimaryScreenWidth;
            win.MinHeight     = SystemParameters.PrimaryScreenHeight / 4.0;
            win.SizeToContent = SizeToContent.Height;

            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);
        }
Esempio n. 2
0
        private static Window SetupExternalDialogWindow(BaseMetroDialog dialog)
        {
            MetroWindow metroWindow = new MetroWindow()
            {
                ShowInTaskbar            = false,
                ShowActivated            = true,
                Topmost                  = true,
                ResizeMode               = ResizeMode.NoResize,
                WindowStyle              = WindowStyle.None,
                WindowStartupLocation    = WindowStartupLocation.CenterScreen,
                ShowTitleBar             = false,
                ShowCloseButton          = false,
                WindowTransitionsEnabled = false
            };

            try
            {
                metroWindow.Resources.MergedDictionaries.Add(new ResourceDictionary()
                {
                    Source = new Uri("pack://application:,,,/小喵谷登入器;component/Styles/Controls.xaml")
                });
                metroWindow.Resources.MergedDictionaries.Add(new ResourceDictionary()
                {
                    Source = new Uri("pack://application:,,,/小喵谷登入器;component/Styles/Fonts.xaml")
                });
                metroWindow.Resources.MergedDictionaries.Add(new ResourceDictionary()
                {
                    Source = new Uri("pack://application:,,,/小喵谷登入器;component/Styles/Colors.xaml")
                });
                metroWindow.SetResourceReference(MetroWindow.GlowBrushProperty, "AccentColorBrush");
            }
            catch (Exception exception)
            {
            }
            metroWindow.Width         = SystemParameters.PrimaryScreenWidth;
            metroWindow.MinHeight     = SystemParameters.PrimaryScreenHeight / 4;
            metroWindow.SizeToContent = SizeToContent.Height;
            dialog.ParentDialogWindow = metroWindow;
            metroWindow.Content       = dialog;
            EventHandler parentDialogWindow = null;

            parentDialogWindow = (object sender, EventArgs e) => {
                metroWindow.Closed       -= parentDialogWindow;
                dialog.ParentDialogWindow = null;
                metroWindow.Content       = null;
            };
            metroWindow.Closed += parentDialogWindow;
            return(metroWindow);
        }
Esempio n. 3
0
        public static void AbrirWindow(string title, string window, string isModal = "1", string WinParams = "x")
        {
            try
            {
                Type        ventana  = Type.GetType("Nomina1._0." + window);
                var         datos    = WinParams.Split(',');
                MetroWindow nventana = (MetroWindow)Activator.CreateInstance(ventana);
                if (WinParams != "x")
                {
                    nventana = (MetroWindow)Activator.CreateInstance(ventana, datos);
                }



                nventana.Title         = title;
                nventana.ShowInTaskbar = false;
                // nventana.WindowStyle = WindowStyle.ToolWindow;
                nventana.SetResourceReference(MetroWindow.GlowBrushProperty, "AccentColorBrush");
                nventana.ResizeMode = ResizeMode.CanResizeWithGrip;
                if (window == "PrincipalWindow")
                {
                    nventana.ShowInTaskbar = true;
                    nventana.WindowStyle   = WindowStyle.ThreeDBorderWindow;
                    _PrincipalWindow       = nventana;
                }
                else
                {
                    nventana.Owner = _PrincipalWindow;
                }
                if (isModal == "1")
                {
                    nventana.WindowStartupLocation = WindowStartupLocation.CenterScreen;

                    nventana.ShowDialog();
                }
                else
                {
                    nventana.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                    nventana.Show();
                }
            }catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
 public void PopupWindowWithBorder(string title, string text)
 {
     if (m_PopupWin != null)
     {
         m_PopupWin.Close();
     }
     m_PopupWin = new MetroWindow()
     {
         Owner = this, WindowStartupLocation = WindowStartupLocation.CenterOwner, Title = title, Width = 500, Height = 300
     };
     m_PopupWin.Closed += (o, args) => m_PopupWin = null;
     m_PopupWin.Content = new TextBlock()
     {
         Text = text, FontSize = 28, FontWeight = FontWeights.Light, VerticalAlignment = VerticalAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center
     };
     m_PopupWin.BorderThickness = new Thickness(1);
     m_PopupWin.GlowBrush       = null;
     m_PopupWin.SetResourceReference(MetroWindow.BorderBrushProperty, "AccentColorBrush");
     m_PopupWin.Show();
 }