Inheritance: MonoBehaviour
Exemple #1
0
        private void TitleInfoLayer_GDIPaint(GDIGraphics g)
        {
            Graphics gdiGraph = g.GdiGraph;

            gdiGraph.SmoothingMode     = SmoothingMode.HighQuality;// 指定高质量、低速度呈现。
            gdiGraph.TextRenderingHint = TextRenderingHint.AntiAlias;

            RectangleF rect  = new RectangleF(0, 0, titleInfoLayer.Width, titleInfoLayer.Height);
            Brush      brush = new SolidBrush(Color.FromArgb(153, 114, 49));

            DrawUtils.LimitBoxDraw(gdiGraph, titleInfo, font, brush, rect, true, 0);
        }
Exemple #2
0
    public static void DrawGrid(Texture2D texture, int tileWidth, int tileHeight, Color color)
    {
        for (int y = 0; y < texture.height; y += tileHeight)
        {
            DrawUtils.DrawLine(texture, 0, y, texture.width, y, color);
        }

        for (int x = 0; x < texture.width; x += tileWidth)
        {
            DrawUtils.DrawLine(texture, x, 0, x, texture.height, color);
        }
    }
        public StrokeProps(Stroke stroke)
        {
            InitializeComponent();
            // -------------------------------------------------------------------
            cbPattern.Items.Clear();
            cbPattern.Items.AddRange(DrawUtils.GetPenPatternNames()); // получение всех имён доступных типов линий
            cbPattern.SelectedIndex = 1;
            // -------------------------------------------------------------------
            cbWidth.Items.Clear();
            for (var i = 1; i < 61; i++)
            {
                cbWidth.Items.Add(i.ToString("0"));
            }
            // -------------------------------------------------------------------
            cbColor.Items.Clear();
            cbColor.Items.AddRange(DrawUtils.GetAllColorNames()); // получение всех имён доступных цветов
            cbColor.Items.Add("Выбор цвета...");                  // добавление пункта выбора цвета
            cbColor.Text = DrawUtils.GetColorNameFromIndex(_lastColorIndex);
            // -------------------------------------------------------------------
            _stroke = (Stroke)stroke.Clone();
            // -------------------------------
            var index = DrawUtils.ColorToIndex(_stroke.Color);

            if (index < 0)
            {
                DrawUtils.AddCustomColor(_stroke.Color);
                cbColor.Items.Insert(cbColor.Items.Count - 1, "Мой цвет");
                index = cbColor.Items.Count - 2;
            }
            if (index >= 0)
            {
                cbColor.SelectedIndex = index;
            }
            // -------------------------------
            tbTrasparent.Value = 255 - _stroke.Alpha;
            lbTrasparent.Text  = String.Format("{0} %", (int)(tbTrasparent.Value / 255.0 * 100.0));
            // -------------------------------
            cbWidth.SelectedIndex = (int)_stroke.Width - 1;
            // -------------------------------
            if (_stroke.DashStyle == DashStyle.Custom)
            {
                cbPattern.SelectedIndex = 0;
            }
            else
            {
                cbPattern.SelectedIndex = (int)_stroke.DashStyle + 1;
            }
            // -------------------------------------------------------------------
            cbLineJoin.Items.Clear();
            // получение всех имён доступных типов соединений линий
            cbLineJoin.Items.AddRange(DrawUtils.GetLineJoinNames());
            cbLineJoin.SelectedIndex = (int)_stroke.LineJoin;
        }
Exemple #4
0
        void draw()
        {
            Graphics g = gdi.Graphics;
            float    w = Width;
            float    h = Height;

            g.Clear(Color.Transparent);
            g.DrawImage(bg, 0, 0, w, h);
            drawMarquee();
            g.DrawImage(marqueeSurface, conMarquee.Location);
            DrawUtils.drawRotateImg(g, btn, rotate, btnExpand.Left + btnExpand.Width / 2, btnExpand.Top + btnExpand.Height / 2, btnExpand.Width, btnExpand.Height);
        }
