static void OnUIModeChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { ShortcutManager mgr = obj as ShortcutManager; if (mgr != null) { mgr.UpdateAdornerVisualStates(); var handler = mgr.UIModeChanged; if (handler != null) { handler(mgr, EventArgs.Empty); } } }
static void OnAreShortcutAdornmentsVisibleChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e) { ShortcutManager mgr = obj as ShortcutManager; if (mgr != null) { if (mgr.AreShortcutAdornmentsVisible) { mgr.timer.Start(); } else { mgr.timer.Stop(); } mgr.UpdateAdornerVisualStates(); } }
void OnTabShortcutExecuted(object sender, ExecutedRoutedEventArgs e) { var data = e.Parameter as LayoutInstance; if (data != null) { this.SelectedItem = data; var shortcutManager = ShortcutManager.GetInstance(this); if (shortcutManager != null) { shortcutManager.PushUISubMode("ViewSelect"); shortcutManager.AreShortcutAdornmentsVisible = true; } e.Handled = true; } }
void OnShortcutCommandExecuted(object sender, ExecutedRoutedEventArgs e) { var tabData = e.Parameter as OpenTabItemData; if (tabData != null) { this.SelectedItem = tabData; if (tabData.SubMode != null) { var manager = ShortcutManager.GetInstance(this); if (manager != null) { manager.PushUISubMode(tabData.SubMode); } } } }
void OnShortcutCommandExecuted(object sender, ExecutedRoutedEventArgs e) { var tabData = e.Parameter as FileTabDefinition; bool leaveShortcutMode = false; if (tabData != null) { if (tabData.Command != null) { tabData.Command.Execute(tabData.CommandParameter); leaveShortcutMode = true; } else { this.SelectedItem = tabData; if (tabData.SubMode != null) { var manager = ShortcutManager.GetInstance(this); if (manager != null) { manager.PushUISubMode(tabData.SubMode); } } else { leaveShortcutMode = true; } } if (leaveShortcutMode) { var toolsWindow = this.FindParent <ToolsUIWindow>(); if (toolsWindow != null) { toolsWindow.LeaveShortcutMode(); } } } }
void OnViewPresenterLoaded(object sender, RoutedEventArgs e) { var presenter = sender as ContentPresenter; if ((presenter != null) && (presenter.Content is ViewSite)) { var site = (ViewSite)presenter.Content; presenter.SetBinding(ShortcutManager.ShortcutProperty, new Binding { Source = site.ViewSource, Path = new PropertyPath(ViewSource.ShortcutKeyProperty), StringFormat = "{0}:ViewSelect" }); ShortcutManager.SetHorizontalAlignment(presenter, HorizontalAlignment.Left); ShortcutManager.SetVerticalAlignment(presenter, VerticalAlignment.Top); ShortcutManager.SetOffset(presenter, new Point(25, 25)); ShortcutManager.SetCommand(presenter, LayoutControl.ViewShortcutCommand); ShortcutManager.SetCommandParameter(presenter, site); ShortcutManager.SetCommandTarget(presenter, presenter); presenter.Loaded -= OnViewPresenterLoaded; } }
public ToolsUIWindow() { this.StateTable = new Dictionary<object, object>(); this.Application = ToolsUIApplication.Instance; if (this.Application == null) { throw new InvalidOperationException("ToolsUIWindow must be used in conjunction with ToolsUIApplication!"); } // NOTE: Can't use !IsMainWindow here, because it will never return true (the application hasn't had // a chance to set it yet, as we're the constructor!) if (this.Application.MainToolsUIWindow != null) { this.Style = this.Application.MainToolsUIWindow.Style; this.ServiceProvider = CreateServiceProvider(); } this.Layouts = new ObservableCollection<LayoutInstance>(); AddHandler(Thumb.DragStartedEvent, (DragStartedEventHandler)OnDragStarted); AddHandler(Thumb.DragDeltaEvent, (DragDeltaEventHandler)OnDragDelta); AddHandler(Thumb.DragCompletedEvent, (DragCompletedEventHandler)OnDragCompleted); this.sizerTable = new Dictionary<string, Action<DragDeltaEventArgs>>(); CommandBindings.Add(new CommandBinding(CloseWindowCommand, OnCloseWindowExecuted)); CommandBindings.Add(new CommandBinding(ExitCommand, OnExitExecuted)); CommandBindings.Add(new CommandBinding(MinimizeCommand, OnMinimizeExecuted, OnMinimizeCanExecute)); CommandBindings.Add(new CommandBinding(MaximizeCommand, OnMaximizeExecuted, OnMaximizeCanExecute)); CommandBindings.Add(new CommandBinding(RestoreCommand, OnRestoreExecuted, OnRestoreCanExecute)); CommandBindings.Add(new CommandBinding(ToggleFileTabCommand, OnToggleFileTabExecuted)); CommandBindings.Add(new CommandBinding(OpenDocumentDropdownCommand, OnOpenDocumentDropdownExecuted)); CommandBindings.Add(new CommandBinding(ActivateDocumentCommand, OnActivateDocumentExecuted)); CommandBindings.Add(new CommandBinding(EditLayoutsCommand, OnEditLayoutsExecuted)); CommandBindings.Add(new CommandBinding(RevertToDefaultWindowStateCommand, OnRevertToDefaultWindowStateExecuted)); this.SourceInitialized += OnSourceInitialized; this.MinWidth = 200; this.MinHeight = 200; this.shortcutDisplayTimer = new DispatcherTimer(); this.shortcutDisplayTimer.Tick += OnShortcutTimerTick; this.shortcutDisplayTimer.Interval = TimeSpan.FromMilliseconds(400); this.shortcutManager = new ShortcutManager(); this.shortcutManager.UIModeChanged += OnUIModeChanged; this.shortcutManager.EmptyModePushed += OnEmptyModePushed; ShortcutManager.SetInstance(this, this.shortcutManager); }
public static void SetInstance(DependencyObject obj, ShortcutManager value) { obj.SetValue(InstanceProperty, value); }