コード例 #1
0
        private void CutOrDelete(IDataObject dataObject, out bool isDeleted)
        {
            isDeleted = false;

            string Content = NodeTreeHelper.GetString(StateView.State.Node, PropertyName);

            Debug.Assert(Content != null);
            Debug.Assert(Start <= End);
            Debug.Assert(End <= Content.Length);

            if (Start < End)
            {
                if (dataObject != null)
                {
                    dataObject.SetData(typeof(string), Content.Substring(Start, End - Start));
                }

                Content = Content.Substring(0, Start) + Content.Substring(End);

                IFocusController Controller = StateView.ControllerView.Controller;
                int OldCaretPosition        = StateView.ControllerView.CaretPosition;
                int NewCaretPosition        = Start;
                Controller.ChangeTextAndCaretPosition(StateView.State.ParentIndex, PropertyName, Content, OldCaretPosition, NewCaretPosition, true);

                StateView.ControllerView.ClearSelection();
                isDeleted = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Replaces the selection with the content of the clipboard.
        /// </summary>
        public override void Paste(out bool isChanged)
        {
            isChanged = false;

            if (ClipboardHelper.TryReadText(out string Text) && Text.Length > 0)
            {
                string Content = NodeTreeHelper.GetString(StateView.State.Node, PropertyName);
                Debug.Assert(Content != null);
                Debug.Assert(Start <= End);
                Debug.Assert(End <= Content.Length);

                Content = Content.Substring(0, Start) + Text + Content.Substring(End);

                IFocusController Controller = StateView.ControllerView.Controller;
                int OldCaretPosition        = StateView.ControllerView.CaretPosition;
                int NewCaretPosition        = Start + Text.Length;
                Controller.ChangeTextAndCaretPosition(StateView.State.ParentIndex, PropertyName, Content, OldCaretPosition, NewCaretPosition, false);

                StateView.ControllerView.ClearSelection();
                isChanged = true;
            }
        }