Esempio n. 1
0
        private async Task <bool> checkFields()
        {
            bool ifAllCorrect = false;

            MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;

            if (cmbProducts.SelectedItem == null)
            {
                await window.ShowMessageAsync("Products", "Please select product.");
            }
            else if (string.IsNullOrEmpty(txtQuantity.Text))
            {
                await window.ShowMessageAsync("Quantity", "Please input value.");
            }
            else if (string.IsNullOrEmpty(txtQuantity.Text))
            {
                await window.ShowMessageAsync("Total", "Please input value.");
            }
            else
            {
                ifAllCorrect = true;
            }

            return(ifAllCorrect);
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
 public EditOrderViewModel(Order ent, MahApps.Metro.Controls.MetroWindow wind, DataContext api, bool isnew,
                           IEnumerable <Product> prod, IEnumerable <Manager> man, IEnumerable <Customer> cust) : base(ent, wind)
 {
     Products  = prod;
     Managers  = man;
     Customers = cust;
 }
        protected override Window EnsureWindow(object model, object view, bool isDialog) {
            var window = view as Window;

            if (window == null) {
                var metroWindow = new MetroWindow {
                    Content = view,
                    SizeToContent = SizeToContent.WidthAndHeight,
                    TitlebarHeight = 0
                };
                window = metroWindow;
                //Interaction.GetBehaviors(metroWindow).Add(new GlowWindowBehavior());
                metroWindow.SetValue(MoveableWindowBehavior.IsEnabledProperty, true);
                metroWindow.SetValue(View.IsGeneratedProperty, true);

                var owner = InferOwnerOf(window);
                if (owner != null) {
                    window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    window.Owner = owner;
                } else
                    window.WindowStartupLocation = WindowStartupLocation.CenterScreen;
            } else {
                var owner = InferOwnerOf(window);
                if ((owner != null) && isDialog)
                    window.Owner = owner;
            }

            SetupRxWindow(model, view, window);

            return window;
        }
        /// <summary>
        /// Initializes a new instance of the CameraView class.
        /// </summary>
        public CameraView()
        {
            InitializeComponent();
            DataContextChanged += CameraView_DataContextChanged;

            _parentWindow = (MetroWindow) Application.Current.MainWindow;
        }
 public CameraPositioningCalibrationView(MetroWindow parentWindow, MetroDialogSettings settings)
     : base(parentWindow, settings)
 {
     InitializeComponent();
     DataContextChanged += CameraPositioningCalibrationView_DataContextChanged;
     CloseButton.Command = CloseCommand;
 }
 public AddProductDirectDaily(DirectSalesDailyView dsv, List <ProductsOrderedDS> lstpod)
 {
     window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;
     directSalesDailyView = dsv;
     lstProdDS            = lstpod;
     InitializeComponent();
 }
        public static async Task<MessageDialogResult> ShowMessage(MetroWindow Wnd, string message, MessageDialogStyle dialogStyle)
        {
            var metroWindow = Wnd as MetroWindow;
            metroWindow.MetroDialogOptions.ColorScheme = MetroDialogColorScheme.Accented;

            return await metroWindow.ShowMessageAsync("Atenção", message, dialogStyle, metroWindow.MetroDialogOptions);
        }        
        public SimulationSettingsControl(MetroWindow containingWindow, SimulationSettings settings, FMTesterConfiguration configuration, ExecutionInstance instance, ExecutionEnvironment environment)
        {            
            InitializeComponent();
            this.containingWindow = containingWindow;
            this.ModelSimulationSettings = settings;
            this.configuration = configuration;
            this.instance = instance;
            this.environment = environment;
            
            if (settings != null)
            {
                ModelSimulationTimeNumUpDown.Value = settings.ModelSimulationTime as double?;
                DesiredValueReachedNumUpDown.Value = settings.StableStartTime as double?;
                SmoothnessStartDifferenceNumUpDown.Value = settings.SmoothnessStartDifference as double?;
                ResponsivenessCloseNumUpDown.Value = settings.ResponsivenessClose as double?;

                DesiredValueNameTextBox.Text = settings.DesiredVariable.Name;
                DesiredValueFromNumUpDown.Value = Decimal.ToDouble(settings.DesiredVariable.FromValue) as double?;
                DesiredValueToNumUpDown.Value = Decimal.ToDouble(settings.DesiredVariable.ToValue) as double?;

                ActualValueNameTextBox.Text = settings.ActualVariable.Name;
                ActualValueFromNumUpDown.Value = Decimal.ToDouble(settings.ActualVariable.FromValue) as double?;
                ActualValueToNumUpDown.Value = Decimal.ToDouble(settings.ActualVariable.ToValue) as double?;

                DisturbanceValueNameTextBox.Text = settings.DisturbanceVariable.Name;
                DisturbanceValueToNumUpDown.Value = Decimal.ToDouble(settings.DisturbanceVariable.ToValue) as double?;
            }
        }
 public static void Navigate(Button element, MetroWindow currentWindow, TargetWindow targetWindow)
 {
     var tagInfo = (element as Button).Tag;
     var tWindow = GetTargetWindowRef(targetWindow);
     tWindow.Show();
     currentWindow.Hide();
 }
        public async void CalibrateMagnetometer(MetroWindow window)
        {
            var controller = await window.ShowProgressAsync("Please wait...", "Setting up Magnetometer Calibration.", true);

            await Task.Delay(3000);
            controller.SetTitle("Magnetometer Calibration");
            for (int i = 0; i < 101; i++)
            {
                controller.SetProgress(i / 100.0);
                controller.SetMessage(string.Format("Rotate the controller in all directions: {0}%", i));

                if (controller.IsCanceled) break;
                await Task.Delay(100);
            }
            await controller.CloseAsync();

            if (controller.IsCanceled)
            {
                await window.ShowMessageAsync("Magnetometer Calibration", "Calibration has been cancelled.");
            }
            else
            {
                await window.ShowMessageAsync("Magnetometer Calibration", "Calibration finished successfully.");
            }
        }
Esempio n. 12
0
		public async Task<object> Execute( MetroWindow window, object args )
		{
			Window = window;
			Csa = args as ConfirmationServiceArgs;
			Debug.Assert( Csa != null, "Csa != null" );

			Dialog = new ConfirmDialog();

			Tcs = new TaskCompletionSource<bool?>();

			Vm = Dialog.DataContext as ConfirmDialogViewModel;
			Debug.Assert( Vm != null, "Vm != null" );

			Vm.Reset();
			Vm.AffirmativeText = Csa.AffirmativeText;
			Vm.NegativeText = Csa.NegativeText;
			Vm.Title = Csa.Title;
			Vm.Message = Csa.Message;
			Vm.DisplayDontAskAgain = Csa.DisplayDontAskAgain;

			Vm.CloseRequested += Vm_CloseRequested;

			await window.ShowMetroDialogAsync( Dialog );
			return await Tcs.Task;
		}
 public static void Navigate(string text, MetroWindow currentWindow, TargetWindow targetWindow)
 {
     var tagInfo = text;
     var tWindow = GetTargetWindowRef(targetWindow);
     tWindow.Show();
     currentWindow.Hide();
 }
Esempio n. 14
0
        public async Task ShowsRightWindowCommandsOnTopByDefault()
        {
            await TestHost.SwitchToAppThread();

            var window = new MetroWindow();

            Assert.Equal(WindowCommandsOverlayBehavior.Always, window.RightWindowCommandsOverlayBehavior);
        }
        public async Task ShowsWindowCommandsOnTopByDefault()
        {
            await TestHost.SwitchToAppThread();

            var window = new MetroWindow();

            Assert.True(window.ShowWindowCommandsOnTop);
        }
Esempio n. 16
0
        public SwitchProfileDialog(string[] profiles, MetroWindow parentWindow, MetroDialogSettings settings)
            : base(parentWindow, settings)
        {
            InitializeComponent();

            foreach (string profile in profiles)
                PART_ProfileComboBox.Items.Add(profile);
        }
Esempio n. 17
0
        private async void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;
            dgvClients.ItemsSource = await loadDataGridDetails();

            btnUpdate.Visibility = Visibility.Hidden;
            btnSave.Visibility   = Visibility.Visible;
        }
