Exemple #1
0
        public TileTemplate4X2()
        {
            var tileBorders = new[]
            {
                    new TileTemplateBorder(
                        Direction.Top,                                      // Top border:       left, right
                        new[] { 0, 1 },                                     // Junction points color indexes
                        new[] { new Point(-20, -40), new Point(20, -40) }), // Junction points coordinates for drawing

                    new TileTemplateBorder(
                        Direction.Right,                                    // Right border:     top, bottom
                        new[] { 2, 3 },                                     // Junction points color indexes
                        new[] { new Point(40, -20), new Point(40, 20) }),   // Junction points coordinates for drawing

                    new TileTemplateBorder(
                        Direction.Bottom,                                   // Bottom border:    righ, left
                        new[] { 0, 3 },                                     // Junction points color indexes
                        new[] { new Point(20, 40), new Point(-20, 40) }),   // Junction points coordinates for drawing

                    new TileTemplateBorder(
                        Direction.Left,                                     // Left border:      bottop, top
                        new[] { 1, 2 },                                     // Junction points color indexes
                        new[] { new Point(-40, 20), new Point(-40, -20) })  // Junction points coordinates for drawing
                };

            var labelRectangle = new Rectangle(-40, -40, 20, 20);

            var frameRectangle = new Rectangle(-40, -40, 80, 80);

            this.Initialize(tileBorders, labelRectangle, frameRectangle);
        }
Exemple #2
0
        protected override void OnRender(Graphics g, Map map)
        {
            // Render the rosetta
            base.OnRender(g, map);
            
            var clip = g.ClipBounds;
            var oldTransform = g.Transform;
            var newTransform = new Matrix(1f, 0f, 0f, 1f, clip.Left + Size.Width*0.5f, clip.Top + Size.Height*0.5f);

            g.Transform = newTransform;

            var width = Size.Width;
            var height = Size.Height;
            var pts = new[]
                          {
                              new PointF(0f, -0.35f*height),
                              new PointF(0.125f*width, 0.35f*height),
                              new PointF(0f, 0.275f*height),
                              new PointF(-0.125f*width, 0.35f*height),
                              new PointF(0f, -0.35f*height),
                          };

            // need to outline the needle
            if (NeedleOutlineWidth>0)
            {
                g.DrawPolygon(new Pen(OpacityColor(NeedleOutlineColor), NeedleOutlineWidth), pts);
            }

            // need to outline the needle
            g.FillPolygon(new SolidBrush(OpacityColor(NeedleFillColor)), pts );

            g.Transform = oldTransform;

        }
        public static bool IsImage(this HttpPostedFileBase file)
        {
            if (file.ContentType.Contains("image"))
            {
                return true;
            }

            var formats = new[]
            {
                ImageFormat.Jpeg,
                ImageFormat.Png,
                ImageFormat.Gif,
                ImageFormat.Jpeg,
                ImageFormat.Bmp,
                ImageFormat.Tiff
            };

            using (var img = Image.FromStream(file.InputStream))
            {
                return formats.Contains(img.RawFormat);
            }

            // Or can use:

            //string[] formats = new string[] { ".jpg", ".png", ".gif", ".jpeg", ".Bmp", ".Tiff" };

            //return formats.Any(item => file.FileName.EndsWith(item, StringComparison.OrdinalIgnoreCase));
        }
        /// <summary>
        /// Converts a colour from HSL to RGB
        /// </summary>
        /// <remarks>Adapted from the algoritm in Foley and Van-Dam</remarks>
        /// <param name="hsl">The HSL value</param>
        /// <returns>A Color structure containing the equivalent RGB values</returns>
        public static Color HSL_to_RGB(HSL hsl)
        {
            double r = 0, g = 0, b = 0;
            double temp1, temp2;

            if (hsl.L == 0) r = g = b = 0;
            else
            {
                if (hsl.S == 0) r = g = b = hsl.L;
                else
                {
                    temp2 = ((hsl.L <= 0.5) ? hsl.L*(1.0 + hsl.S) : hsl.L + hsl.S - (hsl.L*hsl.S));
                    temp1 = 2.0*hsl.L - temp2;

                    var t3 = new[] { hsl.H + 1.0/3.0, hsl.H, hsl.H - 1.0/3.0 };
                    var clr = new double[] { 0, 0, 0 };
                    for (int i = 0; i < 3; i++)
                    {
                        if (t3[i] < 0) t3[i] += 1.0;
                        if (t3[i] > 1) t3[i] -= 1.0;

                        if (6.0*t3[i] < 1.0) clr[i] = temp1 + (temp2 - temp1)*t3[i]*6.0;
                        else if (2.0*t3[i] < 1.0) clr[i] = temp2;
                        else if (3.0*t3[i] < 2.0) clr[i] = (temp1 + (temp2 - temp1)*((2.0/3.0) - t3[i])*6.0);
                        else clr[i] = temp1;
                    }
                    r = clr[0];
                    g = clr[1];
                    b = clr[2];
                }
            }

            return Color.FromArgb((int)(255*r), (int)(255*g), (int)(255*b));
        }
