예제 #1
0
        public ImageForm(Image img, int x, int y, AlignX alignx, AlignY aligny)
        {
            this.InitializeComponent();
            PictureBox.Image = img;
            Width            = PictureBox.Width;
            Height           = PictureBox.Height;
            switch (alignx)
            {
            case AlignX.Left:
                break;

            case AlignX.Middle:
                x -= PictureBox.Width / 2;
                break;

            case AlignX.Right:
                x -= PictureBox.Width;
                break;
            }
            switch (aligny)
            {
            case AlignY.Top:
                break;

            case AlignY.Middle:
                y -= PictureBox.Height / 2;
                break;

            case AlignY.Bottom:
                y -= PictureBox.Height;
                break;
            }
            Location = new Point(x, y);
        }
예제 #2
0
        // offsetはLocalPositionに足されるので注意
        public void Add(
            Control child,
            float offsetX = 0f,
            float offsetY = 0f,
            AlignX alignX = AlignX.Left,
            AlignY alignY = AlignY.Top)
        {
            float x = 0f;

            switch (alignX)
            {
            case AlignX.Center: x = (this.Width - child.Width) * 0.5f; break;

            case AlignX.Right: x = this.Width - child.Width; break;
            }
            float y = 0f;

            switch (alignY)
            {
            case AlignY.Center: y = (this.Height - child.Height) * 0.5f; break;

            case AlignY.Bottom: y = (this.Height - child.Height); break;
            }
            child.SetLocalPosition(
                child.LocalLeftX + offsetX + x,
                child.LocalTopY + offsetY + y);
            AddChildAsTail(child);
        }
예제 #3
0
 // fontsize, width, heightをすべて指定する場合は折り返し
 public int AddText(
     string text,
     Vector3 origin,
     Vector3 rightVector,
     Vector3 downVector,
     float fontSize,
     float boxWidth,
     float boxHeight,
     AlignX alignX          = AlignX.Left,
     AlignY alignY          = AlignY.Top,
     float lineSpacingRatio = DefaultLineSpacingRatio)
 {
     return(AddText(
                text,
                origin,
                rightVector,
                downVector,
                fontSize,
                boxWidth,
                boxHeight,
                alignX,
                alignY,
                TextOverflow.Wrap,
                lineSpacingRatio));
 }
예제 #4
0
파일: Utilities.cs 프로젝트: NKID00/toys
        public void MessageBoxShow(int x, int y, AlignX alignx, AlignY aligny, string text, string caption, MessageBoxButtons buttons, MessageBoxIcon icon)
        {
            if (!locked)
            {
                mutex.WaitOne();
                locked = true;
            }
            var tcaption = msgid.ToString();

            new Thread(new ThreadStart(() =>
            {
                var handle = IntPtr.Zero;
                new Thread(new ThreadStart(() =>
                {
                    MessageBox.Show(text, tcaption, buttons, icon);
                }
                                           )).Start();
                while ((handle = FindWindow(IntPtr.Zero, tcaption)) == IntPtr.Zero)
                {
                    ;
                }
                SetWindowText(handle, caption);
                GetWindowRect(handle, out var r);
                var rw = r.Width - r.X;
                var rh = r.Height - r.Y;
                switch (alignx)
                {
                case AlignX.Left:
                    break;

                case AlignX.Middle:
                    x -= rw / 2;
                    break;

                case AlignX.Right:
                    x -= rw;
                    break;
                }
                switch (aligny)
                {
                case AlignY.Top:
                    break;

                case AlignY.Middle:
                    y -= rh / 2;
                    break;

                case AlignY.Bottom:
                    y -= rh;
                    break;
                }
                MoveWindow(handle, x, y, rw, rh, true);
                mutex.WaitOne();
                mutex.ReleaseMutex();
                PostMessage(handle, 0x10, IntPtr.Zero, IntPtr.Zero);
            }
                                       )).Start();
            msgid++;
        }
예제 #5
0
 public void Add(
     DebugUiControl child,
     float offsetX = 0f,
     float offsetY = 0f,
     AlignX alignX = AlignX.Left,
     AlignY alignY = AlignY.Top)
 {
     _contentPanel.Add(child, offsetX, offsetY, alignX, alignY);
 }