Esempio n. 18
0
 internal AdvancedInputDialog(MetroWindow parentWindow, MetroDialogSettings settings)
     : base(parentWindow, settings)
 {
     InitializeComponent();
     PART_AffirmativeButton.Content = settings.AffirmativeButtonText;
     PART_NegativeButton.Content = settings.NegativeButtonText;
     Input = settings.DefaultText;
 }
Esempio n. 19
0
 public SoftContext(MetroWindow window)
 {
     DmSystem = new DmSystem(new DmPlugin());
     MainWindow = window;
     HttpClient = new HttpClient();
     IsLogin = false;
     TaskEngine = new TaskEngine();
 }
 private void AddMetroResources(MetroWindow window)
 {
     _resourceDictionaries = LoadResources();
     foreach (ResourceDictionary dictionary in _resourceDictionaries)
     {
         window.Resources.MergedDictionaries.Add(dictionary);
     }
 }
Esempio n. 21
0
 public PerformanceOverview()
 {
     mainWindow = Application.Current.Windows.OfType<MetroWindow>().FirstOrDefault(x => x.Title == "Ultimate Festival Organizer");
     ufoVM = (UFOCollectionVM)mainWindow.DataContext;
     DataContext = ufoVM;
     InitializeComponent();
     initialized = true;
 }
Esempio n. 22
0
        protected override Window EnsureWindow(object model, object view, bool isDialog)
        {
            var metroWindow = view as MetroWindow;
            if (metroWindow == null)
            {
                var userControl = view as UserControl;
                double minHeight = 150D;
                double minWidth = 500D;
                double? height = null;
                double? width = null;
                if (userControl != null)
                {
                    minHeight = userControl.MinHeight;
                    minWidth = userControl.MinWidth;
                    height = userControl.Height;
                    width = userControl.Width;
                }

                metroWindow = new MetroWindow
                {
                    Content = view,
                    SizeToContent = SizeToContent.Manual,
                    MinHeight = minHeight,
                    MinWidth = minWidth,
                    SaveWindowPosition = true
                };
                if (height.HasValue && width.HasValue)
                {
                    metroWindow.Height = height.Value;
                    metroWindow.Width = width.Value;
                }

                foreach (var resourceDict in _resources)
                {
                    metroWindow.Resources.MergedDictionaries.Add(resourceDict);
                }

                metroWindow.SetValue(View.IsGeneratedProperty, true);
                var owner = this.InferOwnerOf(metroWindow);
                if (owner != null)
                {
                    metroWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    metroWindow.Owner = owner;
                }
                else
                {
                    metroWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                }
            }
            else
            {
                var owner = this.InferOwnerOf(metroWindow);
                if (owner != null && isDialog)
                    metroWindow.Owner = owner;
            }

            return metroWindow;
        }
		public static async Task<MessageDialogResult> ShowDeleteMultipleGameStatsMessage(MetroWindow window, int count)
		{
			var settings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
			return
				await
				window.ShowMessageAsync("Delete Games",
				                        "This will delete the selected games (" + count + ").\n\nAre you sure?",
				                        MessageDialogStyle.AffirmativeAndNegative, settings);
		}
        public QuickDropDialog(MetroWindow parent)
        {
            _parent = parent;
            InitializeComponent();

            InitDragAndDrop();
            IsOpen = true;
            PictureSlidesLabLogo.Source = ImageUtil.BitmapToImageSource(Properties.Resources.PictureSlidesLab);
        }
        public static void HandleUrl(string url, MetroWindow window)
        {
            url = WebUtility.UrlDecode(url.Remove(0, FullName.Length));

            var r = Regex.Matches(url, "(project|projectGroup)/([^/]*)/([^/]*)/([^/]*)/?");
            foreach (Match m in r)
            {
                var linkType = m.Groups[1].ToString();
              
                switch (linkType)
                {
                    case "project":
                        var gitHubUser = m.Groups[2].ToString();
                        var repositoryName = m.Groups[3].ToString();
                        var assemblyName = m.Groups[4].ToString();

                        var w = new InstallerWindow { Owner = window };
                        w.ListAssemblies(
                            string.Format("https://github.com/{0}/{1}", gitHubUser, repositoryName), true,
                            assemblyName != "" ? m.Groups[4].ToString() : null);
                        w.ShowDialog();
                        break;

                    case "projectGroup":
                        
                        var remaining = url.Remove(0, 13);
                        var assemblies = new List<LeagueSharpAssembly>();

                        while (remaining.IndexOf("/", StringComparison.InvariantCulture) != -1)
                        {
                            var data = remaining.Split(new[] {'/'});
                            if (data.Length < 3)
                            {
                                break;
                            }
                            
                            var assembly = new LeagueSharpAssembly(data[2], "", 
                                string.Format("https://github.com/{0}/{1}", data[0], data[1]));
                            assemblies.Add(assembly);
                            for (int i = 0; i < 3; i++)
                            {
                                remaining = remaining.Remove(0, remaining.IndexOf("/", StringComparison.InvariantCulture) + 1);
                            }
                        }

                        if (assemblies.Count > 0)
                        {
                            assemblies.ForEach(
                                assembly => Config.Instance.SelectedProfile.InstalledAssemblies.Add(assembly));
                            ((MainWindow) window).PrepareAssemblies(assemblies, true, true, false);
                            ((MainWindow) window).ShowTextMessage(Utility.GetMultiLanguageText("Installer"),
                                Utility.GetMultiLanguageText("SuccessfullyInstalled"));
                        }
                        break;
                }
            }
        }
 internal SALoginDialog(MetroWindow parentWindow, LoginDialogSettings settings)
     : base(parentWindow, settings)
 {
     InitializeComponent();
     Username = settings.InitialUsername;
     UsernameWatermark = settings.UsernameWatermark;
     PasswordWatermark = settings.PasswordWatermark;
     NegativeButtonButtonVisibility = settings.NegativeButtonVisibility;
 }
		public static async Task<MessageDialogResult> ShowDeleteGameStatsMessage(MetroWindow window, GameStats stats)
		{
			var settings = new MetroDialogSettings {AffirmativeButtonText = "Yes", NegativeButtonText = "No"};
			return
				await
				window.ShowMessageAsync("Delete Game",
				                        stats.Result + " vs " + stats.OpponentHero + "\nfrom " + stats.StartTime + "\n\nAre you sure?",
				                        MessageDialogStyle.AffirmativeAndNegative, settings);
		}
 public static void Present(MetroWindow context, int index)
 {
     Flyout flyout = context.Flyouts.Items[index] as Flyout;
     if (flyout != null)
     {
         flyout.IsOpen = !flyout.IsOpen;
         return;
     }
     return;
 }
        private Button GetButton(MetroWindow window, string buttonName)
        {
            var windowButtonCommands = window.GetPart<WindowButtonCommands>("PART_WindowButtonCommands");
            Assert.NotNull(windowButtonCommands);

            var button = windowButtonCommands.Template.FindName(buttonName, windowButtonCommands) as Button;
            Assert.NotNull(button);

            return button;
        }
