Exemplo n.º 1
0
        private void calcPrintCWidth(StringMeasure stringMeasure)
        {
            string str  = new string(' ', Config.PrintCLength);
            Font   font = Config.Font;

            printCWidth = stringMeasure.GetDisplayLength(str, font);

            str         += " ";
            printCWidthL = stringMeasure.GetDisplayLength(str, font);

            str          += " ";
            printCWidthL2 = stringMeasure.GetDisplayLength(str, font);
        }
Exemplo n.º 2
0
 public override void SetWidth(StringMeasure sm, float subPixel)
 {
     if (Error)
     {
         Width = 0;
         return;
     }
     Width     = sm.GetDisplayLength(Str, Font);
     XsubPixel = subPixel;
 }
Exemplo n.º 3
0
		public override void SetWidth(StringMeasure sm, float subPixel)
		{
			if (this.Error)
			{
				Width = 0;
				return;
			}
			if (cImage != null)
				return;
			Width = sm.GetDisplayLength(Str, Config.Font);
			XsubPixel = subPixel;
		}
Exemplo n.º 4
0
        private string CreateTypeCString(string str, bool alignmentRight)
        {
            if (printCWidth == -1)
            {
                calcPrintCWidth(stringMeasure);
            }
            int length = 0;
            int width  = 0;

            if (str != null)
            {
                //length = Config.Encode.GetByteCount(str);
                length = uEmuera.Utils.GetByteCount(str);
            }
            int  printcLength = Config.PrintCLength;
            Font font         = null;

            try
            {
                font = new Font(Style.Fontname, Config.Font.Size, Style.FontStyle, GraphicsUnit.Pixel);
            }
            catch
            {
                return(str);
            }

            if ((alignmentRight) && (length < printcLength))
            {
                str   = new string(' ', printcLength - length) + str;
                width = stringMeasure.GetDisplayLength(str, font);
                while (width > printCWidth)
                {
                    if (str[0] != ' ')
                    {
                        break;
                    }
                    str   = str.Remove(0, 1);
                    width = stringMeasure.GetDisplayLength(str, font);
                }
            }
            else if ((!alignmentRight) && (length < printcLength + 1))
            {
                str  += new string(' ', printcLength + 1 - length);
                width = stringMeasure.GetDisplayLength(str, font);
                while (width > printCWidthL)
                {
                    if (str[str.Length - 1] != ' ')
                    {
                        break;
                    }
                    str   = str.Remove(str.Length - 1, 1);
                    width = stringMeasure.GetDisplayLength(str, font);
                }
            }
            return(str);
        }
Exemplo n.º 5
0
        private static int getDivideIndex(AConsoleDisplayPart part, StringMeasure sm)
        {
            if (!part.CanDivide)
            {
                return(-1);
            }
            ConsoleStyledString css = part as ConsoleStyledString;

            if (part == null)
            {
                return(-1);
            }
            int    widthLimit = Config.DrawableWidth - css.PointX;
            string str        = css.Str;
            Font   font       = css.Font;
            int    point      = 0;
            int    highLength = str.Length; //widthLimitを超える最低の文字index(文字数-1)。
            int    lowLength  = 0;          //超えない最大の文字index。
            //int i = (int)(widthLimit / fontDisplaySize);//およその文字数を推定
            //if (i > str.Length - 1)//配列の外を参照しないように。
            //	i = str.Length - 1;
            int i = lowLength;            //およその文字数を推定←やめた

            string test = null;

            while ((highLength - lowLength) > 1)            //差が一文字以下になるまで繰り返す。
            {
                test  = str.Substring(0, i);
                point = sm.GetDisplayLength(test, font);
                if (point <= widthLimit)                //サイズ内ならlowLengthを更新。文字数を増やす。
                {
                    lowLength = i;
                    i++;
                }
                else                //サイズ外ならhighLengthを更新。文字数を減らす。
                {
                    highLength = i;
                    i--;
                }
            }
            return(lowLength);
        }