예제 #6
0
 void Initialize()
 {
     this.lineSpacing       = DebugPrimitiveRenderer.DefaultLineSpacingRatio;
     this.backgroundEnabled = false;
     this.borderEnabled     = false;
     this.color             = new Color32(255, 255, 255, 255);
     this.alignX            = AlignX.Left;
     this.alignY            = AlignY.Top;
 }
예제 #7
0
 public void Add(
     Control control,
     float offsetX = 0f,
     float offsetY = 0,
     AlignX alignX = AlignX.Left,
     AlignY alignY = AlignY.Top)
 {
     root.Add(control, offsetX, offsetY, alignX, alignY);
 }
예제 #8
0
 void Initialize(bool backgroundEnabled)
 {
     LineSpacing       = RendererBase.DefaultLineSpacingRatio;
     BackgroundEnabled = backgroundEnabled;
     BorderEnabled     = false;
     Color             = new Color32(255, 255, 255, 255);
     AlignX            = AlignX.Left;
     AlignY            = AlignY.Top;
 }
예제 #9
0
 public Text(FontAsset font, string text, Vector2 position, Color color, float alpha = 1.0f, AlignX alignX = BeauSharp.AlignX.Left, AlignY alignY = BeauSharp.AlignY.Top)
     : base(false)
 {
     this.font = font;
     this.text = text;
     Position = position;
     Color = color;
     Alpha = alpha;
     AlignX = alignX;
     AlignY = alignY;
     UpdateSize();
 }
예제 #10
0
파일: Program.cs 프로젝트: NKID00/toys
 private static void ShowImage(Image img, int x, int y, AlignX alignx, AlignY aligny)
 {
     new Thread(new ThreadStart(() =>
     {
         var imgform      = new ImageForm(img, x, y, alignx, aligny);
         var image_handle = imgform.Handle;
         new Thread(new ThreadStart(() =>
         {
             lock (image_lock_obj) { }
             PostMessage(image_handle, 0x10, IntPtr.Zero, IntPtr.Zero);
         }
                                    )).Start();
         Application.Run(imgform);
     }
                                )).Start();
 }
예제 #11
0
 // fontsizeのみ指定する場合、オーバーフロー処理は行わない
 public int AddText(
     string text,
     float leftX,
     float topY,
     float fontSize,
     AlignX alignX          = AlignX.Left,
     AlignY alignY          = AlignY.Top,
     float lineSpacingRatio = DefaultLineSpacingRatio)
 {
     return(AddText(
                text,
                leftX,
                topY,
                fontSize,
                float.MaxValue,
                float.MaxValue,
                alignX,
                alignY,
                TextOverflow.Wrap,
                lineSpacingRatio));
 }
예제 #12
0
파일: Utilities.cs 프로젝트: NKID00/toys
 private void ImageShow(Image img, int x, int y, AlignX alignx, AlignY aligny)
 {
     if (!locked)
     {
         mutex.WaitOne();
         locked = true;
     }
     new Thread(new ThreadStart(() =>
     {
         var imgform      = new ImageForm(img, x, y, alignx, aligny);
         var image_handle = imgform.Handle;
         new Thread(new ThreadStart(() =>
         {
             mutex.WaitOne();
             mutex.ReleaseMutex();
             PostMessage(image_handle, 0x10, IntPtr.Zero, IntPtr.Zero);
         }
                                    )).Start();
         Application.Run(imgform);
     }
                                )).Start();
 }
예제 #13
0
 // 箱サイズのみ指定する場合、スケールで合わせる
 public int AddText(
     string text,
     float leftX,
     float topY,
     float boxWidth,
     float boxHeight,
     AlignX alignX          = AlignX.Left,
     AlignY alignY          = AlignY.Top,
     float lineSpacingRatio = DefaultLineSpacingRatio)
 {
     return(AddText(
                text,
                leftX,
                topY,
                0f,
                boxWidth,
                boxHeight,
                alignX,
                alignY,
                TextOverflow.Scale,
                lineSpacingRatio));
 }
