Example #1
0
 public GrepViewModel(GherkinViewModel gherkinViewModel, MultiFileOpener multiFilesOpener, IAppSettings appSettings, string default_grep_text) :
     base(appSettings)
 {
     m_GherkinViewModel = gherkinViewModel;
     m_MultiFilesOpener = multiFilesOpener;
     SetDefaultGrepConditions(default_grep_text);
 }
        private void OpenGreppedFile(MultiFileOpener multiFilesOpener, string grepLine)
        {
            m_MultiFilesOpener = multiFilesOpener;
            Tuple <string, int> fileNameAndLineNo = TryGetFileNameAndLineNo(grepLine);

            GreppedLineNo = fileNameAndLineNo.Item2;

            if (!File.Exists(fileNameAndLineNo.Item1))
            {
                return;
            }

            var tab = m_MultiFilesOpener.OpenEditorTab(fileNameAndLineNo.Item1);

            m_GreppedFileEditorViewModel = tab.Item2.EditorTabContentViewModel;
            if (tab.Item1)
            {
                // new editor created so that we need to wait EditorLoadeded event to finish work
                EventAggregator <EditorLoadedArg> .Instance.Event += OnGrepEditorLoaded;
            }
            else
            {
                // directly move cursor because the text editor has been loaded
                ScrollCursorToLine(GreppedLineNo);
            }
        }
        public WorkAreaEditorViewModel(TextEditor editor, MultiFileOpener multiFilesOpener, IAppSettings appSettings)
        {
            m_WorkAreaEditor = new GherkinEditor(editor,
                                                 null, // subEditor,
                                                 editor.Document,
                                                 appSettings,
                                                 new FontFamily(appSettings.Fonts.FontFamilyName),
                                                 appSettings.Fonts.FontSize,
                                                 installElementGenerators: false);
            editor.Options.CopyFileToHandler = CopyFileTo;
            editor.Options.RequireControlModifierForHyperlinkClick = false;     // Directly open web browser for work area instead of using Ctrl key
            m_MultiFilesOpener = multiFilesOpener;
            m_AppSettings      = appSettings;

            m_WorkAreaEditor.TextEditor.Options.ContainOpenableFilePath = ContainOpenableFilePath;
            m_WorkAreaEditor.TextEditor.Options.FilePathClickedHandler  = OnFilePathClickedHandler;

            EventAggregator <WindowDeactivatedArg> .Instance.Event += OnWindowDeactivatedEvent;
        }
Example #4
0
        public GherkinViewModel(IAppSettings appSettings,
                                MultiFileOpener multiFilesOpener,
                                GherkinSettingViewModel gherkinSettings,
                                AboutViewModel aboutViewModel,
                                CodePageListPopupViewModel codePageListPopupViewModel)
        {
            m_AppSettings = appSettings;
            GherkinFormatUtil.AppSettings            = appSettings;
            m_AppSettings.SynchronizeCursorPositions = false;   // Do not synchronize at start up

            m_MultiFilesOpener = multiFilesOpener;
            m_MultiFilesOpener.OpeningTabEvent         += OnOpeningTab;
            m_MultiFilesOpener.LoadFilesCompletedEvent += OnLoadFilesCompleted;

            GherkinSettings            = gherkinSettings;
            GherkinSettings.TabPanels  = TabPanels;
            AboutViewModel             = aboutViewModel;
            CodePageListPopupViewModel = codePageListPopupViewModel;
            CodePageListPopupViewModel.CodePageChangedEvent += delegate { base.OnPropertyChanged(nameof(Codepage)); };

            GherkinSettings.ChangeFoldingTextColorOfAvalonEdit();
            EventAggregator <DeleteEditorTabRequestedArg> .Instance.Event     += OnDeleteEditorTab;
            EventAggregator <DeleteAllEditorTabsRequestedArg> .Instance.Event += OnDeleteAllEditorTabsRequested;
            EventAggregator <RenameDocumentRequestedArg> .Instance.Event      += OnRenameDocumentRequested;
            EventAggregator <SaveAsDocumentRequestedArg> .Instance.Event      += OnSaveAsDocumentRequested;
            EventAggregator <StatusChangedArg> .Instance.Event             += OnStatusChanged;
            EventAggregator <IndentationCompletedArg> .Instance.Event      += OnIndentationCompleted;
            EventAggregator <FailedToFindEditorControlArg> .Instance.Event += OnFailedToFindEditorControl;
            EventAggregator <HideScenarioIndexArg> .Instance.Event         += OnHideScenarioIndex;
            EventAggregator <FileSavedAsArg> .Instance.Event += OnFileSavedAs;
            EventAggregator <OpenNewGherkinEditorRequestedArg> .Instance.Event += OnOpenNewGherkinEditorRequested;
            EventAggregator <EditorLoadedArg> .Instance.Event            += OnEditorLoaded;
            EventAggregator <FileLoadedArg> .Instance.Event              += OnFileLoaded;
            EventAggregator <ShowViewerEditorRequestArg> .Instance.Event += OnShowViewerEditorRequested;
            EventAggregator <CustomImageClickedArg> .Instance.Event      += OnCustomImageClicked;
            EventAggregator <StartEditTableRequestArg> .Instance.Event   += OnStartEditTableRequested;

            // register it to GherkinEditerCommand
            GherkinEditerCommand.GherkinViewModel = this;
        }
        public static void TryOpenGreppedFile(MultiFileOpener multiFilesOpener, string grepLine)
        {
            var opener = new GreppedFileOpener();

            opener.OpenGreppedFile(multiFilesOpener, grepLine);
        }