public static IViewModel Edit(ILayoutViewModel layout) { var application_settings = IoC.Get <ApplicationSettings>(); if (layout is ProgramLayoutViewModel) { var temp = layout as ProgramLayoutViewModel; var vm = new CaptureViewModel <Program, ProgramViewModel>(temp.AssociatedObject) { Title = "Edit Windows Layout", ItemsTitle = "Windows", AcceptAction = (l1, l2) => application_settings.Update(l1, l2), CaptureAction = () => WindowManager.GetPrograms() }; return(vm); } if (layout is IconLayoutViewModel) { var temp = layout as IconLayoutViewModel; var vm = new CaptureViewModel <Icon, IconViewModel>(temp.AssociatedObject) { Title = "Edit Icons Layout", ItemsTitle = "Icons", AcceptAction = (l1, l2) => application_settings.Update(l1, l2), CaptureAction = () => IconManagerWrapper.GetIcons() }; return(vm); } throw new Exception(); }
private void OnKeyPressed(object sender, KeyPressedEventArgs args) { if (SuppressShortcuts) { return; } logger.Trace("Detected shortcut [{0} - {1}]", args.Modifier, args.GetWpfKey()); var layout = Layouts.SingleOrDefault(l => l.Shortcut.Match(args.Modifier, args.GetWpfKey())); if (layout == null) { return; } logger.Trace("Apply layout {0} [{1} - {2}]", layout.Name, layout.Shortcut, layout.GetType()); if (layout is Layout <Program> ) { WindowManager.ApplyLayout(layout as Layout <Program>); } if (layout is Layout <Icon> ) { IconManagerWrapper.ApplyLayout(layout as Layout <Icon>); } }
public void Apply() { if (CurrentLayout is ProgramLayoutViewModel) { var layout = CurrentLayout as ProgramLayoutViewModel; WindowManager.ApplyLayout(layout.AssociatedObject); } else if (CurrentLayout is IconLayoutViewModel) { var layout = CurrentLayout as IconLayoutViewModel; IconManagerWrapper.ApplyLayout(layout.AssociatedObject); } else { throw new Exception(); } }
public static IViewModel Create(CaptureCommand.CaptureKind kind) { var application_settings = IoC.Get <ApplicationSettings>(); switch (kind) { case CaptureCommand.CaptureKind.Windows: { var layout = new Layout <Program> { Name = "Default" }; var vm = new CaptureViewModel <Program, ProgramViewModel>(layout) { Title = "Capture Windows Layout", ItemsTitle = "Windows", CaptureOnActivation = true, AcceptAction = (l, _) => application_settings.Add(l), CaptureAction = () => WindowManager.GetPrograms() }; return(vm); } case CaptureCommand.CaptureKind.Icons: { var layout = new Layout <Icon> { Name = "Default" }; var vm = new CaptureViewModel <Icon, IconViewModel>(layout) { Title = "Capture Icons Layout", ItemsTitle = "Icons", CaptureOnActivation = true, AcceptAction = (l, _) => application_settings.Add(l), CaptureAction = () => IconManagerWrapper.GetIcons() }; return(vm); } default: throw new Exception(); } }