Example #1
0
        public SmilesToolbarGenerator(
            IServiceProvider provider, string menuName, SmilesToolbar toolbar)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            if (menuName == null)
            {
                throw new ArgumentNullException("menuName");
            }
            if (toolbar == null)
            {
                throw new ArgumentNullException("toolbar");
            }

            _serviceProvider = provider;
            _toolbar         = toolbar;
            _menuName        = menuName;

            _menuService           = _serviceProvider.GetRequiredService <IMenuService>();
            _commandHandlerService = _serviceProvider.GetRequiredService <ICommandHandlerService>();
            _styleImageManager     = _serviceProvider.GetRequiredService <IStyleImageManager>();

            UpdateMenu();

            _menuChangedSubscription = _menuService
                                       .MenuChanged
                                       .Where(changedMenuName => _menuName == changedMenuName)
                                       .Subscribe(changedMenuName => UpdateMenu());
            _toolbar.ButtonClick += ToolbarButtonClick;
        }
Example #2
0
        public ConsoleForm([NotNull] IServiceProvider provider)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }

            _provider              = provider;
            _commandService        = _provider.GetRequiredService <ICommandService>();
            _commandHandlerService = _provider.GetRequiredService <ICommandHandlerService>();
            _history = new List <string>();

            InitializeComponent();

            var styleImageManager = _provider.GetService <IStyleImageManager>();

            if (styleImageManager != null)
            {
                Icon = styleImageManager.TryGetImage("console", StyleImageType.Small).ToIcon();
            }

            _toolbarGenerator = new StripMenuGenerator(_provider, _toolStrip, "Janus.Console.Toolbar");

            var font = new Font("Courier New", 10F);

            _consoleEditor.Font = font;

            _defaultStyle = new TextStyle(
                "Default", 0, font, Color.Black, Color.White, false,
                CaseMode.Mixed, true, false, PredefinedStyle.None);
            _commandNameStyle = new TextStyle(
                "CommandName", 1, font, Color.Brown, Color.White, false,
                CaseMode.Mixed, true, false, PredefinedStyle.None);
            _parameterNameStyle = new TextStyle(
                "ParameterName", 2, font, Color.Red, Color.White, false,
                CaseMode.Mixed, true, false, PredefinedStyle.None);
            _parameterValueStyle = new TextStyle(
                "ParameterValue", 3, font, Color.Blue, Color.White, false,
                CaseMode.Mixed, true, false, PredefinedStyle.None);

            _consoleEditor.TextStyles.AddRange(
                new[] {
                _defaultStyle,
                _commandNameStyle,
                _parameterNameStyle,
                _parameterValueStyle
            });

            Prompt();
        }
Example #3
0
        private RoslynCommandTarget(ITextView textView, ITextBuffer languageBuffer)
        {
            ICommandHandlerServiceFactory commandHandlerServiceFactory = CompositionManager.GetExportedValue <ICommandHandlerServiceFactory>();

            if (commandHandlerServiceFactory != null)
            {
                commandHandlerServiceFactory.Initialize(languageBuffer.ContentType.TypeName);

                CurrentHandlers = commandHandlerServiceFactory.GetService(languageBuffer);
            }

            _languageBuffer = languageBuffer;
            _textView       = textView;
        }
Example #4
0
        public SelectionService(IConcurrencyService concurrencyService, ICommandHandlerService commandHandlerService)
        {
            var changes = Subject.Synchronize(new Subject <Func <Selection, Selection> >());

            mMakeChange = changes.OnNext;

            WhenSelectionChanges = changes
                                   .ObserveOn(concurrencyService.TaskPoolRxScheduler)
                                   .Scan(Selection.Empty, (sel, change) => change(sel))
                                   .Do(s => CurrentSelection = s)
                                   .Publish(Selection.Empty)
                                   .ConnectForEver();

            commandHandlerService.RegisterHandler(
                Commands.ChangeSelectedEventItems,
                ReactiveCommand.Create <Func <Selection, Selection> >(ChangeSelection));
        }