Esempio n. 30
0
        internal ADSelectionDialog(MetroWindow parentWindow)
            : base(parentWindow, null)
        {
            InitializeComponent();

            this.ctlList.ItemsSource = IParseRule.RulesPlayer;

            this.m_tcs = new TaskCompletionSource<object>();
            this.m_cancel = DialogSettings.CancellationToken.Register(() => this.m_tcs.TrySetResult(null));
        }
        internal ClientSelectionDialog(MetroWindow parentWindow)
            : base(parentWindow, null)
        {
            InitializeComponent();

            this.ctlList.ItemsSource = SongInfo.LastResult;

            this.m_tcs = new TaskCompletionSource<object>();
            this.m_cancel = DialogSettings.CancellationToken.Register(() => this.m_tcs.TrySetResult(null));
        }
Esempio n. 32
0
        public Task<object> Execute( MetroWindow window, object args )
        {
            var directory = args as string;

            SaveFileDialog dlg = new SaveFileDialog
            {
                InitialDirectory = directory
            };

            return Task.FromResult<object>( dlg.ShowDialog( window ) == true ? dlg.FileName : null );
        }
        public ChannelSettings(TwitchBot inBot, Popup inCurrentPopup, MetroWindow inWindow)
        {
            
            this.Loaded += ChannelSettings_Loaded;

            Bot = inBot;
            CurrentPopup = inCurrentPopup;
            mWindow = inWindow;

            InitializeComponent();
        }
Esempio n. 34
0
 private bool EnsureMainMetroWindow()
 {
     if (_mainWindow == null)
     {
         if (System.Windows.Application.Current.MainWindow == null)
             return false;
         _mainWindow = System.Windows.Application.Current.MainWindow as MetroWindow;
         if (_mainWindow == null) return false;
     }
     return true;
 }
Esempio n. 35
0
        public void disconnect()
        {
            ThisWindow.Close();
            MainWindow x = new MainWindow();

            x.Show();
            MahApps.Metro.Controls.MetroWindow wd = Window.GetWindow(x) as MahApps.Metro.Controls.MetroWindow;
            if (wd != null)
            {
                wd.ShowMessageAsync("You were Disconnected ", " You were disconnected and sent back to login Window");
            }
        }
Esempio n. 36
0
        private void MetroWindow_Loaded(object sender, RoutedEventArgs e)
        {
            window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;
            loadProductsOnCombo();
            if (FhBoxesViews != null)
            {
                dgvProducts.ItemsSource = lstProdsMods;
            }

            if (FhDrugstoreView != null)
            {
                dgvProducts.ItemsSource = lstProductForDrugstores;
            }
        }
Esempio n. 37
0
        private async void Btn_overTimeReasonReg_Click(object sender, RoutedEventArgs e)
        {
            ClientConfig cf = InitSetting.CConf;

            MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;

            if (txtOverTimeReason.Text.Trim() == "")
            {
                await window.ShowMessageAsync("알림창", "내용을 입력하여 주시기 바랍니다.");
            }
            else
            {
                cf.overtimeReason = txtOverTimeReason.Text.Trim();
                this.Close();
                MainWindow mw = (MainWindow)Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive);

                mw.Opacity = 1;
            }
        }
Esempio n. 38
0
        private async void CheckIdleTimer_Tick(object sender, System.EventArgs e)
        {
            moveTime.Content = "Total time : " + Win32.GetTickCount().ToString() + "; " + "Last input time : " + Win32.GetLastInputTime().ToString();

            //20분 이석처리시 (1000 -> 1초, 60000 -> 1분)
            if (Win32.GetIdleTime() > 1200000)
            {
                _moveFg = 1;
                Win32.LockWorkStation();
            }
            else
            {
                if (_moveFg == 1)
                {
                    _moveFg = 0;
                    MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;
                    if (window != null)
                    {
                        await window.ShowMessageAsync("알림창", "다시 자리로 돌아오셨습니다.");
                    }
                }
            }
        }
 public void connect()
 {
     if (pass != null && name != null)
     {
         UserSet USER = new UserSet();
         USER = ctx.UserSets.SingleOrDefault(u => u.login == name);
         if (USER != null)
         {
             if (USER.password == pass && (Roles(USER) == 1 || Roles(USER) == 2 || Roles(USER) == 3))
             {
                 acceuil acceuil = new acceuil(USER.profile);
                 acceuil.Show();
                 ThisWindow.Close();
                 MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(acceuil) as MahApps.Metro.Controls.MetroWindow;
                 if (window != null)
                 {
                     DateTime dt = DateTime.Today;
                     string   mt = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(dt.Month);
                     window.ShowMessageAsync("Hello " + USER.login, "It is ' " + dt.DayOfWeek + " the " + dt.Day + " of " + mt + " '. ");
                 }
             }
             else
             {
                 MessageBox.Show("Wrong Pass! Please verify");
             }
         }
         else
         {
             MessageBox.Show("User Doesn't Exist ! Please verify");
         }
     }
     else
     {
         MessageBox.Show("Wrong UserName! Please verify");
     }
 }
