Esempio n. 1
0
        public override void Execute()
        {
            base.Execute();

            var firs      = this.PParser.PLineString.First();
            var firsWidth = CharCommand.GetLineStringWidth(firs, this.PParser.PIEdit.GetGraphics, this.PParser.PLanguageMode.TabSpaceCount);

            this.PParser.SetBgStartPoint(new CPoint(this.PParser.GetLeftSpace, 0, firsWidth, -1));
            var last      = this.PParser.PLineString.Last();
            var lastWidth = CharCommand.GetLineStringWidth(last, this.PParser.PIEdit.GetGraphics, this.PParser.PLanguageMode.TabSpaceCount);

            this.PParser.SetBgEndPoint(new CPoint(
                                           this.PParser.GetLeftSpace + lastWidth,
                                           (this.PParser.PLineString.Count - 1) * FontContainer.FontHeight,
                                           lastWidth,
                                           last.Length - 1
                                           ));


            this.PParser.PCursor.CousorPointForWord.X = last.Length;
            this.PParser.PCursor.CousorPointForWord.Y = this.PParser.PLineString.Count - 1;
            this.PParser.PCursor.SetPosition(this.PParser.GetLeftSpace, (this.PParser.PLineString.Count - 1) * FontContainer.FontHeight, this.PParser.GetLeftSpace);
            this.PParser.PCursor.SetPosition();
            this.PParser.PIEdit.SetVerticalScrollValue();
            this.PParser.PIEdit.Invalidate();
        }
Esempio n. 2
0
        /// <summary>
        /// 添加字符串
        /// </summary>
        /// <param name="c"></param>
        public void AddChar(char c)
        {
            //this.SetSurosrPointLocal();
            this.PInsertChar = c;

            if (this.PParser.GetSelectPartPoint != null)
            {
                this.isDelectString = true;
                base.Execute();

                #region 记忆删除字符
                var selectBgs = this.GetSelectBg();
                this.pDeleteString = this.DeleteSelectPart(out this.PDeleteLineCount, false);
                this.SetDrawBgClearSelectAndPucker(selectBgs);
                this.ChangeIncrementLine(this.GetDeleteLineCount * -1);
                #endregion
            }
            #region 插入单个字符串
            if (this.PActionOperation == null)
            {
                base.Execute();
            }
            this.SetSurosrPoint();
            var    lnpID        = this.PParser.GetLineString.GetLnpAndId();
            string insertString = c.ToString();
            if (c == CharCommand.Char_Tab)
            {
                insertString = " ".PadLeft(this.PParser.PLanguageMode.TabSpaceCount, ' ');
            }
            this.PInsertString = insertString;
            var text = this.GetLineStringEffectualText();
            text = text.Insert(this.PParser.PCursor.CousorPointForWord.X + 1, insertString);
            this.SetResetLineString(this.PParser.GetLineString, text);
            this.RemovePuckerLeavingOnly(lnpID, this.PParser.GetLineString);

            int with = CharCommand.GetCharWidth(this.PParser.PIEdit.GetGraphics, insertString, FontContainer.DefaultFont);
            this.PCharWidth = with;

            this.PParser.PCursor.CousorPointForEdit.X += with;
            this.PParser.PCursor.CousorPointForWord.X += insertString.Length;
            if (this.PParser.PCursor.CousorPointForEdit.X > this.PParser.PIEdit.GetWidth - 20)
            {
                if (this.PParser.PCursor.CousorPointForEdit.X > this.PParser.GetMaxWidth + this.PParser.GetLeftSpace)
                {
                    this.PParser.PIEdit.SetMaxScollMaxWidth(this.PParser.PCursor.CousorPointForEdit.X);
                }

                this.PParser.PCursor.CousorPointForEdit.X -= with;
                this.PParser.PIEdit.SetHorizontalScrollValue(with + this.PParser.PIEdit.GetHorizontalScrollValue, 1);
            }
            this.PParser.PCursor.SetPosition(this.PParser.PCursor.CousorPointForEdit.X, -1, this.PParser.GetLeftSpace);
            this.PParser.PCursor.SetPosition();
            //this.PParser.ResetLineLNPAndClearPucker(formerly, this.PParser.GetLineString);
            this.PParser.PIEdit.Invalidate();
            this.End();
            #endregion
        }
