コード例 #1
0
        private void RenameThumbnail(string oldName, LabeledThumbnail labeledThumbnail)
        {
            if (oldName == labeledThumbnail.NameLable) return;

            var newPath = labeledThumbnail.ImagePath.Replace(@"\" + oldName, @"\" + labeledThumbnail.NameLable);

            File.Move(labeledThumbnail.ImagePath, newPath);
            labeledThumbnail.ImagePath = newPath;

            Globals.ThisAddIn.ShapePresentation.RenameShape(oldName, labeledThumbnail.NameLable);

            Globals.ThisAddIn.SyncShapeRename(oldName, labeledThumbnail.NameLable, CurrentCategory);
        }
コード例 #2
0
        private void RemoveThumbnail(LabeledThumbnail thumbnail, bool removeSelection = true)
        {
            if (removeSelection &&
                _selectedThumbnail.Contains(thumbnail))
            {
                _selectedThumbnail.Remove(thumbnail);
            }

            myShapeFlowLayout.Controls.Remove(thumbnail);

            if (myShapeFlowLayout.Controls.Count == 0)
            {
                ShowNoShapeMessage();
            }
        }
コード例 #3
0
        private void MultiSelectClickHandler(LabeledThumbnail clickedThumbnail)
        {
            if (MouseButtons != MouseButtons.Left &&
                MouseButtons != MouseButtons.Right) return;

            // for right click, if selection > 1, the context menu should appear with selection
            // remained, else we should change the focus. Specially, when selection > 1, some of
            // the options in the context menu serves for the clicked item, such as rename.
            if (MouseButtons == MouseButtons.Right)
            {
                if (_selectedThumbnail.Count > 1 &&
                    _selectedThumbnail.Contains(clickedThumbnail))
                {
                    _selectedThumbnail.Remove(clickedThumbnail);
                    _selectedThumbnail.Insert(0, clickedThumbnail);

                    return;
                }
            }

            // if Ctrl key is not holding, i.e. not doing multi-selecting, all highlighed
            // thumbnail should be dehighlighted
            if (!ModifierKeys.HasFlag(Keys.Control))
            {
                foreach (var thumbnail in _selectedThumbnail)
                {
                    thumbnail.DeHighlight();
                }

                _selectedThumbnail.Clear();
            }

            if (!_selectedThumbnail.Contains(clickedThumbnail))
            {
                // highlight the thumbnail and add the clicked thumbnail to the collection
                clickedThumbnail.Highlight();

                _selectedThumbnail.Insert(0, clickedThumbnail);
                FocusSelected();
            }
            else
            {
                // turn off the highlighting if the clicked thumbnail is currently highlighted
                if (ModifierKeys.HasFlag(Keys.Control))
                {
                    clickedThumbnail.DeHighlight();

                    _clickOnSelected = false;
                    _selectedThumbnail.Remove(clickedThumbnail);
                }
            }
        }
コード例 #4
0
        private void FirstClickOnThumbnail(LabeledThumbnail clickedThumbnail)
        {
            if (_selectedThumbnail == null) return;

            if (_selectedThumbnail.Count != 0)
            {
                // this flag doesn't apply for multi selection, thus turn off
                _clickOnSelected = false;

                // common part, end editing
                if (_selectedThumbnail[0].State == LabeledThumbnail.Status.Editing)
                {
                    _selectedThumbnail[0].FinishNameEdit();
                }
                else
                if (_selectedThumbnail[0] == clickedThumbnail)
                {
                    _clickOnSelected = true;
                }

                MultiSelectClickHandler(clickedThumbnail);
            }
            else
            {
                clickedThumbnail.Highlight();

                _selectedThumbnail.Insert(0, clickedThumbnail);
                FocusSelected();
            }
        }
コード例 #5
0
        public void AddCustomShape(string shapeName, string shapePath, bool immediateEditing)
        {
            DehighlightSelected();

            var labeledThumbnail = new LabeledThumbnail(shapePath, shapeName) { ContextMenuStrip = shapeContextMenuStrip };

            labeledThumbnail.Click += LabeledThumbnailClick;
            labeledThumbnail.DoubleClick += LabeledThumbnailDoubleClick;
            labeledThumbnail.NameEditFinish += NameEditFinishHandler;

            myShapeFlowLayout.Controls.Add(labeledThumbnail);

            if (myShapeFlowLayout.Controls.Contains(_noShapePanel))
            {
                myShapeFlowLayout.Controls.Remove(_noShapePanel);
            }

            myShapeFlowLayout.ScrollControlIntoView(labeledThumbnail);

            _selectedThumbnail.Insert(0, labeledThumbnail);

            if (immediateEditing)
            {
                labeledThumbnail.StartNameEdit();
            }
            else
            {
                // the shape must be sorted immediately since the name has been
                // setteled
                ReorderThumbnail(labeledThumbnail);
            }
        }
コード例 #6
0
        private void ReorderThumbnail(LabeledThumbnail labeledThumbnail)
        {
            var index = FindLabeledThumbnailIndex(labeledThumbnail.NameLable);

            // if the current control is the only control or something goes wrong, don't need
            // to reorder
            if (index == -1 ||
                index >= myShapeFlowLayout.Controls.Count)
            {
                return;
            }

            myShapeFlowLayout.Controls.SetChildIndex(labeledThumbnail, index);
        }