예제 #14
0
        // offsetはLocalPositionに足されるので注意
        public void Add(
            DebugUiControl child,
            float offsetX = 0f,
            float offsetY = 0f,
            AlignX alignX = AlignX.Left,
            AlignY alignY = AlignY.Top)
        {
            var innerWidth  = this.width;
            var innerHeight = this.height;

            if (this.borderEnabled)
            {
                innerWidth  -= (this.borderWidth * 2f);
                innerHeight -= (this.borderWidth * 2f);
            }
            float x = 0f;

            switch (alignX)
            {
            case AlignX.Center: x = (innerWidth - child.width) * 0.5f; break;

            case AlignX.Right: x = innerWidth - child.width; break;
            }
            float y = 0f;

            switch (alignY)
            {
            case AlignY.Center: y = (innerHeight - child.height) * 0.5f; break;

            case AlignY.Bottom: y = (innerHeight - child.height); break;
            }
            child.SetLocalPosition(
                child.localLeftX + offsetX + x,
                child.localTopY + offsetY + y);
            AddChildAsTail(child);
        }
예제 #15
0
        public async Task <FileResponse> TextStampAsync(FileParameter file, string text, string pages, AlignX alignX, AlignY alignY, string jobIdExt = null)
        {
            var _alignX = (AlignX2)Enum.Parse(typeof(AlignX2), alignX.ToString(), true);
            var _alignY = (AlignY2)Enum.Parse(typeof(AlignY2), alignY.ToString(), true);

            return(await TextStampAsync(text, pages, _alignX, _alignY, jobIdExt, file));
        }
예제 #16
0
 public void SetChildRelativeLoactionY(AlignY parentAlignY, Int32 offset, AlignY childAlignY)
 {
     childRelativeLocationY.parentAlign = parentAlignY;
     childRelativeLocationY.offset      = offset;
     childRelativeLocationY.childAlign  = childAlignY;
 }
예제 #17
0
 //
 // Child Relative Location Y
 //
 public void SetChildRelativeLoactionY(AlignY parentAndChildAlignY)
 {
     childRelativeLocationY.parentAlign = parentAndChildAlignY;
     childRelativeLocationY.offset      = 0;
     childRelativeLocationY.childAlign  = parentAndChildAlignY;
 }
예제 #18
0
 public ChildRelativeLocationY(AlignY parentAlignY, Int32 offset, AlignY childAlignY)
 {
     this.parentAlign = parentAlignY;
     this.offset      = offset;
     this.childAlign  = childAlignY;
 }
예제 #19
0
        public int AddText(
            string text,
            float leftX,
            float topY,
            float fontSize,
            float boxWidth,
            float boxHeight,
            AlignX alignX,
            AlignY alignY,
            TextOverflow overflow,
            float lineSpacingRatio)
        {
            int verticesBegin = vertexCount;

            float width, height;
            float scale = 0f;
            bool  wrap;
            float normalizedBoxWidth, normalizedBoxHeight;

            if (overflow == TextOverflow.Wrap)
            {
                UnityEngine.Debug.Assert(fontSize > 0f);
                scale = fontSize / (float)font.fontSize;
                normalizedBoxWidth  = boxWidth / scale;
                normalizedBoxHeight = boxHeight / scale;
                wrap = true;
            }
            else //if (overflow == TextOverflow.Scale)
            {
                normalizedBoxWidth = normalizedBoxHeight = float.MaxValue;
                wrap = false;
            }
            var drawnLines = AddTextNormalized(out width, out height, text, normalizedBoxWidth, normalizedBoxHeight, lineSpacingRatio, wrap);

            if (drawnLines <= 0) // 何も書いてないなら抜ける
            {
                return(drawnLines);
            }

            if (overflow == TextOverflow.Scale)
            {
                var scaleX = boxWidth / width;
                var scaleY = boxHeight / height;
                scale = Mathf.Min(scaleX, scaleY);
            }

            // TODO: 以下の計算はまだ仮
            var offset = Vector2.zero;

            switch (alignX)
            {
            case AlignX.Center: offset.x = -width * 0.5f; break;

            case AlignX.Right: offset.x = -width; break;
            }
            switch (alignY)
            {
            case AlignY.Center: offset.y = -height * 0.5f; break;

            case AlignY.Bottom: offset.y = -height; break;
            }
            offset   *= scale;
            offset.x += leftX;
            offset.y += topY;
            TransformVertices(verticesBegin, scale, ref offset);
            return(drawnLines);
        }