Esempio n. 40
0
        protected internal void CleanUp(FlyoutsControl flyoutsControl)
        {
            if (this.windowTitleThumb != null)
            {
                this.windowTitleThumb.DragStarted              -= this.WindowTitleThumbOnDragStarted;
                this.windowTitleThumb.DragCompleted            -= this.WindowTitleThumbOnDragCompleted;
                this.windowTitleThumb.PreviewMouseLeftButtonUp -= this.WindowTitleThumbOnPreviewMouseLeftButtonUp;
                this.windowTitleThumb.DragDelta          -= this.WindowTitleThumbMoveOnDragDelta;
                this.windowTitleThumb.MouseDoubleClick   -= this.WindowTitleThumbChangeWindowStateOnMouseDoubleClick;
                this.windowTitleThumb.MouseRightButtonUp -= this.WindowTitleThumbSystemMenuOnMouseRightButtonUp;
            }
            var thumbContentControl = this.flyoutHeader as IMetroThumb;

            if (thumbContentControl != null)
            {
                thumbContentControl.DragStarted              -= this.WindowTitleThumbOnDragStarted;
                thumbContentControl.DragCompleted            -= this.WindowTitleThumbOnDragCompleted;
                thumbContentControl.PreviewMouseLeftButtonUp -= this.WindowTitleThumbOnPreviewMouseLeftButtonUp;
                thumbContentControl.DragDelta          -= this.WindowTitleThumbMoveOnDragDelta;
                thumbContentControl.MouseDoubleClick   -= this.WindowTitleThumbChangeWindowStateOnMouseDoubleClick;
                thumbContentControl.MouseRightButtonUp -= this.WindowTitleThumbSystemMenuOnMouseRightButtonUp;
            }
            this.parentWindow = null;
        }
        private static void ChangeAllWindowCommandsBrush(this MetroWindow window, Brush foregroundBrush, ControlzEx.Theming.Theme currentAppTheme)
        {
            if (foregroundBrush == null)
            {
                window.LeftWindowCommands?.ClearValue(Control.ForegroundProperty);
                window.RightWindowCommands?.ClearValue(Control.ForegroundProperty);
            }

            // set the theme based on current application or window theme
            var theme = currentAppTheme != null && currentAppTheme.BaseColorScheme == ThemeManager.BaseColorDark
                ? ThemeManager.BaseColorDark
                : ThemeManager.BaseColorLight;

            // set the theme to light by default
            window.LeftWindowCommands?.SetValue(WindowCommands.ThemeProperty, theme);
            window.RightWindowCommands?.SetValue(WindowCommands.ThemeProperty, theme);

            // clear or set the foreground property
            if (foregroundBrush != null)
            {
                window.LeftWindowCommands?.SetValue(Control.ForegroundProperty, foregroundBrush);
                window.RightWindowCommands?.SetValue(Control.ForegroundProperty, foregroundBrush);
            }
        }
 private static void ChangeAllWindowCommandsBrush(this MetroWindow window, Brush brush)
 {
     window.ChangeWindowCommandButtonsBrush(brush);
     window.WindowButtonCommands.SetValue(Control.ForegroundProperty, brush);
 }
 private static void ChangeWindowCommandButtonsBrush(this MetroWindow window, Brush brush, Position position)
 {
     window.InvokeCommandButtons(x => x.SetValue(Control.ForegroundProperty, brush), position);
 }
 public static void ChangeWindowCommandButtonsBrush(this MetroWindow window, string brush, Position position)
 {
     window.InvokeCommandButtons(x => x.SetResourceReference(Control.ForegroundProperty, brush), position);
 }
        public static void UpdateWindowCommandsForFlyout(this MetroWindow window, Flyout flyout)
        {
            Brush brush = flyout.Foreground;

            window.ChangeAllWindowCommandsBrush(brush, flyout.Position);
        }
Esempio n. 46
0
        private async void regWorkData(String workDate, String _sDateTime, String _eDateTime, int sTime, int eTime)
        {
            try
            {
                MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;

                ClientConfig cf = InitSetting.CConf;

                //18:00이후 인경우만 처리(저녁)
                int _dinnerTime = 0;
                if (!(bool)cheDinner.IsChecked)
                {
                    if (sTime <= 180000 && eTime > 190000)
                    {
                        _dinnerTime = 60;
                    }
                }

                //12:00이후 인경우만 처리 (점심)
                int _lunchTime = 0;
                if (sTime <= 120000 && eTime > 130000)
                {
                    _lunchTime = 60;
                }

                WorkEntity we = new WorkEntity()
                {
                    id       = cf.userID,
                    workDate = workDate
                };

                String result   = await new CallWebApi().CallPostApiWorks("workInfoFind", we);
                Works  workList = JsonConvert.DeserializeObject <Works>(result);

                //같은 날자에 등록되어 있는 자료가 있음.
                if (workList.workList.Count > 0)
                {
                    var totalWorkHour = workList.workList
                                        .Where(w => (
                                                   (
                                                       (
                                                           double.Parse(w.workTimeS) <= double.Parse(_sDateTime)
                                                           &&
                                                           double.Parse(w.workTimeE) > double.Parse(_sDateTime)
                                                       )
                                                       ||
                                                       (
                                                           double.Parse(w.workTimeS) < double.Parse(_eDateTime)
                                                           &&
                                                           double.Parse(w.workTimeE) >= double.Parse(_eDateTime)
                                                       )
                                                   ) &&
                                                   w.workHour > 0
                                                   )
                                               ).ToList <WorkEntity>();

                    if (totalWorkHour.Count > 0)
                    {
                        //MessageBox.Show("등록된 자료중에 시간이 중복되는 자료가 있습니다.");
                        await window.ShowMessageAsync("알림창", "등록된 자료중에 시간이 중복되는 자료가 있습니다.");

                        return;
                    }
                }

                //저장할 항목
                we.workTimeS  = _sDateTime;
                we.workTimeE  = _eDateTime;
                we.dinnerTime = _dinnerTime;
                we.lunchTime  = _lunchTime;

                DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(_sDateTime);
                DateTime workEnd   = CDateTime.GetDateFrom_yyyyMMddHHmmss(_eDateTime);

                TimeSpan TS = new TimeSpan(workEnd.Ticks - workStart.Ticks);

                //총근무시간
                int spanMinute = (int)TS.TotalMinutes - _dinnerTime - _lunchTime;
                we.workHour = spanMinute;

                /*
                 * 야근시간계산법
                 * 야근시간(기본 8시간 근무시)
                 * 18시 이후에 근무하는 것은 기본적으로 야근으로 처리
                 * 주말이나 휴일 근무일 경우 모드 연장근무로 처리
                 */

                int overTime = spanMinute - 480;
                if (sTime >= 180000)
                {
                    overTime = spanMinute;
                }

                var _day = CDateTime.GetDayOfWeekHangul(workStart);

                if ((bool)cheHoly.IsChecked || _day.Equals("토") || _day.Equals("일"))
                {
                    overTime = spanMinute;
                }

                we.workOver = overTime <= 0 ? 0 : overTime;

                //오버타임인데 이유가 없을 경우
                if (overTime > 0 && overTimeReason.Content.ToString().Trim().Length == 0)
                {
                    MainWindow mw = (MainWindow)Application.Current.Windows.OfType <Window>().SingleOrDefault(x => x.IsActive);

                    pop_inputReason popup = new pop_inputReason();
                    popup.Owner = mw;
                    mw.Opacity  = 0.8;
                    popup.ShowDialog();

                    if (cf.overtimeReason.Trim() == "")
                    {
                        await window.ShowMessageAsync("알림창", "야근이유가 등록되지 않았습니다.");

                        return;
                    }
                }

                we.overTimeReason = cf.overtimeReason;

                if (overTime > 0)
                {
                    we.status = "0";
                }
                else
                {
                    we.status = "1";
                }

                //등록처리
                result = await new CallWebApi().CallPostApiWorks("workInfoAdd", we);
                var rtn = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);

                foreach (KeyValuePair <string, string> item in rtn)
                {
                    if (item.Key.Equals("result") && item.Value.Equals("NG"))
                    {
                        if (window != null)
                        {
                            await window.ShowMessageAsync("알림창", "등록에 실패하였습니다. 관리자에게 문의 부탁드립니다.");
                        }
                        break;
                    }
                    else
                    {
                        if (window != null)
                        {
                            if (overTime > 0)
                            {
                                await window.ShowMessageAsync("알림창", "등록었습니다. 야근이 있는 경우 승인 후 야근시간이 반영되어 집니다.");
                            }
                            else
                            {
                                await window.ShowMessageAsync("알림창", "등록되었습니다.");
                            }
                        }
                        break;
                    }
                }
                GetList();
                cf.overtimeReason = "";
            }
            catch { }
        }