Exemple #5
0
        private void ScVxDate_GDIPaint(GDIGraphics g)
        {
            Graphics graphis = g.GdiGraph;

            graphis.SmoothingMode     = SmoothingMode.HighQuality;
            graphis.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            RectangleF rect = new RectangleF(0, 0, Width - 1, Height - 1);

            //
            Brush brush = new SolidBrush(bgColor);

            DrawUtils.FillRoundRectangle(graphis, brush, rect, 6);

            Pen pen = new Pen(txtColor);

            DrawUtils.DrawRoundRectangle(graphis, pen, rect, 6);

            //
            brush = new SolidBrush(Color.FromArgb(105, 163, 175));

            rect = mainTable.GetCellContentRect(0, 0);
            string d = dt.ToString("yyyy-MM-dd");

            DrawUtils.LimitBoxDraw(graphis, d, font, brush, rect, true, 0);

            //
            rect = mainTable.GetCellContentRect(0, 1);
            d    = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(DateTime.Now.DayOfWeek);
            DrawUtils.LimitBoxDraw(graphis, d, font, brush, rect, true, 0);


            //
            rect = mainTable.GetCellContentRect(0, 2);
            d    = DateTime.Now.ToLongTimeString().ToString();
            DrawUtils.LimitBoxDraw(graphis, d, font, Brushes.WhiteSmoke, rect, true, 0);

            brush.Dispose();

            //
            LinePos linePos = mainTable.GetColLinePos(0);

            linePos.start = new PointF((int)linePos.start.X, (int)(linePos.start.Y + Height / 7));
            linePos.end   = new PointF((int)linePos.end.X, (int)(linePos.end.Y - Height / 7));
            graphis.DrawLine(pen, linePos.start, linePos.end);

            //
            linePos       = mainTable.GetColLinePos(1);
            linePos.start = new PointF((int)linePos.start.X, (int)(linePos.start.Y + Height / 7));
            linePos.end   = new PointF((int)linePos.end.X, (int)(linePos.end.Y - Height / 7));
            graphis.DrawLine(pen, linePos.start, linePos.end);
        }
Exemple #6
0
 private void DrawRectBorder(Graphics g, RectangleF rect)
 {
     #region Внешняя рамка
     DrawUtils.DrawBorder(g, rect, SystemColors.ButtonHighlight, SystemColors.ButtonShadow, 1);
     rect.Inflate(-1, -1);
     using (Pen pen = new Pen(SystemColors.ButtonFace, 2))
         g.DrawRectangle(pen, Rectangle.Ceiling(rect));
     rect.Inflate(-1, -1); // толщина панели
     #endregion
     #region Внутренняя рамка
     DrawUtils.DrawBorder(g, rect, SystemColors.ButtonShadow, SystemColors.ButtonHighlight, 1);
     #endregion
 }
Exemple #7
0
        protected internal override void DoDraw(SvgDrawContext context)
        {
            PdfCanvas cv = context.GetCurrentCanvas();

            cv.WriteLiteral("% ellipse\n");
            if (SetParameters())
            {
                // Use double type locally to have better precision of the result after applying arithmetic operations
                cv.MoveTo((double)cx + (double)rx, cy);
                DrawUtils.Arc((double)cx - (double)rx, (double)cy - (double)ry, (double)cx + (double)rx, (double)cy + (double
                                                                                                                       )ry, 0, 360, cv);
            }
        }
Exemple #8
0
        private void ScTextBox_GDIPaint(GDIGraphics g)
        {
            Graphics graphis = g.GdiGraph;

            graphis.SmoothingMode     = SmoothingMode.HighQuality;
            graphis.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;


            RectangleF rect = new RectangleF(0, 0, (float)Math.Ceiling(Width - 1), (float)Math.Ceiling(Height - 1));
            Pen        pen  = new Pen(Color.FromArgb(255, 191, 152, 90), 1f);

            DrawUtils.DrawRoundRectangle(graphis, pen, rect, 4);
        }
