Example #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GenerateTSClass"/> class.
        /// Adds our command handlers for menu (commands must exist in the command table file)
        /// </summary>
        /// <param name="package">Owner package, not null.</param>
        /// <param name="findSelectorModel"></param>
        private GenerateTSClass(Package package, FileSelectorViewModel findSelectorModel)
        {
            _findSelectorModel = findSelectorModel;
            this._package      = package ?? throw new ArgumentNullException(nameof(package));

            if (this.ServiceProvider.GetService(typeof(IMenuCommandService)) is OleMenuCommandService commandService)
            {
                var menuCommandId = new CommandID(CommandSet, CommandId);
                var menuItem      = new MenuCommand(this.MenuItemCallback, menuCommandId);
                commandService.AddCommand(menuItem);
            }
        }
Example #2
0
        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            _dte = (DTE2)GetGlobalService(typeof(DTE));
            var service = new SolutionService(_dte);

            ((IServiceContainer)this).AddService(typeof(ISolutionService), service);

            _findSelectorModel = new FileSelectorViewModel(service, new FileGeneratorFactory());

            GenerateTSClass.Initialize(this, _findSelectorModel);
            FileSelectorWindowCommand.Initialize(this);
            _monitorSelection = GetGlobalService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;
            _monitorSelection?.AdviseSelectionEvents(this, out _selectionHandle);
        }
Example #3
0
        /// <summary>
        /// ファイルを開く
        /// </summary>
        /// <param name="editor">テキストを展開するためのIEditorインターフェース</param>
        /// <returns>正否</returns>
        public bool OpenFile(IEditor editor)
        {
            FileSelectorControl control = new FileSelectorControl();

            control.Owner = Application.Current.MainWindow;
            var viewModel = new FileSelectorViewModel(control);

            viewModel.Initialize(NovelsCollectorGenerator.GetRecentlyNovelsCollector(),
                                 NovelsCollectorGenerator.GetSemiAutoBackupNovelsCollector(),
                                 NovelsCollectorGenerator.GetNovelsBoxCollector());

            control.SetViewModel(viewModel);
            //ダイアログを表示する
            if (ShowDialogManager.ShowDialog(control) == true)
            {
                OpenFile(editor, control.FilePath);
                return(true);
            }

            return(false);
        }
Example #4
0
 /// <summary>
 /// Initializes the singleton instance of the command.
 /// </summary>
 /// <param name="package">Owner package, not null.</param>
 /// <param name="findSelectorModel"></param>
 public static void Initialize(Package package, FileSelectorViewModel findSelectorModel)
 {
     Instance = new GenerateTSClass(package, findSelectorModel);
 }
        public void SetViewModel(FileSelectorViewModel viewModel)
        {
            _viewModel = viewModel;

            this.DataContext = _viewModel;
        }