예제 #20
0
 /// <summary>
 /// Pops the rendering state off the stack.
 /// </summary>
 public static void PopState()
 {
     #if DEBUG
     if ( _savedTransformations == null || _savedTransformations.Count == 0 )
         throw new Exception("No states available on the stack.");
     #endif
     SavedTransformation oldState = _savedTransformations.Pop();
     Position = oldState.Position;
     Origin = oldState.Origin;
     Scale = oldState.Scale;
     Zoom = oldState.Zoom;
     Rotation = oldState.Rotation;
     Color = oldState.Color;
     Alpha = oldState.Alpha;
     Effects = oldState.Effects;
     Font = oldState.Font;
     AlignX = oldState.AlignH;
     AlignY = oldState.AlignV;
 }
예제 #21
0
 public async Task <byte[]> TextStampAsync(byte[] file, string text, string pages, AlignX alignX, AlignY alignY)
 {
     return(await CustomHttp.postWrapper(
                new List <string> {
         "text", text, "pages", pages, "alignX", Enum.GetName(typeof(AlignX), alignX), "alignY", Enum.GetName(typeof(AlignY), alignY)
     },
                new List <Tuple <byte[], string, string> > {
         new Tuple <byte[], string, string>(file, "file", "pdf.pdf")
     },
                "Stamp/TextStamp",
                _httpClient));
 }
예제 #22
0
        public virtual void AddAuto(DebugUiControl child)
        {
            float minX         = 0f;
            float minY         = 0f;
            float maxX         = width;
            float maxY         = height;
            float borderOffset = borderEnabled ? (borderWidth * 2f) : 0f;

            if (borderEnabled)
            {
                minX += borderOffset;
                minY += borderOffset;
                maxX -= borderOffset;
                maxY -= borderOffset;
            }
            // 右
            float  dx     = 0f;
            float  dy     = 0f;
            float  size   = 0f;
            AlignX alignX = AlignX.Left;
            AlignY alignY = AlignY.Top;

            if ((layout == Layout.RightDown) || (layout == Layout.RightUp))
            {
                alignX = AlignX.Left;
                alignY = (layout == Layout.RightDown) ? AlignY.Top : AlignY.Bottom;
                float childRight = _x + borderWidth + child.width;
                if (childRight > maxX)                 // あふれた。改行する。
                {
                    BreakLine();
                }
                dx   = child.width + borderWidth;
                size = child.height;
            }
            else if ((layout == Layout.LeftDown) || (layout == Layout.LeftUp))
            {
                alignX = AlignX.Right;
                alignY = (layout == Layout.LeftDown) ? AlignY.Top : AlignY.Bottom;
                float childLeft = _x - borderWidth - child.width;
                if (childLeft < minX)                 // あふれた。改行する。
                {
                    BreakLine();
                }
                dx   = -child.width - borderWidth;
                size = child.height;
            }
            else if ((layout == Layout.DownRight) || (layout == Layout.DownLeft))
            {
                alignY = AlignY.Top;
                alignX = (layout == Layout.DownRight) ? AlignX.Left : AlignX.Right;
                float childBottom = _y + borderWidth + child.height;
                if (childBottom > maxY)                 // あふれた。改行する。
                {
                    BreakLine();
                }
                dy   = child.height + borderWidth;
                size = child.width;
            }
            else if ((layout == Layout.UpRight) || (layout == Layout.UpLeft))
            {
                alignY = AlignY.Bottom;
                alignX = (layout == Layout.UpRight) ? AlignX.Left : AlignX.Right;
                float childTop = _y - borderWidth - child.height;
                if (childTop < minY)                 // あふれた。改行する。
                {
                    BreakLine();
                }
                dy   = -child.height - borderWidth;
                size = child.width;
            }
            Add(child, _x, _y, alignX, alignY);
            _x += dx;
            _y += dy;
            _currentLineSize = Mathf.Max(_currentLineSize, size);
        }
예제 #23
0
 public Text(FontAsset font, string text, Vector2 position, AlignX alignX = BeauSharp.AlignX.Left, AlignY alignY = BeauSharp.AlignY.Top)
     : this(font, text, position, Color.White, 1.0f, alignX, alignY)
 {
 }
