예제 #1
0
        public FindResultForm(MainForm mainForm)
        {
            this.InitializeComponent();
            this.mMainForm = mainForm;

            this.mTreeView.NodeMouseDoubleClick += this.OnTreeViewNodeMouseDoubleClick;
        }
예제 #2
0
        public TextEditorForm(MainForm mainForm)
        {
            this.InitializeComponent();
            this.mMainForm = mainForm;

            // TODO: 設定画面
            this.mScintilla.StyleResetDefault();
            this.mScintilla.Styles[Style.Default].Font = "Consolas";
            this.mScintilla.Styles[Style.Default].Size = 18;
            this.mScintilla.StyleClearAll();

            this.mScintilla.Styles[HspLexer.StyleDefault].ForeColor = Color.Black;
            this.mScintilla.Styles[HspLexer.StyleFunction].ForeColor = Color.Blue;
            this.mScintilla.Styles[HspLexer.StylePreprocessor].ForeColor = Color.Blue;
            this.mScintilla.Styles[HspLexer.StyleType].ForeColor = Color.FromArgb(43, 145, 175);
            this.mScintilla.Styles[HspLexer.StyleString].ForeColor = Color.Brown;
            this.mScintilla.Styles[HspLexer.StyleStringLine].ForeColor = Color.Brown;
            this.mScintilla.Styles[HspLexer.StyleCharacter].ForeColor = Color.Brown;
            this.mScintilla.Styles[HspLexer.StyleMacro].ForeColor = Color.Purple;
            this.mScintilla.Styles[HspLexer.StyleComment].ForeColor = Color.Green;
            this.mScintilla.Styles[HspLexer.StyleCommentLine].ForeColor = Color.DarkGreen;
            this.mScintilla.Styles[HspLexer.StyleLabel].ForeColor = Color.Red;

            this.mScintilla.Lexer = Lexer.Container;

            this.mScintilla.Indicators[TextEditorForm.ScintillaIndicatorIndex].Style = IndicatorStyle.FullBox;
            this.mScintilla.Indicators[TextEditorForm.ScintillaIndicatorIndex].ForeColor = Color.DarkOrange;
            this.mScintilla.Indicators[TextEditorForm.ScintillaIndicatorIndex].Alpha = 100;

            this.ShowLineNumbers = true; // DEBUG
            this.mScintilla.WrapMode = WrapMode.Whitespace;
            this.mScintilla.ViewWhitespace = WhitespaceMode.VisibleAlways;
            this.mScintilla.WhitespaceSize = 2;
            this.mScintilla.SetWhitespaceForeColor(true, Color.Orange);

            // https://github.com/notepad-plus-plus/notepad-plus-plus/blob/50c7e228ff71379fb0177aebae36931a4631188d/PowerEditor/src/ScitillaComponent/ScintillaEditView.h
            const int SCI_GETVIEWWS = 2020;
            const int SCI_SETVIEWWS = 2021;
            const int SCWS_INVISIBLE = 0;
            const int SCWS_VISIBLEALWAYS = 1;
            const int SCWS_VISIBLEAFTERINDENT = 2;
            const int SCWS_VISIBLEONLYININDENT = 3;

            const int SCI_GETVIEWEOL = 2355;
            const int SCI_SETVIEWEOL = 2356;

            // 改行コードを表示
            this.mScintilla.DirectMessage(SCI_SETVIEWEOL, new IntPtr(1), IntPtr.Zero);
        }