Esempio n. 47
0
        /// <summary>
        /// 页面跳转,之后的所有页面在此函数经行
        /// </summary>
        /// <param name="viewInfo"></param>
        private void Navigate(ViewInfo viewInfo)
        {
            MyUserControlBase view;


            if (Equals(viewInfo.Parameter, null))
            {
                var assemblyName = viewInfo.ViewName.ToDescription().Split(',');
                if (assemblyName.Length > 1)
                {
                    view =
                        System.Reflection.Assembly.Load(assemblyName[0])
                        .CreateInstance(assemblyName[1]) as MyUserControlBase;
                }
                else
                {
                    view =
                        System.Reflection.Assembly.Load(@"House.UserControls")
                        .CreateInstance(assemblyName[0]) as MyUserControlBase;
                }
            }
            else
            {
                var assemblyName = viewInfo.ViewName.ToDescription().Split(',');
                if (assemblyName.Length > 1)
                {
                    view =
                        System.Reflection.Assembly.Load(assemblyName[0])
                        .CreateInstance(assemblyName[1], true, System.Reflection.BindingFlags.Default,
                                        null, new[] { viewInfo.Parameter }, null, null) as MyUserControlBase;
                }
                else
                {
                    view =
                        System.Reflection.Assembly.Load(@"House.UserControls")
                        .CreateInstance(assemblyName[0], true, System.Reflection.BindingFlags.Default,
                                        null, new[] { viewInfo.Parameter }, null, null) as MyUserControlBase;
                }
            }

            if (view == null)
            {//未找到视图,抛出异常
                //throw new Exception(viewInfo.ViewName.ToString());
                this.RootPanel.Content = "视图加载失败请联系客服";
            }

            if ((view as MainMenu.Views.MainMenuView2) != null)
            {
                this.restoreBtn.Visibility = Visibility;
            }
            else
            {
                this.restoreBtn.Visibility = Visibility.Collapsed;
            }

            switch (viewInfo.ViewType)
            {
            case ViewType.Popup:    //模式对话框
                MahApps.Metro.Controls.MetroWindow popupWindows = new MahApps.Metro.Controls.MetroWindow();
                popupWindows.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                popupWindows.Style     = FindResource(@"CleanWindowStyleKey") as Style;
                popupWindows.GlowBrush = FindResource(@"AccentColorBrush") as System.Windows.Media.Brush;
                //变更语言时,动态更新对话框Title,Title取决于控件的Tag
                popupWindows.SetBinding(MahApps.Metro.Controls.MetroWindow.TitleProperty, new Binding(@"Tag")
                {
                    Source = view
                });
                popupWindows.SetBinding(MahApps.Metro.Controls.MetroWindow.WidthProperty, new Binding(@"Width")
                {
                    Source = view
                });
                popupWindows.SetBinding(MahApps.Metro.Controls.MetroWindow.HeightProperty, new Binding(@"Height")
                {
                    Source = view
                });
                popupWindows.Owner                = Application.Current.MainWindow;
                popupWindows.ResizeMode           = ResizeMode.NoResize;
                popupWindows.IsCloseButtonEnabled = false;
                popupWindows.ShowCloseButton      = false;
                //popupWindows.Icon = new BitmapImage(new Uri("pack://*****:*****@"AccentColorBrush") as System.Windows.Media.Brush;
                //变更语言时,动态更新对话框Title,Title取决于控件的Tag
                singleWindows.SetBinding(MahApps.Metro.Controls.MetroWindow.TitleProperty, new Binding(@"Tag")
                {
                    Source = view
                });
                singleWindows.SetBinding(MahApps.Metro.Controls.MetroWindow.WidthProperty, new Binding(@"Width")
                {
                    Source = view
                });
                singleWindows.SetBinding(MahApps.Metro.Controls.MetroWindow.HeightProperty, new Binding(@"Height")
                {
                    Source = view
                });
                singleWindows.Content    = view;
                singleWindows.ResizeMode = ResizeMode.NoResize;
                //singleWindows.ShowIconOnTitleBar = true;
                singleWindows.Icon = new BitmapImage(new Uri("pack://application:,,,/House.Thems;component/Images/Logo.ico", UriKind.Absolute));
                //singleWindows.Icon = Utility.Windows.ResourceHelper.FindResource("pack://application:,,,/SuperSoft.Resource.Default;component/Images/Logo_White.png");
                //singleWindows.IsCloseButtonEnabled = true;
                //singleWindows.ShowCloseButton = true;
                //singleWindows.Owner = Application.Current.MainWindow;
                singleWindows.Topmost = true;
                singleWindows.Show();
                singleWindows.Focus();
                break;
            }
        }
 public static void UpdateWindowCommandsForFlyout(this MetroWindow window, Flyout flyout)
 {
     window.ChangeAllWindowButtonCommandsBrush(flyout.Foreground, flyout.Position);
 }
