Exemplo n.º 1
0
        private void ChangeTheme_OnClick(object sender, RoutedEventArgs e)
        {
            var theme = sender.As <FrameworkElement>().Tag.As <string>();

            ThemeUtils.SetTheme(theme);
            _settings.Theme = theme;
        }
 public MainWindow()
 {
     InitializeComponent();
     Application.Current.MainWindow = this;
     ThemeUtils.SwitchTheme();
     NavigatePage(new Changelog());
 }
        //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\
        #region --Attributes--


        #endregion
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--


        #endregion
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value is string s)
            {
                if (double.TryParse(s, out double grade))
                {
                    if (grade < 2)
                    {
                        return(new SolidColorBrush(Colors.DarkGreen));
                    }
                    if (grade < 3)
                    {
                        return(new SolidColorBrush(Colors.YellowGreen));
                    }
                    if (grade <= 4)
                    {
                        return(new SolidColorBrush(Colors.DarkOrange));
                    }
                    return(new SolidColorBrush(Colors.DarkRed));
                }
                if (s == "B")
                {
                    return(new SolidColorBrush(Colors.DarkGreen));
                }
            }
            return(ThemeUtils.GetThemeResource <SolidColorBrush>("TumBlueBrush"));
        }
Exemplo n.º 4
0
        public void StartupModules()
        {
            if (App.Environment.ClientInfo.SessionKey != null)
            {
                ThemeUtils.ChangeSkin(App.Environment.ClientInfo.UserProfile.ApplicationSkinName);

                foreach (var module in AllCaches.ModulesInfo)
                {
                    if (module.StartMode == CODES.DEFMOD.STARTMODE.AUTOMATIC)
                    {
                        try
                        {
                            using (var ctrlSA = new SAController())
                            {
                                ctrlSA.CheckRole(module);
                                var startupModule = CreateModuleInstance(module.ModuleID, module.SubModule);
                                startupModule.ShowModule(m_mainForm);
                            }
                        }
                        catch (FaultException ex)
                        {
                            if (ex.Code.Name != ERR_SYSTEM.ERR_SYSTEM_MODULE_NOT_ALLOW_ACCESS.ToString())
                            {
                                frmInfo.ShowError(((IMain)m_mainForm).Language.ApplicationTitle, ex, m_mainForm);
                            }
                        }
                        catch (Exception ex)
                        {
                            frmInfo.ShowError(((IMain)m_mainForm).Language.ApplicationTitle, ErrorUtils.CreateErrorWithSubMessage(ERR_SYSTEM.ERR_SYSTEM_UNKNOWN, ex.Message), m_mainForm);
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        public override void Initialize()
        {
            AvaloniaXamlLoader.Load(this);

            /* Clean everything from the old run up */
            if (PlatformUtils.IsWindows)
            {
#if WindowsNoARM
                ThePBone.Interop.Win32.TrayIcon.ResourceLoader.ClearCache();
#endif
            }

            if (Loc.IsTranslatorModeEnabled())
            {
                SettingsProvider.Instance.Locale = Locales.custom;
            }

            ThemeUtils.Reload();
            Loc.Load();

            MediaKeyRemoteImpl.Init();
            DeviceMessageCache.Init();
            UpdateManager.Init();
            ExperimentManager.Init();

            Log.Information($"Translator mode file location: {Loc.GetTranslatorModeFile()}");

            ScriptManager.Instance.RegisterUserHooks();
        }
Exemplo n.º 6
0
        private void OnActivatedOrLaunched(IActivatedEventArgs args)
        {
            // Sets the log level:
            InitLogger();

            // Override resources to increase the UI performance on mobile devices:
            if (DeviceFamilyHelper.GetDeviceFamilyType() == DeviceFamilyType.Mobile)
            {
                ThemeUtils.OverrideThemeResources();
            }

            isRunning = true;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (!(Window.Current.Content is Frame rootFrame))
            {
                // Create a Frame to act as the navigation context and navigate to the first page:
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            ExtendedSplashScreenPage extendedSplashScreen = new ExtendedSplashScreenPage(args, rootFrame, Push_PushNotificationReceived);

            rootFrame.Content = extendedSplashScreen;

            Window.Current.Activate();
        }
        /// <summary>
        ///     Calculates appropriate colors and icons for a shape's fill color.
        /// </summary>
        private static FillColorAppearance CalculateFillColorAppearance(Color fillColor)
        {
            var hslColor = HslColor.FromRgbColor(fillColor);

            return(new FillColorAppearance
            {
                TextColor = GetTextColor(fillColor),
                OutlineColor
                    = new HslColor
                    {
                        Hue = hslColor.Hue,
                        Saturation = hslColor.Saturation * 3 / 5,
                        Luminosity = GetHighlightLuminosity(hslColor.Luminosity)
                    }.ToRgbColor(),
#if VS12ORNEWER
                EntityGlyph = ThemeUtils.GetThemedButtonImage(EntityGlyph, fillColor),
                BaseTypeIcon = ThemeUtils.GetThemedButtonImage(BaseTypeIcon, fillColor),
                ChevronExpanded = ThemeUtils.GetThemedButtonImage(ChevronExpanded, fillColor),
                ChevronCollapsed = ThemeUtils.GetThemedButtonImage(ChevronCollapsed, fillColor)
#else
                // avoid icon inversion in VS11 because it causes unclear images on light backgrounds
                EntityGlyph = EntityGlyph,
                BaseTypeIcon = BaseTypeIcon,
                ChevronExpanded = ChevronExpanded,
                ChevronCollapsed = ChevronCollapsed
#endif
            });
Exemplo n.º 8
0
        //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\
        #region --Attributes--


        #endregion
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--


        #endregion
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (value is ChatType chatType && chatType == ChatType.CHAT)
            {
                return(ThemeUtils.GetThemeResource <FontFamily>("ContentControlThemeFontFamily"));
            }
            return(ThemeUtils.GetThemeResource <FontFamily>("SymbolThemeFontFamily"));
        }
Exemplo n.º 9
0
 public static ImageList GetArrowsImageList()
 {
     return(_imageListArrows
            ?? (_imageListArrows
                    = ThemeUtils.GetThemedImageList(
                          Resources.MappingDetailsArrowsImageList,
                          TreeViewColors.BackgroundColorKey)));
 }
Exemplo n.º 10
0
 public static ImageList GetToolbarImageList()
 {
     return(_imageListToolbar
            ?? (_imageListToolbar
                    = ThemeUtils.GetThemedImageList(
                          Resources.MappingDetailsCommandStrip,
                          EnvironmentColors.CommandBarOptionsBackgroundColorKey)));
 }
Exemplo n.º 11
0
 public override void InitializeLanguage()
 {
     base.Language = new IEModuleLanguage(ModuleInfo)
     {
         ModuleImageIndex     = ThemeUtils.GetImage24x24Index("MODULE"),
         ModuleTypeImageIndex = ThemeUtils.GetImage24x24Index("MODULE_TYPE")
     };
     base.InitializeLanguage();
 }
Exemplo n.º 12
0
        public LoginWindow()
        {
            InitializeComponent();
            NavigatePage(new Views.Login());
            Startup.LoginWindow = this;
            var settings = Globals.Container.GetInstance <ISettingsManager <SettingsModel> >().Load();

            ThemeUtils.SwitchTheme("Default", "Default", settings.DarkMode);
        }
Exemplo n.º 13
0
        public void BatchError(BatchInfo batch, FaultException ex)
        {
            var item = chkLstBatchName.Items[batch];

            if (item != null)
            {
                var index = lstExecuteResult.Items.Add(item.Description, ThemeUtils.GetImage16x16Index("ERROR"));
                ProcessErrors[index] = ex;
            }
        }
Exemplo n.º 14
0
        public void BatchComplete(BatchInfo batch)
        {
            var item = chkLstBatchName.Items[batch];

            if (item != null)
            {
                lstExecuteResult.Items.Add(item.Description, ThemeUtils.GetImage16x16Index("DONE"));
                chkLstBatchName.Items.Remove(item);
            }
        }
        //更改当前选中的周数
        private void ChangeCurrentWeek(int week)
        {
            this.week = week;
            IList <MenuFlyoutItemBase> weekMenuItemList = WeekMenu.Items;

            foreach (MenuFlyoutItemBase item in weekMenuItemList)
            {
                item.Background = new SolidColorBrush(Colors.Transparent);
            }
            weekMenuItemList[week - 1].Background = ThemeUtils.GetCurrentTheme().Equals(ElementTheme.Dark) ? new SolidColorBrush(Colors.DimGray) : new SolidColorBrush(Colors.LightGray);
        }
        private Panel CreatePanel(
            int left,
            int top,
            int width,
            int height,
            string imageResourceName,
            string accessibleName,
            string accessibleDescription,
            EventHandler mouseClickHandler     = null,
            MouseEventHandler mouseDownHandler = null)
        {
            // Create a new panel to draw the image on
            var panel = new Panel
            {
                Left   = left,
                Top    = top,
                Height = height,
                Width  = width,
                Anchor = AnchorStyles.Bottom | AnchorStyles.Right
            };

            Debug.Assert(imageResourceName != null, "imageResourceName != null");
            var bitmap     = new Bitmap(GetType(), imageResourceName);
            var pictureBox = new PictureBox
            {
                AccessibleName        = accessibleName,
                AccessibleDescription = accessibleDescription,
                AccessibleRole        = AccessibleRole.PushButton
            };

            _themeChangedActions.Add(
                ()
                => pictureBox.Image
                    = ThemeUtils.GetThemedButtonImage(
                          bitmap,
                          EnvironmentColors.ScrollBarBackgroundColorKey));

            if (mouseClickHandler != null)
            {
                pictureBox.Click += mouseClickHandler;
            }

            if (mouseDownHandler != null)
            {
                pictureBox.MouseDown += mouseDownHandler;
            }

            _toolTip.SetToolTip(pictureBox, accessibleDescription);

            panel.Controls.Add(pictureBox);
            panel.BringToFront();
            return(panel);
        }
Exemplo n.º 17
0
 public override void InitializeLanguage()
 {
     base.Language = new GroupRoleSetupLanguage(ModuleInfo)
     {
         RoleYesImageIndex      = ThemeUtils.GetImage16x16Index("ROLE[YES]"),
         RoleNoImageIndex       = ThemeUtils.GetImage16x16Index("ROLE[NO]"),
         HightRoleYesImageIndex = ThemeUtils.GetImage16x16Index("HIGHROLE[YES]"),
         HighRoleNoImageIndex   = ThemeUtils.GetImage16x16Index("HIGHROLE[NO]"),
         FolderOpenImageIndex   = ThemeUtils.GetImage16x16Index("FOLDER[OPEN]"),
         FolderCloseImageIndex  = ThemeUtils.GetImage16x16Index("FOLDER[CLOSE]"),
         Info = LangUtils.TranslateModuleItem(LangType.MODULE_TEXT, ModuleInfo, "Info")
     };
     base.InitializeLanguage();
 }
Exemplo n.º 18
0
        public void ApplyTheme()
        {
            ThemeUtils.ApplyColors(ThemeUtils.ActiveBackColor, ThemeUtils.ActiveForeColor, this);
            // Applay colors to controls
            ThemeUtils.ApplyColors(ThemeUtils.SpecialBackColor, ThemeUtils.SpecialForeColor,
                                   panelButton, labelColor, labelCalibrationButton, labelStart,
                                   this.contextLabelColor, this.contextLabelStop, this.labelCalibration, this.labelCalibrationButton,
                                   panelTemperatute, labelMin, labelMax, labelAverage, m_labelMin, m_labelMax, m_labelAverage);

            pbxArrowWhitePB.Visible = (ThemeUtils.CurrentTheme.Equals("Dark")) ? true : false;
            pbxArrowWhitePT.Visible = (ThemeUtils.CurrentTheme.Equals("Dark")) ? true : false;
            pbxArrowBlackPB.Visible = (ThemeUtils.CurrentTheme.Equals("Dark")) ? false : true;
            pbxArrowBlackPT.Visible = (ThemeUtils.CurrentTheme.Equals("Dark")) ? false : true;
        }
Exemplo n.º 19
0
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--
        public App()
        {
            isRunning = false;

            // Set requested theme:
            ElementTheme theme = ThemeUtils.LoadRequestedTheme();

            RequestedTheme = ThemeUtils.GetActualTheme(theme);

            InitializeComponent();
            Suspending         += OnSuspending;
            Resuming           += App_Resuming;
            UnhandledException += App_UnhandledException;
        }
Exemplo n.º 20
0
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--


        #endregion
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            if (Resources is null)
            {
                return(new SolidColorBrush(Colors.Red));
            }

            if (value is MessageState state && state == MessageState.UNREAD)
            {
                return(new SolidColorBrush(ThemeUtils.GetThemeResource <Color>("SystemAccentColor")));
            }

            return(ThemeUtils.GetThemeResource <SolidColorBrush>("CaptionTextBrush", Resources));
        }
Exemplo n.º 21
0
 //跳转到设置界面
 private void SettingItemButton_Click(object sender, RoutedEventArgs e)
 {
     if (index != 3)
     {
         SettingItemButton.Background  = ThemeUtils.GetCurrentTheme().Equals(ElementTheme.Dark) ? new SolidColorBrush(Colors.DimGray) : new SolidColorBrush(Colors.LightGray);
         ScheduleItemButton.Background = new SolidColorBrush(Colors.Transparent);
         PersonalItemButton.Background = new SolidColorBrush(Colors.Transparent);
         Frame.Navigate(typeof(Setting));
         index = 3;
     }
     if (SplitView.IsPaneOpen)
     {
         SplitView.IsPaneOpen = false;
     }
 }
Exemplo n.º 22
0
#pragma warning restore IDE0052 // Remove unread private members

        #endregion
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--
        public App()
        {
            isRunning = false;

            // Set requested theme:
            ElementTheme theme = ThemeUtils.LoadRequestedTheme();

            RequestedTheme = ThemeUtils.GetActualTheme(theme);

            InitializeComponent();
            Suspending         += OnSuspending;
            Resuming           += OnAppResuming;
            UnhandledException += OnAppUnhandledException;
            AppDomain.CurrentDomain.UnhandledException += OnAppDomainUnhandledException;
            TaskScheduler.UnobservedTaskException      += OnUnobservedTaskException;
        }
Exemplo n.º 23
0
        //切换深色主题开关
        private void DarkThemeToggleSwitch_Toggled(object sender, RoutedEventArgs e)
        {
            ToggleSwitch toggleSwitch = sender as ToggleSwitch;

            if (toggleSwitch != null)
            {
                if (toggleSwitch.IsOn)
                {
                    ThemeUtils.ChangeToDarkTheme();
                }
                else
                {
                    ThemeUtils.ChangeToLightTheme();
                }
                ((Window.Current.Content as Frame).Content as MainPage).OnChangeTheme();
            }
        }
Exemplo n.º 24
0
        public Task Upgrade(IVersionContext versionContext)
        {
            var themeAssembly     = Assembly.Load("Themes.PersonalBlog");
            var themeRegistration = ThemeUtils.GetThemeRegistration(themeAssembly);
            var currentTheme      = new Theme
            {
                Id             = "5f02cb57e63b2b3634d51371",
                Name           = themeRegistration.Name,
                Description    = themeRegistration.Description,
                Creator        = themeRegistration.Creator,
                ScreenShotUri  = themeRegistration.ScreenShotUri,
                ThemeManifests = ThemeUtils.GatherAllManifests(themeAssembly)?.ToList(),
                SectionParts   = ThemeUtils.GetSectionParts(themeAssembly)?.ToList()
            };

            versionContext.InsertData(currentTheme);
            return(Task.CompletedTask);
        }
Exemplo n.º 25
0
        protected override void InitializeModuleData()
        {
            base.InitializeModuleData();

            var ds = new DataSet();

            ds.ReadXml((string)this["P01"]);

            var modules = ds.Tables["DEFMOD"].Rows;

            lstModule.ImageList = ThemeUtils.Image16;

            for (var i = 0; i < modules.Count; i++)
            {
                var codeName = CodeUtils.GetCodeName("DEFMOD", "SUBMOD", (string)modules[i]["SUBMOD"]);
                lstModule.Items.Add(modules[i]["MODNAME"], ThemeUtils.GetImage16x16Index(codeName));
            }
        }
        private Bitmap GetNotificationBitmap(RuntimeConfigState state)
        {
            Bitmap bitmap;

            switch (state)
            {
            case RuntimeConfigState.Normal:
                bitmap = Resources.Information;
                break;

            case RuntimeConfigState.Error:
                bitmap = Resources.Error;
                break;

            default:
                return(null);
            }
            return(ThemeUtils.GetThemedButtonImage(bitmap, BackColor));
        }
Exemplo n.º 27
0
        protected override void InitializeModuleData()
        {
            base.InitializeModuleData();
            if (GroupID != 0)
            {
                lbTitle.Text = string.Format(Language.Info, GroupName);

                try
                {
                    using (var ctrlSA = new SAController())
                    {
                        List <User> users;
                        ctrlSA.ListUsersInGroup(out users, GroupID);
                        lstUserList.ImageList = ThemeUtils.Image16;
                        foreach (var user in users)
                        {
                            lstUserList.Items.Add(new ImageListBoxItem
                            {
                                Value      = user,
                                ImageIndex = ThemeUtils.GetImage16x16Index("USER_EDIT")
                            });
                        }

                        ctrlSA.ListGroupRoles(out m_Roles, GroupID);
                        foreach (var role in m_Roles)
                        {
                            role.TranslatedRoleName = Language.GetRoleName(role.RoleName);
                        }

                        roleTree.DataSource = m_Roles;
                        UpdateCategory(roleTree.Nodes);
                    }
                }
                catch (Exception ex)
                {
                    ShowError(ex);
                    CloseModule();
                }
#if !DEBUG
                colRoleID.Visible = false;
#endif
            }
        }
Exemplo n.º 28
0
        public override void Initialize()
        {
            AvaloniaXamlLoader.Load(this);

            if (Loc.IsTranslatorModeEnabled())
            {
                SettingsProvider.Instance.Locale = Locales.custom;
            }

            ThemeUtils.Reload();
            Loc.Load();

            MediaKeyRemoteImpl.Init();
            DeviceMessageCache.Init();
            UpdateManager.Init();
            ExperimentManager.Init();

            Log.Information($"Translator mode file location: {Loc.GetTranslatorModeFile()}");

            ScriptManager.Instance.RegisterUserHooks();
        }
Exemplo n.º 29
0
        public void RestartApp(AbstractPage.Pages target)
        {
            if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
            {
                MainWindow.Instance.DisableApplicationExit = true;
                MainWindow.Instance.OverrideMinimizeTray   = true;
                MainWindow.Instance.Close();
                MainWindow.Kill();

                ThemeUtils.Reload();

                desktop.MainWindow = MainWindow.Instance;
                desktop.MainWindow.Show();

                MainWindow.Instance.Pager.SwitchPage(target);

                /* Restore crucial information */
                SPPMessageHandler.Instance.DispatchEvent(DeviceMessageCache.Instance.ExtendedStatusUpdate);
                SPPMessageHandler.Instance.DispatchEvent(DeviceMessageCache.Instance.StatusUpdate);
            }
        }
        private async Task LoadAppAsync()
        {
            // Setup listening for theme changes:
            ThemeUtils.SetupThemeListener();

            // Setup listener for window activated changes:
            UiUtils.SetupWindowActivatedListener();

            // Setup window:
            UiUtils.SetupWindow(Application.Current);

            // Perform app update tasks if necessary:
            await AppUpdateHelper.OnAppStartAsync();

            // Setup App Center crashes, push:
            AppCenterHelper.SetupAppCenter();
            await ShowReportCrashIfNeeded();

            // Register background tasks:
            Logger.Info("Registering background tasks...");
            // TODO: Add background tasks here
            Logger.Info("Finished registering background tasks.");

            // Show initial start dialog:

            /*if (!Settings.getSettingBoolean(SettingsConsts.HIDE_INITIAL_START_DIALOG_ALPHA))
             * {
             *  InitialStartDialog initialStartDialog = new InitialStartDialog();
             *  await UiUtils.ShowDialogAsync(initialStartDialog);
             * }
             *
             * // Show what's new dialog:
             * if (!Settings.getSettingBoolean(SettingsConsts.HIDE_WHATS_NEW_DIALOG))
             * {
             *  WhatsNewDialog whatsNewDialog = new WhatsNewDialog();
             *  await UiUtils.ShowDialogAsync(whatsNewDialog);
             * }*/

            EvaluateActivationArgs();
        }