Exemple #5
0
        public void Translate()
        {
            if (TranslationService == null) return;
            var validTypes = new[]
            {
                typeof (Label),
                typeof (Button),
                typeof (SplitButton),
                typeof (CheckBox),
                typeof (RadioButton),
                typeof (GroupBox),
                typeof (TabControl),
                typeof (ToolStripMenuItem),
                typeof (ToolStripDropDownButton),
                typeof (ToolStripButton),
                typeof (LinkLabel),
                typeof (OLVColumn)
            };

            var fields = GetType()
                .GetFields(BindingFlags.NonPublic | BindingFlags.Instance)
                .Select(fi => fi.GetValue(this))
                .Where(v => v != null && validTypes.Contains(v.GetType()))
                .ToList();

            foreach (var field in fields)
            {
                var text = (string) field.GetType().GetProperty("Text").GetValue(field, null);
                text = TranslationService.Translate(text);
                field.GetType().GetProperty("Text").SetValue(field, text, null);
            }
            Text = TranslationService.Translate(Text);

            Invalidate(true);
        }
Exemple #6
0
 internal static CGGradient CreateGraidentWithColors(NSColor startingColor, NSColor endingColor)
 {
     var locations = new[] { 0.0f, 1.0f };
     var cgStartingcolor = startingColor.CGColor;
     var cgEndingColor = endingColor.CGColor;
     var colors = new[] { cgStartingcolor, cgEndingColor };
     return new CGGradient(CGColorSpace.CreateDeviceRGB(), colors, locations);
 }
 /// <summary>
 /// This method assumes that there was a direct correlation between this envelope and the original
 /// rectangle.  This reproportions this window to match the specified newRectangle.
 /// </summary>
 /// <param name="self">The original envelope</param>
 /// <param name="original">The original rectangle </param>
 /// <param name="newRectangle">The new rectangle</param>
 /// <returns>A new IEnvelope </returns>
 public static IEnvelope Reproportion(this IEnvelope self, Rectangle original, Rectangle newRectangle)
 {
     double dx = self.Width * (newRectangle.X - original.X) / original.Width;
     double dy = self.Height * (newRectangle.Y - original.Y) / original.Height;
     double w = (self.Width * newRectangle.Width / original.Width);
     double h = (self.Height * newRectangle.Height / original.Height);
     double[] ext = new[] { self.X + dx, self.X + dx + w, self.Y + dy - h, self.Y + dy };
     return new Envelope(ext);
 }
 public void SetValue(double v)
 {
     var mtx = new[,]
                   {
                       {-v, -v, -v},
                       {-v, 8*v + 1, -v},
                       {-v, -v, -v}
                   };
     filter = new ConvolutionFilter(mtx, 1, 0);
 }
Exemple #9
0
        public static double GetFitToAreaScalingFactor(SD.Size input, SD.Size max, bool only_scale_down)
        {
            if (only_scale_down &&  input.FitsInside(max))
            {
                return 1.0;
            }

            return GetFitToAreaScalingFactor(input.Width, input.Height, max.Width, max.Height);

        }
Exemple #10
0
 public static SD.SizeF ResizeDownToFit(SD.SizeF original, SD.SizeF max)
 {
     if (original.FitsInside(max))
     {
         return original;
     }
     else
     {
         double scale = GetFitToAreaScalingFactor(original, max);
         return original.MultiplyBy((float) scale);
     }
 }
