Пример #1
0
        public void RemoveSelectedMemos()
        {
            if (_memoListBox.SelectedItems.Count == 0)
            {
                return;
            }

            var selecteds = new MemoInfo[_memoListBox.SelectedItems.Count];

            if (selecteds.Length > 0)
            {
                for (int i = 0, len = selecteds.Length; i < len; ++i)
                {
                    selecteds[i] = (MemoInfo)_memoListBox.SelectedItems[i];
                }
            }

            if (!MessageUtil.ConfirmMemoRemoval(selecteds))
            {
                return;
            }

            _memoListBox.BeginUpdate();
            foreach (var item in selecteds)
            {
                var info = (MemoInfo)item;
                _app.RemoveMemo(info);
            }
            _memoListBox.EndUpdate();
        }
Пример #2
0
        private void _deleteMemoToolStripButton_Click(object sender, EventArgs e)
        {
            var info = _targetForm.PageContent.MemoInfo;

            if (!MessageUtil.ConfirmMemoRemoval(new [] { info }))
            {
                return;
            }
            var app = MemopadApplication.Instance;

            app.RemoveMemo(info);
        }
Пример #3
0
        private void _removeMemoTabToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (_currentEditorCanvas == null)
            {
                return;
            }

            var pageContent = (PageContent)_tabControl.SelectedTab.Tag;
            var memoInfo    = pageContent.MemoInfo;

            if (!MessageUtil.ConfirmMemoRemoval(new[] { memoInfo }))
            {
                return;
            }
            _app.RemoveMemo(memoInfo);
        }
Пример #4
0
        private void HandleMemoListBoxDragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(typeof(MemoInfo[])))
            {
                if (_targetKind == MemoListTargetKind.Folder)
                {
                    if (DragDropUtil.IsCopy(e))
                    {
                        var targetFolder = _workspaceView.WorkspaceTree.SelectedFolder;
                        if (targetFolder != null)
                        {
                            var memoInfos = (MemoInfo[])e.Data.GetData(typeof(MemoInfo[]));

                            var existsNotContained = false;
                            foreach (var memoInfo in memoInfos)
                            {
                                var memo = _app.Container.Find <Memo>(memoInfo.MemoId);
                                if (!targetFolder.ContainingMemos.Contains(memo))
                                {
                                    existsNotContained = true;
                                    break;
                                }
                            }
                            if (existsNotContained)
                            {
                                foreach (var memoInfo in memoInfos)
                                {
                                    var memo = _app.Container.Find <Memo>(memoInfo.MemoId);
                                    if (!targetFolder.ContainingMemos.Contains(memo))
                                    {
                                        targetFolder.AddContainingMemo(memo);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (_targetKind == MemoListTargetKind.Tag)
                {
                    if (DragDropUtil.IsCopyAllowed(e))
                    {
                        var targetTag = _workspaceView.WorkspaceTree.SelectedTag;
                        if (targetTag != null)
                        {
                            var memoInfos = (MemoInfo[])e.Data.GetData(typeof(MemoInfo[]));

                            var existsNotContained = false;
                            foreach (var memoInfo in memoInfos)
                            {
                                var memo = _app.Container.Find <Memo>(memoInfo.MemoId);
                                if (!targetTag.Memos.Contains(memo))
                                {
                                    existsNotContained = true;
                                    break;
                                }
                            }
                            if (existsNotContained)
                            {
                                foreach (var memoInfo in memoInfos)
                                {
                                    var memo = _app.Container.Find <Memo>(memoInfo.MemoId);
                                    if (!targetTag.Memos.Contains(memo))
                                    {
                                        targetTag.AddMemo(memo);
                                    }
                                }
                            }
                        }
                    }
                }
                else if (_targetKind == MemoListTargetKind.TrashBox)
                {
                    if (DragDropUtil.IsMove(e))
                    {
                        var memoInfos = (MemoInfo[])e.Data.GetData(typeof(MemoInfo[]));
                        if (MessageUtil.ConfirmMemoRemoval(memoInfos))
                        {
                            foreach (var info in memoInfos)
                            {
                                _app.RemoveMemo(info);
                            }
                        }
                    }
                }
            }
        }