Beispiel #1
0
        public void Dispose_Clone()
        {
            SolidBrush sb = new SolidBrush(Color.Transparent);

            sb.Dispose();
            sb.Clone();
        }
Beispiel #2
0
        public void Dispose_Clone()
        {
            SolidBrush sb = new SolidBrush(Color.Transparent);

            sb.Dispose();
            Assert.Throws <ArgumentException> (() => sb.Clone());
        }
Beispiel #3
0
        public void Clone_Disposed_ThrowsArgumentException()
        {
            var brush = new SolidBrush(Color.LavenderBlush);

            brush.Dispose();

            Assert.Throws <ArgumentException>(null, () => brush.Clone());
        }
Beispiel #4
0
        public void Clone_ImmutableColor_ReturnsMutableClone()
        {
            SolidBrush brush = Assert.IsType <SolidBrush>(Brushes.Bisque);
            SolidBrush clone = Assert.IsType <SolidBrush>(brush.Clone());

            clone.Color = SystemColors.AppWorkspace;
            Assert.Equal(SystemColors.AppWorkspace, clone.Color);
            Assert.Equal(Color.Bisque, brush.Color);
        }
Beispiel #5
0
 public void setSolidRect(Point start, Point finish, SolidBrush sb, Boolean fillMode)
 {
     rectC.X         = Math.Min(start.X, finish.X);
     rectC.Y         = Math.Min(start.Y, finish.Y);
     rectC.Width     = Math.Abs(start.X - finish.X);
     rectC.Height    = Math.Abs(start.Y - finish.Y);
     this.solidBrush = (SolidBrush)sb.Clone();
     this.fillMode   = fillMode;
 }
Beispiel #6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            zeichenfläche = CreateGraphics();

            stift  = new Pen(Color.Black);
            pinsel = new SolidBrush(Color.Blue);

            stiftKopie  = (Pen)(stift.Clone());
            pinselKopie = (SolidBrush)(pinsel.Clone());
        }
Beispiel #7
0
        /// <summary>
        /// Creates a new particle with the given parameters
        /// </summary>
        /// <param name="pos">Position vector to use</param>
        /// <param name="vel">Velocity vector to use</param>
        /// <param name="acc">Acceleration vector to use</param>
        /// <param name="color">Color to use</param>
        public Particle2D(Color color, Vector2D pos, Vector2D vel = null, Vector2D acc = null)
        {
            Position     = pos;
            Velocity     = vel ?? new Vector2D();
            Acceleration = acc ?? new Vector2D();
            Color        = color;

            Brush = new SolidBrush(Color);
            Pen   = new Pen((Brush)Brush.Clone(), 1);
        }
Beispiel #8
0
        public void Transparent()
        {
            SolidBrush sb = new SolidBrush(Color.Transparent);

            Assert.AreEqual(Color.Transparent, sb.Color, "Color");
            sb.Color = Color.Empty;
            SolidBrush clone = (SolidBrush)sb.Clone();

            sb.Dispose();
            Assert.AreEqual(Color.Empty.ToArgb(), clone.Color.ToArgb(), "Clone.Color");
        }
Beispiel #9
0
        /// <summary>
        /// Creates a new particle with the given parameters
        /// </summary>
        /// <param name="pos">Position vector to use</param>
        /// <param name="vel">Velocity vector to use</param>
        /// <param name="acc">Acceleration vector to use</param>
        public Particle2D(Vector2D pos, Vector2D vel = null, Vector2D acc = null)
        {
            Position     = pos;
            Velocity     = vel ?? new Vector2D();
            Acceleration = acc ?? new Vector2D();

            Color = Color.FromArgb(255, rng.Next(0, 255), rng.Next(0, 255), rng.Next(0, 255));

            Brush = new SolidBrush(Color);
            Pen   = new Pen((Brush)Brush.Clone(), 1);
        }