Exemplo n.º 6
0
 public string getStBar(string barStr)
 {
     StringMeasure stringMeasure = new StringMeasure(getGraphics(), this.bgColor, Config.TextDrawingMode);
     StringBuilder bar = new StringBuilder();
     bar.Append(barStr);
     int width = 0;
     while (width < window.MainPicBox.Width)
     {//境界を越えるまで一文字ずつ増やす
         bar.Append(barStr);
         width = stringMeasure.GetDisplayLength(bar.ToString(), Config.Font);
     }
     while (width > window.MainPicBox.Width)
     {//境界を越えたら、今度は超えなくなるまで一文字ずつ減らす(barStrに複数字の文字列がきた場合に対応するため)
         bar.Remove(bar.Length - 1, 1);
         width = stringMeasure.GetDisplayLength(bar.ToString(), Config.Font);
     }
     stringMeasure.Dispose();
     return bar.ToString();
 }
Exemplo n.º 7
0
        private string CreateTypeCString(string str, bool alignmentRight)
        {
            StringMeasure stringMeasure = new StringMeasure(getGraphics(), this.bgColor, Config.TextDrawingMode);
            if (printCWidth == -1)
                calcPrintCWidth(stringMeasure);
            int length = 0;
            int width = 0;
            if (str != null)
                length = Config.Encode.GetByteCount(str);
            int printcLength = Config.PrintCLength;
            Font font = new Font(Style.Fontname, Config.Font.Size, Style.FontStyle, GraphicsUnit.Pixel);

            if ((alignmentRight) && (length < printcLength))
            {
                str = new string(' ', printcLength - length) + str;
                width = stringMeasure.GetDisplayLength(str, font);
                while (width > printCWidth)
                {
                    if (str[0] != ' ')
                        break;
                    str = str.Remove(0, 1);
                    width = stringMeasure.GetDisplayLength(str, font);
                }
            }
            else if ((!alignmentRight) && (length < printcLength + 1))
            {
                str += new string(' ', printcLength + 1 - length);
                width = stringMeasure.GetDisplayLength(str, font);
                while (width > printCWidthL)
                {
                    if (str[str.Length - 1] != ' ')
                        break;
                    str = str.Remove(str.Length - 1, 1);
                    width = stringMeasure.GetDisplayLength(str, font);
                }
            }
            stringMeasure.Dispose();
            return str;
        }
Exemplo n.º 8
0
        private void calcPrintCWidth(StringMeasure stringMeasure)
        {
            string str = new string(' ', Config.PrintCLength);
            printCWidth = stringMeasure.GetDisplayLength(str, Config.Font);

            str += " ";
            printCWidthL = stringMeasure.GetDisplayLength(str, Config.Font);

            str += " ";
            printCWidthL2 = stringMeasure.GetDisplayLength(str, Config.Font);
        }
Exemplo n.º 9
0
 private int getDivideIndex(ConsoleStyledString css, StringMeasure sm)
 {
     int widthLimit = Config.WindowX - css.PointX;
     string str = css.Str;
     Font font = css.Font;
     int point = 0;
     int highLength = str.Length - 1;//widthLimitを超える最低の文字index(文字数-1)。
     int lowLength = 0;//超えない最大の文字index。
     //int i = (int)(widthLimit / fontDisplaySize);//およその文字数を推定
     int i = 0;//およその文字数を推定
     if (i > str.Length - 1)//配列の外を参照しないように。
         i = str.Length - 1;
     string test = null;
     while ((highLength - lowLength) > 1)//差が一文字以下になるまで繰り返す。
     {
         test = str.Substring(0, i);
         point = sm.GetDisplayLength(test, font);
         if (point <= widthLimit)//サイズ内ならlowLengthを更新。文字数を増やす。
         {
             lowLength = i;
             i++;
         }
         else//サイズ外ならhighLengthを更新。文字数を減らす。
         {
             highLength = i;
             i--;
         }
     }
     return lowLength;
 }
Exemplo n.º 10
0
 public void SetWidth(StringMeasure sm)
 {
     Width = sm.GetDisplayLength(Str, Font);
 }