Exemple #9
0
        public void drawMe()
        {
            // Generate sky plane
            GL.Disable(EnableCap.Lighting);
            GL.Color3(Color.Aqua);
            GL.Begin(BeginMode.Polygon);
            GL.Normal3(0.0, -1.0, 0.0);
            GL.Vertex3(-7000, 102.0, -7000);
            GL.Vertex3(7000, 102.0, -7000);
            GL.Vertex3(7000, 102.0, 7000);
            GL.Vertex3(-7000, 102.0, 7000);
            GL.End();

            GL.Enable(EnableCap.Lighting);
            GL.Enable(EnableCap.Light0);

            GL.Enable(EnableCap.ColorMaterial);
            GL.Enable(EnableCap.CullFace);

            GL.Light(LightName.Light0, LightParameter.Position, new Vector4(200.0f, 200.0f, 200.0f, 1.0f));
            GL.Light(LightName.Light0, LightParameter.Ambient, new Vector4(0.5f, 0.5f, 0.5f, 1.0f));

            // Generate ground plane
            GL.Color3(Color.ForestGreen);
            GL.Begin(BeginMode.Polygon);
            GL.Normal3(0.0, 1.0, 0.0);
            GL.Vertex3(-7000, 0.0, -7000);
            GL.Vertex3(-7000, 0.0, 7000);
            GL.Vertex3(7000, 0.0, 7000);
            GL.Vertex3(7000, 0.0, -7000);
            GL.End();

            Vector3 boidHeight    = new Vector3(0, 40, 0);
            Vector3 boidLowHeight = new Vector3(0, 6, 0);

            for (double i = 20; i <= worldSize; i += 20)
            {
                DrawUtils.drawCircle(i, Color.Black);

                /*GL.PushMatrix();
                 * GL.Translate(boidHeight);
                 * DrawUtils.drawCircle(i, Color.Red);
                 * GL.PopMatrix();*/
            }
            DrawUtils.drawCircle(worldSize, Color.Black);

            foreach (Thing thing in things)
            {
                thing.drawMe();
            }
        }
Exemple #10
0
        private void DrawMirrors(Bitmap image, Settings settings)
        {
            double     b = settings.Bounds;
            ImageSpace i = new ImageSpace(settings.Width, settings.Height);

            i.XMin = -b; i.XMax = b;
            i.YMin = -b; i.YMax = b;

            float scale = 2;

            List <Sphere> toDraw = new List <Sphere>();

            toDraw.AddRange(settings.Mirrors);
            //toDraw.Add( AlteredFacetForTrueApparent2DTilings( settings.Mirrors ) );

            using (Graphics g = Graphics.FromImage(image))
                using (Pen p = new Pen(Color.Red, scale * 3.0f))
                    //using( Pen p2 = new Pen( Color.FromArgb( 255, 255, 214, 0 ), 3.0f ) )
                    using (Pen p2 = new Pen(Color.Orange, scale * 3.0f))
                        using (Pen p3 = new Pen(Color.Orange, scale * 3.0f))
                            for (int m = 0; m < toDraw.Count; m++)
                            {
                                Sphere s = toDraw[m];
                                Circle c = H3Models.UHS.IdealCircle(s);         // XXX - not correct
                                if (c.IsLine)
                                {
                                    DrawUtils.DrawLine(-c.P2 * 25, c.P2 * 25, g, i, p);         // XXX - not general.
                                }
                                else
                                {
                                    Sphere temp = H3Models.BallToUHS(s);
                                    DrawUtils.DrawCircle(new Circle {
                                        Center = temp.Center, Radius = temp.Radius
                                    }, g, i, m == 0 ? p2 : m == 4 ? p3 : p);
                                }

                                /* // iii
                                 * Circle c = new Circle();
                                 * c.Radius = Math.Sqrt( 2 );
                                 * c.Center = new Vector3D( 1, Math.Sqrt( 2 ) );
                                 * DrawUtils.DrawCircle( c, g, i, p );
                                 * c.Center = new Vector3D( -1, Math.Sqrt( 2 ) );
                                 * DrawUtils.DrawCircle( c, g, i, p );
                                 * c.Center = new Vector3D( Math.Sqrt( 2 ) - 1, 0 );
                                 * c.Radius = 2 - Math.Sqrt( 2 );
                                 * DrawUtils.DrawCircle( c, g, i, p );
                                 *
                                 * DrawUtils.DrawLine( new Vector3D( -2, 0 ), new Vector3D( 2, 0 ), g, i, p );
                                 */
                            }
        }