Beispiel #10
0
 public void Clone()
 {
     using (SolidBrush sb = new SolidBrush(Color.Transparent)) {
         // we still get a "named" color
         Assert.AreEqual(Color.Transparent, sb.Color, "Color");
         using (SolidBrush clone = (SolidBrush)sb.Clone()) {
             // but not after cloning the brush
             Assert.IsFalse(Color.Transparent.Equals(clone.Color), "Color-Clone-Unnamed");
             Assert.AreEqual(Color.Transparent.ToArgb(), clone.Color.ToArgb(), "Color-Clone-Argb");
         }
     }
 }
Beispiel #11
0
        public void Clone_Color_ReturnsClone()
        {
            var        brush = new SolidBrush(Color.PeachPuff);
            SolidBrush clone = Assert.IsType <SolidBrush>(brush.Clone());

            Assert.NotSame(clone, brush);
            Assert.Equal(brush.Color.ToArgb(), clone.Color.ToArgb());

            // Known colors are not preserved across clones.
            Assert.NotEqual(Color.PeachPuff, clone.Color);

            // Modifying the original brush should not modify the clone.
            brush.Color = Color.PapayaWhip;
            Assert.NotEqual(Color.PapayaWhip, clone.Color);
        }
Beispiel #12
0
        public override void Draw(XGraphics graphics, Palette palette, DrawingContext context)
        {
            var lineSegments = context.UseSmartLineSegments ? m_smartSegments : GetSegments();

            foreach (var lineSegment in lineSegments)
            {
                var pen        = palette.GetLinePen(context.Selected, context.Hover, Style == ConnectionStyle.Dashed);
                Pen specialPen = null;

                if (!context.Hover)
                {
                    if ((ConnectionColor != Color.Transparent) && !context.Selected)
                    {
                        specialPen       = (Pen)pen.Clone();
                        specialPen.Color = ConnectionColor;
                    }
                }

                if (!Settings.DebugDisableLineRendering)
                {
                    graphics.DrawLine(specialPen ?? pen, lineSegment.Start.ToPointF(), lineSegment.End.ToPointF());
                }
                var delta = lineSegment.Delta;
                if (Flow == ConnectionFlow.OneWay && delta.Length > Settings.ConnectionArrowSize)
                {
                    SolidBrush brush        = (SolidBrush)palette.GetLineBrush(context.Selected, context.Hover);
                    SolidBrush specialBrush = null;

                    if (!context.Hover)
                    {
                        if ((ConnectionColor != Color.Transparent) && !context.Selected)
                        {
                            specialBrush       = (SolidBrush)brush.Clone();
                            specialBrush.Color = ConnectionColor;
                        }
                    }

                    Drawing.DrawChevron(graphics, lineSegment.Mid.ToPointF(), (float)(Math.Atan2(delta.Y, delta.X) / Math.PI * 180), Settings.ConnectionArrowSize, specialBrush ?? brush);
                }
                context.LinesDrawn.Add(lineSegment);
            }

            Annotate(graphics, palette, lineSegments);
        }
Beispiel #13
0
        private void ClickHandler(object Sender, MouseEventArgs e)
        {
            if (e.X < 100)                      // GUI area
            {
                int index = (e.Y + 38) / 75 - 1;

                if (index == 0)
                {
                    fmOptions = new OptionForm();
                    fmOptions.Show(this);
                }
                else if (index > 0 && index <= shapeTypes.Length)
                {
                    selectedIndex = index;
                }
                else
                {
                    selectedIndex = -1;
                }
                Invalidate(new System.Drawing.Rectangle(0, 0, 100, Height));
            }
            else if (selectedShape != null)     // Editor Area
            {
                if (isDrawing)
                {
                    isDrawing = false;          // Finish drawing the shape

                    Pen   pen   = currentPen.Clone() as Pen;
                    Brush brush = currentBrush.Clone() as Brush;

                    var shapeParams = new object[4] {
                        pen, brush, mouseStart, e.Location
                    };
                    scene.Add(shapeCreators[selectedShape].Invoke(shapeParams) as Shape);
                    Invalidate(new System.Drawing.Rectangle(100, 0, Width, Height));
                }
                else
                {                               // Start drawing the shape
                    isDrawing  = true;
                    mouseStart = e.Location;
                }
            }
        }
