Example #1
0
        private void Init()
        {
            _dte = GetGlobalService(typeof(DTE)) as DTE2 ?? throw new NullReferenceException($"Unable to get service {nameof(DTE2)}");

            //Log context and Serilog enricher
            VsVersionContext.Current = new VsDteVersionContext(_dte);
            LoggerContext.Current    = new LogentriesSerilogLoggerContext();

            LoggerContext.Current.Logger.Info($"{nameof(ReopenPackage)} started to load. Initializing dependencies...");

            //DI
            IDocumentHistoryManager documentHistory = new DocumentHistoryManager();

            _documentHistoryCommands = documentHistory;
            _documentHistoryQueries  = documentHistory;

            //Commands
            _reopenLastClosedCommand = new RemoveLastCommand(_documentHistoryCommands,
                                                             new ReopenDocumentCommandFactory(_dte));
            _removeLastClosedCommand = new RemoveLastCommand(_documentHistoryCommands,
                                                             new DoNothingDocumentCommandFactory());
            _reopenSomeDocumentsCommandFactory = new HistoryCommandFactory <RemoveSomeCommand>(_documentHistoryCommands,
                                                                                               new ReopenDocumentCommandFactory(_dte));
            _removeSomeDocumentsCommandFactory = new HistoryCommandFactory <RemoveSomeCommand>(_documentHistoryCommands,
                                                                                               new DoNothingDocumentCommandFactory());
            _clearHistoryCommand = new ClearHistoryCommand(_documentHistoryCommands);

            _documentTracker = new DocumentEventsTracker(_dte,
                                                         documentHistory,
                                                         new JsonHistoryRepositoryFactory(new ServiceStackJsonSerializer()),
                                                         new VSMessageBox(this));
        }
        public static async Task InitializeAsync(AsyncPackage package, IHistoryCommand historyCommand)
        {
            var commandService = package == null
                                ? null
                                : await package.GetServiceAsync(typeof(IMenuCommandService)) as OleMenuCommandService;

            Instance = new RemoveClosedDocumentsCommand(package, commandService, historyCommand);
        }
        private RemoveClosedDocumentsCommand(AsyncPackage package, OleMenuCommandService commandService, IHistoryCommand historyCommand)
        {
            _package        = package ?? throw new ArgumentNullException(nameof(package));
            commandService  = commandService ?? throw new ArgumentNullException(nameof(commandService));
            _historyCommand = historyCommand ?? throw new ArgumentNullException(nameof(historyCommand));

            var menuCommandId = new CommandID(CommandSet, CommandId);
            var menuItem      = new MenuCommand(Execute, menuCommandId);

            commandService.AddCommand(menuItem);
        }
Example #4
0
        //----------------------------------------------------------------//

        public async void Notify(Object obj)
        {
            using (ISession session = SessionFactory.CreateSession())
            {
                ConcurrentBag <NotificationModel> notifications = await GetNotifications(session);

                IHistoryCommand historyCommand = CommandFactory.CreateCommand <IHistoryCommand>(session);
                foreach (NotificationModel notificationModel in notifications)
                {
                    await Notify(historyCommand, notificationModel);
                }
            }
        }
        public static async Task InitializeAsync(IDocumentHistoryQueries documentHistoryQueries,
                                                 IHistoryCommand reopenLastClosdCommand,
                                                 IHistoryCommandFactory reopenSomeDocumentsCommandFactory,
                                                 IHistoryCommandFactory removeSomeDocumentsCommandFactory,
                                                 IHistoryCommand clearHistoryCommand,
                                                 IFileExtensionIconResolver fileExtensionIconResolver,
                                                 IHistoryToolWindowRepositoryFactory historyToolWindowRepositoryFactory)
        {
            ContentWindow = new ClosedDocumentsHistoryControl(documentHistoryQueries,
                                                              reopenLastClosdCommand,
                                                              reopenSomeDocumentsCommandFactory,
                                                              removeSomeDocumentsCommandFactory,
                                                              clearHistoryCommand,
                                                              fileExtensionIconResolver,
                                                              historyToolWindowRepositoryFactory);

            await Task.CompletedTask;
        }