Exemple #11
0
        public static VertexArray CreateVertexArray(Context context, int positionLocation)
        {
            Vector4F[] positions = new[] { new Vector4F(0, 0, 0, 1) };
            VertexBuffer positionsBuffer = Device.CreateVertexBuffer(BufferHint.StaticDraw, ArraySizeInBytes.Size(positions));
            positionsBuffer.CopyFromSystemMemory(positions);
            
            VertexArray va = context.CreateVertexArray();
            va.Attributes[positionLocation] = new VertexBufferAttribute(positionsBuffer, ComponentDatatype.Float, 4);
            va.DisposeBuffers = true;

            return va;
        }
Exemple #12
0
        public void InitPalette(WorldRenderer wr)
        {
            var c = new[] {
                Color.Transparent, Color.Green,
                Color.Blue, Color.Yellow,
                Color.Black,
                Color.FromArgb(128,0,0,0),
                Color.Transparent,
                Color.Transparent
            };

            wr.AddPalette(info.Name, new Palette(Exts.MakeArray(256, i => (uint)c[i % 8].ToArgb())), false);
        }
Exemple #13
0
        public override void Draw()
        {
            var index = Checked ? 10u : 11u;
            var coords = new[]
            {
                new PointF(Position.X,     Position.Y),
                new PointF(Position.X + 5, Position.Y),
                new PointF(Position.X + 5, Position.Y + 5),
                new PointF(Position.X,     Position.Y + 5)
            };
            Drawer.Instance().DrawTexture(index, coords);

            DrawString(new PointF(Position.X + 6, Position.Y + 4), Caption);
        }
Exemple #14
0
        public void RenderTriangle()
        {
            Vector4F[] positions = new[] 
            { 
                new Vector4F(-0.5f, -0.5f, 0, 1),
                new Vector4F(0.5f, -0.5f, 0, 1),
                new Vector4F(0.5f, 0.5f, 0, 1) 
            };

            ushort[] indices = new ushort[] 
            { 
                0, 1, 2
            };

            using (GraphicsWindow window = Device.CreateWindow(1, 1))
            using (Framebuffer framebuffer = TestUtility.CreateFramebuffer(window.Context))
            using (ShaderProgram sp = Device.CreateShaderProgram(ShaderSources.PassThroughVertexShader(), ShaderSources.PassThroughFragmentShader()))
            using (VertexBuffer positionsBuffer = Device.CreateVertexBuffer(BufferHint.StaticDraw, ArraySizeInBytes.Size(positions)))
            using (IndexBuffer indexBuffer = Device.CreateIndexBuffer(BufferHint.StaticDraw, indices.Length * sizeof(ushort)))
            using (VertexArray va = window.Context.CreateVertexArray())
            {
                positionsBuffer.CopyFromSystemMemory(positions);
                indexBuffer.CopyFromSystemMemory(indices);

                va.Attributes[sp.VertexAttributes["position"].Location] =
                    new VertexBufferAttribute(positionsBuffer, ComponentDatatype.Float, 4);
                va.IndexBuffer = indexBuffer;

                window.Context.Framebuffer = framebuffer;
                window.Context.Draw(PrimitiveType.Triangles, 0, 3, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState());
                TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 0, 0);

                //
                // Verify detach
                //
                window.Context.Clear(new ClearState() { Buffers = ClearBuffers.ColorBuffer, Color = Color.FromArgb(0, 255, 0) });
                va.Attributes[sp.VertexAttributes["position"].Location] = null;
                va.IndexBuffer = null;
                window.Context.Draw(PrimitiveType.Triangles, 0, 0, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState());
                TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 0, 255, 0);

                //
                // Verify rendering without indices
                //
                va.Attributes[sp.VertexAttributes["position"].Location] =
                    new VertexBufferAttribute(positionsBuffer, ComponentDatatype.Float, 4);
                window.Context.Draw(PrimitiveType.Triangles, 0, 3, new DrawState(TestUtility.CreateRenderStateWithoutDepthTest(), sp, va), new SceneState());
                TestUtility.ValidateColor(framebuffer.ColorAttachments[0], 255, 0, 0);
            }
        }
Exemple #15
0
        public static bool FitsInside( this SD.SizeF size , SD.SizeF s)
        {
            if (size.Width > s.Width)
            {
                return false;
            }

            if (size.Height > s.Height)
            {
                return false;
            }

            return true;
        }
