public void ReturnDevelopmentValue() { using (new DeploymentContextInjectionScope(targetEnvironment: TargetEnvironment.DEVELOPMENT)) { DateSetting.Should().Be(new(2021, 3, 3)); Setting1.Should().Be("one.1"); Setting2.Should().Be(3); Setting3.Should().Be("three.1"); Invoking(() => Setting4) .Should().Throw <NotSupportedException>() .WithMessage($"'{nameof(Setting4)}' does not provide a value for target environment '{TargetEnvironment.DEVELOPMENT}'."); Invoking(() => Setting5).Should().NotThrow().And.Subject().Should().Be(0); Setting6.Should().Be(1); Setting7.Should().Be(1); } }
public void ReturnAcceptanceValue() { using (new DeploymentContextInjectionScope(targetEnvironment: TargetEnvironment.ACCEPTANCE)) { DateSetting.Should().Be(DateTime.MinValue); Setting1.Should().Be("one.2"); Setting2.Should().Be(1); Setting3.Should().Be("three.2"); Invoking(() => Setting4).Should().NotThrow().And.Subject().Should().Be("four"); Invoking(() => Setting5) .Should().Throw <NotSupportedException>() .WithMessage($"'{nameof(Setting5)}' does not provide a value for target environment '{TargetEnvironment.ACCEPTANCE}'."); Setting6.Should().Be(3); Setting7.Should().Be(4); } }
public ActionResult ChangeYear(string newChangedYear) { if (newChangedYear == null) { return(RedirectToAction("ModifyWebSettings")); } DateSetting dSet = new DateSetting() { Year = DateTime.Parse(newChangedYear + "/1/1") }; ent.DateSettings.Add(dSet); ent.SaveChanges(); WebSetting web = ent.WebSettings.FirstOrDefault(); web.DSetId = dSet.DSetId; ent.SaveChanges(); return(RedirectToAction("ModifyWebSettings")); }
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; }
public SettingsModel(Sidebar sidebar) { DockEdgeItems = new DockEdge[2] { DockEdge.Left, DockEdge.Right }; DockEdge = Framework.Settings.Instance.DockEdge; Monitor[] _monitors = Monitor.GetMonitors(); ScreenItems = _monitors.Select((s, i) => new ScreenItem() { Index = i, Text = string.Format("#{0}", i + 1) }).ToArray(); if (Framework.Settings.Instance.ScreenIndex < _monitors.Length) { ScreenIndex = Framework.Settings.Instance.ScreenIndex; } else { ScreenIndex = _monitors.Where(s => s.IsPrimary).Select((s, i) => i).Single(); } UIScale = Framework.Settings.Instance.UIScale; XOffset = Framework.Settings.Instance.XOffset; YOffset = Framework.Settings.Instance.YOffset; PollingInterval = Framework.Settings.Instance.PollingInterval; UseAppBar = Framework.Settings.Instance.UseAppBar; AlwaysTop = Framework.Settings.Instance.AlwaysTop; HighDPISupport = Framework.Settings.Instance.HighDPISupport; ShowAltTab = Framework.Settings.Instance.ShowAltTab; ClickThrough = Framework.Settings.Instance.ClickThrough; ShowTrayIcon = Framework.Settings.Instance.ShowTrayIcon; AutoUpdate = Framework.Settings.Instance.AutoUpdate; RunAtStartup = Framework.Settings.Instance.RunAtStartup; SidebarWidth = Framework.Settings.Instance.SidebarWidth; AutoBGColor = Framework.Settings.Instance.AutoBGColor; BGColor = Framework.Settings.Instance.BGColor; BGOpacity = Framework.Settings.Instance.BGOpacity; FontSettingItems = new FontSetting[5] { FontSetting.x10, FontSetting.x12, FontSetting.x14, FontSetting.x16, FontSetting.x18 }; FontSetting = Framework.Settings.Instance.FontSetting; FontColor = Framework.Settings.Instance.FontColor; AlertFontColor = Framework.Settings.Instance.AlertFontColor; DateSettingItems = new DateSetting[4] { DateSetting.Disabled, DateSetting.Short, DateSetting.Normal, DateSetting.Long }; DateSetting = Framework.Settings.Instance.DateSetting; CollapseMenuBar = Framework.Settings.Instance.CollapseMenuBar; ShowClock = Framework.Settings.Instance.ShowClock; Clock24HR = Framework.Settings.Instance.Clock24HR; ObservableCollection <MonitorConfig> _config = new ObservableCollection <MonitorConfig>(Framework.Settings.Instance.MonitorConfig.Select(c => c.Clone()).OrderByDescending(c => c.Order)); if (sidebar.Ready) { foreach (MonitorConfig _record in _config) { _record.HardwareOC = new ObservableCollection <HardwareConfig>( from hw in sidebar.Model.MonitorManager.GetHardware(_record.Type) join config in _record.Hardware on hw.ID equals config.ID into merged from newhw in merged.DefaultIfEmpty(hw) orderby newhw.Order descending, newhw.Name ascending select newhw ); } } MonitorConfig = _config; if (Framework.Settings.Instance.Hotkeys != null) { ToggleKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Toggle); ShowKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Show); HideKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Hide); ReloadKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Reload); CloseKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Close); CycleEdgeKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.CycleEdge); CycleScreenKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.CycleScreen); } IsChanged = false; }
public SettingsModel(Sidebar sidebar) { DockEdgeItems = new DockItem[2] { new DockItem() { Text = Resources.SettingsDockLeft, Value = DockEdge.Left }, new DockItem() { Text = Resources.SettingsDockRight, Value = DockEdge.Right } }; DockEdge = Framework.Settings.Instance.DockEdge; Monitor[] _monitors = Monitor.GetMonitors(); ScreenItems = _monitors.Select((s, i) => new ScreenItem() { Index = i, Text = string.Format("#{0}", i + 1) }).ToArray(); if (Framework.Settings.Instance.ScreenIndex < _monitors.Length) { ScreenIndex = Framework.Settings.Instance.ScreenIndex; } else { ScreenIndex = _monitors.Where(s => s.IsPrimary).Select((s, i) => i).Single(); } CultureItems = Utilities.Culture.GetAll(); Culture = Framework.Settings.Instance.Culture; UIScale = Framework.Settings.Instance.UIScale; XOffset = Framework.Settings.Instance.XOffset; YOffset = Framework.Settings.Instance.YOffset; PollingInterval = Framework.Settings.Instance.PollingInterval; UseAppBar = Framework.Settings.Instance.UseAppBar; AlwaysTop = Framework.Settings.Instance.AlwaysTop; ToolbarMode = Framework.Settings.Instance.ToolbarMode; ClickThrough = Framework.Settings.Instance.ClickThrough; ShowTrayIcon = Framework.Settings.Instance.ShowTrayIcon; AutoUpdate = Framework.Settings.Instance.AutoUpdate; RunAtStartup = Framework.Settings.Instance.RunAtStartup; SidebarWidth = Framework.Settings.Instance.SidebarWidth; AutoBGColor = Framework.Settings.Instance.AutoBGColor; BGColor = Framework.Settings.Instance.BGColor; BGOpacity = Framework.Settings.Instance.BGOpacity; // Logger settings BacktraceHost = Framework.Settings.Instance.BacktraceHost; BacktraceToken = Framework.Settings.Instance.BacktraceToken; BacktraceClientSiteLimiting = Framework.Settings.Instance.BacktraceClientSiteLimiting; BacktraceDatabasePath = Framework.Settings.Instance.BacktraceDatabasePath; TextAlignItems = new TextAlignItem[2] { new TextAlignItem() { Text = Resources.SettingsTextAlignLeft, Value = TextAlign.Left }, new TextAlignItem() { Text = Resources.SettingsTextAlignRight, Value = TextAlign.Right } }; TextAlign = Framework.Settings.Instance.TextAlign; FontSettingItems = new FontSetting[5] { FontSetting.x10, FontSetting.x12, FontSetting.x14, FontSetting.x16, FontSetting.x18 }; FontSetting = Framework.Settings.Instance.FontSetting; FontColor = Framework.Settings.Instance.FontColor; AlertFontColor = Framework.Settings.Instance.AlertFontColor; AlertBlink = Framework.Settings.Instance.AlertBlink; DateSettingItems = new DateSetting[4] { DateSetting.Disabled, DateSetting.Short, DateSetting.Normal, DateSetting.Long }; DateSetting = Framework.Settings.Instance.DateSetting; CollapseMenuBar = Framework.Settings.Instance.CollapseMenuBar; InitiallyHidden = Framework.Settings.Instance.InitiallyHidden; ShowClock = Framework.Settings.Instance.ShowClock; Clock24HR = Framework.Settings.Instance.Clock24HR; ObservableCollection <MonitorConfig> _config = new ObservableCollection <MonitorConfig>(Framework.Settings.Instance.MonitorConfig.Select(c => c.Clone()).OrderByDescending(c => c.Order)); if (sidebar.Ready) { foreach (MonitorConfig _record in _config) { _record.HardwareOC = new ObservableCollection <HardwareConfig>( from hw in sidebar.Model.MonitorManager.GetHardware(_record.Type) join config in _record.Hardware on hw.ID equals config.ID into merged from newhw in merged.DefaultIfEmpty(hw).Select(newhw => { newhw.ActualName = hw.ActualName; if (string.IsNullOrEmpty(newhw.Name)) { newhw.Name = hw.ActualName; } return(newhw); }) orderby newhw.Order descending, newhw.Name ascending select newhw ); } } MonitorConfig = _config; if (Framework.Settings.Instance.Hotkeys != null) { ToggleKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Toggle); ShowKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Show); HideKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Hide); ReloadKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Reload); CloseKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.Close); CycleEdgeKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.CycleEdge); CycleScreenKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.CycleScreen); ReserveSpaceKey = Framework.Settings.Instance.Hotkeys.FirstOrDefault(k => k.Action == Hotkey.KeyAction.ReserveSpace); } IsChanged = false; _loggerChange = false; }