Esempio n. 3
0
        public void Char(int codePoint)
        {
            if (_lineNumber == 0)
            {
                if (_msgInitValue1 != 0)
                {
                    return;
                }
                _currentFontSize = .9;
                _fastForwarding  = true;
            }

            var isInTable1 = Array.IndexOf(CharTable1, codePoint) != -1;
            var isInTable2 = Array.IndexOf(CharTable2, codePoint) != -1;

            var glyphInfo = _fontInfo.GlyphInfo[codePoint];

            var cmd = new CharCommand();

            //cmd.Time = _currentTime;
            cmd.CodePoint   = codePoint;
            cmd.IsInTable1  = isInTable1;
            cmd.IsInTable2  = isInTable2;
            cmd.HasFurigana = false;
            if (_isFuriganaOpen)
            {
                // ReSharper disable once CompareOfFloatsByEqualityOperator
                cmd.IsInTable1  = _furiganaStartX != _xPosition;
                cmd.HasFurigana = true;
            }

            var f = _currentFontSize * _mtlParam.BigTextSize / (_fontInfo.SmallerSize + _fontInfo.BiggerSize);

            cmd.AnotherSizeRelatedThing2 = f;
            f *= _mtlParam.f_1c;
            cmd.AnotherSizeRelatedThing1 = f;
            cmd.Width = glyphInfo.Width * _currentFontSize;

            cmd.SomeSizeRelatedThing = _mtlParam.BigTextSize * _currentFontSize;

            cmd.XPos  = _xPosition;
            cmd.YPos  = _yPosition;
            cmd.Color = _currentTextColor;
            cmd.Fade  = _currentFade;

            // here also were some time calculations
            if (_fastForwarding)
            {
                cmd.Fade = 0;
            }

            _xPosition += cmd.Width;

            _commands.Add(cmd);
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        private void BackSpaceChar()
        {
            LineString lineString = null;
            string     lineText   = string.Empty;
            var        lnpID      = this.PParser.GetLineString.GetLnpAndId();

            if (this.PParser.PCursor.CousorPointForWord.X < 0)
            {
                if (this.PParser.PCursor.CousorPointForWord.Y == 0)
                {
                    this.PIsAddUndo = false;
                    return;
                }
                this.pEBackSpaceType = EBackSpaceType.Enter;
                this.SetOperationAction();
                string leavings = this.PParser.GetLineString.Text;
                var    nowLine  = this.PParser.GetLineString;
                this.PParser.PLineString.RemoveAt(this.PParser.PCursor.CousorPointForWord.Y);
                this.PParser.PCursor.CousorPointForWord.Y--;
                this.PParser.PCursor.CousorPointForEdit.Y -= FontContainer.FontHeight;
                if (this.PParser.PCursor.CousorPointForWord.Y < 0)
                {
                    this.PParser.PCursor.CousorPointForWord.Y = 0;
                    return;
                }
                lineString = this.PParser.GetLineString;
                this.MergeLineString(lineString, nowLine);
                this.ChangeIncrementLine(-1);
            }
            else
            {
                pEBackSpaceType = EBackSpaceType.Char;
                this.SetOperationAction();
                lineString = this.PParser.GetLineString;
                this.pChar = lineString.Text[this.PParser.PCursor.CousorPointForWord.X];
                lineText   = this.GetLineStringEffectualText(lineString).Remove(this.PParser.PCursor.CousorPointForWord.X, 1);

                int with = CharCommand.GetCharWidth(this.PParser.PIEdit.GetGraphics, this.pChar.ToString(), FontContainer.DefaultFont);
                this.PParser.PCursor.XForLeft             -= with;
                this.PParser.PCursor.CousorPointForEdit.X -= with;
                this.PParser.PCursor.CousorPointForWord.X -= 1;
                this.SetResetLineString(lineString, lineText);
                this.RemovePuckerLeavingOnly(lnpID, lineString);
                this.EndInsertChar();
            }
            this.SetSurosrPoint();
            this.PParser.PCursor.SetPosition();
        }
Esempio n. 5
0
 /// <summary>
 /// 注释所有的行
 /// </summary>
 /// <param name="startY"></param>
 /// <param name="count"></param>
 private void CommentAllLine(int startY, int count)
 {
     count = startY + count;
     for (; startY < count; startY++)
     {
         var ls = this.PParser.PLineString[startY];
         if (string.IsNullOrWhiteSpace(ls.Text) || (this.CommentYs != null && this.CommentYs.Contains(startY)))
         {
             continue;
         }
         //ls.PWord.Insert(this.minInsertWordIndex,
         ls.Text = ls.Text.Insert(this.minInsertLineIndex, this.PCommentStartStr);
         this.SetResetLineString(ls);
         if (this.PCommentStartWidth == -1)
         {
             var w = ls.PWord[this.minInsertWordIndex];
             this.PCommentStartWidth = CharCommand.GetCharWidth(this.PParser.PIEdit.GetGraphics, this.PCommentStartStr, w.PIncluedFont == null ? null : w.PIncluedFont.PFont);
         }
     }
 }