Esempio n. 49
0
        /// <summary>
        /// 页面导航跳转,生成新页面
        /// </summary>
        /// <param name="viewInfo">页面信息</param>
        private void navigate(ViewInfo viewInfo)
        {
            Application.Current.MainWindow.Cursor = Cursors.Wait;

            UserControlBase view = null;

            if (Equals(viewInfo, null))
            {
                Application.Current.Resources["UiMessage"] = "未找到页面信息,请确认MenuFunctionViewInfoMap.json配置正确!";
                LogHelper.Info(Application.Current.Resources["UiMessage"].ToString());
                Application.Current.MainWindow.Cursor = Cursors.Arrow;
                return;
            }
            //已经打开则激活
            if (layoutDocumentPane.Children.Any(a => a.Title == viewInfo.DisplayName.ToString()))
            {
                var tmp = layoutDocumentPane.Children.FirstOrDefault(a => a.Title == viewInfo.DisplayName.ToString());
                tmp.IsActive = true;

                Application.Current.Resources["UiMessage"] = $"{viewInfo.DisplayName} 页面已经打开,设置激活成功!";
                Application.Current.MainWindow.Cursor      = Cursors.Arrow;

                return;
            }

            try
            {
                view = System.Reflection.Assembly.Load(viewInfo.ViewAssemblyName)
                       .CreateInstance(viewInfo.ViewName) as UserControlBase;
            }
            catch (Exception ex)
            {
                Application.Current.Resources["UiMessage"] = "未找到页面:" + viewInfo.ViewName + ex.Message;
                LogHelper.Error(Application.Current.Resources["UiMessage"] + viewInfo.ToString(), ex);
                Application.Current.MainWindow.Cursor = Cursors.Arrow;
                return;
            }

            if (Equals(view, null))
            {
                Application.Current.Resources["UiMessage"] = "未找到页面:" + viewInfo.ViewName;
                LogHelper.Info(Application.Current.Resources["UiMessage"] + viewInfo.ToString());
                Application.Current.MainWindow.Cursor = Cursors.Arrow;
                return;
            }

            VmBase viewModel = null;

            try
            {
                viewModel = System.Reflection.Assembly.Load(viewInfo.ViewModelAssemblyName)
                            .CreateInstance(viewInfo.ViewModelName) as VmBase;
            }
            catch (Exception ex)
            {
                Application.Current.Resources["UiMessage"] = "未找到ViewModel:" + viewInfo.ViewModelName;
                LogHelper.Error(Application.Current.Resources["UiMessage"] + viewInfo.ToString(), ex);
                Application.Current.MainWindow.Cursor = Cursors.Arrow;
                return;
            }
            if (Equals(viewModel, null))
            {
                Application.Current.Resources["UiMessage"] = "未找到ViewModel:" + viewInfo.ViewModelName;
                LogHelper.Info(Application.Current.Resources["UiMessage"] + viewInfo.ToString());
                Application.Current.MainWindow.Cursor = Cursors.Arrow;
                return;
            }
            //Application.Current.Resources["UiMessage"] = viewInfo.DisplayName;
            //LogHelper.Info(Application.Current.Resources["UiMessage"] + viewInfo.ToString());
            //view.Parameter = viewInfo.Parameter;
            //viewModel.Parameter = view.Parameter;
            viewModel.Parameter  = viewInfo.Parameter;
            viewModel.MenuModule = viewInfo.MenuModule;
            view.DataContext     = viewModel;
            //根据页面类型生成页面
            switch (viewInfo.ViewType)
            {
            case ViewType.PopupNoTitle:     //没有标题栏的页面
                MahApps.Metro.Controls.MetroWindow popupNoTitleWindows = new MahApps.Metro.Controls.MetroWindow();
                popupNoTitleWindows.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                popupNoTitleWindows.Style                 = Utility.Windows.ResourceHelper.FindResource(@"CleanWindowStyleKey") as Style;
                popupNoTitleWindows.GlowBrush             = Utility.Windows.ResourceHelper.FindResource(@"AccentColorBrush") as System.Windows.Media.Brush;
                popupNoTitleWindows.Owner                 = Application.Current.MainWindow.IsInitialized == false ? null : Application.Current.MainWindow;
                popupNoTitleWindows.ResizeMode            = ResizeMode.NoResize;
                popupNoTitleWindows.IsCloseButtonEnabled  = false;
                popupNoTitleWindows.ShowInTaskbar         = popupNoTitleWindows.Owner == null ? true : false;
                popupNoTitleWindows.MouseDown            += PopupWindows_MouseDown;
                popupNoTitleWindows.ShowCloseButton       = false;
                popupNoTitleWindows.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                popupNoTitleWindows.Width                 = view.Width;
                popupNoTitleWindows.Height                = view.Height;
                popupNoTitleWindows.TitlebarHeight        = 0;
                //有限实用配置的图标,没有则使用默认的图标,没有则使用主窗体的
                popupNoTitleWindows.Icon =
                    Utility.Windows.BitmapImageHelper.GetBitmapImage(viewInfo.Icon)
                    ?? Utility.Windows.BitmapImageHelper.GetBitmapImage(@"pack://*****:*****@"CleanWindowStyleKey") as Style;
                popupWindows.GlowBrush            = Utility.Windows.ResourceHelper.FindResource(@"AccentColorBrush") as System.Windows.Media.Brush;
                popupWindows.Owner                = Application.Current.MainWindow.IsInitialized == false ? null : Application.Current.MainWindow;
                popupWindows.ResizeMode           = ResizeMode.NoResize;
                popupWindows.IsCloseButtonEnabled = false;
                popupWindows.ShowCloseButton      = false;
                popupWindows.Width                = view.Width;
                popupWindows.Height               = view.Height;
                popupWindows.Title                = viewInfo.DisplayName;
                //有则使用配置的图标,没有则使用默认的图标,再没有则使用主窗体的图标
                popupWindows.Icon =
                    Utility.Windows.BitmapImageHelper.GetBitmapImage(viewInfo.Icon)
                    ?? Utility.Windows.BitmapImageHelper.GetBitmapImage(@"pack://*****:*****@"pack://application:,,,/Solution.Desktop.Resource;component/Images/logo_16x16.ico")
                    ?? Application.Current.MainWindow.Icon;
                layoutDocument.Content = view;
                layoutDocumentPane.Children.Add(layoutDocument);
                layoutDocument.IsActive = true;
                layoutDocument.Closed  += LayoutDocument_Closed;
                Application.Current.MainWindow.Cursor = Cursors.Arrow;
                break;

            case ViewType.SingleWindow:    //单个视图。主要为了显示帮助窗口
                MahApps.Metro.Controls.MetroWindow singleWindows = new MahApps.Metro.Controls.MetroWindow();
                singleWindows.TitlebarHeight        = 23;
                singleWindows.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                singleWindows.Style     = Utility.Windows.ResourceHelper.FindResource(@"CleanWindowStyleKey") as Style;
                singleWindows.GlowBrush = Utility.Windows.ResourceHelper.FindResource(@"AccentColorBrush") as System.Windows.Media.Brush;
                singleWindows.Content   = view;
                singleWindows.Width     = view.Width;
                singleWindows.Height    = view.Height;
                singleWindows.Title     = viewInfo.DisplayName;
                //有则使用配置的图标,没有则使用默认的图标,再没有则使用主窗体的图标
                singleWindows.Icon =
                    Utility.Windows.BitmapImageHelper.GetBitmapImage(viewInfo.Icon)
                    ?? Utility.Windows.BitmapImageHelper.GetBitmapImage(@"pack://application:,,,/Solution.Desktop.Resource;component/Images/logo_16x16.ico")
                    ?? Application.Current.MainWindow.Icon;
                singleWindows.Closed += Window_Closed;

                singleWindows.Show();
                singleWindows.Focus();
                Application.Current.MainWindow.Cursor = Cursors.Arrow;
                break;
            }
        }
Esempio n. 50
0
        private async void regWorkData(String workDate, String _sDateTime, String _eDateTime)
        {
            try
            {
                MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;

                ClientConfig cf = InitSetting.CConf;

                //18:00이후 인경우만 처리(저녁)
                int _dinnerTime = 0;

                //12:00이후 인경우만 처리 (점심)
                int _lunchTime = 0;

                WorkEntity we = new WorkEntity()
                {
                    id       = cf.userID,
                    workDate = workDate
                };

                //저장할 항목
                we.workTimeS  = _sDateTime;
                we.workTimeE  = _eDateTime;
                we.dinnerTime = _dinnerTime;
                we.lunchTime  = _lunchTime;

                DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(_sDateTime);
                DateTime workEnd   = CDateTime.GetDateFrom_yyyyMMddHHmmss(_eDateTime);

                TimeSpan TS = new TimeSpan(workEnd.Ticks - workStart.Ticks);

                //총근무시간
                int spanMinute = (int)TS.TotalMinutes - _dinnerTime - _lunchTime;
                we.workHour = 0;

                //야근시간
                int overTime = spanMinute * -1;
                we.workOver = overTime;

                we.overTimeReason = vacationReason.Text;
                we.status         = "0";

                //등록처리
                String result = await new CallWebApi().CallPostApiWorks("workInfoAdd", we);
                var    rtn    = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);

                foreach (KeyValuePair <string, string> item in rtn)
                {
                    if (item.Key.Equals("result") && item.Value.Equals("NG"))
                    {
                        if (window != null)
                        {
                            await window.ShowMessageAsync("알림창", "등록에 실패하였습니다. 관리자에게 문의 부탁드립니다.");
                        }
                        break;
                    }
                    else
                    {
                        if (window != null)
                        {
                            await window.ShowMessageAsync("알림창", "등록었습니다. 승인 후 시간이 반영되어 집니다.");
                        }
                        break;
                    }
                }
                GetList();
                cf.overtimeReason = "";
            }
            catch { }
        }
Esempio n. 51
0
        private async void regWorkData(String workDate, String _sDateTime, String _eDateTime, int sTime, int eTime)
        {
            try
            {
                MahApps.Metro.Controls.MetroWindow window = Window.GetWindow(this) as MahApps.Metro.Controls.MetroWindow;

                ClientConfig cf = InitSetting.CConf;

                //18:00이후 인경우만 처리(저녁)
                int _dinnerTime = 0;

                if (sTime <= 180000 && eTime > 190000)
                {
                    _dinnerTime = 60;
                }

                //12:00이후 인경우만 처리 (점심)
                int _lunchTime = 0;
                if (sTime <= 120000 && eTime > 130000)
                {
                    _lunchTime = 60;
                }

                WorkEntity we = new WorkEntity()
                {
                    id       = cf.userID,
                    workDate = workDate
                };

                String result   = await new CallWebApi().CallPostApiWorks("workInfoFind", we);
                Works  workList = JsonConvert.DeserializeObject <Works>(result);

                //같은 날자에 등록되어 있는 자료가 있음.
                if (workList.workList.Count > 0)
                {
                    var totalWorkHour = workList.workList
                                        .Where(w => (
                                                   (
                                                       double.Parse(w.workTimeS) <= double.Parse(_sDateTime)
                                                       &&
                                                       double.Parse(w.workTimeE) > double.Parse(_sDateTime)
                                                   )
                                                   ||
                                                   (
                                                       double.Parse(w.workTimeS) < double.Parse(_eDateTime)
                                                       &&
                                                       double.Parse(w.workTimeE) >= double.Parse(_eDateTime)
                                                   )
                                                   )
                                               ).ToList <WorkEntity>();

                    if (totalWorkHour.Count > 0)
                    {
                        MessageBox.Show("등록된 자료중에 시간이 중복되는 자료가 있습니다.");
                        return;
                    }
                }

                //저장할 항목
                we.workTimeS  = _sDateTime;
                we.workTimeE  = _eDateTime;
                we.dinnerTime = _dinnerTime;
                we.lunchTime  = _lunchTime;

                DateTime workStart = CDateTime.GetDateFrom_yyyyMMddHHmmss(_sDateTime);
                DateTime workEnd   = CDateTime.GetDateFrom_yyyyMMddHHmmss(_eDateTime);

                TimeSpan TS = new TimeSpan(workEnd.Ticks - workStart.Ticks);

                //총근무시간
                int spanMinute = (int)TS.TotalMinutes - _dinnerTime - _lunchTime;
                we.workHour = spanMinute;

                //야근시간
                int overTime = spanMinute - 480;
                we.workOver = overTime <= 0 ? 0 : overTime;

                if (overTime > 0)
                {
                    we.status = "0";
                }
                else
                {
                    we.status = "1";
                }

                //등록처리
                result = await new CallWebApi().CallPostApiWorks("workInfoAdd", we);
                var rtn = JsonConvert.DeserializeObject <Dictionary <string, string> >(result);

                foreach (KeyValuePair <string, string> item in rtn)
                {
                    if (item.Key.Equals("result") && item.Value.Equals("NG"))
                    {
                        if (window != null)
                        {
                            this.Show();
                            await window.ShowMessageAsync("알림창", "등록에 실패하였습니다. 관리자에게 문의 부탁드립니다.");
                        }
                        break;
                    }
                    else
                    {
                        if (window != null)
                        {
                            if (overTime > 0)
                            {
                                this.Show();
                                cf.workStatus = "0";
                                await window.ShowMessageAsync("알림창", "등록었습니다. 야근이 있는 경우 승인 후 야근시간이 반영되어 집니다.");
                            }
                            else
                            {
                                cf.workStatus = "0";
                                _uc_dashboard = new uc_DashBoard();
                                uc_Class.Uc_Link(Contents_Border, _uc_dashboard);
                            }
                        }
                        break;
                    }
                }
                cf.overtimeReason = "";
            }
            catch
            {
            }
        }
Esempio n. 52
0
        /// <summary>
        /// 导航到页面
        /// </summary>
        /// <param name="viewInfo">ViewInfo实例</param>
        private void navigateView(ViewInfo viewInfo)
        {
            //树形导航的内容
            var    module = viewInfo?.Module as Module;
            object view   = null;

            try
            {
                view = System.Reflection.Assembly.Load(module?.AssemblyName)
                       .CreateInstance(module?.ViewName);
                if (Equals(view, null))
                {
                    throw new NullReferenceException("加载模块时错误,页面未找到!");
                }
            }
            catch (Exception ex)
            {
                string msg = $"加载{module?.Name}{module?.AssemblyName}时错误,请确认模块名称和页面名称配置正确!{System.Environment.NewLine}{TypeExtensions.GetPropertiesValue<Module>(module)}{System.Environment.NewLine}{ex.Message}{System.Environment.NewLine}{ex.StackTrace}";
                LogHelper.Logger.Error(msg, ex);
                (Application.Current.MainWindow as MetroWindow).ShowMessageAsync("系统错误", msg);
                return;
            }

            switch (viewInfo.ViewType)
            {
            case ViewType.DockableView:    //可停靠的页面
            default:
                #region DockableView
                try
                {
                    if (layoutDocumentPane.Children.Any(a => a.ContentId == module?.Id.ToString()))
                    {
                        var tmp = layoutDocumentPane.Children.FirstOrDefault(a => a.ContentId == module?.Id.ToString());
                        tmp.IsActive = true;
                        return;
                    }
                    LayoutDocument layoutDocument = new LayoutDocument();
                    layoutDocument.Title     = module?.Name;
                    layoutDocument.ContentId = module?.Id.ToString();
                    layoutDocument.ToolTip   = layoutDocument.Title;
                    var icon = Utility.Windows.BitmapImageHelper.GetBitmapImage(module?.Icon, 16, 16);
                    layoutDocument.IconSource        = icon;
                    (view as UserControlBase).Margin = (Thickness)Utility.Windows.ResourceHelper.FindResource("UserControlMargin");
                    var viewModelBase = (view as UserControlBase)?.DataContext as ViewModelBase;
                    if (!Equals(viewModelBase, null))
                    {
                        viewModelBase.Parameter.Add(new KeyValuePair <string, object>(ParentName, layoutDocument));
                        if (!Equals(viewInfo.Parameter))
                        {
                            viewModelBase.Parameter.Add(new KeyValuePair <string, object>(DataModelName, viewInfo.Parameter));
                        }
                    }
                    layoutDocument.Content = view;
                    layoutDocumentPane.Children.Add(layoutDocument);
                    layoutDocument.IsActive = true;
                    Application.Current.MainWindow.Cursor = Cursors.Arrow;
                    LogHelper.Logger.Info($"{StaticData.CurrentUser?.Name }/{StaticData.CurrentUser?.NickName},打开{module?.Name}模块");
                }
                catch (Exception ex)
                {
                    string msg = $"加载{module?.AssemblyName}时错误,请确认模块名称和页面名称配置正确!{System.Environment.NewLine}{TypeExtensions.GetPropertiesValue<Module>(module)}{System.Environment.NewLine}{ex.Message }{System.Environment.NewLine}{ex.StackTrace}";
                    LogHelper.Logger.Error(msg, ex);
                    (Application.Current.MainWindow as MetroWindow).ShowMessageAsync("系统错误", msg);
                }
                #endregion
                break;

            case ViewType.MetroPopup:    //Metro蒙版模式对话框
                #region MetroPopup
                try
                {
                    var customDialog = new CustomDialog()
                    {
                        Title = module.Name
                    };
                    var userControlBase = view as UserControlBase;
                    var viewModelBase   = userControlBase.DataContext as ViewModelBase;
                    if (!Equals(viewModelBase, null))
                    {
                        viewModelBase.Parameter.Add(new KeyValuePair <string, object>(ParentName, customDialog));
                        if (!Equals(viewInfo.Parameter))
                        {
                            viewModelBase.Parameter.Add(new KeyValuePair <string, object>(DataModelName, viewInfo.Parameter));
                        }
                    }
                    customDialog.Content = view;
                    LogHelper.Logger.Info($"{StaticData.CurrentUser?.Name }/{StaticData.CurrentUser?.NickName},打开{module?.Name}Metro对话框模块");
                    var windows = Application.Current.MainWindow as MahApps.Metro.Controls.MetroWindow;
                    windows?.ShowMetroDialogAsync(customDialog);
                }
                catch (Exception ex)
                {
                    string msg = $"加载{module?.AssemblyName}时错误,请确认模块名称和页面名称配置正确!{System.Environment.NewLine}{TypeExtensions.GetPropertiesValue<Module>(module)}{System.Environment.NewLine}{ex.Message }{System.Environment.NewLine}{ex.StackTrace}";
                    LogHelper.Logger.Error(msg, ex);
                    (Application.Current.MainWindow as MetroWindow).ShowMessageAsync("系统错误", msg);
                }
                #endregion
                break;

            case ViewType.Popup:    //模式对话框弹出窗体
                #region Popup
                try
                {
                    MahApps.Metro.Controls.MetroWindow popupWindows = new MahApps.Metro.Controls.MetroWindow();
                    //popupWindows.TitlebarHeight = 25;
                    popupWindows.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                    popupWindows.Style                     = Utility.Windows.ResourceHelper.FindResource(@"CleanWindowStyleKey") as Style;
                    popupWindows.WindowTitleBrush          = Utility.Windows.ResourceHelper.FindResource(@"PopupWindowsTitleColorBrush") as System.Windows.Media.Brush;
                    popupWindows.NonActiveWindowTitleBrush = Utility.Windows.ResourceHelper.FindResource(@"PopupWindowsTitleColorBrush") as System.Windows.Media.Brush;
                    popupWindows.Background                = Utility.Windows.ResourceHelper.FindResource(@"PopupWindowsBackgroundColorBrush") as System.Windows.Media.Brush;
                    popupWindows.GlowBrush                 = Utility.Windows.ResourceHelper.FindResource(@"PopupWindowsGlowBrush") as System.Windows.Media.Brush;
                    popupWindows.Owner                     = Application.Current.MainWindow.IsInitialized == false ? null : Application.Current.MainWindow;
                    popupWindows.ResizeMode                = ResizeMode.NoResize;
                    popupWindows.IsCloseButtonEnabled      = true;
                    popupWindows.ShowCloseButton           = true;
                    popupWindows.Width                     = (view as UserControlBase).Width + popupWindows.BorderThickness.Left + popupWindows.BorderThickness.Right;
                    popupWindows.Height                    = (view as UserControlBase).Height + popupWindows.TitlebarHeight;
                    popupWindows.Title                     = module?.Name;
                    //有则使用配置的图标,没有则使用默认的图标,再没有则使用主窗体的图标
                    popupWindows.Icon =
                        Utility.Windows.BitmapImageHelper.GetBitmapImage(module?.Icon)
                        ?? Utility.Windows.BitmapImageHelper.GetBitmapImage(@"pack://*****:*****@"CleanWindowStyleKey") as Style;
                    singleWindows.WindowTitleBrush          = Utility.Windows.ResourceHelper.FindResource(@"PopupWindowsTitleColorBrush") as System.Windows.Media.Brush;
                    singleWindows.NonActiveWindowTitleBrush = Utility.Windows.ResourceHelper.FindResource(@"PopupWindowsTitleColorBrush") as System.Windows.Media.Brush;
                    singleWindows.Background                = Utility.Windows.ResourceHelper.FindResource(@"PopupWindowsBackgroundColorBrush") as System.Windows.Media.Brush;
                    singleWindows.GlowBrush                 = Utility.Windows.ResourceHelper.FindResource(@"AccentColorBrush") as System.Windows.Media.Brush;
                    //singleWindows.Owner = Application.Current.MainWindow.IsInitialized == false ? null : Application.Current.MainWindow;
                    singleWindows.IsCloseButtonEnabled = true;
                    singleWindows.ShowCloseButton      = true;
                    singleWindows.Width  = (view as UserControlBase).Width + singleWindows.BorderThickness.Left + singleWindows.BorderThickness.Right;
                    singleWindows.Height = (view as UserControlBase).Height + singleWindows.TitlebarHeight;
                    singleWindows.Title  = module?.Name;
                    //有则使用配置的图标,没有则使用默认的图标,再没有则使用主窗体的图标
                    singleWindows.Icon =
                        Utility.Windows.BitmapImageHelper.GetBitmapImage(module?.Icon)
                        ?? Utility.Windows.BitmapImageHelper.GetBitmapImage(@"pack://application:,,,/Desktop.Resource;component/Images/Logo_128.ico")
                        ?? Application.Current.MainWindow.Icon;
                    var viewModelBase = (view as UserControlBase)?.DataContext as ViewModelBase;
                    if (!Equals(viewModelBase, null))
                    {
                        viewModelBase.Parameter.Add(new KeyValuePair <string, object>(ParentName, singleWindows));
                        if (!Equals(viewInfo.Parameter))
                        {
                            viewModelBase.Parameter.Add(new KeyValuePair <string, object>(DataModelName, viewInfo.Parameter));
                        }
                    }
                    singleWindows.ShowInTaskbar = true;
                    singleWindows.Content       = view;
                    singleWindows.Closed       += windows_Closed;
                    singleWindows.MouseDown    += popupWindows_MouseDown;
                    singleWindows.Focus();
                    singleWindows.Show();
                }
                catch (Exception ex)
                {
                    string msg = $"加载{module?.AssemblyName}时错误,请确认模块名称和页面名称配置正确!{System.Environment.NewLine}{TypeExtensions.GetPropertiesValue<Module>(module)}{System.Environment.NewLine}{ex.Message }{System.Environment.NewLine}{ex.StackTrace}";
                    LogHelper.Logger.Error(msg, ex);
                    (Application.Current.MainWindow as MetroWindow).ShowMessageAsync("系统错误", msg);
                }
                #endregion
                break;
            }
        }
Esempio n. 53
0
 public static void ResetAllWindowCommandsBrush(this MetroWindow window)
 {
     window.ChangeAllWindowCommandsBrush(window.OverrideDefaultWindowCommandsBrush);
 }