Exemple #16
0
        public void TestMapDecorationTest()
        {
            Map m = new Map(new Size(780, 540)) {BackColor = Color.White, SRID = 0};
            GeoPoint[] pts = new [] {new GeoPoint(0, 0), new GeoPoint(779, 539)};
            FeatureProvider p = new FeatureProvider(m.Factory.CreateLineString(pts));
            m.Layers.Add(new VectorLayer("t",p));
            m.ZoomToExtents();

            m.Decorations.Add(new TestDecoration
                                  {
                                      Anchor = MapDecorationAnchor.LeftTop,
                                      BorderColor = Color.Green,
                                      BackgroundColor = Color.LightGreen,
                                      BorderWidth = 2,
                                      Location = new Point(10, 10),
                                      BorderMargin = new Size(5, 5),
                                      RoundedEdges = true,
                                      Opacity = 0.6f
                                  });

            m.Decorations.Add(new TestDecoration
            {
                Anchor = MapDecorationAnchor.RightTop,
                BorderColor = Color.Red,
                BackgroundColor = Color.LightCoral,
                BorderWidth = 2,
                Location = new Point(10, 10),
                BorderMargin = new Size(5, 5),
                RoundedEdges = true,
                Opacity = 0.2f
            });

            m.Decorations.Add(new ScaleBar
            {
                Anchor = MapDecorationAnchor.Default,
                BorderColor = Color.Blue,
                BackgroundColor = Color.CornflowerBlue,
                BorderWidth = 2,
                Location = new Point(10, 10),
                BorderMargin = new Size(5, 5),
                RoundedEdges = true,
                BarWidth = 4,
                ScaleText =ScaleBarLabelText.RepresentativeFraction,
                NumTicks = 2,
                Opacity = 1f
            });
            Image bmp = m.GetMap();
            bmp.Save("TestMapDecorationTest.bmp");
        }
        public void Fill_UpstairsAdded()
        {
            var populator = new DungeonPopulator();
            var dungeon = new FakeDungeon(5, 7);
            var points = new[] { new Point(2, 2), new Point(3, 3) };
            foreach (var p in points)
                dungeon[p].Type = XType.Empty;

            populator.Fill(dungeon);

            Assert.That(dungeon,
                Has.Exactly(1).Matches<Cell>(cell =>
                    cell.Type == XType.StairsUp
                    && points.Contains(cell.Location)));
        }
 static HorizontalPanel()
 {
     var gradientColors = new[]
     {
         Color.FromArgb(204, 217, 234),
         Color.FromArgb(217, 227, 240),
         Color.FromArgb(232, 238, 247),
         Color.FromArgb(237, 242, 249),
         Color.FromArgb(240, 244, 250),
         Color.FromArgb(241, 245, 251)
     };
     gradient = new Bitmap(1, 6);
     for (var i = 0; i < 6; i++)
         gradient.SetPixel(0, i, gradientColors[i]);
 }
