Exemplo n.º 1
0
        // ========================================
        // method
        // ========================================
        public override void ConfigureEditor(IEditor editor)
        {
            var facade = MemopadApplication.Instance;

            var editorHandle = new MemoShapeEditorHandle();

            editorHandle.KeyMap = facade.KeySchema.MemoContentEditorKeyMap;
            editor.InstallEditorHandle(editorHandle);

            editor.InstallHandle(new ResizeHandle(Directions.Left)
            {
                Cursor = Cursors.SizeWE
            });
            editor.InstallHandle(new ResizeHandle(Directions.Up)
            {
                Cursor = Cursors.SizeNS
            });
            editor.InstallHandle(new ResizeHandle(Directions.Right)
            {
                Cursor = Cursors.SizeWE
            });
            editor.InstallHandle(new ResizeHandle(Directions.Down)
            {
                Cursor = Cursors.SizeNS
            });
            editor.InstallHandle(new ResizeHandle(Directions.UpLeft)
            {
                Cursor = Cursors.SizeNWSE
            });
            editor.InstallHandle(new ResizeHandle(Directions.UpRight)
            {
                Cursor = Cursors.SizeNESW
            });
            editor.InstallHandle(new ResizeHandle(Directions.DownLeft)
            {
                Cursor = Cursors.SizeNESW
            });
            editor.InstallHandle(new ResizeHandle(Directions.DownRight)
            {
                Cursor = Cursors.SizeNWSE
            });

            editor.InstallRole(new SelectRole());
            editor.InstallRole(new FocusRole(InitFocus, CommitFocus));
            editor.InstallRole(new ResizeRole());
            editor.InstallRole(new RemoveRole());
            editor.InstallRole(new CopyRole());
            editor.InstallRole(new ReorderRole());
            editor.InstallRole(new SetStyledTextFontRole(() => Model.StyledText, FontModificationKinds.All));
            editor.InstallRole(new SetStyledTextColorRole(() => Model.StyledText));
            editor.InstallRole(new SetStyledTextAlignmentRole(() => Model.StyledText, AlignmentModificationKinds.All));

            var editorFocus = new MemoStyledTextFocus(Host, facade.Settings.KeyScheme == KeySchemeKind.Emacs, false);

            editorFocus.LinkClicked += (sender, e) => {
                LinkUtil.GoLink(e.Link);
            };

            editor.InstallFocus(editorFocus);
        }
Exemplo n.º 2
0
        public override void ConfigureEditor(IEditor editor)
        {
            var facade = MemopadApplication.Instance;

            var editorHandle = new MemoTableCellEditorHandle();

            editorHandle.KeyMap = facade.KeySchema.MemoTableCellEditorKeyMap;
            editor.InstallEditorHandle(editorHandle);

            editor.InstallHandle(new SelectionIndicatingHandle());

            editor.InstallRole(new SelectRole());
            editor.InstallRole(new FocusRole(InitFocus, CommitFocus));
            editor.InstallRole(new SetStyledTextFontRole(() => Model.StyledText, FontModificationKinds.All));
            editor.InstallRole(new SetStyledTextColorRole(() => Model.StyledText));
            editor.InstallRole(new SetStyledTextAlignmentRole(() => Model.StyledText, AlignmentModificationKinds.All));

            var editorFocus = new MemoStyledTextFocus(Host, facade.Settings.KeyScheme == KeySchemeKind.Emacs, false);

            editorFocus.IsConsiderHostBounds = true;
            editorFocus.LinkClicked         += (sender, e) => {
                LinkUtil.GoLink(e.Link);
            };
            editor.InstallFocus(editorFocus);

            editor.SelectionChanged += (sender, e) => {
                if (editor.IsSelected)
                {
                    var canvas = Host.Site.EditorCanvas;
                    var rect   = Figure.GetCharRect(0);
                    canvas.Caret.Position = rect.Location;

                    var loc = canvas.TranslateToControlPoint(rect.Location);
                    canvas.SetImePosition(loc);

                    canvas.EnsureVisible(editor);
                }
            };
        }
Exemplo n.º 3
0
        // ------------------------------
        // private
        // ------------------------------
        private void InitEditorFocus(IEditor editor)
        {
            var app         = MemopadApplication.Instance;
            var editorFocus = new MemoStyledTextFocus(editor, app.Settings.KeyScheme == KeySchemeKind.Emacs, true);

            editorFocus.IsCurrentLineBackgroundEnable = true;
            editorFocus.IsConsiderImeWindowSize       = true;
            editorFocus.IsConsiderHostBounds          = true;
            editorFocus.Figure.Padding    = DefaultPadding;
            editorFocus.Figure.DragTarget = CreateFocusFigureDragTarget();
            editorFocus.Figure.DragSource = CreateFocusFigureDragSource();

            /// キー入力時にテキストがemptyなら削除
            editorFocus.ShortcutKeyProcess += (sender, e) => {
                RemoveIfEmpty(editorFocus, e.KeyData);
            };
            editorFocus.KeyDown += (sender, e) => {
                RemoveIfEmpty(editorFocus, e.KeyData);
            };
            //editorFocus.KeyDown += (sender, e) => {
            //    var mtext = Host.Model as MemoText;
            //    if (mtext.IsSticky) {
            //        /// stickyなら何もしない
            //        return;
            //    }

            //    var editorCanvas = Host.Site.EditorCanvas;
            //    if (
            //        editorFocus.StyledText.IsEmpty &&
            //        e.KeyData != Keys.ProcessKey &&
            //        editorCanvas.GetImeString().Length == 0
            //    ) {
            //        var parent = Host.Parent;
            //        Host.RequestFocus(FocusKind.Rollback, null);
            //        Host.RequestRemove();
            //        parent.RequestSelect(SelectKind.True, true);
            //    }
            //};
            editorFocus.LinkClicked += (sender, e) => {
                LinkUtil.GoLink(e.Link);
            };

            editor.InstallFocus(editorFocus);

            /// コミット時にStyledTextがemptyなら削除
            editor.FocusChanged += (sender, e) => {
                var mtext = Host.Model as MemoText;
                if (mtext.IsSticky)
                {
                    /// stickyなら何もしない
                    return;
                }

                if (!editor.IsFocused)
                {
                    var styledText = Model.StyledText;
                    if (styledText.IsEmpty)
                    {
                        var parent = editor.Parent;
                        editor.RequestRemove();
                        parent.RequestSelect(SelectKind.True, true);
                    }
                }
            };
        }