Exemple #11
0
        public PaintGunMod(PaintGun_GameSession session) : base(MOD_NAME, session)
        {
            string msg = "### PaintGun v23";

            VRage.Utils.MyLog.Default.WriteLineAndConsole(msg);
            Log.Info(msg);

            session.SetUpdateOrder(MyUpdateOrder.AfterSimulation); // define what update types the modAPI session comp should trigger

            DisablePaintGunVanillaShoot();

            // Systems
            Caches            = new Caches(this);
            Constants         = new Constants(this);
            PlayerHandler     = new PlayerHandler(this);
            NetworkLibHandler = new NetworkLibHandler(this);

            if (IsPlayer)
            {
                TextAPI    = new TextAPI(this);
                DrawUtils  = new DrawUtils(this);
                GameConfig = new GameConfig(this);
            }

            // Features
            Palette  = new Palette(this);
            Painting = new Painting(this);

            if (IsPlayer)
            {
                CheckPlayerField      = new CheckPlayerField(this);
                Settings              = new Settings(this);
                PaletteInputHandler   = new PaletteInputHandler(this);
                PaletteScheduledSync  = new PaletteScheduledSync(this);
                HUDSounds             = new HUDSounds(this);
                LocalToolHandler      = new LocalToolHandler(this);
                LocalToolDescription  = new LocalToolDescription(this);
                SelectionGUI          = new SelectionGUI(this);
                ToolHandler           = new ToolHandler(this);
                ChatCommands          = new ChatCommands(this);
                Notifications         = new Notifications(this);
                PaletteHUD            = new PaletteHUD(this);
                ColorPickerGUIWarning = new ColorPickerGUIWarning(this);
                ConfigMenuHandler     = new ConfigMenuHandler(this);
            }

            if (Constants.EnableTestComponent)
            {
                TestComp = new TestComp(this);
            }
        }
 /// <inheritdoc/>
 public override void Draw(FRPaintEventArgs e)
 {
   base.Draw(e);
   if (Control.Width > 0 && Control.Height > 0)
   {
     foreach (Control c in pnPanel.Controls)
     {
       using (Bitmap bmp = DrawUtils.DrawToBitmap(c, true))
       {
         e.Graphics.DrawImage(bmp, (int)AbsLeft + c.Left, (int)AbsTop + c.Top);
       }
     }
   }
 }
Exemple #13
0
        private void ScVxSearchAndTitle_GDIPaint(GDIGraphics g)
        {
            Graphics graphis = g.GdiGraph;

            graphis.SmoothingMode     = SmoothingMode.HighQuality;
            graphis.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            RectangleF rect = mainTable.GetCellContentRect(0, 0);

            Brush brush = new SolidBrush(titleColor);

            DrawUtils.LimitBoxDraw(graphis, title, titlefont, brush, rect, false, true, 0);
            brush.Dispose();
        }
        private static void ShowInstallingButton()
        {
            var buttonWidth = 250;

            GUILayout.Space(5);
            using (new AppCenterGuiFieldHelper.UnityHorizontal(AppCenterEditorHelper.uiStyle.GetStyle("gpStyleEmpty")))
            {
                GUILayout.FlexibleSpace();
                var image = DrawUtils.RotateImage(AssetDatabase.LoadAssetAtPath("Assets/AppCenterEditorExtensions/Editor/UI/Images/wheel.png", typeof(Texture2D)) as Texture2D, angle++);
                GUILayout.Button(new GUIContent("  SDK is installing", image), AppCenterEditorHelper.uiStyle.GetStyle("Button"), GUILayout.MaxWidth(buttonWidth), GUILayout.MinHeight(32));
                GUILayout.FlexibleSpace();
            }
            GUILayout.Space(5);
        }
Exemple #15
0
        private void OkBtn_GDIPaint(GDIGraphics g)
        {
            Graphics graphis = g.GdiGraph;

            graphis.SmoothingMode = SmoothingMode.HighQuality;

            RectangleF rect = new RectangleF(0, 0, okBtn.Width, okBtn.Height);

            Brush brush = new SolidBrush(okBtnColor);

            graphis.FillRectangle(brush, rect);

            DrawUtils.LimitBoxDraw(graphis, okBtnText, okBtnFont, Brushes.WhiteSmoke, rect, DrawPositionType.Center, true, false, 0);
        }
Exemple #16
0
        public RectangleF SizedBoundsRect(IDictionary <string, object> props)
        {
            PointF        location  = new PointF((float)props["Left"], (float)props["Top"]);
            SizeF         size      = new SizeF((float)props["Width"], (float)props["Height"]);
            RectangleF    rect      = new RectangleF(location, size);
            int           spinvalve = (int)props["SpinValve"];
            List <PointF> points    = new List <PointF>();

            DrawUtils.AddPointsRange(points, new PointF[4]
            {
                new PointF(rect.X, rect.Y),
                new PointF(rect.X + rect.Width, rect.Y + rect.Height),
                new PointF(rect.X + rect.Width, rect.Y),
                new PointF(rect.X, rect.Y + rect.Height)
            });
            float[] angles = new float[4] {
                0, 90, -45, 45
            };
            DrawUtils.Rotate(points, angles[spinvalve], rect);
            float minX, maxX, minY, maxY;

            minX = rect.Right;
            minY = rect.Bottom;
            maxX = rect.Left;
            maxY = rect.Top;
            foreach (PointF pnt in points)
            {
                if (minX > pnt.X)
                {
                    minX = pnt.X;
                }
                if (minY > pnt.Y)
                {
                    minY = pnt.Y;
                }
                if (maxX < pnt.X)
                {
                    maxX = pnt.X;
                }
                if (maxY < pnt.Y)
                {
                    maxY = pnt.Y;
                }
            }
            rect.X    = minX;
            rect.Y    = minY;
            rect.Size = new SizeF(maxX - minX, maxY - minY);
            return(rect);
        }
