static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); var settingsPath = Directory.GetParent(Application.LocalUserAppDataPath).FullName; var knownTypes = new[] { typeof(HoursLayer), typeof(MinutesLayer), typeof(SecondsLayer), typeof(NumbersLayer), }; var settings = Settings.Load(Path.Combine(settingsPath, "settings.json")); var skinpacks = SkinPackCollection.Load(Path.Combine(settingsPath, "skinpacks"), Path.Combine(Application.StartupPath, "clocks"), knownTypes); Parser.Default.ParseArguments <Options>(args) .WithParsed(options => { if (!string.IsNullOrEmpty(options.PreviewFile) && File.Exists(options.PreviewFile)) { Application.Run(new frmPreview(options.PreviewFile, knownTypes)); } else { Application.Run(new frmClock(settings, skinpacks, options.DisplayFile, knownTypes)); } }) .WithNotParsed(errors => { Application.Run(new frmClock(settings, skinpacks, knownTypes: knownTypes)); }); }
public void Setup() { var files = new Dictionary <string, string>() { { "skinpacks.json", $"[ \"{skinpackname}\" ]" }, { $"{skinpackname}/skinpack.json", "{ \"Name\": \"" + skinpackname + "\" }" } }; _sut = new SkinPackCollection(new FakeFileReader(files), new FakeFileWriter(), Array.Empty <Type>()); }
public void SetupTest() { _settings = new FakeSettings() { SelectedSkinpack = "test", SelectedSkin = "Black" }; var filereader = TestHelpers.GetFakeFileReader(); var skinPack = new SkinPackCollection(filereader, null, Array.Empty <Type>()); _form = new frmSettings(skinPack, _settings); }
public void Setup() { var filereader = TestHelpers.GetFakeFileReader(); var skinPack = new SkinPackCollection(filereader, null, Array.Empty <Type>()); _getSut = (s) => { var sut = new SettingsViewModel(new FakeSettings() { SelectedSkinpack = "test", SelectedSkin = "Black" }, skinPack, s); s.AdvanceByMs(2 * 100); return(sut); }; }
public void Setup() { _settings = Mock.Of <ISettings>(s => s.HasSettings == true && s.SelectedSkinpack == "test" && s.SelectedSkin == "Red" && s.Size == new Size(100, 100) && s.Location == new Point(200, 200)); _skinpacks = new SkinPackCollection(TestHelpers.GetFakeFileReader(), null, Array.Empty <Type>()); _timer = Mock.Of <ITimer>(); _locationFixer = Mock.Of <ILocationFixer>(); Mock.Get(_locationFixer).Setup(x => x.FixLocation(It.IsAny <Point>())).Returns <Point>(x => x); _sut = new frmClockViewModel(_settings, _skinpacks, _timer, _locationFixer, throttleTimeInMs: 50); }
public SettingsViewModel(ISettings settings, SkinPackCollection skinPacks, IScheduler customMainThreadScheduler = null) { customMainThreadScheduler = customMainThreadScheduler ?? RxApp.MainThreadScheduler; _settings = settings; _skinPacks = skinPacks; _selectedSkinPack = _settings.SelectedSkinpack; _selectedSkin = _settings.SelectedSkin; _skins = this.WhenAnyValue(x => x.SelectedSkinPack) .ObserveOn(customMainThreadScheduler) .Select(sp => GetSkins(sp).ToList()) .ToProperty(this, x => x.Skins); _skinPackList = _skinPacks.Packs.Keys; this.WhenAnyValue(x => x.SelectedSkin).ObserveOn(customMainThreadScheduler).Subscribe(UpdateSelectedSkin); }
public frmClock(ISettings settings, SkinPackCollection skinpacks, string skinOverride = null, params Type [] knownTypes) { _settings = settings; _skinpacks = skinpacks; InitializeComponent(); FormBorderStyle = FormBorderStyle.None; StartPosition = FormStartPosition.Manual; Text = "CodeMade Clock"; TopMost = true; tsmClose.Image = il24.Images[0]; ShowInTaskbar = false; _knownTypes = knownTypes; ViewModel = new frmClockViewModel(settings, skinpacks, new ClockTimer(), new LocationFixer(this), skinOverride, knownTypes: knownTypes); this.WhenActivated(disposable => { this.Bind(ViewModel, vm => vm.Width, frm => frm.Width, this.Events().Resize) .DisposeWith(disposable); this.Bind(ViewModel, vm => vm.Height, frm => frm.Height, this.Events().Resize) .DisposeWith(disposable); this.Bind(ViewModel, vm => vm.Location, frm => frm.Location, this.Events().LocationChanged) .DisposeWith(disposable); ViewModel.WhenAnyValue(x => x.Image) .WhereNotNull() .Subscribe(img => WinAPI.SetFormBackground(this, img)); }); }