Exemple #19
0
        public void TestDrawTexture()
        {
            var pixels = new[] { new Pixel(), new Pixel(), new Pixel(), new Pixel() };
            _window = new GameWindow { Width = 200, Height = 200 };
            _window.RenderFrame += (caller, args) =>
            {
                GL.Viewport(0, 0, 200, 200);
                GL.ReadBuffer(ReadBufferMode.Front);

                GL.Enable(EnableCap.Texture2D);
                int textureId = GL.GenTexture();
                GL.BindTexture(TextureTarget.Texture2D, textureId);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Nearest);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
                var bitmap = new Bitmap(@"..\..\Images\testtexture.png");
                var data = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height),
                                                  ImageLockMode.ReadOnly,
                                                  System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height,
                    0, PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);
                bitmap.UnlockBits(data);

                GL.Clear(ClearBufferMask.ColorBufferBit);
                GL.Begin(PrimitiveType.Quads);
                {
                    GL.TexCoord2(0.0f, 0.0f);
                    GL.Vertex2(-1.0f, -1.0f);
                    GL.TexCoord2(1.0f, 0.0f);
                    GL.Vertex2(1.0f, -1.0f);
                    GL.TexCoord2(1.0f, 1.0f);
                    GL.Vertex2(1.0f, 1.0f);
                    GL.TexCoord2(0.0f, 1.0f);
                    GL.Vertex2(-1.0f, 1.0f);
                }
                GL.End();
                _window.SwapBuffers();
                pixels[0].ReadBuffer(99, 99);
                pixels[1].ReadBuffer(99, 100);
                pixels[2].ReadBuffer(100, 100);
                pixels[3].ReadBuffer(100, 99);
                _window.Close();
            };
            _window.Run();
            Assert.AreEqual(new Pixel(1.0f, 0.0f, 0.0f), pixels[0]);
            Assert.AreEqual(new Pixel(0.0f, 1.0f, 0.0f), pixels[1]);
            Assert.AreEqual(new Pixel(0.0f, 0.0f, 1.0f), pixels[2]);
            Assert.AreEqual(new Pixel(0.0f, 0.0f, 0.0f), pixels[3]);
        }
        protected override void AfterInitGLOverride()
        {
            base.AfterInitGLOverride();

            var textures = new[]
                           {
                           	this.back1, this.front1, this.left1, this.right1, this.bottom1, this.top1,
                           	this.back2, this.front2, this.left2, this.right2, this.bottom2, this.top2,
                           };
            foreach (var texture in textures)
            {
                texture.Load();
                texture.WrapS = TextureWrapMode.ClampToEdgeSgis;
                texture.WrapT = TextureWrapMode.ClampToEdgeSgis;
            }
        }
        /// <summary>
        /// Calculate the RBG projection.
        /// </summary>
        /// <param name="bitmap">The image to process.</param>
        /// <returns>Return horizontal RGB projection in value [0] and vertical RGB projection in value [1].</returns>
        public static double[][] GetRgbProjections(Bitmap bitmap)
        {
            var width = bitmap.Width - 1;
            var height = bitmap.Width - 1;

            var horizontalProjection = new double[width];
            var verticalProjection = new double[height];

            var bitmapData1 = bitmap.LockBits(new Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);

            unsafe
            {
                var imagePointer1 = (byte*)bitmapData1.Scan0;

                for (var y = 0; y < height; y++)
                {
                    for (var x = 0; x < width; x++)
                    {
                        var blu = imagePointer1[0];
                        var green = imagePointer1[1];
                        var red = imagePointer1[2];

                        int luminosity = (byte)(((0.2126 * red) + (0.7152 * green)) + (0.0722 * blu));

                        horizontalProjection[x] += luminosity;
                        verticalProjection[y] += luminosity;

                        imagePointer1 += 4;
                    }

                    imagePointer1 += bitmapData1.Stride - (bitmapData1.Width * 4);
                }
            }

            MaximizeScale(ref horizontalProjection, height);
            MaximizeScale(ref verticalProjection, width);

            var projections =
                new[]
                    {
                        horizontalProjection,
                        verticalProjection
                    };

            bitmap.UnlockBits(bitmapData1);
            return projections;
        }
Exemple #22
0
        private void Task1_Paint(object sender, PaintEventArgs e)
        {
            var g = e.Graphics;
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            var pen = new Pen(Color.Black, 3);

            int width = ClientRectangle.Width;
            int height = ClientRectangle.Height;

            g.FillRectangle(new SolidBrush(Color.AliceBlue), new Rectangle(0, 0, width, height));
            g.FillRectangle(new SolidBrush(Color.Aquamarine), new Rectangle(0, height - 100, width, height));

            var r1 = new Rectangle(width / 2, height - 200, 200, 150);
            g.DrawRectangle(pen, r1);
            g.FillRectangle(new SolidBrush(Color.Chocolate), r1);

            var p1 = new[]
            {
                new Point(width/2 - 10, height - 200),
                new Point(width/2 + 210, height - 200),
                new Point(width/2 + (210)/2, height - 300),
            };
            g.DrawPolygon(pen, p1);
            g.FillPolygon(new SolidBrush(Color.Chocolate), p1);

            var r2 = new Rectangle(width / 2 + 50, height - 150, 50, 100);
            g.DrawRectangle(pen, r2);
            g.FillRectangle(new SolidBrush(Color.Brown), r2);

            for (int i = 0; i < 3; i++)
            {
                var r3 = new Rectangle(width / 2 - 250, height - 170 + i * 50, 50, 50);
                g.DrawEllipse(pen, r3);
                g.FillEllipse(new SolidBrush(Color.CornflowerBlue), r3);

                var p2 = new[]
                {
                    new Point(width/2 - 170, height - 100 - i*40),
                    new Point(width/2 - 130, height - 100 - i*40),
                    new Point(width/2 - 150, height - 140 - i*40),
                };
                g.DrawPolygon(pen, p2);
                g.FillPolygon(new SolidBrush(Color.ForestGreen), p2);
            }
        }
        public VectorOfPointF Detect(Image<Gray, byte> image, int innerCornersPerChessboardCols,
            int innerCornersPerChessboardRows)
        {
            var corners = new VectorOfPointF();

            CvInvoke.FindChessboardCorners(image, new Size(innerCornersPerChessboardCols, innerCornersPerChessboardRows),
                corners);

            if (corners.Size != innerCornersPerChessboardCols*innerCornersPerChessboardRows)
            {
                return new VectorOfPointF(new[] {new PointF(0, 0)});
            }

            var refinedCorners = new[] {corners.ToArray()};

            image.FindCornerSubPix(refinedCorners, new Size(11, 11), new Size(-1, -1), new MCvTermCriteria(10));

            return new VectorOfPointF(refinedCorners[0]);
        }
        public void Fill_CharacterAdded()
        {
            var populator = new DungeonPopulator();
            var dungeon = new FakeDungeon(5, 7);
            var points = new[] { new Point(2, 2), new Point(3, 3) };
            foreach (var p in points)
                dungeon[p].Type = XType.Empty;

            populator.Fill(dungeon);

            var expectedLocation = dungeon
                .Single(cell => cell.Type == XType.StairsUp)
                .Location;

            Assert.That(dungeon.Character,
                Is.Not.Null
                .And.With.Property(nameof(Character.Location))
                .EqualTo(expectedLocation));
        }