Exemple #17
0
        private void tbTest_Scroll(object sender, EventArgs e)
        {
            lbTest.Text = String.Format("{0} %", tbTest.Value);
            decimal value    = tbTest.Value;
            decimal pveuhi   = (decimal)drw.Props["PVEUHi"];
            decimal pveulo   = (decimal)drw.Props["PVEULo"];
            int     formatpv = (int)drw.Props["FormatPV"];

            drw.Props["PVText"]    = DrawUtils.Float((pveuhi - pveulo) * value / 100m + pveulo, formatpv);
            drw.Props["PVPercent"] = value;
            if (updater != null)
            {
                updater(drw, UpdateKind.UpdateAfter);
            }
        }
Exemple #18
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            Texture2D tex = mod.GetTexture("Projectiles/Justice4");

            //spriteBatch.End();
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.EffectMatrix);
            DrawUtils.AnotherDraw(BlendState.NonPremultiplied);
            Rectangle rectangle = new Rectangle(0, 256 * projectile.frame, 256, 256);

            spriteBatch.Draw(tex, projectile.Center - Main.screenPosition, rectangle, Color.White * projectile.Opacity, 0, rectangle.Size() / 2, projectile.scale * 4f, SpriteEffects.None, 0);
            //spriteBatch.End();
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix);
            DrawUtils.AnotherDraw(BlendState.AlphaBlend);
            return(false);
        }
Exemple #19
0
        public Form1()
        {
            InitializeComponent();

            _inProgres       = false;
            _obiectInProgres = null;
            _obiectInMove    = null;
            _linieInProgres  = null;

            _isNearInitialPoint = false;

            _objects = new List <Obiect>();

            _drawUtils = new DrawUtils(pictureBox1);
        }
Exemple #20
0
    public static void colorComboSelectedIndexChanged(object sender, ref int LastColorIndex,
                                                      ChangeCommitted changed)
    {
        ComboBox cbox = (ComboBox)sender;

        if (cbox.SelectedIndex == cbox.Items.Count - 1)
        {
            try
            {
                int selIndex;
                using (ColorDialog dlgSelectColor = new ColorDialog())
                {
                    dlgSelectColor.Color = DrawUtils.ColorFromIndex(LastColorIndex);
                    selIndex             = LastColorIndex;
                    if (dlgSelectColor.ShowDialog() == DialogResult.OK)
                    {
                        Color selColor = dlgSelectColor.Color;
                        if (!DrawUtils.FindColor(selColor))
                        {
                            DrawUtils.AddCustomColor(selColor);
                            dlgSelectColor.CustomColors = DrawUtils.GetCustomColors();
                            cbox.Items.Insert(cbox.Items.Count - 1, "Мой цвет");
                            cbox.SelectedIndex = cbox.Items.Count - 2;
                        }
                        else
                        {
                            cbox.SelectedIndex = DrawUtils.ColorToIndex(selColor);
                        }
                        if (changed != null)
                        {
                            changed(sender, new EventArgs());
                        }
                    }
                    else
                    {
                        cbox.SelectedIndex = selIndex;
                    }
                }
            }
            catch
            { }
        }
        else
        {
            LastColorIndex = cbox.SelectedIndex;
            cbox.Refresh();
        }
    }