Example #5
0
        public ConsoleForm([NotNull] IServiceProvider provider)
        {
            if (provider == null)
                throw new ArgumentNullException("provider");

            _provider = provider;
            _commandService = _provider.GetRequiredService<ICommandService>();
            _commandHandlerService = _provider.GetRequiredService<ICommandHandlerService>();
            _history = new List<string>();

            InitializeComponent();

            var styleImageManager = _provider.GetService<IStyleImageManager>();
            if (styleImageManager != null)
                Icon = styleImageManager.TryGetImage("console", StyleImageType.Small).ToIcon();

            _toolbarGenerator = new StripMenuGenerator(_provider, _toolStrip, "Janus.Console.Toolbar");

            var font = new Font("Courier New", 10F);
            _consoleEditor.Font = font;

            _defaultStyle = new TextStyle(
                "Default", 0, font, Color.Black, Color.White, false,
                CaseMode.Mixed, true, false, PredefinedStyle.None);
            _commandNameStyle = new TextStyle(
                "CommandName", 1, font, Color.Brown, Color.White, false,
                CaseMode.Mixed, true, false, PredefinedStyle.None);
            _parameterNameStyle = new TextStyle(
                "ParameterName", 2, font, Color.Red, Color.White, false,
                CaseMode.Mixed, true, false, PredefinedStyle.None);
            _parameterValueStyle = new TextStyle(
                "ParameterValue", 3, font, Color.Blue, Color.White, false,
                CaseMode.Mixed, true, false, PredefinedStyle.None);

            _consoleEditor.TextStyles.AddRange(
                new[] {
                    _defaultStyle,
                    _commandNameStyle,
                    _parameterNameStyle,
                    _parameterValueStyle
                });

            Prompt();
        }
Example #6
0
 private void CommandStatusChanged(ICommandHandlerService sender, string[] commandNames)
 {
     _uiAsyncOperation.Post(
         () =>
     {
         var updated = false;
         commandNames.ForEach(
             commandName =>
         {
             List <ToolStripItem> commandControls;
             if (_commandControls.TryGetValue(commandName, out commandControls))
             {
                 commandControls.ForEach(UpdateMenuCommandStatus);
                 updated = true;
             }
         });
         if (updated)
         {
             UpdateItemsVisibility(_toolStrip.Items);
         }
     });
 }
Example #7
0
 public WindowManagerEx(ICommandHandlerService commandHandlerService)
 {
     mCommandHandlerService = commandHandlerService;
 }
        public HomeScreenViewModel(
            IScreenFactory screenFactory,
            IConcurrencyService concurrencyService,
            ICommandHandlerService commandHandlerService,
            IConnectionService connectionService,
            IDialogService dialogService,
            IAddMethodDialog addMethodDialog,
            ISelectionService selectionService,
            IQuickEventListDialog quickEventListDialog,
            ISelectedCallsScreen selectedCallsScreen,
            IPayloadScreen payloadScreen)
        {
            SelectedCallsScreen = selectedCallsScreen;
            PayloadScreen       = payloadScreen;

            var isUpdating = GoPauseControl.SetupGoPause(out var attachGoPauseHandlers)
                             .ObserveOn(concurrencyService.TaskPoolRxScheduler);

            WhenActivated(disposables =>
            {
                DisplayName = Workspace.Name;

                isUpdating.Subscribe(x =>
                {
                    if (x)
                    {
                        Workspace.ResumeUpdates();
                    }
                    else
                    {
                        Workspace.PauseUpdates();
                    }
                }).DisposeWith(disposables);

                attachGoPauseHandlers(commandHandlerService).DisposeWith(disposables);

                var closeCommand = ReactiveUI.ReactiveCommand.Create(() => connectionService.Close());
                commandHandlerService.RegisterHandler(Commands.CloseWorkspace, closeCommand)
                .DisposeWith(disposables);

                addMethodDialog.Model        = Workspace.Model;
                var addMethodToConfigCommand = ReactiveUI.ReactiveCommand.Create(async() =>
                {
                    var methodToAdd = await dialogService.ShowDialogContent(addMethodDialog);
                    Workspace.AddSourceMethod(methodToAdd);
                });
                commandHandlerService.RegisterHandler(Commands.ShowAddToConfiguration, addMethodToConfigCommand)
                .DisposeWith(disposables);

                var selectionHasItemsWithEvents = selectionService.WhenSelectionChanges.Select(s => s.PrimaryInstrumentedCall != null || s.SelectedObservableInstances.Count > 0).ObserveOn(concurrencyService.DispatcherRxScheduler);

                var quickEventListCommand = ReactiveUI.ReactiveCommand.Create(async() =>
                {
                    Selection sel        = selectionService.CurrentSelection;
                    bool haveObservables = false;

                    if (sel.SelectedObservableInstances.Count > 0)
                    {
                        haveObservables = true;
                        quickEventListDialog.Observables = sel.SelectedObservableInstances
                                                           .ToObservable()
                                                           .ToObservableChangeSet(o => o.ObservableId);

                        if (sel.SelectedObservableInstances.Count == 1)
                        {
                            var obs  = sel.SelectedObservableInstances[0];
                            var call = obs.Call;
                            quickEventListDialog.Title = $"{call.Method.DetailName}: {call.CalledMethod} @{obs.Created.Timestamp}";
                        }
                        else
                        {
                            quickEventListDialog.Title = $"{sel.SelectedObservableInstances.Count} IObservable instances";
                        }
                    }
                    else
                    {
                        var call = sel.PrimaryInstrumentedCall;
                        if (call != null)
                        {
                            haveObservables = true;
                            quickEventListDialog.Observables = call.ObservableInstances.ToObservableChangeSet(o => o.ObservableId);
                            quickEventListDialog.Title       = $"{call.Method.DetailName}: {call.CalledMethod}";
                        }
                    }

                    if (haveObservables)
                    {
                        await dialogService.ShowDialogContent(quickEventListDialog);
                    }
                }, selectionHasItemsWithEvents);
                commandHandlerService.RegisterHandler(Commands.QuickEventList, quickEventListCommand)
                .DisposeWith(disposables);

                var openEventListCommand = ReactiveUI.ReactiveCommand.Create(() =>
                {
                    Selection sel = selectionService.CurrentSelection;

                    if (sel.SelectedObservableInstances.Count > 0)
                    {
                        Workspace.CreateEventsDocument(sel.SelectedObservableInstances);
                    }
                    else if (sel.PrimaryInstrumentedCall != null)
                    {
                        Workspace.CreateEventsDocument(new[] { sel.PrimaryInstrumentedCall });
                    }
                }, selectionHasItemsWithEvents);
                commandHandlerService.RegisterHandler(Commands.OpenEventList, openEventListCommand)
                .DisposeWith(disposables);

                // Document screens
                Workspace.Documents
                .Transform(screenFactory.CreateDocumentScreen)
                .ObserveOn(concurrencyService.DispatcherRxScheduler)
                .Bind(out var documentScreens)
                .OnItemAdded(screen => ActiveDocumentScreen = screen)
                .Transform(screen => screen.Activator.Activate())
                .DisposeMany()
                .Subscribe()
                .DisposeWith(disposables);

                DocumentScreens = documentScreens;
            });
        }