Exemple #25
0
        private void Task1_Paint(object sender, PaintEventArgs e)
        {
            var g = e.Graphics;
            e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            var img = new[]
            {
                Image.FromFile(_trees[0]),
                Image.FromFile(_trees[1])
            };

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    g.DrawImage(img[i % 2], 50 * i, 50 * j);
                }

            }
        }
Exemple #26
0
		protected override void OnComplete()
		{
			//var rect = DragRectangle.ToRectanglePolygon();

			var bottom = DragRectangle.Top - DragRectangle.Height;
			var points = new[]{
				new WinPoint(DragRectangle.Left, bottom),
				new WinPoint (DragRectangle.Left, DragRectangle.Top),
				new WinPoint(DragRectangle.Right, DragRectangle.Top),
				new WinPoint (DragRectangle.Right, bottom)};

			Viewport.ClientToWorld().Transform(points);

			var box = new Envelope();
			box.ExpandToInclude(ToCoordinate(points[0]));
			box.ExpandToInclude(ToCoordinate(points[1]));
			box.ExpandToInclude(ToCoordinate(points[2]));
			box.ExpandToInclude(ToCoordinate(points[3]));
			
			Select(box);
		}
        public void HSLColor_should_be_RGB_convertable()
        {
            Colors[] colortable = new []{
                new Colors(  0,   0,   0,   0,   0,   0), // Black
                new Colors(360, 100,   0,   0,   0,   0), // Black
                new Colors(  0,   0, 100, 255, 255, 255), // White
                new Colors(360, 100, 100, 255, 255, 255), // White

                new Colors(  0,  80,  50, 230,  25,  25),
                new Colors( 90,  80,  50, 128, 230,  25),
                new Colors(180,  80,  50,  25, 229, 230),
                new Colors(270,  80,  50, 127,  25, 230),

                new Colors( 72,  36,  28,  87,  97,  46)
            };

            foreach (Colors colors in colortable) {
                var hsl = new NickColor.HSLColor(colors.H, colors.S, colors.L);
                var rgb = Color.FromArgb(colors.R, colors.G, colors.B);
                AssertRGBEqual(hsl.ToColor(), rgb);
            }
        }
        public void Update(DeckCard[] dcards)
        {
            int[] starCount = new []{0, 0, 0, 0, 0, 0, 0};
            string[] typeArray = new string[] { "直伤", "范围","控制", "辅助", "铺场", "防御" };
            int[] typeCount = new[] { 0, 0, 0, 0, 0, 0 };
            foreach (var deckCard in dcards)
            {
                if (deckCard.BaseId == 0)
                    continue;
                starCount[deckCard.Star-1]++;

                var cardData = CardConfigManager.GetCardConfig(deckCard.BaseId);
                if (cardData.Remark.Contains("直伤")) typeCount[0]++;
                if (cardData.Remark.Contains("范围")) typeCount[1]++;
                if (cardData.Remark.Contains("状态")) typeCount[2]++;
                if (cardData.Remark.Contains("治疗") || cardData.Remark.Contains("能量") || cardData.Remark.Contains("手牌")) typeCount[3]++;
                if (cardData.Remark.Contains("召唤")) typeCount[4]++;
                if (cardData.Remark.Contains("防御")) typeCount[5]++;
            }
            chartStar.SetData(new[]{"1","2","3","4","5","6","7"}, starCount);
            chartType.SetData(typeArray, typeCount);
        }