예제 #24
0
        /// <summary>
        /// Renders text with the given parameters.
        /// </summary>
        /// <param name="font">The SpriteFont to use.</param>
        /// <param name="text">The text to render.</param>
        /// <param name="position">The position of the text.</param>
        /// <param name="color">The color of the text.</param>
        /// <param name="alpha">The transparency to use.</param>
        /// <param name="alignH">The horizontal alignment.</param>
        /// <param name="alignV">The vertical alignment.</param>
        /// <param name="scale">The scaling factors to use.</param>
        /// <param name="rotation">The rotation of the </param>
        public static void Text(FontAsset font, string text, Vector2 position, Color color, float alpha, AlignX alignH, AlignY alignV, Vector2 scale, Angle rotation)
        {
            Vector2 origin = Font.SpriteFont.MeasureString(text);
            origin.X *= AlignFactor(alignH);
            origin.Y *= AlignFactor(alignV);

            SpriteBatch.DrawString(font.SpriteFont, text, Calc.Floor(position), color * Math.Min(alpha, 1), rotation.Radians, origin, scale, Effects, 0);
        }
예제 #25
0
 public async Task <FileResponse> TextStampAsync(FileParameter file, string text, string pages, AlignX alignX, AlignY alignY, string jobIdExt = null)
 {
     return(await TextStampAsync(text, pages, alignX, alignY, jobIdExt, file));
 }
예제 #26
0
 /// <summary>
 /// Returns the vertical offset factor for the given vertical alignment.
 /// </summary>
 public static float AlignFactor(AlignY alignV)
 {
     if (alignV == AlignY.Top)
         return 0;
     else if (alignV == AlignY.Center)
         return 0.5f;
     return 1.0f;
 }
예제 #27
0
 public ChildRelativeLocationY(AlignY parentAndChildAlignY)
 {
     this.parentAlign = parentAndChildAlignY;
     this.offset      = 0;
     this.childAlign  = parentAndChildAlignY;
 }
예제 #28
0
 /// <summary>
 /// Resets the rendering state.
 /// </summary>
 public static void ResetState()
 {
     Position = Vector2.Zero;
     Origin = Vector2.Zero;
     Scale = Vector2.One;
     Zoom = 1.0f;
     Rotation = Angle.Zero;
     Color = Color.White;
     Alpha = 1.0f;
     Effects = SpriteEffects.None;
     Font = DefaultFont;
     AlignX = AlignX.Left;
     AlignY = AlignY.Top;
 }
예제 #29
0
        public virtual void AddAuto(Control child)
        {
            float minX         = 0f;
            float minY         = 0f;
            float maxX         = Width;
            float maxY         = Height;
            float borderOffset = BorderEnabled ? (BorderWidth * 2f) : 0f;

            if (BorderEnabled)
            {
                minX += borderOffset;
                minY += borderOffset;
                maxX -= borderOffset;
                maxY -= borderOffset;
            }
            // 右
            float  dx     = 0f;
            float  dy     = 0f;
            float  size   = 0f;
            AlignX alignX = AlignX.Left;
            AlignY alignY = AlignY.Top;

            if ((layout == Layout.RightDown) || (layout == Layout.RightUp))
            {
                alignX = AlignX.Left;
                alignY = (layout == Layout.RightDown) ? AlignY.Top : AlignY.Bottom;
                float childRight = x + BorderWidth + child.Width;
                if (childRight > maxX) // あふれた。改行する。
                {
                    BreakLine();
                }
                dx   = child.Width + BorderWidth;
                size = child.Height;
            }
            else if ((layout == Layout.LeftDown) || (layout == Layout.LeftUp))
            {
                alignX = AlignX.Right;
                alignY = (layout == Layout.LeftDown) ? AlignY.Top : AlignY.Bottom;
                float childLeft = x - BorderWidth - child.Width;
                if (childLeft < minX) // あふれた。改行する。
                {
                    BreakLine();
                }
                dx   = -child.Width - BorderWidth;
                size = child.Height;
            }
            else if ((layout == Layout.DownRight) || (layout == Layout.DownLeft))
            {
                alignY = AlignY.Top;
                alignX = (layout == Layout.DownRight) ? AlignX.Left : AlignX.Right;
                float childBottom = y + BorderWidth + child.Height;
                if (childBottom > maxY) // あふれた。改行する。
                {
                    BreakLine();
                }
                dy   = child.Height + BorderWidth;
                size = child.Width;
            }
            else if ((layout == Layout.UpRight) || (layout == Layout.UpLeft))
            {
                alignY = AlignY.Bottom;
                alignX = (layout == Layout.UpRight) ? AlignX.Left : AlignX.Right;
                float childTop = y - BorderWidth - child.Height;
                if (childTop < minY) // あふれた。改行する。
                {
                    BreakLine();
                }
                dy   = -child.Height - BorderWidth;
                size = child.Width;
            }
            Add(child, x, y, alignX, alignY);
            x += dx;
            y += dy;
            currentLineSize = Mathf.Max(currentLineSize, size);
        }