Example #6
0
        //----------------------------------------------------------------//

        public override async Task <Message> ExecuteAsync(Message message)
        {
            String status = null;

            if (message != null)
            {
                Int32 historyId = 0;
                using (ISession session = SessionFactory.CreateSession())
                {
                    IHistoryCommand historyCommand = CommandFactory.CreateCommand <IHistoryCommand>(session);
                    if (await historyCommand.SetHistoryAsSuccess(historyId))
                    {
                        status = CommonConstants.SUCCESS;
                    }
                }
            }
            else
            {
                status = CommonConstants.FUCK_YOU;
            }

            return(await BotClient.SendTextMessageAsync(message.Chat.Id, status, replyToMessageId : message.MessageId));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="ClosedDocumentsHistoryControl"/> class.
        /// </summary>
        public ClosedDocumentsHistoryControl(IDocumentHistoryQueries documentHistoryQueries,
                                             IHistoryCommand reopenLastClosdCommand,
                                             IHistoryCommandFactory reopenSomeDocumentsCommandFactory,
                                             IHistoryCommandFactory removeSomeDocumentsCommandFactory,
                                             IHistoryCommand clearHistoryCommand,
                                             IFileExtensionIconResolver fileExtensionIconResolver,
                                             IHistoryToolWindowRepositoryFactory historyToolWindowRepositoryFactory)
        {
            InitializeComponent();

            _documentHistoryQueries            = documentHistoryQueries;
            _reopenLastClosdCommand            = reopenLastClosdCommand;
            _reopenSomeDocumentsCommandFactory = reopenSomeDocumentsCommandFactory;
            _removeSomeDocumentsCommandFactory = removeSomeDocumentsCommandFactory;
            _clearHistoryCommand                = clearHistoryCommand;
            _fileExtensionIconResolver          = fileExtensionIconResolver;
            _historyToolWindowRepositoryFactory = historyToolWindowRepositoryFactory;

            var openState = new ButtonDisabledState(_openSelected,
                                                    new Image()
            {
                Source = WpfImageSourceConverter.CreateBitmapSource(VSDocumentReopen.Resources.OpenFile_16x)
            },
                                                    new Image()
            {
                Source = WpfImageSourceConverter.CreateBitmapSource(VSDocumentReopen.Resources.OpenFile_16x_Gray)
            });

            openState.Disable();

            var removeState = new ButtonDisabledState(_removeSelected,
                                                      new Image()
            {
                Source = WpfImageSourceConverter.CreateBitmapSource(VSDocumentReopen.Resources.RemoveGuide_16x)
            },
                                                      new Image()
            {
                Source = WpfImageSourceConverter.CreateBitmapSource(VSDocumentReopen.Resources.RemoveGuide_16x_Gray)
            });

            removeState.Disable();

            var removeNonExistingState = new ButtonDisabledState(_removeNonExisting,
                                                                 new Image()
            {
                Source = WpfImageSourceConverter.CreateBitmapSource(VSDocumentReopen.Resources.RemoveNonExisting_16x)
            },
                                                                 new Image()
            {
                Source = WpfImageSourceConverter.CreateBitmapSource(VSDocumentReopen.Resources.RemoveNonExisting_16x_Gray)
            });

            removeNonExistingState.Disable();

            var clearState = new ButtonDisabledState(_clearAll,
                                                     new Image()
            {
                Source = WpfImageSourceConverter.CreateBitmapSource(VSDocumentReopen.Resources.ClearWindowContent_16x)
            },
                                                     new Image()
            {
                Source = WpfImageSourceConverter.CreateBitmapSource(VSDocumentReopen.Resources.ClearWindowContent_16x_Gray)
            });

            clearState.Disable();

            _documentHistoryQueries.HistoryChanged += DocumentHistoryChanged;
            UpdateHistoryView(GetFullHistory);

            _listView.Focus();
            var customizationSettings = LoadCustomizationSettings();

            _columnHeaders = Enumerable.Range(0, _listViewContect.Columns.Count).ToDictionary(i => i++,
                                                                                              i => _listViewContect.Columns[i].GetGridViewHeaderText());

            AddContextMenu(customizationSettings);
            HandleColumnsStatus(customizationSettings);
        }