예제 #1
0
파일: TextElement.cs 프로젝트: fxbit/FxMath
        public TextElement( String  str )
        {
            // set the text
            Internal_String = str;

            // init the lists
            listPlotsGeometry = new List<PlotGeometry>();

            // set the position and the size of the element
            this.Position = new Vector.FxVector2f( 0 );
            this.Size = new Vector.FxVector2f( 500, 250 );

            // init format
            _TextFormat = new TextElementFormat();
            _TextFormat.familyName = "Calibri";
            _TextFormat.weight = SharpDX.DirectWrite.FontWeight.Black;
            _TextFormat.fontStyle = SharpDX.DirectWrite.FontStyle.Normal;
            _TextFormat.fontStretch = SharpDX.DirectWrite.FontStretch.Normal;
            _TextFormat.fontSize = 8.0f;

            // init text rectangle
            textRectangle = new SharpDX.RectangleF( 0, 0, Size.x, Size.y );

            // init the color of the fonts
            _FontColor = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
        }
예제 #2
0
 public BasicMenuGroup(string name, RectangleF rectangle, MenuItem[] menuItems) : base(name, rectangle)
 {
     foreach (var menuItem in menuItems.Where(x => x != null))
     {
         menuItem.SetParent(this);
         Add(menuItem.SelectButton, menuItem);
     }
 }
예제 #3
0
        public QuickAccessMenu(RectangleF rectangle, MenuGroup parentGroup)
        {
            Rectangle = rectangle;
            MenuGroup = parentGroup;

            LastButton = Game.Time;
            ButtonDelay = 0.1f;

            ButtonRectangle = new RectangleF(0, 0, 24, 24);
            ButtonSprites = new ButtonCollection<Sprite>();
            ButtonSprites.AddAll(
                new Sprite(TextureLoader.BitmapToTexture(Get(Properties.Resources.Button_A, ButtonRectangle.Width))),
                new Sprite(TextureLoader.BitmapToTexture(Get(Properties.Resources.Button_B, ButtonRectangle.Width))),
                new Sprite(TextureLoader.BitmapToTexture(Get(Properties.Resources.Button_X, ButtonRectangle.Width))),
                new Sprite(TextureLoader.BitmapToTexture(Get(Properties.Resources.Button_Y, ButtonRectangle.Width))));
        }
예제 #4
0
 public static void Initialize()
 {
     
     MenuRectangle = CenterScreen.Offset(new Vector2(0, Drawing.Height / 6f)).RectangleFromCenter(250);
     Menu = new QuickAccessMenu(MenuRectangle,
         new BasicMenuGroup("Group1", MenuRectangle, new MenuItem[]
         {
             new TextMenuItem("A", ControllerButton.A, () => Chat.Print("Testing A!")),
             new TextMenuItem("B", ControllerButton.B, null, new BasicMenuGroup("Group2", MenuRectangle, new MenuItem[]
             {
                 new TextMenuItem("A 1", ControllerButton.A, () => Chat.Print("Testing Sub A!")),
                 new TextMenuItem("B 1", ControllerButton.B, null, new BasicMenuGroup("Group 3", MenuRectangle, new MenuItem[]
                 {
                     new TextMenuItem("B 1 1", ControllerButton.B, () => { }), 
                 })),
                 
             })),
             new TextMenuItem("X", ControllerButton.X, null),
             new TextMenuItem("Y", ControllerButton.Y, null),
         }));
     Menu.Show();
     Game.OnUpdate += Game_OnUpdate;
 }
예제 #5
0
 private static void PrepVariables()
 {
     HudRectangle = new RectangleF(Drawing.Width / 3.575f, Drawing.Height - Drawing.Height / 5.5f, Drawing.Width - Drawing.Width / 3.425f * 2, 300);
 }
예제 #6
0
파일: Drawer.cs 프로젝트: fealty/Frost
        public void Fill(Rectangle rectangleRegion, Brush brush)
        {
            Contract.Requires(brush != null);
            Contract.Assert(_Target != null);

            RectangleF roundedRectangle = new RectangleF
            {
                Left = rectangleRegion.Left,
                Top = rectangleRegion.Top,
                Right = rectangleRegion.Right,
                Bottom = rectangleRegion.Bottom
            };

            _Target.FillRectangle(roundedRectangle, brush);
        }