예제 #30
0
 public SavedTransformation(Vector2 position, Vector2 origin, Vector2 scale, float zoom, Angle rotation, Color color, float alpha, SpriteEffects effect, FontAsset font
     , AlignX alignH, AlignY alignV)
 {
     Position = position;
     Origin = origin;
     Scale = scale;
     Zoom = zoom;
     Rotation = rotation;
     Color = color;
     Alpha = alpha;
     Effects = effect;
     Font = font;
     AlignH = alignH;
     AlignV = alignV;
 }
예제 #31
0
        // rightVectorとdownVectorが正規直交していないと平行四辺形に歪むので注意
        int AddText(
            string text,
            Vector3 origin,
            Vector3 rightVector,
            Vector3 downVector,
            float fontSize,
            float boxWidth,
            float boxHeight,
            AlignX alignX,
            AlignY alignY,
            TextOverflow overflow,
            float lineSpacingRatio)
        {
            int verticesBegin = vertexCount;

            float width, height;
            var   scale = 0f;
            bool  wrap;
            float normalizedBoxWidth, normalizedBoxHeight;

            if (overflow == TextOverflow.Wrap)
            {
                UnityEngine.Debug.Assert(fontSize > 0f);
                scale = fontSize / (float)font.fontSize;
                normalizedBoxWidth  = boxWidth * scale;
                normalizedBoxHeight = boxHeight * scale;
                wrap = true;
            }
            else //if (overflow == TextOverflow.Scale)
            {
                normalizedBoxWidth = normalizedBoxHeight = float.MaxValue;
                wrap = false;
            }
            var drawnLines = AddTextNormalized(out width, out height, text, normalizedBoxWidth, normalizedBoxHeight, lineSpacingRatio, wrap);

            if (drawnLines <= 0) // 何も書いてないなら抜ける
            {
                return(drawnLines);
            }

            if (overflow == TextOverflow.Scale)
            {
                var scaleX = boxWidth / width;
                var scaleY = boxHeight / height;
                scale = Mathf.Min(scaleX, scaleY);
            }

            var matrix   = Matrix4x4.Translate(origin);
            var rotation = Matrix4x4.identity;

            rotation.m00 = rightVector.x;
            rotation.m10 = rightVector.y;
            rotation.m20 = rightVector.z;
            rotation.m01 = -downVector.x;
            rotation.m11 = -downVector.y;
            rotation.m21 = -downVector.z;
            var up = Vector3.Cross(downVector, rightVector);

            rotation.m02 = up.x;
            rotation.m12 = up.y;
            rotation.m22 = up.z;
            matrix      *= rotation;

            matrix *= Matrix4x4.Scale(new Vector3(scale, -scale, 1f));
            // TODO: 以下の計算はまだ仮
            float offsetX = 0f;

            switch (alignX)
            {
            case AlignX.Center: offsetX = -width * 0.5f; break;

            case AlignX.Right: offsetX = -width; break;
            }
            float offsetY = 0f;

            switch (alignY)
            {
            case AlignY.Center: offsetY = -height * 0.5f; break;

            case AlignY.Bottom: offsetY = -height; break;
            }
            matrix *= Matrix4x4.Translate(new Vector3(offsetX, offsetY, 0f));
            TransformVertices(verticesBegin, ref matrix);
            return(drawnLines);
        }