public TypeInterfaceToolWindowRegistrar(Lifetime lifetime, ToolWindowManager toolWindowManager, IShellLocks locks, ISettingsStore settingsStore, IActionManager actionManager, IActionBarManager actionBarManager, IShortcutManager shortcutManager, TypeInterfaceToolWindowDescriptor toolWindowDescriptor, ITheming theming, IThemedIconManager themedIconManager, IColorThemeManager colorThemeManager) { myLifetime = lifetime; myLocks = locks; mySettingsStore = settingsStore; myActionBarManager = actionBarManager; myTheming = theming; myThemedIconManager = themedIconManager; myColorThemeManager = colorThemeManager; myToolWindowClass = toolWindowManager.Classes[toolWindowDescriptor]; myToolWindowClass.RegisterEmptyContent( lifetime, lt => { var emptyLabel = new RichTextLabel { BackColor = SystemColors.Control, Dock = DockStyle.Fill }; emptyLabel.RichTextBlock.Add(new RichText("No hierarchies open", new TextStyle(FontStyle.Bold))); emptyLabel.RichTextBlock.Add( new RichText("Use " + actionManager.GetHowToExecuteAction(shortcutManager, typeof(BrowseTypeHierarchyAction)), TextStyle.Default)); emptyLabel.RichTextBlock.Add(new RichText("on a type to see hierarchy", TextStyle.Default)); emptyLabel.RichTextBlock.Parameters = new RichTextBlockParameters(8, ContentAlignment.MiddleCenter); return emptyLabel.BindToLifetime(lt); }); }
private void RegisterShortcuts(IShortcutManager s) { var token = _cancellationSource.Token; foreach (var source in Items) { s.RegisterAction($"{source.Name}::Connection::Toggle", b => b.WithCallback(async(_) => await ToggleConnectAsync(source))); s.RegisterAction($"{source.Name}::Connection::Connect", b => b.WithCallback(async(_) => { await _semaphore.WaitAsync(token); if (_currentSource != source) { await ConnectAndSetAsCurrentSourceAsync(source, token); } _semaphore.Release(); })); s.RegisterAction($"{source.Name}::Connection::Disconnect", b => b.WithCallback(async(_) => { await _semaphore.WaitAsync(token); if (_currentSource == source) { await DisconnectCurrentSourceAsync(token); } _semaphore.Release(); })); } }
public TypeInterfaceToolWindowRegistrar(Lifetime lifetime, ToolWindowManager toolWindowManager, IShellLocks locks, ISettingsStore settingsStore, IActionManager actionManager, IActionBarManager actionBarManager, IShortcutManager shortcutManager, TypeInterfaceToolWindowDescriptor toolWindowDescriptor, ITheming theming, IThemedIconManager themedIconManager, IColorThemeManager colorThemeManager) { myLifetime = lifetime; myLocks = locks; mySettingsStore = settingsStore; myActionBarManager = actionBarManager; myTheming = theming; myThemedIconManager = themedIconManager; myColorThemeManager = colorThemeManager; myToolWindowClass = toolWindowManager.Classes[toolWindowDescriptor]; myToolWindowClass.RegisterEmptyContent( lifetime, lt => { var emptyLabel = new RichTextLabel { BackColor = SystemColors.Control, Dock = DockStyle.Fill }; emptyLabel.RichTextBlock.Add(new RichText("No hierarchies open", new TextStyle(FontStyle.Bold))); emptyLabel.RichTextBlock.Add( new RichText("Use " + actionManager.GetHowToExecuteAction(shortcutManager, typeof(BrowseTypeHierarchyAction)), TextStyle.Default)); emptyLabel.RichTextBlock.Add(new RichText("on a type to see hierarchy", TextStyle.Default)); emptyLabel.RichTextBlock.Parameters = new RichTextBlockParameters(8, ContentAlignment.MiddleCenter); return(emptyLabel.BindToLifetime(lt)); }); }
public TypeInterfaceToolWindowRegistrar(Lifetime lifetime, ToolWindowManager toolWindowManager, IActionManager actionManager, IActionBarManager actionBarManager, IShortcutManager shortcutManager, TypeInterfaceToolWindowDescriptor toolWindowDescriptor, IUIApplication environment, IWindowsHookManager windowsHookManager) { _lifetime = lifetime; _actionBarManager = actionBarManager; _environment = environment; _windowsHookManager = windowsHookManager; _toolWindowClass = toolWindowManager.Classes[toolWindowDescriptor]; _toolWindowClass.RegisterEmptyContent( lifetime, lt => { var emptyLabel = new RichTextLabel(environment) { BackColor = SystemColors.Control, Dock = DockStyle.Fill }; emptyLabel.RichTextBlock.Add(new RichText("No hierarchies open", new TextStyle(FontStyle.Bold))); emptyLabel.RichTextBlock.Add( new RichText("Use " + actionManager.GetHowToExecuteAction(shortcutManager, typeof(BrowseTypeHierarchyAction)), TextStyle.Default)); emptyLabel.RichTextBlock.Add(new RichText("on a type to see hierarchy", TextStyle.Default)); emptyLabel.RichTextBlock.Parameters = new RichTextBlockParameters(8, ContentAlignment.MiddleCenter); return(emptyLabel.BindToLifetime(lt)); }); }
private void RegisterActions(IShortcutManager s, IOutputTarget target) { var token = _cancellationSource.Token; target.RegisterActions(s); #region Connection s.RegisterAction($"{target.Identifier}::Connection::Toggle", b => b.WithCallback(async(_) => await ToggleConnectAsync(target))); s.RegisterAction($"{target.Identifier}::Connection::Connect", b => b.WithCallback(async(_) => { await _semaphores[target].WaitAsync(token); if (target.Status == ConnectionStatus.Disconnected) { await target.ConnectAsync(); await target.WaitForIdle(token); } _semaphores[target].Release(); })); s.RegisterAction($"{target.Identifier}::Connection::Disconnect", b => b.WithCallback(async(_) => { await _semaphores[target].WaitAsync(token); if (target.Status == ConnectionStatus.Connected) { await target.DisconnectAsync(); await target.WaitForDisconnect(token); } _semaphores[target].Release(); })); #endregion }
public TrayContext( ILowLevelProcessor processor, IShortcutManager shortcutManager, IExceptionShield shield, IConverter <OpenedWindow, ToolStripMenuItem> converter) { _processor = processor; _shield = shield; _shield.SetLogger(_logger); _windowsCache = new SortedSet <OpenedWindow>(_processor.GetOpenedWindows(), new OpenedWindowComparer()); _trayManager = new TrayMenuManager(converter, ItemClickCallback, ExitCallback); _trayIcon = new NotifyIcon { Icon = Resources.MainIcon.ToIcon(), ContextMenuStrip = _trayManager.Init(_windowsCache), Visible = true, Text = Resources.WintoxToolTip }; _trayIcon.Click += TrayClickCallback; shortcutManager.Register(FiredShortcutCallback); }
protected virtual void RegisterShortcuts(IShortcutManager s) { #region AutoConnectEnabled s.RegisterAction($"{Name}::AutoConnectEnabled::Set", b => b.WithSetting <bool>(s => s.WithLabel("Enable auto connect")).WithCallback((_, enabled) => AutoConnectEnabled = enabled)); s.RegisterAction($"{Name}::AutoConnectEnabled::Toggle", b => b.WithCallback(_ => AutoConnectEnabled = !AutoConnectEnabled)); #endregion }
private void UnregisterActions(IShortcutManager s, IOutputTarget target) { target.UnregisterActions(s); s.UnregisterAction($"{target.Identifier}::Connection::Toggle"); s.UnregisterAction($"{target.Identifier}::Connection::Connect"); s.UnregisterAction($"{target.Identifier}::Connection::Disconnect"); }
async static public void TriggerShortcut(string shortcut) { IShortcutManager manager = ShortcutManager.instance; List <string> shortcuts = manager.GetAvailableShortcutIds().ToList(); if (!shortcuts.Contains(shortcut)) { Debug.LogWarning($"{shortcut} is not a shortcut!"); return; } if (manager.GetAvailableProfileIds().Contains(temporaryProfile)) { manager.DeleteProfile(temporaryProfile); } manager.CreateProfile(temporaryProfile); string previousProfile = manager.activeProfileId; manager.activeProfileId = temporaryProfile; manager.ClearShortcutOverride(shortcut); var binding = new ShortcutBinding(new KeyCombination(KeyCode.F12)); manager.RebindShortcut(shortcut, binding); EditorWindow.focusedWindow.SendEvent(Event.KeyboardEvent("F12")); await Task.Delay(100); manager.activeProfileId = previousProfile; manager.DeleteProfile(temporaryProfile); }
protected override void RegisterShortcuts(IShortcutManager s) { base.RegisterShortcuts(s); #region Arguments s.RegisterAction($"{Name}::Arguments::Set", b => b.WithSetting <string>(s => s.WithLabel("Arguments")).WithCallback((_, arguments) => Arguments = arguments)); #endregion }
public override void RegisterActions(IShortcutManager s) { base.RegisterActions(s); #region PipeName s.RegisterAction($"{Identifier}::PipeName::Set", b => b.WithSetting <string>(s => s.WithLabel("Pipe name")).WithCallback((_, pipeName) => PipeName = pipeName)); #endregion }
public override void RegisterActions(IShortcutManager s) { base.RegisterActions(s); #region ComPort s.RegisterAction($"{Identifier}::SerialPort::Set", b => b.WithSetting <string>(s => s.WithLabel("Device ID")).WithCallback((_, deviceId) => SelectSerialPortByDeviceId(deviceId))); #endregion }
public ShortcutViewModel(IShortcutManager manager, IEventAggregator eventAggregator) { _manager = manager; Logger.Debug($"Initialized with {manager.AvailableActions.Count} available actions"); eventAggregator.Subscribe(this); AvailableActionsView = CollectionViewSource.GetDefaultView(AvailableActions); AvailableActionsView.Filter = o => { if (o is not IShortcutActionDescriptor actionDescriptor) { return(false); } if (SelectedBinding == null) { return(false); } var(selectedGesture, _) = SelectedBinding.Value; if (!actionDescriptor.AcceptsSimpleGesture && selectedGesture is ISimpleInputGestureDescriptor) { return(false); } if (!actionDescriptor.AcceptsAxisGesture && selectedGesture is IAxisInputGestureDescriptor) { return(false); } if (!string.IsNullOrWhiteSpace(ActionsFilter)) { var filterWords = ActionsFilter.Split(' '); if (!filterWords.All(w => actionDescriptor.Name.Contains(w, StringComparison.InvariantCultureIgnoreCase))) { return(false); } } return(true); }; _manager.OnGesture += HandleGesture; _captureGestureChannel = Channel.CreateBounded <IInputGesture>(new BoundedChannelOptions(1) { FullMode = BoundedChannelFullMode.DropOldest, SingleReader = true, SingleWriter = true }); PropertyChanged += (s, e) => { if (e.PropertyName == nameof(ActionsFilter) || e.PropertyName == nameof(SelectedBinding)) { AvailableActionsView.Refresh(); } }; }
public virtual void RegisterActions(IShortcutManager s) { void UpdateSettings(DeviceAxis axis, Action <DeviceAxisSettings> callback) { if (axis != null) { callback(AxisSettings[axis]); } }
public AgentExtensibleAction(Lifetime lifetime, IOriginalActionHandler <TWorkflowProvider, TWorkflow, TActionGroup> handler, Agent agent, IActionManager actionManager, IShortcutManager shortcutManager) { this.lifetime = lifetime; this.handler = handler; this.agent = agent; this.actionManager = actionManager; this.shortcutManager = shortcutManager; }
public MpcMediaSourceViewModel(IShortcutManager shortcutManager, IEventAggregator eventAggregator) : base(shortcutManager, eventAggregator) { _eventAggregator = eventAggregator; _writeMessageChannel = Channel.CreateUnbounded <object>(new UnboundedChannelOptions() { SingleReader = true, SingleWriter = true, }); }
public OutputTargetViewModel(IShortcutManager shortcutManager, IEventAggregator eventAggregator, IOutputTargetFactory outputTargetFactory) { _shortcutManager = shortcutManager; _outputTargetFactory = outputTargetFactory; eventAggregator.Subscribe(this); _semaphores = new Dictionary <IOutputTarget, SemaphoreSlim>(); _cancellationSource = new CancellationTokenSource(); AvailableOutputTargetTypes = ReflectionUtils.FindImplementations <IOutputTarget>().ToList(); }
public MediaSourceViewModel(IShortcutManager shortcutManager, IEventAggregator eventAggregator, IEnumerable <IMediaSource> sources) { eventAggregator.Subscribe(this); Items.AddRange(sources); _currentSource = null; _semaphore = new SemaphoreSlim(1, 1); _cancellationSource = new CancellationTokenSource(); RegisterShortcuts(shortcutManager); }
public override void RegisterActions(IShortcutManager s) { base.RegisterActions(s); #region Uri s.RegisterAction($"{Identifier}::Uri::Set", b => b.WithSetting <string>(s => s.WithLabel("Uri").WithDescription("websocket uri")).WithCallback((_, uriString) => { if (Uri.TryCreate(uriString, UriKind.Absolute, out var uri)) { Uri = uri; } })); #endregion }
protected override void RegisterShortcuts(IShortcutManager s) { base.RegisterShortcuts(s); #region Endpoint s.RegisterAction($"{Name}::Endpoint::Set", b => b.WithSetting <string>(s => s.WithLabel("Endpoint").WithDescription("ip:port")).WithCallback((_, endpointString) => { if (IPEndPoint.TryParse(endpointString, out var endpoint)) { Endpoint = endpoint; } })); #endregion }
protected AbstractMediaSource(IShortcutManager shortcutManager, IEventAggregator eventAggregator) { _statusEvent = new AsyncManualResetEvent(); eventAggregator.Subscribe(this); PropertyChanged += (s, e) => { if (string.Equals(e.PropertyName, "Status", StringComparison.OrdinalIgnoreCase)) { _statusEvent.Reset(); } }; RegisterShortcuts(shortcutManager); }
public AgentClickHandler(Lifetime lifetime, Agent agent, IActionManager actionManager, IShortcutManager shortcutManager, IThreading threading) { this.actionManager = actionManager; this.shortcutManager = shortcutManager; this.threading = threading; var buttons = new List <string> { "Options", "Done" }; // ReSharper disable ConvertToLambdaExpression agent.AgentClicked.Advise(lifetime, _ => { var lifetimeDefinition = Lifetimes.Define(lifetime); var options = GetOptions(); agent.ShowBalloon(lifetimeDefinition.Lifetime, "What do you want to do?", string.Empty, options, buttons, true, balloonLifetime => { agent.BalloonOptionClicked.Advise(balloonLifetime, tag => { lifetimeDefinition.Terminate(); ExecuteOption(tag); }); agent.ButtonClicked.Advise(balloonLifetime, button => { lifetimeDefinition.Terminate(); if (button == "Options") { ExecuteAction("ShowOptions"); } }); }); }); // ReSharper restore ConvertToLambdaExpression }
public override void RegisterActions(IShortcutManager s) { base.RegisterActions(s); #region Endpoint s.RegisterAction($"{Identifier}::Endpoint::Set", b => b.WithSetting <string>(s => s.WithLabel("Endpoint").WithDescription("ip:port")).WithCallback((_, endpointString) => { if (IPEndPoint.TryParse(endpointString, out var endpoint)) { Endpoint = endpoint; } })); #endregion #region Protocol s.RegisterAction($"{Identifier}::Protocol::Set", b => b.WithSetting <ProtocolType?>(s => s.WithLabel("Protocol").WithItemsSource(EnumUtils.GetValues <ProtocolType?>())).WithCallback((_, protocol) => { if (protocol.HasValue) { Protocol = protocol.Value; } })); #endregion }
public void RegisterShortcuts(IShortcutManager s) { foreach (var name in MotionProviderNames) { #region MotionProvider::Speed s.RegisterAction($"MotionProvider::{name}::Speed::Offset", b => b.WithSetting <DeviceAxis>(p => p.WithLabel("Target axis").WithItemsSource(DeviceAxis.All)) .WithSetting <float>(p => p.WithLabel("Value offset").WithStringFormat("{}{0}%")) .WithCallback((_, axis, offset) => { var motionProvider = GetMotionProvider(axis, name); if (motionProvider == null) { return; } motionProvider.Speed = MathF.Max(0.01f, motionProvider.Speed + offset / 100); })); s.RegisterAction($"MotionProvider::{name}::Speed::Set", b => b.WithSetting <DeviceAxis>(p => p.WithLabel("Target axis").WithItemsSource(DeviceAxis.All)) .WithSetting <float>(p => p.WithLabel("Value").WithStringFormat("{}{0}%")) .WithCallback((_, axis, value) => { var motionProvider = GetMotionProvider(axis, name); if (motionProvider == null) { return; } motionProvider.Speed = MathF.Max(0.01f, value / 100); })); s.RegisterAction($"MotionProvider::{name}::Speed::Drive", b => b.WithSetting <DeviceAxis>(p => p.WithLabel("Target axis").WithItemsSource(DeviceAxis.All)) .WithCallback((gesture, axis) => { if (gesture is not IAxisInputGesture axisGesture) { return; } var motionProvider = GetMotionProvider(axis, name); if (motionProvider == null) { return; } motionProvider.Speed = MathF.Max(0.01f, motionProvider.Speed + axisGesture.Delta); }), ShortcutActionDescriptorFlags.AcceptsAxisGesture); #endregion #region MotionProvider::Minimum s.RegisterAction($"MotionProvider::{name}::Minimum::Offset", b => b.WithSetting <DeviceAxis>(p => p.WithLabel("Target axis").WithItemsSource(DeviceAxis.All)) .WithSetting <float>(p => p.WithLabel("Value offset").WithStringFormat("{}{0}%")) .WithCallback((_, axis, offset) => { var motionProvider = GetMotionProvider(axis, name); if (motionProvider == null) { return; } motionProvider.Minimum = MathUtils.Clamp(motionProvider.Minimum + offset, 0, 100); })); s.RegisterAction($"MotionProvider::{name}::Minimum::Set", b => b.WithSetting <DeviceAxis>(p => p.WithLabel("Target axis").WithItemsSource(DeviceAxis.All)) .WithSetting <float>(p => p.WithLabel("Value").WithStringFormat("{}{0}%")) .WithCallback((_, axis, value) => { var motionProvider = GetMotionProvider(axis, name); if (motionProvider == null) { return; } motionProvider.Minimum = MathUtils.Clamp(value, 0, 100); })); s.RegisterAction($"MotionProvider::{name}::Minimum::Drive", b => b.WithSetting <DeviceAxis>(p => p.WithLabel("Target axis").WithItemsSource(DeviceAxis.All)) .WithCallback((gesture, axis) => { if (gesture is not IAxisInputGesture axisGesture) { return; } var motionProvider = GetMotionProvider(axis, name); if (motionProvider == null) { return; } motionProvider.Minimum = MathUtils.Clamp(motionProvider.Minimum + axisGesture.Delta, 0, 100); }), ShortcutActionDescriptorFlags.AcceptsAxisGesture); #endregion #region MotionProvider::Maximum s.RegisterAction($"MotionProvider::{name}::Maximum::Offset", b => b.WithSetting <DeviceAxis>(p => p.WithLabel("Target axis").WithItemsSource(DeviceAxis.All)) .WithSetting <float>(p => p.WithLabel("Value offset").WithStringFormat("{}{0}%")) .WithCallback((_, axis, offset) => { var motionProvider = GetMotionProvider(axis, name); if (motionProvider == null) { return; } motionProvider.Maximum = MathUtils.Clamp(motionProvider.Maximum + offset, 0, 100); })); s.RegisterAction($"MotionProvider::{name}::Maximum::Set", b => b.WithSetting <DeviceAxis>(p => p.WithLabel("Target axis").WithItemsSource(DeviceAxis.All)) .WithSetting <float>(p => p.WithLabel("Value").WithStringFormat("{}{0}%")) .WithCallback((_, axis, value) => { var motionProvider = GetMotionProvider(axis, name); if (motionProvider == null) { return; } motionProvider.Maximum = MathUtils.Clamp(value, 0, 100); })); s.RegisterAction($"MotionProvider::{name}::Maximum::Drive", b => b.WithSetting <DeviceAxis>(p => p.WithLabel("Target axis").WithItemsSource(DeviceAxis.All)) .WithCallback((gesture, axis) => { if (gesture is not IAxisInputGesture axisGesture) { return; } var motionProvider = GetMotionProvider(axis, name); if (motionProvider == null) { return; } motionProvider.Maximum = MathUtils.Clamp(motionProvider.Maximum + axisGesture.Delta, 0, 100); }), ShortcutActionDescriptorFlags.AcceptsAxisGesture); #endregion } }
public override void UnregisterActions(IShortcutManager s) { base.UnregisterActions(s); s.UnregisterAction($"{Identifier}::Endpoint::Set"); s.UnregisterAction($"{Identifier}::Protocol::Set"); }
public FileTemplatesGenerateAction(Lifetime lifetime, Agent agent, IActionManager actionManager, IShortcutManager shortcutManager) { actionHelper = new ExtensibleActionHelper(lifetime, this, agent, actionManager, shortcutManager); }
public RefactorThisAction(Lifetime lifetime, Agent agent, IActionManager actionManager, IShortcutManager shortcutManager) { actionHelper = new ExtensibleActionHelper(lifetime, this, agent, actionManager, shortcutManager); }
public NavigateFromHereAction(Lifetime lifetime, Agent agent, IActionManager actionManager, IShortcutManager shortcutManager) { actionHelper = new ExtensibleActionHelper(lifetime, this, agent, actionManager, shortcutManager); }
public WhirligigMediaSourceViewModel(IShortcutManager shortcutManager, IEventAggregator eventAggregator) : base(shortcutManager, eventAggregator) { _eventAggregator = eventAggregator; }
public override void UnregisterActions(IShortcutManager s) { base.UnregisterActions(s); s.UnregisterAction($"{Identifier}::PipeName::Set"); }
public OverridingActionRegistrar(Lifetime lifetime, Agent agent, ISolution solution, IShellLocks shellLocks, IActionManager actionManager, IShortcutManager shortcutManager, IPsiFiles psiFiles, RecentFilesTracker tracker, OccurencePresentationManager presentationManager, MainWindowPopupWindowContext mainWindowPopupWindowContext) { RegisterHandler(actionManager, "RefactorThis", lifetime, new RefactorThisAction(lifetime, agent, actionManager, shortcutManager)); RegisterHandler(actionManager, "NavigateTo", lifetime, new NavigateFromHereAction(lifetime, agent, actionManager, shortcutManager)); RegisterHandler(actionManager, "Generate", lifetime, new GenerateAction(lifetime, agent, actionManager, shortcutManager)); RegisterHandler(actionManager, "GenerateFileBesides", lifetime, new FileTemplatesGenerateAction(lifetime, agent, actionManager, shortcutManager)); RegisterHandler(actionManager, "GotoRecentFiles", lifetime, new GotoRecentFilesAction(lifetime, agent, solution, shellLocks, psiFiles, tracker, presentationManager, mainWindowPopupWindowContext)); RegisterHandler(actionManager, "GotoRecentEdits", lifetime, new GotoRecentEditsAction(lifetime, agent, solution, shellLocks, psiFiles, tracker, presentationManager, mainWindowPopupWindowContext)); }