예제 #7
0
        public void DisplayName(string name)
        {
            var brush = new SolidColorBrush(renderTarget, Color4.White);
            var layoutRect = new SharpDX.RectangleF(0, 0, bounds.Width, bounds.Height);

            renderTarget.BeginDraw();
            renderTarget.Clear(Color4.Black);
            renderTarget.DrawRectangle(new SharpDX.RectangleF(0, 0, bounds.Width, bounds.Height), brush, 10f);
            renderTarget.DrawText(name, textFormat, layoutRect, solidColorBrush);

            //int nx = 4;
            //int ny = 4;
            //for (int i = 0; i < nx - 1; i++)
            //    for (int j = 0; j < ny - 1; j++)
            //    {
            //        float x = (float)bounds.Width / (float)nx * (i + 1);
            //        float y = (float)bounds.Height / (float)ny * (j + 1);

            //        const int w = 10;
            //        renderTarget.DrawLine(new Vector2(x - w, y), new Vector2(x + w, y), brush, 1);
            //        renderTarget.DrawLine(new Vector2(x, y - w), new Vector2(x, y + w), brush, 1);
            //    }

            int nx = 4;
            int ny = 4;
            for (int i = 0; i < nx - 1; i++)
            {
                float x = (float)bounds.Width / (float)nx * (i + 1);
                renderTarget.DrawLine(new Vector2(x, 0), new Vector2(x, bounds.Height), brush, 1);
            }
            for (int i = 0; i < ny - 1; i++)
            {
                float y = (float)bounds.Height / (float)ny * (i + 1);
                renderTarget.DrawLine(new Vector2(0, y), new Vector2(bounds.Width, y), brush, 1);
            }
            renderTarget.EndDraw();

            brush.Dispose();
        }
예제 #8
0
            public void DrawHealth()
            {
                // Get the screen position
                var pos = ScreenPosition;

                // Calculate the outline rectangle
                var rect = new RectangleF((int) (pos.X + HealthBar.X), (int) (pos.Y + HealthBar.Y), (int) HealthBar.Width, (int) HealthBar.Height);

                // Draw the background
                Drawing.DrawLine(new Vector2(rect.Left, rect.Top + rect.Height / 2), new Vector2(rect.Right, rect.Top + rect.Height / 2), rect.Height, HealthBarBackgroundColor);

                // Get the health percent
                var percent = (Handle == null ? MaxHealth : Handle.Health) / MaxHealth;

                // Draw the percent lines
                var colors = HealthBarColors[MasterMind.IsSpectatorMode ? Team : (Team.IsAlly() ? GameObjectTeam.Order : GameObjectTeam.Chaos)];
                var max = rect.Height - HealthBarBorderWidth * 2;
                for (var i = 0; i < max; i++)
                {
                    var start = new Vector2(rect.Left + HealthBarBorderWidth, rect.Top + HealthBarBorderWidth + i);
                    Line.DrawLine(Color.FromArgb((byte) (colors.Item1.R + (colors.Item2.R - colors.Item1.R) * (i / max)),
                        (byte) (colors.Item1.G + (colors.Item2.G - colors.Item1.G) * (i / max)),
                        (byte) (colors.Item1.B + (colors.Item2.B - colors.Item1.B) * (i / max))), 1, start, start + new Vector2((int) ((rect.Width - HealthBarBorderWidth * 2) * percent), 0));
                }

                // Draw the separating lines
                var step = 1 / MaxHealth;
                var currentStep = step;
                for (var i = 0; i < MaxHealth - 1; i++)
                {
                    // Draw the separator
                    var start = new Vector2((float) (rect.Left + HealthBarBorderWidth + Math.Round(currentStep * (rect.Width - HealthBarBorderWidth * 2))), rect.Top);
                    Drawing.DrawLine(start, start + new Vector2(0, rect.Height), HealthBarPadding, Color.FromArgb(200, HealthBarBackgroundColor));

                    // Increase step
                    currentStep += step;
                }
            }
예제 #9
0
        public override void Render(CanvasRenderArguments args, SizeF Zoom)
        {
            lock (this)
            {
                // check if we have set the image
                if (mImageBitmap != null)
                {

                    var rect = new SharpDX.RectangleF(0, 0, Size.X, Size.Y);
                    // render the image
                    args.renderTarget.DrawBitmap(mImageBitmap, rect, 1, BitmapInterpolationMode.Linear);
                }
            }
        }
예제 #10
0
        public Result DrawStrikethrough(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref Strikethrough strikethrough, ComObject clientDrawingEffect)
        {
            var rect = new SharpDX.RectangleF(0, strikethrough.Offset, strikethrough.Width, strikethrough.Offset + strikethrough.Thickness);
            var rectangleGeometry = new RectangleGeometry(_d2DFactory, rect);
            var matrix = new Matrix3x2()
            {
                M11 = 1,
                M12 = 0,
                M21 = 0,
                M22 = 1,
                M31 = baselineOriginX,
                M32 = baselineOriginY
            };
            var transformedGeometry = new TransformedGeometry(_d2DFactory, rectangleGeometry, matrix);
            
            var  brushColor = (Color4)Color.Black;

            if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect)
                brushColor = (Color4)(clientDrawingEffect as ColorDrawingEffect).Color;

            var brush = new SolidColorBrush(_renderTarget, brushColor);

            _renderTarget.DrawGeometry(transformedGeometry, brush);
            _renderTarget.FillGeometry(transformedGeometry, brush);

            rectangleGeometry.Dispose();
            transformedGeometry.Dispose();
            brush.Dispose();

            return Result.Ok;
        }