Exemple #29
0
        public Form1(Vm viewModel)
        {
            InitializeComponent();

            barButtonItemSaveTorrent.BindTo(viewModel.SaveTorrentFileCommand);
            barButtonItemOpenPageInBrowser.BindTo(viewModel.OpenPageInDefaultBrowser);
            barButtonItemOpenUserDetails.BindTo(viewModel.OpenUserInDefaultBrowser);

            barStaticItem1.Caption = Res.Loading;

            viewModel.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "StatusTime")
                {
                    barStaticItem1.Caption = viewModel.StatusTime;
                }
                if (args.PropertyName == "TotalSize")
                {
                    barStaticItem2.Caption = viewModel.TotalSize;
                }
            };

            Load += async (sender, args) =>
            {
                await viewModel.Load();
            };

            gridView1.BindFocusedRowChangedTo(viewModel.SelectedTorrent, row => viewModel.SelectedTorrent = row);

            bindingSource.DataSource = viewModel;

            mainGridControl.DataSource = torrentsBindingSource;

            gridView1.RowCellStyle += (sender, args) =>
            {
                if (args.Column == colStatus)
                {
                    var category = (ReleaseStatus)args.CellValue;

            //                    Color color;
            //
            //                    switch (category)
            //                    {
            //                        case ReleaseStatus.Gold:
            //                            color = Color.Gold;
            //                            break;
            //                        case ReleaseStatus.Silver:
            //                            color = Color.Silver;
            //                            break;
            //                        case ReleaseStatus.Bronze:
            //                            color = Color.SaddleBrown;
            //                            break;
            //                        default:
            //                            color = Color.Transparent;
            //                            break;
            //                    }

            //                    args.Appearance.GradientMode = LinearGradientMode.Horizontal;
            //                    args.Appearance.BackColor2 = Color.White;
            //                    args.Appearance.BackColor = color;
            //                    args.Appearance.ForeColor = color;
                    args.Appearance.Font = new Font(args.Appearance.Font.FontFamily, args.Appearance.Font.Size,
                        FontStyle.Bold);
                }

                if (args.Column == colIsVerified)
                {
                    var category = (IsVerifiedByModerator)args.CellValue;

                   /* switch (category)
                    {
                        case IsVerifiedByModerator.Verified:
                            color = Color.DarkGreen;
                            break;
                        case IsVerifiedByModerator.Verifying:
                            color = Color.GreenYellow;
                            break;
                        case IsVerifiedByModerator.Pending:
                            color = Color.Yellow;
                            break;
                        case IsVerifiedByModerator.IsNotGoodEnough:
                            color = Color.OrangeRed;
                            break;
                        case IsVerifiedByModerator.WrongCompilation:
                            color = Color.Red;
                            break;
                        case IsVerifiedByModerator.Repeat:
                            color = Color.Brown;
                            break;
                        default:
                            color = Color.Transparent;
                            break;
                    }*/

                    args.Appearance.Font = new Font(args.Appearance.Font.FontFamily, args.Appearance.Font.Size,FontStyle.Bold);
                }

                if (args.Column == colUserName)
                {
                    args.Appearance.Font = new Font(args.Appearance.Font.FontFamily, args.Appearance.Font.Size,FontStyle.Bold); ;
                }
            };

            #if (!DEBUG)

            var hideColumns = new [] {colid, colOwnerId, colTorrentFileId, colPageExists};

            hideColumns.ForEach(it =>
            {
                it.Visible = false;
                it.OptionsColumn.ShowInCustomizationForm = false;
            });

            #endif
        }
Exemple #30
0
 internal Win32Bitmap(Sd.Bitmap nativeBitmap)
 {
     _nativeBitmap = nativeBitmap;
 }