Пример #1
0
        public override bool Equals(object obj)
        {
            DateSetting _that = obj as DateSetting;

            if (_that == null)
            {
                return(false);
            }

            return(string.Equals(this.Format, _that.Format, StringComparison.Ordinal));
        }
Пример #2
0
        public SettingsModel(Sidebar sidebar)
        {
            DockEdgeItems = new DockEdge[2] { DockEdge.Left, DockEdge.Right };
            DockEdge = Properties.Settings.Default.DockEdge;

            Monitor[] _monitors = Monitor.GetMonitors();

            ScreenItems = _monitors.Select((s, i) => new ScreenItem() { Index = i, Text = string.Format("#{0}", i + 1) }).ToArray();

            if (Properties.Settings.Default.ScreenIndex < _monitors.Length)
            {
                ScreenIndex = Properties.Settings.Default.ScreenIndex;
            }
            else
            {
                ScreenIndex = _monitors.Where(s => s.IsPrimary).Select((s, i) => i).Single();
            }

            UIScale = Properties.Settings.Default.UIScale;

            XOffset = Properties.Settings.Default.XOffset;

            YOffset = Properties.Settings.Default.YOffset;

            PollingInterval = Properties.Settings.Default.PollingInterval;

            UseAppBar = Properties.Settings.Default.UseAppBar;

            AlwaysTop = Properties.Settings.Default.AlwaysTop;

            HighDPISupport = Properties.Settings.Default.HighDPISupport;

            ClickThrough = Properties.Settings.Default.ClickThrough;

            ShowTrayIcon = Properties.Settings.Default.ShowTrayIcon;

            CheckForUpdates = Properties.Settings.Default.CheckForUpdates;

            RunAtStartup = Startup.StartupTaskExists();

            SidebarWidth = Properties.Settings.Default.SidebarWidth;

            BGColor = Properties.Settings.Default.BGColor;

            BGOpacity = Properties.Settings.Default.BGOpacity;

            FontSettingItems = new FontSetting[5]
            {
                FontSetting.x10,
                FontSetting.x12,
                FontSetting.x14,
                FontSetting.x16,
                FontSetting.x18
            };
            FontSetting = Properties.Settings.Default.FontSetting;

            FontColor = Properties.Settings.Default.FontColor;

            AlertFontColor = Properties.Settings.Default.AlertFontColor;

            DateSettingItems = new DateSetting[4]
            {
                DateSetting.Disabled,
                DateSetting.Short,
                DateSetting.Normal,
                DateSetting.Long
            };
            DateSetting = Properties.Settings.Default.DateSetting;

            CollapseMenuBar = Properties.Settings.Default.CollapseMenuBar;

            ShowClock = Properties.Settings.Default.ShowClock;

            Clock24HR = Properties.Settings.Default.Clock24HR;
            
            if (sidebar.Ready)
            {
                foreach (MonitorConfig _record in Properties.Settings.Default.MonitorConfig)
                {
                    _record.Hardware = (
                        from hw in sidebar.Model.MonitorManager.GetHardware(_record.Type)
                        join config in _record.Hardware on hw.ID equals config.ID into c
                        from config in c.DefaultIfEmpty(hw)
                        select config
                        ).ToArray();
                }
            }

            MonitorConfig = Properties.Settings.Default.MonitorConfig.Select(c => c.Clone()).ToArray();

            if (Properties.Settings.Default.Hotkeys != null)
            {
                ToggleKey = Properties.Settings.Default.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Toggle);

                ShowKey = Properties.Settings.Default.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Show);

                HideKey = Properties.Settings.Default.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Hide);

                ReloadKey = Properties.Settings.Default.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Reload);

                CloseKey = Properties.Settings.Default.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Close);
            }

            IsChanged = false;
        }