Ejemplo n.º 1
0
        public void CreateMemo()
        {
            if (_tree.SelectedNode == null)
            {
                return;
            }
            var memoInfo = default(MemoInfo);

            if (IsUntaggedSelected)
            {
                memoInfo = _facade.CreateMemo();
            }
            else
            {
                var selected = SelectedTag;
                if (selected != null)
                {
                    memoInfo = _facade.CreateMemo();
                    if (memoInfo != null)
                    {
                        var memo = _facade.Container.Find <Memo>(memoInfo.MemoId);
                        selected.AddMemo(memo);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public string CreateMemo(string title)
        {
            var ret = _facade.MainForm.Invoke(
                (Func <string>)(() => {
                var info = _facade.CreateMemo(title);
                return(info.MemoId);
            })
                );

            return(ret as string);
        }
Ejemplo n.º 3
0
        private void CreateMemoForMemoFinder()
        {
            _memoListBox.BeginUpdate();

            var memoInfo = _app.CreateMemo();

            //var memo = _app.Container.Find<Memo>(memoInfo.MemoId);
            //if (_memoFinderView.IsTagSelected) {
            //    var tag = _memoFinderView.SelectedTag;
            //    if (tag != null) {
            //        tag.AddMemo(memo);
            //    }
            //}

            _memoListBox.EndUpdate();
        }
Ejemplo n.º 4
0
        public MemoInfo CreateMemo()
        {
            if (_tree.SelectedNode == null)
            {
                return(null);
            }
            var selected = _tree.SelectedNode.Tag as MemoFolder;

            if (selected == null)
            {
                return(null);
            }
            var memoInfo = _facade.CreateMemo();

            if (memoInfo != null)
            {
                var memo = _facade.Container.Find <Memo>(memoInfo.MemoId);
                memo.AddContainedFolder(selected);
            }
            return(memoInfo);
        }
        private void InitMenuItems()
        {
            _cutInNewMemo        = new ToolStripMenuItem("切り出す(&C)");
            _cutInNewMemo.Click += (sender, e) => {
                using (var form = new CreateMemoForm()) {
                    form.Font      = _app.Theme.CaptionFont;
                    form.MemoTitle = "新しいノート";
                    if (form.ShowDialog() == DialogResult.OK)
                    {
                        var copied = Owner.Referer.Target.CopyBlocksAndInlines(Owner.Referer.Selection.Range);

                        _app.ShowMainForm();
                        _app.ActivateMainForm();
                        var info = _app.CreateMemo(form.MemoTitle);

                        if (form.OriginalModification == CreateMemoForm.OriginalModificationKind.Remove)
                        {
                            Owner.RemoveForward();
                        }
                        else if (form.OriginalModification == CreateMemoForm.OriginalModificationKind.ReplaceWithLink)
                        {
                            Owner.RemoveForward();
                            Owner.InsertLink(info.Title, new Link(UriUtil.GetUri(info)));
                            if (copied.Last() is BlockBreak)
                            {
                                Owner.InsertBlockBreak();
                            }
                        }

                        var pageContent = _app.MainForm.FindPageContent(info);
                        var canvas      = pageContent.EditorCanvas;
                        var caret       = canvas.Caret;
                        var loc         = CaretUtil.GetExpectedMemoTextPosition(caret.Position);
                        MemoEditorHelper.AddBlocksAndInlines(canvas.RootEditor.Children.First(), loc, copied, false);
                    }
                }
            };


            _splitThisParagraph        = new ToolStripMenuItem("この行で分割(&S)");
            _splitThisParagraph.Click += (sender, e) => {
                using (_editor.Site.CommandExecutor.BeginChain()) {
                    var referer = Owner.Referer;
                    var stext   = referer.Target;

                    var lineIndex = stext.GetLineIndex(referer.CaretIndex);
                    var lineStart = stext.GetLineStartCharIndex(lineIndex);
                    var flows     = stext.CopyBlocksAndInlines(lineStart);

                    var rect = Rectangle.Empty;
                    rect = _focus.Figure.GetCharRect(lineStart);

                    Owner.Selection.Range = Range.FromStartAndEnd(lineStart - 1, stext.Length - 2);
                    Owner.RemoveForward();
                    _editor.RequestFocus(FocusKind.Commit, null);

                    var loc        = new Point(_editor.Figure.Left, rect.Bottom + 16);
                    var memoEditor = _editor.Parent;
                    var created    = MemoEditorHelper.AddBlocksAndInlines(memoEditor, loc, flows, true);
                    created.RequestFocusCommit(true);
                }
            };

            _splitParagraphs        = new ToolStripMenuItem("段落ごとに分割(&P)");
            _splitParagraphs.Click += (sender, e) => {
                using (_editor.Figure.Root.DirtManager.BeginDirty())
                    using (_editor.Site.CommandExecutor.BeginChain()) {
                        var referer    = Owner.Referer;
                        var stext      = referer.Target;
                        var memoEditor = _editor.Parent;

                        var created  = default(IEditor);
                        var createds = new List <IEditor>();
                        var cTop     = _editor.Figure.Top;
                        foreach (var block in stext.Blocks)
                        {
                            var flows = new Flow[] { block.CloneDeeply() as Block, };
                            var loc   = new Point(_editor.Figure.Left, cTop);
                            created = MemoEditorHelper.AddBlocksAndInlines(memoEditor, loc, flows, true);
                            createds.Add(created);
                            cTop += created.Figure.Height + 16;
                        }
                        created.RequestFocusCommit(true);

                        _editor.RequestRemove();

                        var cmd = new SelectMultiCommand(createds, SelectKind.True, true);
                        cmd.Execute();
                    }
            };


            _openLink        = new ToolStripMenuItem("リンクを開く(&O)");
            _openLink.Click += (sender, e) => {
                var run = Owner.GetInlineAtCaretIndex() as Run;
                if (run != null && run.HasLink)
                {
                    LinkUtil.GoLink(run.Link);
                }
            };

            _removeLink        = new ToolStripMenuItem("リンクを削除(&R)");
            _removeLink.Click += (sender, e) => {
                Owner.UnsetLink();
            };

            _setLink        = new ToolStripMenuItem("リンクを設定(&L)");
            _setLink.Click += (sender, e) => {
                if (Owner.Selection.IsEmpty)
                {
                    var run = Owner.GetInlineAtCaretIndex() as Run;
                    if (run != null)
                    {
                        var oldUri = default(string);
                        if (run != null && run.HasLink)
                        {
                            oldUri = run.Link.Uri;
                        }

                        var oldText = run.Text;
                        var dialog  = new LinkSelectForm();
                        if (dialog.ShowDialog(_app.MainForm, oldUri, run.Text) == DialogResult.OK)
                        {
                            var uri     = dialog.Uri;
                            var newText = dialog.TitleText;
                            if (newText != oldText)
                            {
                                Owner.SetRunText(run, newText);
                            }
                            if (uri != oldUri)
                            {
                                Owner.SetLink(uri, null);
                            }
                        }
                    }
                }
                else
                {
                    var range   = Owner.Selection.Range;
                    var oldText = Owner.Referer.Target.Text.Substring(range.Offset, range.Length);

                    var dialog = new LinkSelectForm();
                    dialog.TitleTextTextBoxEnabled = false;
                    if (dialog.ShowDialog(_app.MainForm, null, oldText) == DialogResult.OK)
                    {
                        Owner.SetLink(dialog.Uri, null);
                    }
                }
            };


            _addComment        = new ToolStripMenuItem("コメントを追加(&C)");
            _addComment.Click += (sender, e) => {
                MemoEditorHelper.AddCommentForMemoText(Owner);
            };
        }
Ejemplo n.º 6
0
 // --- generated handler ---
 private void _createMemoLinkLabel_LinkClicked(object sender, EventArgs e)
 {
     _facade.CreateMemo();
 }
Ejemplo n.º 7
0
 private void CreateMemo()
 {
     _app.ShowMainForm();
     _app.ActivateMainForm();
     _app.CreateMemo();
 }