예제 #3
0
        public FindDialog(MainForm mainForm, FindDialogType findDialogType)
        {
            // TODO: フォームが2つ以上生成されないようにする

            this.InitializeComponent();

            this.mMainForm = mainForm;
            this.mCurrentTextEditorForm = this.mMainForm.GetCurrentTextEditorForm();
            this.OnDockPanelActiveDocumentChanged(this, EventArgs.Empty);

            // タブの選択(デフォルトでは検索を選択)
            this.mTabControl.SelectedTab =
                findDialogType == FindDialogType.Find ? this.mTabPageFind :
                findDialogType == FindDialogType.Replace ? this.mTabPageReplace :
                this.mTabPageFind;

            this.OnTabControlSelectedIndexChanged(this, EventArgs.Empty);

            // 検索文字列
            this.mRecentFindTextList =
                Properties.Settings.Default.RecentFindTextList?.Cast<string>().ToList() ??
                new List<string>();
            this.mComboBoxFindText.Items.AddRange(this.mRecentFindTextList.ToArray<object>());

            // 置換文字列
            this.mRecentReplaceTextList =
                Properties.Settings.Default.RecentReplaceTextList?.Cast<string>().ToList() ??
                new List<string>();
            this.mComboBoxReplaceText.Items.AddRange(this.mRecentReplaceTextList.ToArray<object>());

            // 検索対象
            this.mComboBoxSearchScope.SelectedItem =
                this.mComboBoxSearchScope.Items.Cast<string>()
                    .FirstOrDefault(item => item == this.mSearchScopeDictionary[SearchScope.CurrentDocument]);

            // 検索オプション
            FindOptions findOptions = (FindOptions)Properties.Settings.Default.FindOptions;
            this.mCheckBoxWholeWord.Checked = findOptions.HasFlag(FindOptions.MatchWholeWordOnly);
            this.mCheckBoxMatchCase.Checked = findOptions.HasFlag(FindOptions.MatchCase);
            this.mCheckBoxWrapAround.Checked = findOptions.HasFlag(FindOptions.WrapAround);

            // 検索モード
            FindMode findMode = (FindMode)Properties.Settings.Default.FindMode;

            switch (findMode) {
                case FindMode.Normal:
                    this.mRadioButtonFindModeNormal.Checked = true;
                    break;
                case FindMode.EscapeSequence:
                    this.mRadioButtonFindModeEscapeSequence.Checked = true;
                    break;
                case FindMode.RegularExpression:
                    this.mRadioButtonFindModeRegularExpression.Checked = true;
                    break;
                default:
                    this.mRadioButtonFindModeNormal.Checked = true;
                    break;
            }

            // 検索方向
            FindDirection findDirection = (FindDirection)Properties.Settings.Default.FindDirection;
            switch (findDirection) {
                case FindDirection.Up:
                    this.mRadioButtonFindDirectionUp.Checked = true;
                    break;
                case FindDirection.Down:
                    this.mRadioButtonFindDirectionDown.Checked = true;
                    break;
                default:
                    this.mRadioButtonFindDirectionDown.Checked = true;
                    break;
            }

            // ウィンドウの透明化
            this.mCheckBoxTransparent.Checked = Properties.Settings.Default.FindDialogTransparent;
            this.OnCheckBoxTransparentCheckedChanged(this, EventArgs.Empty);

            FindDialogTransparentMode transparentMode =
                    (FindDialogTransparentMode)Properties.Settings.Default.FindDialogTransparentMode;

            switch (transparentMode) {
                case FindDialogTransparentMode.OnLosingFocus:
                    this.mRadioButtonTransparentOnLosingFocus.Checked = true;
                    break;
                case FindDialogTransparentMode.Always:
                    this.mRadioButtonTransparentAlways.Checked = true;
                    break;
                default:
                    this.mRadioButtonTransparentOnLosingFocus.Checked = true;
                    break;
            }

            this.mTrackBarTransparency.Value =
                Math.Min(100, Math.Max(5, Properties.Settings.Default.FindDialogOpacity));

            // イベント ハンドラー
            this.mMainForm.DockPanel.ActiveDocumentChanged += this.OnDockPanelActiveDocumentChanged;

            this.Activated += this.OnFormActivated;
            this.Deactivate += this.OnFormDeactivate;

            this.mTabControl.SelectedIndexChanged += this.OnTabControlSelectedIndexChanged;

            this.mComboBoxFindText.TextChanged += this.OnComboBoxFindTextChanged;

            this.mComboBoxSearchScope.DropDown += this.OnComboBoxSearchScopeDropDown;

            this.mButtonFindNext.Click += this.OnButtonFindNextClick;
            this.mButtonCount.Click += this.OnButtonCountClick;
            this.mButtonFindAll.Click += this.OnButtonFindAllClick;
            this.mButtonFindAllDocuments.Click += this.OnButtonFindAllDocumentsClick;
            this.mButtonClose.Click += this.OnButtonCloseClick;

            this.mButtonReplace.Click += this.OnButtonReplaceClick;
            this.mButtonReplaceAll.Click += this.OnButtonReplaceAllClick;
            this.mButtonReplaceAllDocuments.Click += this.OnButtonReplaceAllDocumentsClick;

            // 検索オプション
            this.mCheckBoxWholeWord.CheckedChanged += this.OnCheckBoxWholeWordCheckedChanged;
            this.mCheckBoxMatchCase.CheckedChanged += this.OnCheckBoxMatchCaseCheckedChanged;
            this.mCheckBoxWrapAround.CheckedChanged += this.OnCheckBoxWrapAroundCheckedChanged;

            // 検索モード
            this.mRadioButtonFindModeNormal.CheckedChanged += this.OnRadioButtonFindModeNormalCheckedChanged;
            this.mRadioButtonFindModeEscapeSequence.CheckedChanged += this.OnRadioButtonFindModeEscapeSequenceCheckedChanged;
            this.mRadioButtonFindModeRegularExpression.CheckedChanged += this.OnRadioButtonFindModeRegularExpressionCheckedChanged;

            // 検索方向
            this.mRadioButtonFindDirectionUp.CheckedChanged += this.OnRadioButtonFindDirectionUpCheckedChanged;
            this.mRadioButtonFindDirectionDown.CheckedChanged += this.OnRadioButtonFindDirectionDownCheckedChanged;

            // ウィンドウの透明化
            this.mCheckBoxTransparent.CheckedChanged += this.OnCheckBoxTransparentCheckedChanged;
            this.mRadioButtonTransparentOnLosingFocus.CheckedChanged += this.OnRadioButtonTransparentOnLosingFocusCheckedChanged;
            this.mRadioButtonTransparentAlways.CheckedChanged += this.OnRadioButtonTransparentAlwaysCheckedChanged;
            this.mTrackBarTransparency.ValueChanged += this.OnTrackBarTransparencyValueChanged;
        }