Exemple #21
0
        private void cbPattern_DrawItem(object sender, DrawItemEventArgs e)
        {
            ComboBox cb = (ComboBox)sender;
            Graphics g  = e.Graphics;

            // Draw the background of the item.
            e.DrawBackground();
            Rectangle largerect = new Rectangle(e.Bounds.X, e.Bounds.Top,
                                                e.Bounds.Width - 1, e.Bounds.Height - 1);

            try
            {
                switch (DrawUtils.FillModeFromIndex(e.Index))
                {
                case Draws.Plugins.FillMode.None: ShowItemText(e, cb, g, largerect); break;

                case Draws.Plugins.FillMode.Solid: ShowItemText(e, cb, g, largerect); break;

                case Draws.Plugins.FillMode.LinearGradient:
                    using (LinearGradientBrush brush =
                               new LinearGradientBrush(largerect,
                                                       (Color)drw.Props["PatternColor"], (Color)drw.Props["BackColor"],
                                                       DrawUtils.LinearGradientModeFromIndex(e.Index)))
                    {
                        g.FillRectangle(brush, largerect);
                    }
                    break;

                case Draws.Plugins.FillMode.Hatch:
                    using (HatchBrush brush =
                               new HatchBrush(DrawUtils.HatchStyleFromIndex(e.Index),
                                              (Color)drw.Props["PatternColor"], (Color)drw.Props["BackColor"]))
                    {
                        g.FillRectangle(brush, largerect);
                    }
                    break;
                }
            }
            catch //(Exception ex)
            {
                g.FillRectangle(Brushes.White, largerect);
                g.DrawRectangle(Pens.Red, largerect.X, largerect.Y, largerect.Width, largerect.Height);
                //Console.WriteLine("{0} Exception caught.", ex);
                //throw;
            }
            // Draw the focus rectangle if the mouse hovers over an item.
            e.DrawFocusRectangle();
        }
Exemple #22
0
 public void Draw(List <Actor> actors, List <UseCase> useCases)
 {
     for (int i = 0; i < listOfRelation.Count; i++)
     {
         for (int j = 0; j < actors.Count; j++)
         {
             for (int k = 0; k < useCases.Count; k++)
             {
                 if (listOfRelation[i].IsRelation(actors[j].ID, useCases[k].ID))
                 {
                     DrawUtils.DrawNodeCurve(actors[j].transform, useCases[k].transform, 0, 30);
                 }
             }
         }
     }
 }
Exemple #23
0
    public static void colorComboSelectInList(object sender, Color color)
    {
        ComboBox cbox  = (ComboBox)sender;
        int      Index = DrawUtils.ColorToIndex(color);

        if (Index < 0)
        {
            DrawUtils.AddCustomColor(color);
            cbox.Items.Insert(cbox.Items.Count - 1, "Мой цвет");
            Index = cbox.Items.Count - 2;
        }
        if (Index >= 0)
        {
            cbox.SelectedIndex = Index;
        }
    }
Exemple #24
0
        public override bool PreDraw(SpriteBatch spriteBatch, Color lightColor)
        {
            //spriteBatch.End();
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.EffectMatrix);
            DrawUtils.AnotherDraw(BlendState.NonPremultiplied);
            Texture2D tex1 = mod.GetTexture("Projectiles/EyeBullet1");
            Texture2D tex2 = mod.GetTexture("Projectiles/EyeBullet2");
            Texture2D tex3 = mod.GetTexture("Projectiles/EyeBullet3");
            float     ops1, ops2;
            bool      IsScale = false;

            if (projectile.ai[0] < 0)
            {
                IsScale = true;
                ops1    = 0;
                ops2    = 0;
            }
            else if (projectile.ai[0] < 30)
            {
                IsScale = true;
                ops1    = projectile.ai[0] / 30;
                ops2    = 0;
            }
            else
            {
                ops1 = (60 - projectile.ai[0]) / 30;
                ops2 = (projectile.ai[0] - 30) / 30;
            }
            if (IsScale)
            {
                spriteBatch.Draw(tex1, projectile.Center - Main.screenPosition, null, Color.White, projectile.rotation, tex1.Size() / 2, projectile.scale * 0.3f * (ExtraAlpha / 30f), SpriteEffects.None, 0);
            }
            else
            {
                spriteBatch.Draw(tex1, projectile.Center - Main.screenPosition, null, Color.White * ops1, projectile.rotation, tex1.Size() / 2, projectile.scale * 0.3f, SpriteEffects.None, 0);
            }
            spriteBatch.Draw(tex2, projectile.Center - Main.screenPosition, null, Color.White * ops2, projectile.rotation, tex2.Size() / 2, projectile.scale * 0.3f, SpriteEffects.None, 0);
            DrawUtils.AnotherDraw(BlendState.Additive);
            //spriteBatch.End();
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.PointWrap, DepthStencilState.Default, RasterizerState.CullNone, null, Main.GameViewMatrix.EffectMatrix);
            spriteBatch.Draw(tex3, projectile.Center - Main.screenPosition, null, Color.White * ops2 * 0.6f, 0, tex3.Size() / 2, projectile.scale * 0.45f, SpriteEffects.None, 0);

            DrawUtils.AnotherDraw(BlendState.AlphaBlend);
            //spriteBatch.End();
            //spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, Main.DefaultSamplerState, DepthStencilState.None, Main.instance.Rasterizer, null, Main.GameViewMatrix.EffectMatrix);
            return(false);
        }