Beispiel #14
0
        //Explanantion of g
        //g is a brush for an image
        //use g to draw on that image
        // that image is to draw on the window, passed down.
        // g goes from levelWindow(form spring), to the game, to the level, to the draw system, to the view
        // what you use to draw things to the image
        // g is a property(essentially the image)
        // every image has a graphics object associated with it, latched on it.
        public void Draw(Graphics g)
        {
            List <Entity> entityList = getApplicableEntities();

            //this is where all the entities are drawn, so modify this for depth
            foreach (View v in views)
            {
                v.Draw(g, entityList);
            }


            //Draw text flash
            if (level.sysManager != null && textState >= 0)
            {
                StringFormat centerFormat = new StringFormat();
                centerFormat.Alignment     = StringAlignment.Center;
                centerFormat.LineAlignment = StringAlignment.Center;
                PointF textPosition = new PointF(getMainView().displayX + getMainView().displayWidth / 2, getMainView().displayY + getMainView().displayHeight / 4);
                if (textShadow)
                {
                    float      shadowOffsetX    = 1.2f;
                    float      shadowOffsetY    = 1.0f;
                    int        maxShadowOpacity = 170;
                    SolidBrush shadowBrush      = ( SolidBrush )level.sysManager.drawSystem.textBrush.Clone();
                    shadowBrush.Color = Color.FromArgb(Math.Min(shadowBrush.Color.A, maxShadowOpacity), Color.Black);
                    g.DrawString(text, textFont, shadowBrush, textPosition.X + shadowOffsetX, textPosition.Y + shadowOffsetY, centerFormat);
                }
                g.DrawString(text, textFont, textBrush, textPosition.X, textPosition.Y, centerFormat);
            }

            //Draw Const Text
            if (level.sysManager != null && constMessages.Count > 0)
            {
                Dictionary <string, Color> msgs = level.sysManager.drawSystem.constMessages;
                foreach (string str in msgs.Keys)
                {
                    StringFormat centerFormat = new StringFormat();
                    centerFormat.Alignment     = StringAlignment.Center;
                    centerFormat.LineAlignment = StringAlignment.Center;
                    PointF     textPosition = new PointF(getMainView().displayX + getMainView().displayWidth / 2, getMainView().displayY + getMainView().displayHeight / 4);
                    SolidBrush brush        = new SolidBrush(msgs[str]);
                    if (textShadow)
                    {
                        float      shadowOffsetX    = 1.2f;
                        float      shadowOffsetY    = 1.0f;
                        int        maxShadowOpacity = 170;
                        SolidBrush shadowBrush      = ( SolidBrush )brush.Clone();
                        shadowBrush.Color = Color.FromArgb(Math.Min(shadowBrush.Color.A, maxShadowOpacity), Color.Black);
                        g.DrawString(str, textFont, shadowBrush, textPosition.X + shadowOffsetX, textPosition.Y + shadowOffsetY, centerFormat);
                    }
                    g.DrawString(str, textFont, brush, textPosition.X, textPosition.Y, centerFormat);
                }
            }

            //Draw fade
            if (level.sysManager != null && getFlashTime() > 0)
            {
                g.FillRectangle(level.sysManager.drawSystem.getFlashBrush(), new Rectangle(( int )(getMainView().displayX), ( int )(getMainView().displayY),
                                                                                           ( int )(getMainView().displayWidth), ( int )(getMainView().displayHeight)));
            }


            /*
             * //If you are in the level editor. Box the selected entities
             * //Ignore this unless you are playing with level editor
             * if (creatLev != null && creatLev.vars.selectedEntity != null)
             * {
             *  foreach (Entity e in creatLev.vars.allSelectedEntities)
             *  {
             *      PositionComponent posComp = (PositionComponent)creatLev.vars.selectedEntity.getComponent(GlobalVars.POSITION_COMPONENT_NAME);
             *      g.FillRectangle(selectedEntFillColor, posComp.x - posComp.width / 2, posComp.y - posComp.height / 2, posComp.width, posComp.height);
             *      g.DrawRectangle(selectedEntBorderColor, posComp.x - posComp.width / 2, posComp.y - posComp.height / 2, posComp.width, posComp.height);
             *  }
             * }
             * */
        }