예제 #11
0
            // Find a box that fits inside the MinMax quadrilateral.
            private static RectangleF GetMinMaxBox(List<Vector2> points)
            {
                // Find the MinMax quadrilateral.
                Vector2 ul = new Vector2(0, 0), ur = ul, ll = ul, lr = ul;
                GetMinMaxCorners(points, ref ul, ref ur, ref ll, ref lr);

                // Get the coordinates of a box that lies inside this quadrilateral.
                var xmin = ul.X;
                var ymin = ul.Y;

                var xmax = ur.X;
                if (ymin < ur.Y)
                {
                    ymin = ur.Y;
                }

                if (xmax > lr.X)
                {
                    xmax = lr.X;
                }
                var ymax = lr.Y;

                if (xmin < ll.X)
                {
                    xmin = ll.X;
                }
                if (ymax > ll.Y)
                {
                    ymax = ll.Y;
                }

                var result = new RectangleF(xmin, ymin, xmax - xmin, ymax - ymin);
                g_MinMaxBox = result; // For debugging.
                return result;
            }
예제 #12
0
 public override void Draw(RectangleF rectangle)
 {
     
 }
예제 #13
0
 public override void Draw(RectangleF rectangle)
 {
     if (Child != null && Child.Active)
     {
         Child.Draw();
         return;
     }
     rectangle.DrawFillRectangle(Color.FromArgb(180, Color.Black));
     Drawing.DrawText(rectangle.Center.Offset(-Text.Length * 8, -10), Color.White, Text, 10);
 }
        public Result DrawUnderline(object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref Underline underline, ComObject clientDrawingEffect)
        {
            var rect = new SharpDX.RectangleF(0, underline.Offset, underline.Width, underline.Offset + underline.Thickness);
            var rectangleGeometry = new RectangleGeometry(_d2DFactory, rect);
            var matrix = new Matrix3x2()
            {
                M11 = 1,
                M12 = 0,
                M21 = 0,
                M22 = 1,
                M31 = baselineOriginX,
                M32 = baselineOriginY
            };
            var transformedGeometry = new TransformedGeometry(_d2DFactory, rectangleGeometry, matrix);

            var brushColor = new Color4(1, 0, 0, 0);
            if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect)
                brushColor = (clientDrawingEffect as ColorDrawingEffect).Color;

            var brush = new SolidColorBrush(_renderTarget, brushColor);

            _renderTarget.DrawGeometry(transformedGeometry, brush);
            _renderTarget.FillGeometry(transformedGeometry, brush);

            rectangleGeometry.Dispose();
            transformedGeometry.Dispose();
            brush.Dispose();

            return SharpDX.Result.Ok;
        }
예제 #15
0
파일: TextElement.cs 프로젝트: fxbit/FxMath
        public override void Load( CanvasRenderArguments args )
        {
            if ( lineBrush != null && !lineBrush.IsDisposed )
                lineBrush.Dispose();

            if (DW_textFormat != null && !DW_textFormat.IsDisposed)
                DW_textFormat.Dispose();

            // init the lines brushs
            lineBrush = new SolidColorBrush( args.renderTarget, _FontColor );

            _TextFormat.fontCollection = args.WriteFactory.GetSystemFontCollection(false);
            // init the text format
            DW_textFormat = new SharpDX.DirectWrite.TextFormat( args.WriteFactory,
                                                            _TextFormat.familyName,
                                                            _TextFormat.fontCollection,
                                                            _TextFormat.weight,
                                                            _TextFormat.fontStyle,
                                                            _TextFormat.fontStretch,
                                                            _TextFormat.fontSize,
                                                            "en-us" );

            // get the size of the string
            SharpDX.DirectWrite.TextLayout textL= new SharpDX.DirectWrite.TextLayout( args.WriteFactory, Internal_String, DW_textFormat, 1500, 1500 );
            Size = new Vector.FxVector2f(textL.GetFontSize(0) * Internal_String.Length,
                                         textL.GetFontSize(0));
            textL.Dispose();

            // init text rectangle
            textRectangle = new RectangleF( 0, 0, Size.x, Size.y );
        }