Exemple #25
0
        void DrawString(Graphics g)
        {
            Graphics gdiGraph = g;

            gdiGraph.SmoothingMode     = SmoothingMode.HighQuality;// 指定高质量、低速度呈现。
            gdiGraph.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;

            float      msgHintsWidth = 0;
            RectangleF rect          = new RectangleF(0, 0, Width, Height);

            DrawItemRect(gdiGraph, rect);

            if (useMsgHints && msgHintsCount > 0)
            {
                msgHintsWidth = msgHintsRect.Width / 1.5f;
            }

            //
            rect = new RectangleF(gradientSize, 0, Width - gradientSize * 2 - msgHintsWidth, Height);
            Font font = new Font("微软雅黑", 10);

            System.Drawing.Brush brush2;
            if (this == scTabHead.GetSelectedItem())
            {
                brush2 = new SolidBrush(selectFontColor);
            }
            else
            {
                brush2 = new SolidBrush(normalFontColor);
            }

            DrawUtils.LimitBoxDraw(gdiGraph, Name, font, brush2, rect, true, 0);


            if (useMsgHints && msgHintsCount > 0)
            {
                msgHintsWidth = msgHintsRect.Width;
                float x = Width - msgHintsRect.Width - gradientSize - 5;
                rect = new RectangleF(x, 4, msgHintsRect.Width, msgHintsRect.Height);

                SolidBrush brush = new SolidBrush(Color.FromArgb(200, 255, 0, 0));
                gdiGraph.FillEllipse(brush, rect);

                DrawUtils.LimitBoxDraw(gdiGraph, msgHintsCount.ToString(), font, Brushes.White, rect, true, 0);
            }
        }
Exemple #26
0
        protected override GraphicsPath CreateHitGeometryByGDIPLUS(GDIGraphics g)
        {
            float r = BarHeight / 3;

            GraphicsPath path = DrawUtils.CreateRoundedRectanglePath(barRect, r);

            path.FillMode = FillMode.Winding;

            for (int i = 0; i < progressNodeRects.Count(); i++)
            {
                path.StartFigure();
                path.AddEllipse(progressNodeRects[i]);
                path.CloseFigure();
            }

            return(path);
        }
        /// <summary>
        /// Draw the entity.
        /// </summary>
        /// <param name="spriteBatch">Sprite batch to draw on.</param>
        override protected void DrawEntity(SpriteBatch spriteBatch)
        {
            // draw panel itself, but only if got style
            if (_skin != PanelSkin.None)
            {
                // get texture based on skin
                Texture2D   texture   = Resources.PanelTextures[(int)_skin];
                TextureData data      = Resources.PanelData[(int)_skin];
                Vector2     frameSize = new Vector2(data.FrameWidth, data.FrameHeight);

                // draw panel
                DrawUtils.DrawSurface(spriteBatch, texture, _destRect, frameSize, 1f, FillColor, Scale);
            }

            // call base draw function
            base.DrawEntity(spriteBatch);
        }
Exemple #28
0
 private void cbxPrintMode_DrawItem(object sender, DrawItemEventArgs e)
 {
     if (e.Index >= 0)
     {
         e.DrawBackground();
         Graphics g        = e.Graphics;
         string[] resNames = new string[] { "defaultmode.png", "splitmode.png", "scalemode.png" };
         using (Bitmap bmp = ResourceLoader.GetBitmap(resNames[e.Index]))
         {
             bmp.MakeTransparent(Color.Silver);
             g.DrawImage(bmp, e.Bounds.X + 3, e.Bounds.Y + 3);
         }
         SizeF sz = DrawUtils.MeasureString("Wg");
         g.DrawString((string)cbxPrintMode.Items[e.Index], cbxPrintMode.Font, SystemBrushes.WindowText,
                      e.Bounds.X + 70, e.Bounds.Y + (e.Bounds.Height - sz.Height) / 2);
     }
 }