Example #9
0
 public ISubscriber WithYourCommandHandlerService(ICommandHandlerService commandHandlerService)
 {
     this.CommandHandlerService = commandHandlerService;
     return(this);
 }
 public CoreController(ICommandHandlerService commandHandler)
 {
     _commandHandler = commandHandler;
 }
Example #11
0
        public StripMenuGenerator(
            [NotNull] IServiceProvider serviceProvider,
            [NotNull] ToolStrip toolStrip,
            [NotNull] string menuName,
            bool useSmallImages)
        {
            if (serviceProvider == null)
            {
                throw new ArgumentNullException("serviceProvider");
            }
            if (menuName == null)
            {
                throw new ArgumentNullException("menuName");
            }
            if (toolStrip == null)
            {
                throw new ArgumentNullException("toolStrip");
            }

            _serviceProvider = serviceProvider;
            _toolStrip       = toolStrip;
            _menuName        = menuName;
            _useSmallImages  = useSmallImages;

            if (toolStrip is ContextMenuStrip)
            {
                _menuType = TargetMenuType.ContextMenu;
            }
            else if (toolStrip is MenuStrip || toolStrip is ToolStripDropDownMenu)
            {
                _menuType = TargetMenuType.Menu;
            }
            else
            {
                _menuType = TargetMenuType.Toolbar;
            }

            _styleImageManager     = _serviceProvider.GetRequiredService <IStyleImageManager>();
            _menuService           = _serviceProvider.GetRequiredService <IMenuService>();
            _commandHandlerService = _serviceProvider.GetRequiredService <ICommandHandlerService>();
            _defaultCommandService = _serviceProvider.GetService <IDefaultCommandService>();
            _checkStateService     = _serviceProvider.GetService <ICheckStateService>();

            _uiAsyncOperation = _serviceProvider.GetRequiredService <IUIShell>().CreateUIAsyncOperation();

            Init();

            _disposables.Add(
                _menuService
                .MenuChanged
                .Where(changedMenuName => changedMenuName == _menuName)
                .Subscribe(arg => Init()));

            _disposables.Add(
                _commandHandlerService.SubscribeCommandStatusChanged(_serviceProvider, CommandStatusChanged));

            if (_checkStateService != null)
            {
                _disposables.Add(
                    _checkStateService.SubscribeCheckStateChanged(_serviceProvider, CheckStateChanged));
            }

            if (_defaultCommandService != null)
            {
                _disposables.Add(
                    _defaultCommandService.DefaultCommandChanged.Subscribe(
                        arg => _uiAsyncOperation.Post(Init)));
            }
        }
Example #12
0
 public CommandReceiver(ICommandHandlerService commandHandlerService)
 {
     this.commandHandlerService = commandHandlerService;
 }