Exemple #1
0
        protected override BaseAction GetOperationAciton()
        {
            var action = new PuckerAction(this.PParser);

            action.pY = this.pY;
            return(action);
        }
Exemple #2
0
        /// <summary>
        /// 移除折叠剩余部分,同时将原来的折叠行的ID赋予新行。
        /// </summary>
        /// <param name="upLNPID"></param>
        /// <param name="ls"></param>
        protected void RemovePuckerLeavingOnly(Tuple <LineNodeProperty, int, bool> upLNPID, LineString ls)
        {
            if (upLNPID == null)
            {
                return;
            }

            var upLNP = upLNPID.Item1;

            if (upLNP != null && upLNP.IsFurl && ls.PLNProperty != null)
            {
                ls.PLNProperty.IsFurl = true;
                ls.ID = upLNPID.Item2;
                this.PParser.PPucker.RmovePuckerLeavingOnly(ls);
                return;
            }

            //#region 展开

            if (upLNPID.Item1 != null && upLNPID.Item1.IsFurl && !this.PParser.GetLineString.IsFurl())
            {
                this.PParser.GetLineString.ID = upLNPID.Item2;
                this.PParser.GetLineString.IsCommentPucker = true;
                var puckerAction = new PuckerAction(this.PParser);
                puckerAction.SetPuckerIndexY(this.PParser.PCursor.CousorPointForWord.Y);
                puckerAction.ClickPucker();
                this.PParser.GetLineString.IsCommentPucker = false;
                this.PParser.AddAction(puckerAction);
                return;
            }

            //#endregion

            //if (upLNPID.Item3) {
            //    if (ls.IsStartRange()) {
            //        ls.ID = upLNPID.Item2;
            //        this.PParser.PPucker.RmovePuckerLeavingOnly(ls);
            //        ls.PLNProperty.IsFurl = true;
            //    }
            //}
        }
Exemple #3
0
        /// <summary>
        /// 粘贴
        /// </summary>
        public void Paste()
        {
            string value = GetPasteText();

            if (string.IsNullOrEmpty(value))
            {
                return;
            }
            this.PParser.PIEdit.SetChangeText();
            int startY = this.PParser.PCursor.CousorPointForWord.Y;

            this.PStartLineY = startY;
            if (this.PParser.GetSelectPartPoint != null)
            {
                //var pasteAction = this.DeletePartBefore();
                this.PActionOperation = this.GetCutPasteAction();
                var pasteAction = this.PActionOperation as CutPasteAction;
                var selectBgs   = this.GetSelectBg();
                var delStr      = this.DeleteSelectPart(out this.PDeleteLineCount, false);

                //pasteAction.PPasteText = delStr;
                pasteAction.PDeleteString = delStr;
                pasteAction.PDeletePoints = this.GetSelectBg();
                this.SetDrawBgClearSelectAndPucker(selectBgs);
            }
            #region 设置开始坐标
            int startBgY       = this.PParser.PCursor.CousorPointForWord.Y;
            int startWordIndex = this.PParser.PCursor.CousorPointForWord.X;
            if (!this.IsPaste)
            {
                this.SetSelectBg(new CPoint(
                                     this.PParser.PCursor.CousorPointForEdit.X,
                                     this.PParser.PCursor.CousorPointForEdit.Y,
                                     this.PParser.GetLineString.Width,
                                     this.PParser.PCursor.CousorPointForWord.X
                                     ), null);
            }
            #endregion
            #region 粘贴内容
            var lnpID         = this.PParser.GetLineString.GetLnpAndId();
            var leavingString = this.GetLineStringEffectualText().Substring(this.PParser.PCursor.CousorPointForWord.X + 1);
            var array         = value.Split(CharCommand.Char_Newline);
            if (array.Length == 1)
            {
                var line = array[0].TrimEnd(CharCommand.Char_Enter);
                this.PParser.GetLineString.Text = this.PParser.GetLineString.Text.Substring(0, this.PParser.PCursor.CousorPointForWord.X + 1) + line + leavingString;
                //this.SetResetLineString(this.PParser.GetLineString);
                this.SetResetLineString(this.PParser.GetLineString);
                this.RemovePuckerLeavingOnly(lnpID, this.PParser.GetLineString);
                this.PParser.PCursor.CousorPointForWord.X += line.Length;
                int x = this.PParser.GetLineStringIndexWidth(this.PParser.GetLineString, this.PParser.PCursor.CousorPointForWord.X);
                this.PParser.PCursor.SetPosition(x + this.PParser.GetLeftSpace, -1, this.PParser.GetLeftSpace);
            }
            else
            {
                this.PParser.PPucker.InitSelectPuckerStartEndY();
                #region 展开
                if (this.PParser.GetLineString.IsFurl())
                {
                    var puckerAction = new PuckerAction(this.PParser);
                    puckerAction.SetPuckerIndexY(this.PParser.PCursor.CousorPointForWord.Y);
                    puckerAction.ClickPucker();
                    this.PParser.AddAction(puckerAction);
                }
                #endregion
                for (var i = 0; i < array.Length; i++)
                {
                    var line = array[i].TrimEnd(CharCommand.Char_Enter);
                    if (i == 0)
                    {
                        this.PParser.GetLineString.Text = this.PParser.GetLineString.Text.Substring(0, Math.Min(this.PParser.GetLineString.Text.Length, this.PParser.PCursor.CousorPointForWord.X + 1)) + line;
                        this.SetResetLineString(this.PParser.GetLineString);
                        continue;
                    }
                    var ls = this.PParser.PCharFontStyle.GetLineString();
                    if (i == array.Length - 1)
                    {
                        line += leavingString;
                        this.SetResetLineString(ls, line);
                        this.PParser.PCursor.CousorPointForWord.X = ls.Text.Length - leavingString.Length - 1;
                        this.RemovePuckerLeavingOnly(lnpID, ls);
                    }
                    else
                    {
                        this.SetResetLineString(ls, line);
                    }
                    this.PParser.PLineString.Insert(this.PParser.PCursor.CousorPointForWord.Y + i, ls);
                }
                var lastIndex = this.PParser.PCursor.CousorPointForWord.Y + array.Length - 1;
                this.PParser.PCursor.CousorPointForWord.Y += array.Length - 1;
                int x = this.PParser.GetLineStringIndexWidth(this.PParser.PLineString[lastIndex], this.PParser.PCursor.CousorPointForWord.X);
                this.PParser.PCursor.SetPosition(x + this.PParser.GetLeftSpace, this.PParser.PCursor.CousorPointForEdit.Y + (array.Length - 1) * FontContainer.FontHeight, this.PParser.GetLeftSpace);
                startY += array.Length - 1;
            }
            #endregion
            #region 设置结束坐标
            var startLs = this.PParser.PLineString[startBgY];
            if (!string.IsNullOrEmpty(startLs.Text) && !this.IsPaste)
            {
                this.SetSelectGgLineWidth(this.PParser.GetLineStringIndexWidth(startLs, startLs.Length));
            }
            if (!this.IsPaste)
            {
                this.SetSelectBg(null, new CPoint(
                                     this.PParser.PCursor.CousorPointForEdit.X,
                                     this.PParser.PCursor.CousorPointForEdit.Y,
                                     this.PParser.GetLineString.Width,
                                     this.PParser.PCursor.CousorPointForWord.X
                                     ));
            }
            #endregion

            this.ChangeIncrementLine(array.Length - 1 - this.GetDeleteLineCount, startY);
        }