Exemple #29
0
 private void tsbRibberColor_Click(object sender, EventArgs e)
 {
     ribberColorDialog.Color = RibberTool.RibberStyle.Color;
     if (ribberColorDialog.ShowDialog() == DialogResult.OK)
     {
         Color selColor = ribberColorDialog.Color;
         foreach (var item in ribberColorDialog.CustomColors)
         {
             if (item != 16777215 && !DrawUtils.FindColor(Color.FromArgb(item)))
             {
                 DrawUtils.AddCustomColor(selColor);
             }
         }
         RibberTool.RibberStyle.Color = selColor;
         UpdateRibberToolColorImage();
     }
 }
Exemple #30
0
 private void tsbPencilColor_ButtonClick(object sender, EventArgs e)
 {
     penсilColorDialog.Color = PenTool.PenStyle.Color;
     if (penсilColorDialog.ShowDialog() == DialogResult.OK)
     {
         Color selColor = penсilColorDialog.Color;
         foreach (var item in penсilColorDialog.CustomColors)
         {
             if (item != 16777215 && !DrawUtils.FindColor(Color.FromArgb(item)))
             {
                 DrawUtils.AddCustomColor(selColor);
             }
         }
         PenTool.PenStyle.Color = selColor;
         UpdatePenToolColorImage();
     }
 }
Exemple #31
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            worldCamera = new Cameras.QuaternionCameraComponent(this);
            float fov = 9.0f/16.0f*this.GraphicsDevice.Viewport.AspectRatio*90.0f;
            worldCamera.Perspective(fov, 16.0f / 9.0f, 0.5f, 20000.0f);
            worldCamera.Position = new Vector3(0, -370, 160);
            worldCamera.LookAt(new Vector3(0.0f, 0.0f, 0.0f));
            worldCamera.ClickAndDragMouseRotation = true;
            worldCamera.CurrentBehavior = Cameras.QuaternionCamera.Behavior.AimMode;
            worldCamera.MovementSpeed = 100.0f;
            Components.Add(worldCamera);

            originalWorldCamera = worldCamera;
            bulletViewCamera = new PhysicsCamera(this);
            bulletViewCamera.Perspective(fov, 16.0f / 9.0f, 0.5f, 20000.0f);

            wireframeRasterizerState = new RasterizerState();
            wireframeRasterizerState.FillMode = FillMode.WireFrame;

            solidRasterizerState = new RasterizerState();
            solidRasterizerState.FillMode = FillMode.Solid;

            playerColors = new List<Vector3>();
            playerColors.Add(new Vector3(1.0f, 0.0f, 0.0f));
            playerColors.Add(new Vector3(0.0f, 1.0f, 0.0f));
            playerColors.Add(new Vector3(0.0f, 0.0f, 1.0f));
            playerColors.Add(new Vector3(1.0f, 1.0f, 0.0f));
            playerColors.Add(new Vector3(0.0f, 1.0f, 1.0f));
            playerColors.Add(new Vector3(1.0f, 0.0f, 1.0f));
            playerColors.Add(new Vector3(1.0f, 1.0f, 1.0f));
            playerColors.Add(new Vector3(1.0f, 0.5f, 0.5f));
            playerColors.Add(new Vector3(0.5f, 1.0f, 0.5f));
            playerColors.Add(new Vector3(0.5f, 0.5f, 1.0f));

            terrain = new Terrain.Terrain(this);
            Components.Add(terrain);

            physicsEngine = new PhysicsEngine(this, IntegrationMethod.RungeKutta4);
            Components.Add(physicsEngine);

            mainHUD = new HUD(this);
            Components.Add(mainHUD);

            drawUtils = new DrawUtils(this);
            Components.Add(drawUtils);

            tanks = new Tank[numPlayers];
            players = new Player[numPlayers];

            for (int i = 0; i < numPlayers; i++)
            {
                players[i] = new Player(this);
                tanks[i] = new Tank(this, Vector3.Zero, i, playerColors.ElementAt(i));
            }

            numPlayersAlive = numPlayers;

            currentTank = tanks[currentPlayer];

            weaponManager = new WeaponManager(this);

            bulletManager = new BulletManager(this);
            Components.Add(bulletManager);

            base.Initialize();
        }