public static void Pin() { Control?mainWindow = WindowingUtils.GetMainWindow(); if (mainWindow is Window window) { window.Topmost = !window.Topmost; } }
public DaysEditorViewModel(IEnumerable <WorkingDay>?days) : base(new ObservableCollection <WorkingDayViewModel>(days?.Select(d => new WorkingDayViewModel(d)))) { var currentDay = Model?.FirstOrDefault(d => d.Date == DateTime.Today); currentDay ??= Model?.FirstOrDefault(); if (!(currentDay is null)) { SelectedDay = currentDay; } Add = ReactiveCommand.Create(() => { var vm = new AddTaskViewModel(); Observable .Merge(vm.Add, vm.Cancel.Select <Unit, WorkingTask?>(_ => null)) .Take(1) .Subscribe(item => { if (item != null) { Log.Info("Created item {@Item}", item); var itemVm = new WorkingTaskViewModel(item); SelectedDay?.Tasks?.Add(item); new MiniMainWindow(itemVm) { Owner = WindowingUtils.GetMainWindow() as Window // hope it will be fixed some day https://github.com/AvaloniaUI/Avalonia/issues/3254 }.Show(); } }); return(vm); }); ShowElapsed = ReactiveCommand.Create(() => { var vm = new TotalElapsedViewModel(SelectedDay?.Tasks ?? Enumerable.Empty <WorkingTask>()); return(vm); }); }