// Update is called once per frame private void Update() { ColorData cols = new ColorData(); for(int i = 0; i < 5; i++) { maxCubes = 0; foreach(GameObject randomObject in GameObject.FindObjectsOfType(typeof(GameObject))) { if(randomObject.name == "Cube" + i) { maxCubes++; randomObject.GetComponent<Renderer>().material.color = cols.GetAColorToUse(i); } } } if(Input.GetButtonDown("Jump")) { SetScaleOfCubes(); } }
// Update is called once per frame private void Update() { ColorData cols = new ColorData(); for (int i = 0; i < numOfCubes; i++) { GameObject cubeCol = GameObject.Find ("Cube" + i); if(Application.loadedLevelName=="Scene3") { GameObject cubeRow0 = GameObject.Find ("Cubes0"); GameObject cubeRow1 = GameObject.Find("Cubes1"); Renderer[] rowZeroColor = cubeRow0.GetComponentsInChildren<Renderer>(); Renderer[] rowOneColor = cubeRow1.GetComponentsInChildren<Renderer>(); rowZeroColor[i].material.color=cols.GetAColorToUse(i); rowOneColor[i].material.color=cols.GetAColorToUse(i); rowOneColor[i].gameObject.transform.localScale=new Vector3(1, 2, 1); } else cubeCol.GetComponent<Renderer> ().material.color = cols.GetAColorToUse (i); } if (Input.GetButtonDown ("Jump")) set_scale_of_cubes (); }
// Update is called once per frame private void Update() { ColorData cols = new ColorData(); cubenumber++; GameObject o = GameObject.Find("Cube" + cubenumber); if (o == null) { cubenumber = 0; o = GameObject.Find("Cube" + cubenumber); } o.GetComponent<Renderer>().material.color = cols.GetAColorToUse(cubenumber); if (Input.GetButtonDown("Jump")) set_scale_of_cubes(); /* groupnumber++; cubenumber++; GameObject o = GameObject.Find ("Cubes" + groupnumber + "/Cube" + cubenumber); o.GetComponent<Renderer>().material.color = cols.GetAColorToUse(cubenumber); if (Input.GetButtonDown("Jump")) set_scale_of_cubes(); */ }
// used by DataGridViewCheckBoxCell internal static void DrawCheckBackground(bool controlEnabled, CheckState controlCheckState, Graphics g, Rectangle bounds, Color checkColor, Color checkBackground, bool disabledColors, ColorData colors) { using ( WindowsGraphics wg = WindowsGraphics.FromGraphics( g )) { WindowsBrush brush; if (!controlEnabled && disabledColors) { brush = new WindowsSolidBrush(wg.DeviceContext, SystemColors.Control); } else if (controlCheckState == CheckState.Indeterminate && checkBackground == SystemColors.Window && disabledColors) { Color comboColor = SystemInformation.HighContrast ? SystemColors.ControlDark : SystemColors.Control; byte R = (byte)((comboColor.R + SystemColors.Window.R) / 2); byte G = (byte)((comboColor.G + SystemColors.Window.G) / 2); byte B = (byte)((comboColor.B + SystemColors.Window.B) / 2); brush = new WindowsSolidBrush(wg.DeviceContext, Color.FromArgb(R, G, B)); } else { brush = new WindowsSolidBrush(wg.DeviceContext, checkBackground); } try { wg.FillRectangle(brush, bounds); } finally { if (brush != null) { brush.Dispose(); } } } }
protected void DrawCheckBackground3DLite(PaintEventArgs e, Rectangle bounds, Color checkColor, Color checkBackground, ColorData colors, bool disabledColors) { Graphics g = e.Graphics; Color field = checkBackground; if (!Control.Enabled && disabledColors) { field = SystemColors.Control; } using (Brush fieldBrush = new SolidBrush(field)) { using (Pen dark = new Pen(colors.buttonShadow), light = new Pen(colors.buttonFace), lightlight = new Pen(colors.highlight)) { bounds.Width--; bounds.Height--; // fall a little short of SW, NW, NE, SE because corners come out nasty g.DrawPie(dark, bounds, (float)(135 + 1), (float)(90 - 2)); g.DrawPie(dark, bounds, (float)(225 + 1), (float)(90 - 2)); g.DrawPie(lightlight, bounds, (float)(315 + 1), (float)(90 - 2)); g.DrawPie(lightlight, bounds, (float)(45 + 1), (float)(90 - 2)); bounds.Inflate(-1, -1); g.FillEllipse(fieldBrush, bounds); g.DrawEllipse(light, bounds); } } }
void PaintFlatWorker(PaintEventArgs e, Color checkColor, Color checkBackground, Color checkBorder, ColorData colors) { System.Drawing.Graphics g = e.Graphics; LayoutData layout = Layout(e).Layout(); PaintButtonBackground(e, Control.ClientRectangle, null); PaintImage(e, layout); DrawCheckFlat(e, layout, checkColor, colors.options.highContrast ? colors.buttonFace : checkBackground, checkBorder); PaintField(e, layout, colors, checkColor, true); }
public PlainTextData(bool autosize, string text, ColorData color, QuickFont.QFontAlignment alignment, float offsetX, float offsetY) { Text = text; AutoSize = autosize; Color = color; Alignment = alignment; OffsetX = offsetX; OffsetY = offsetY; }
// Update is called once per frame private void Update() { ColorData cols = new ColorData(); for (int i = 0; i < 5; i++) { GameObject o = GameObject.Find("Cube" + i); o.GetComponent<Renderer>().material.color = cols.GetAColorToUse(i); } if (Input.GetButtonDown("Jump")) set_scale_of_cubes(); }
// Update is called once per frame private void Update() { ColorData cols = new ColorData(); //Searches for all cubes tagged with "cube" and adds them to an array //The array will be used to go through all the cubes in the scene GameObject [] allCubes; allCubes = GameObject.FindGameObjectsWithTag("cube"); for (int i = 0; allCubes.Length > i ; i++) { GameObject o = GameObject.Find("Cube" + i); if (allCubes[1] == o ) { o.GetComponent<Renderer>().material.color = cols.GetAColorToUse(i); Debug.Log(o); } } if (Input.GetButtonDown("Jump")) set_scale_of_cubes(); }
protected void DrawCheckFlat(PaintEventArgs e, LayoutData layout, Color checkColor, Color checkBackground, Color checkBorder, ColorData colors) { Rectangle bounds = layout.checkBounds; // Removed subtracting one for Width and Height. In Everett we needed to do this, // since we were using GDI+ to draw the border. Now that we are using GDI, // we should not do before drawing the border. if (!layout.options.everettButtonCompat) { bounds.Width--; bounds.Height--; } using (WindowsGraphics wg = WindowsGraphics.FromGraphics( e.Graphics )) { using(WindowsPen pen = new WindowsPen(wg.DeviceContext, checkBorder)){ wg.DrawRectangle(pen, bounds); } // Now subtract, since the rest of the code is like Everett. if (layout.options.everettButtonCompat) { bounds.Width--; bounds.Height--; } bounds.Inflate(-1, -1); } if (Control.CheckState == CheckState.Indeterminate) { bounds.Width++; bounds.Height++; DrawDitheredFill(e.Graphics, colors.buttonFace, checkBackground, bounds); } else { using( WindowsGraphics wg = WindowsGraphics.FromGraphics( e.Graphics )) { using (WindowsBrush brush = new WindowsSolidBrush(wg.DeviceContext, checkBackground)) { // Even though we are using GDI here as opposed to GDI+ in Everett, we still need to add 1. bounds.Width++; bounds.Height++; wg.FillRectangle(brush, bounds); } } } DrawCheckOnly(e, layout, colors, checkColor, checkBackground, true); }
void Start(){ GameObject[] cubesInScene; cubesInScene = GameObject.FindGameObjectsWithTag ("Cube"); numberOfCubes = cubesInScene.Length; Debug.Log (numberOfCubes); listOfCubeData = new List<CubeData> (); CubeData newCube; for (int i = 0; i < numberOfCubes; i++) { newCube = new CubeData(cubesInScene[i]); listOfCubeData.Add (newCube); } ColorData cols = new ColorData(); int iter = 0; foreach (CubeData cd in listOfCubeData) { cd.cube.GetComponent<Renderer>().material.color = cols.GetAColorToUse(iter % 5); iter++; } }
// Update is called once per frame private void Update() { ColorData cols = new ColorData(); int i = 0; GameObject o; int groupnum = 0; if (GameObject.Find ("Cubes" + groupnum)) {//check if there is a group isGroups = true; while (GameObject.Find("Cubes"+groupnum+"/Cube" + i)) { o = GameObject.Find ("Cubes"+groupnum+"/Cube" + i); o.GetComponent<Renderer> ().material.color = cols.GetAColorToUse (i % 5);//make more colors if you want moar pretty i++; } groupnum++;//hardcoded bad practice! ToDo fix i=0; while (GameObject.Find("Cubes"+groupnum+"/Cube" + i)) { o = GameObject.Find ("Cubes"+groupnum+"/Cube" + i); o.GetComponent<Renderer> ().material.color = cols.GetAColorToUse (i % 5);//make more colors if you want moar pretty i++; } } else { while (GameObject.Find("Cube" + i)) { o = GameObject.Find ("Cube" + i); o.GetComponent<Renderer> ().material.color = cols.GetAColorToUse (i % 5);//make more colors if you want moar pretty i++; } } if (Input.GetButtonDown("Jump")) set_scale_of_cubes(); }
private async void openFileDialog1_FileOk(object sender, CancelEventArgs e) { //var input = Image.FromFile(openFileDialog1.FileName, true); //pictureBox1.Image = Processor.ResizeImageTo500(input); // clear label2.Text = ""; chart1.Series["R"].Points.Clear(); chart1.Series["G"].Points.Clear(); chart1.Series["B"].Points.Clear(); chart1.Series["Gray"].Points.Clear(); // calculate ColorData = await Task.Run(() => Processor.Count(openFileDialog1.FileName)); // show label2.Text = ColorData.CountUnique + ""; for (int i = 0; i < 256; i++) { chart1.Series["R"].Points.AddXY(i, ColorData.CountR[i]); chart1.Series["G"].Points.AddXY(i, ColorData.CountG[i]); chart1.Series["B"].Points.AddXY(i, ColorData.CountB[i]); chart1.Series["Gray"].Points.AddXY(i, ColorData.CountGrayScale[i]); } }
private void Draw3DBorderRaised(Graphics g, ref Rectangle bounds, ColorData colors) { bool stockColor = colors.buttonFace.ToKnownColor() == SystemColors.Control.ToKnownColor(); using( WindowsGraphics wg = WindowsGraphics.FromGraphics(g) ) { // Draw counter-clock-wise. Point p1 = new Point(bounds.X + bounds.Width - 1, bounds.Y ); // upper inner right. Point p2 = new Point(bounds.X , bounds.Y ); // upper left. Point p3 = new Point(bounds.X , bounds.Y + bounds.Height - 1 ); // bottom inner left. Point p4 = new Point(bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1 ); // inner bottom right. // Draw counter-clock-wise. // top + left WindowsPen pen = stockColor ? new WindowsPen(wg.DeviceContext, SystemColors.ControlLightLight) : new WindowsPen(wg.DeviceContext, colors.highlight); try { wg.DrawLine(pen, p1, p2); // top (right-left) wg.DrawLine(pen, p2, p3); // left(up-down) } finally { pen.Dispose(); } // bottom + right if (stockColor) { pen = new WindowsPen(wg.DeviceContext, SystemColors.ControlDarkDark); } else { pen = new WindowsPen(wg.DeviceContext, colors.buttonShadowDark); } try { p1.Offset(0,-1); // need to paint last pixel too. wg.DrawLine(pen, p3, p4); // bottom(left-right) wg.DrawLine(pen, p4, p1); // right (bottom-up) } finally { pen.Dispose(); } // Draw inset p1.Offset(-1, 2); p2.Offset( 1, 1); p3.Offset( 1,-1); p4.Offset(-1,-1); if (stockColor) { if (SystemInformation.HighContrast) { pen = new WindowsPen(wg.DeviceContext, SystemColors.ControlLight); } else { pen = new WindowsPen(wg.DeviceContext, SystemColors.Control); } } else { pen = new WindowsPen(wg.DeviceContext, colors.buttonFace); } // top + left inset try { wg.DrawLine(pen, p1, p2); // top (right-left) wg.DrawLine(pen, p2, p3); // left(up-down) } finally { pen.Dispose(); } // Bottom + right inset if (stockColor) { pen = new WindowsPen(wg.DeviceContext, SystemColors.ControlDark); } else { pen = new WindowsPen(wg.DeviceContext, colors.buttonShadow); } try { p1.Offset(0,-1); // need to paint last pixel too. wg.DrawLine(pen, p3, p4); // bottom(left-right) wg.DrawLine(pen, p4, p1); // right (bottom-up) } finally { pen.Dispose(); } } }
/// <devdoc> /// Draws a border for the in the 3D style of the popup button. /// </devdoc> protected internal static void Draw3DLiteBorder(Graphics g, Rectangle r, ColorData colors, bool up) { using( WindowsGraphics wg = WindowsGraphics.FromGraphics(g) ) { // Draw counter-clock-wise. Point p1 = new Point(r.Right - 1, r.Top ); // upper inner right. Point p2 = new Point(r.Left , r.Top ); // upper left. Point p3 = new Point(r.Left , r.Bottom - 1); // bottom inner left. Point p4 = new Point(r.Right - 1, r.Bottom - 1); // inner bottom right. // top, left WindowsPen pen = up ? new WindowsPen(wg.DeviceContext, colors.highlight) : new WindowsPen(wg.DeviceContext, colors.buttonShadow); try { wg.DrawLine(pen, p1, p2); // top (right-left) wg.DrawLine(pen, p2, p3); // left (top-down) } finally { pen.Dispose(); } // bottom, right pen = up ? new WindowsPen(wg.DeviceContext, colors.buttonShadow) : new WindowsPen(wg.DeviceContext, colors.highlight); try { p1.Offset(0,-1); // need to paint last pixel too. wg.DrawLine(pen, p3, p4); // bottom (left-right) wg.DrawLine(pen, p4, p1); // right(bottom-up) } finally { pen.Dispose(); } } }
private void DrawButton(Graphics g, ColorData colorData, LayoutData layout, bool up) { Image img = this.GetImage(); if (img != null) { if (this.Enabled) { this.DrawImage(g, ref layout.faceBounds, img, layout.faceBounds.X, layout.faceBounds.Y); } else { this.DrawImageDisabled(g, ref layout.faceBounds, img, layout.faceBounds.X, layout.faceBounds.Y); } } string text = this.Text; //MatchCollection matches = Regex.Matches(this.Text, @"<\w*>", RegexOptions.Compiled); //if (matches.Count > 0) //{ // Rectangle[] rectangles = new Rectangle[matches.Count]; // int recW = layout.textBounds.Width / matches.Count; // for (int i = 0; i < matches.Count; i++) // { // Match m = matches[i]; // rectangles[i] = new Rectangle(recW * i + layout.textBounds.X, layout.textBounds.Y, recW, layout.textBounds.Height); // string val = m.Value.Trim().Trim('<', '>'); // Image mImg = GetImage(Convert.ToInt32(val)); // this.DrawImage(g, ref rectangles[i], mImg, rectangles[i].X, rectangles[i].Y); // text = text.Replace(m.Value, string.Empty); // } //} this.PaintField(g, text, layout, colorData, true); this.DrawBorder(g, layout.cellBounds, colorData, up); //else // ControlPaint.DrawBorder(graphics, clientRectangle, colors.buttonShadow, ButtonBorderStyle.Solid); }
protected void Draw3DBorder(Graphics g, Rectangle bounds, ColorData colors, bool raised) { if (Control.BackColor != SystemColors.Control && SystemInformation.HighContrast) { if (raised) { Draw3DBorderHighContrastRaised(g, ref bounds, colors); } else { ControlPaint.DrawBorder(g, bounds, ControlPaint.Dark(Control.BackColor), ButtonBorderStyle.Solid); } } else { if (raised) { Draw3DBorderRaised(g, ref bounds, colors); } else { Draw3DBorderNormal(g, ref bounds, colors); } } }
// used by DataGridViewCheckBoxCell internal static void DrawCheckOnly(int checkSize, bool controlChecked, bool controlEnabled, CheckState controlCheckState, Graphics g, LayoutData layout, ColorData colors, Color checkColor, Color checkBackground) { // check // if (controlChecked) { if (!controlEnabled) { checkColor = colors.buttonShadow; } else if (controlCheckState == CheckState.Indeterminate) { checkColor = SystemInformation.HighContrast ? colors.highlight : colors.buttonShadow; } Rectangle fullSize = layout.checkBounds; if (fullSize.Width == checkSize) { fullSize.Width++; fullSize.Height++; } fullSize.Width++; fullSize.Height++; Bitmap checkImage = null; if (controlCheckState == CheckState.Checked) { checkImage = GetCheckBoxImage(checkColor, fullSize, ref checkImageCheckedBackColor, ref checkImageChecked); } else { Debug.Assert(controlCheckState == CheckState.Indeterminate, "we want to paint the check box only if the item is checked or indeterminate"); checkImage = GetCheckBoxImage(checkColor, fullSize, ref checkImageIndeterminateBackColor, ref checkImageIndeterminate); } if (layout.options.everettButtonCompat) { fullSize.Y -= 1; } else { fullSize.Y -= 2; } ControlPaint.DrawImageColorized(g, checkImage, fullSize, checkColor); } }
void PaintFlatWorker(PaintEventArgs e, Color checkColor, Color checkBackground, Color checkBorder, ColorData colors) { Graphics g = e.Graphics; LayoutData layout = Layout(e).Layout(); PaintButtonBackground(e, Control.ClientRectangle, null); PaintImage(e, layout); DrawCheckFlat(e, layout, checkColor, colors.options.highContrast ? colors.buttonFace : checkBackground, checkBorder); AdjustFocusRectangle(layout); PaintField(e, layout, colors, checkColor, true); }
// used by DataGridViewCheckBoxCell internal static void DrawCheckBackground(bool controlEnabled, CheckState controlCheckState, Graphics g, Rectangle bounds, Color checkColor, Color checkBackground, bool disabledColors, ColorData colors) { using (WindowsGraphics wg = WindowsGraphics.FromGraphics(g)) { WindowsBrush brush; if (!controlEnabled && disabledColors) { brush = new WindowsSolidBrush(wg.DeviceContext, SystemColors.Control); } else if (controlCheckState == CheckState.Indeterminate && checkBackground == SystemColors.Window && disabledColors) { Color comboColor = SystemInformation.HighContrast ? SystemColors.ControlDark : SystemColors.Control; byte R = (byte)((comboColor.R + SystemColors.Window.R) / 2); byte G = (byte)((comboColor.G + SystemColors.Window.G) / 2); byte B = (byte)((comboColor.B + SystemColors.Window.B) / 2); brush = new WindowsSolidBrush(wg.DeviceContext, Color.FromArgb(R, G, B)); } else { brush = new WindowsSolidBrush(wg.DeviceContext, checkBackground); } try { wg.FillRectangle(brush, bounds); } finally { if (brush != null) { brush.Dispose(); } } } }
protected void DrawCheckFlat(PaintEventArgs e, LayoutData layout, Color checkColor, Color checkBackground, Color checkBorder, ColorData colors) { Rectangle bounds = layout.checkBounds; // Removed subtracting one for Width and Height. In Everett we needed to do this, // since we were using GDI+ to draw the border. Now that we are using GDI, // we should not do before drawing the border. if (!layout.options.everettButtonCompat) { bounds.Width--; bounds.Height--; } using (WindowsGraphics wg = WindowsGraphics.FromGraphics(e.Graphics)) { using (WindowsPen pen = new WindowsPen(wg.DeviceContext, checkBorder)){ wg.DrawRectangle(pen, bounds); } // Now subtract, since the rest of the code is like Everett. if (layout.options.everettButtonCompat) { bounds.Width--; bounds.Height--; } bounds.Inflate(-1, -1); } if (Control.CheckState == CheckState.Indeterminate) { bounds.Width++; bounds.Height++; DrawDitheredFill(e.Graphics, colors.buttonFace, checkBackground, bounds); } else { using (WindowsGraphics wg = WindowsGraphics.FromGraphics(e.Graphics)) { using (WindowsBrush brush = new WindowsSolidBrush(wg.DeviceContext, checkBackground)) { // Even though we are using GDI here as opposed to GDI+ in Everett, we still need to add 1. bounds.Width++; bounds.Height++; wg.FillRectangle(brush, bounds); } } } DrawCheckOnly(e, layout, colors, checkColor, checkBackground); }
/// <devdoc> /// Draws the button's text. /// </devdoc> void DrawText(Graphics g, LayoutData layout, Color c, ColorData colors) { Rectangle r = layout.textBounds; bool disabledText3D = layout.options.shadowedText; if (Control.UseCompatibleTextRendering) { // Draw text using GDI+ using (StringFormat stringFormat = CreateStringFormat()) { // DrawString doesn't seem to draw where it says it does if ((Control.TextAlign & LayoutUtils.AnyCenter) == 0) { r.X -= 1; } r.Width += 1; if (disabledText3D && !Control.Enabled) { r.Offset(1, 1); using (SolidBrush brush = new SolidBrush(colors.highlight)) { g.DrawString(Control.Text, Control.Font, brush, r, stringFormat); r.Offset(-1, -1); brush.Color = colors.buttonShadow; g.DrawString(Control.Text, Control.Font, brush, r, stringFormat); } } else { Brush brush; if (c.IsSystemColor) { brush = SystemBrushes.FromSystemColor(c); } else { brush = new SolidBrush(c); } g.DrawString(Control.Text, Control.Font, brush, r, stringFormat); if (!c.IsSystemColor) { brush.Dispose(); } } } } else { // Draw text using GDI (Whidbey feature). TextFormatFlags formatFlags = CreateTextFormatFlags(); if (disabledText3D && !Control.Enabled) { if (Application.RenderWithVisualStyles) { //don't draw chiseled text if themed as win32 app does. TextRenderer.DrawText(g, Control.Text, Control.Font, r, colors.buttonShadow, formatFlags); } else { r.Offset(1, 1); TextRenderer.DrawText(g, Control.Text, Control.Font, r, colors.highlight, formatFlags); r.Offset(-1, -1); TextRenderer.DrawText(g, Control.Text, Control.Font, r, colors.buttonShadow, formatFlags); } } else { TextRenderer.DrawText(g, Control.Text, Control.Font, r, c, formatFlags); } } }
internal ColorData Calculate() { ColorData colors = new ColorData(this); colors.buttonFace = backColor; if (backColor == SystemColors.Control) { colors.buttonShadow = SystemColors.ControlDark; colors.buttonShadowDark = SystemColors.ControlDarkDark; colors.highlight = SystemColors.ControlLightLight; } else { if (!highContrast) { colors.buttonShadow = ControlPaint.Dark(backColor); colors.buttonShadowDark = ControlPaint.DarkDark(backColor); colors.highlight = ControlPaint.LightLight(backColor); } else { colors.buttonShadow = ControlPaint.Dark(backColor); colors.buttonShadowDark = ControlPaint.LightLight(backColor); colors.highlight = ControlPaint.LightLight(backColor); } } const float lowlight = .1f; float adjust = 1 - lowlight; if (colors.buttonFace.GetBrightness() < .5) { adjust = 1 + lowlight * 2; } colors.lowButtonFace = Color.FromArgb(Adjust255(adjust, colors.buttonFace.R), Adjust255(adjust, colors.buttonFace.G), Adjust255(adjust, colors.buttonFace.B)); adjust = 1 - lowlight; if (colors.highlight.GetBrightness() < .5) { adjust = 1 + lowlight * 2; } colors.lowHighlight = Color.FromArgb(Adjust255(adjust, colors.highlight.R), Adjust255(adjust, colors.highlight.G), Adjust255(adjust, colors.highlight.B)); if (highContrast && backColor != SystemColors.Control) { colors.highlight = colors.lowHighlight; } colors.windowFrame = foreColor; /* debug * / colors.buttonFace = Color.Yellow; colors.buttonShadow = Color.Blue; colors.highlight = Color.Brown; colors.lowButtonFace = Color.Beige; colors.lowHighlight = Color.Cyan; colors.windowFrame = Color.Red; colors.windowText = Color.Green; / * debug */ if (colors.buttonFace.GetBrightness() < .5) { colors.constrastButtonShadow = colors.lowHighlight; } else { colors.constrastButtonShadow = colors.buttonShadow; } if (!enabled && disabledTextDim) { colors.windowText = colors.buttonShadow; } else { colors.windowText = colors.windowFrame; } IntPtr hdc = this.graphics.GetHdc(); try { using (WindowsGraphics wg = WindowsGraphics.FromHdc(hdc)) { colors.buttonFace = wg.GetNearestColor(colors.buttonFace); colors.buttonShadow = wg.GetNearestColor(colors.buttonShadow); colors.buttonShadowDark = wg.GetNearestColor(colors.buttonShadowDark); colors.constrastButtonShadow = wg.GetNearestColor(colors.constrastButtonShadow); colors.windowText = wg.GetNearestColor(colors.windowText); colors.highlight = wg.GetNearestColor(colors.highlight); colors.lowHighlight = wg.GetNearestColor(colors.lowHighlight); colors.lowButtonFace = wg.GetNearestColor(colors.lowButtonFace); colors.windowFrame = wg.GetNearestColor(colors.windowFrame); } } finally { this.graphics.ReleaseHdc(); } return colors; }
/* * This is an effect that displays a color to its max and the nto its mix */ public void ParanoidZen(ref Color colorState, double adjfactor, ColorData colorData) { // Console.WriteLine(colorState.B + " " +adjfactor); if (change) { adjfactor += .5; if (colorState.B - adjfactor < 0) { colorState.B = 0; } else { colorState.B = (byte)(colorState.B - adjfactor); } for (int i = 0; i < (colorData).Count; i++) { colorData[i] = colorState; if (colorState.B == 0) { change = false; } } } else { adjfactor += .5; if (colorState.B + adjfactor > 255) { colorState.B = 255; } else { colorState.B = (byte) (colorState.B + adjfactor); } for (int i = 0; i < ( colorData).Count; i++) { colorData[i] = colorState; if (colorState.B == 255) { change = true; } } } }
/* * This is a color trailing effect * */ public void HappyTrails(ColorData _colorData, double adjfactor) { for (int i = 0; i < _colorData.Count; i++) { Color color = _colorData[i]; color.R = (byte) (color.R/adjfactor); color.G = (byte) (color.G/adjfactor); if(color.B < 250) color.B = (byte) (color.B + adjfactor); _colorData[i] = color; } }
static ColorData GetData (Color color) { var cd = color.Tag as ColorData; if (cd == null) { cd = new ColorData (color); color.Tag = cd; } return cd; }
public void ChangeSpriteColor(ColorData colorDataObj) { spriteRendererObj.color = colorDataObj.value; }
public PlainBackgroundData() { Color = new ColorData(); }
internal void PaintField(PaintEventArgs e, LayoutData layout, ColorData colors, Color foreColor, bool drawFocus) { Graphics g = e.Graphics; Rectangle maxFocus = layout.focus; DrawText(g, layout, foreColor, colors); if (drawFocus) { DrawFocus(g, maxFocus); } }
protected void DrawCheckOnly(PaintEventArgs e, LayoutData layout, ColorData colors, Color checkColor, Color checkBackground) { DrawCheckOnly(flatCheckSize, Control.Checked, Control.Enabled, Control.CheckState, e.Graphics, layout, colors, checkColor, checkBackground); }
public PointsGisLayer(Game engine, int maxPointsCount, bool isDynamic = false) : base(engine) { DotsBuffer = new ConstantBuffer(engine.GraphicsDevice, typeof(DotsData)); ColorBuffer = new ConstantBuffer(engine.GraphicsDevice, typeof(ColorData), 16); PointsCountToDraw = maxPointsCount; PointsDrawOffset = 0; SizeMultiplier = 1; IsDynamic = isDynamic; var vbOptions = isDynamic ? VertexBufferOptions.Dynamic : VertexBufferOptions.Default; firstBuffer = new VertexBuffer(engine.GraphicsDevice, typeof(Gis.GeoPoint), maxPointsCount, vbOptions); currentBuffer = firstBuffer; PointsCpu = new Gis.GeoPoint[maxPointsCount]; Flags = (int) (PointFlags.DOTS_WORLDSPACE); shader = Game.Content.Load<Ubershader>("globe.Point.hlsl"); factory = shader.CreateFactory( typeof(PointFlags), Primitive.PointList, VertexInputElement.FromStructure<Gis.GeoPoint>(), BlendState.AlphaBlend, RasterizerState.CullCCW, DepthStencilState.None); ColorDatas = new ColorData[16]; for (int i = 0; i < ColorDatas.Length; i++) { ColorDatas[i] = new ColorData {Color = Color.White}; } ColorBuffer.SetData(ColorDatas); }
protected void DrawBorder(Graphics g, Rectangle bounds, ColorData colors, bool raised) { if (raised) { this.DrawBorderRaised(g, ref bounds, colors); } else { this.DrawBorderNormal(g, ref bounds, colors); } }
protected void PaintField(Graphics g, string text, LayoutData layout, ColorData colors, bool drawFocus) { using (Brush foreBrush = new SolidBrush(colors.foreColor)) { g.DrawString(text, this.Font, foreBrush, layout.textBounds); } }
//TODO clean up stale code private void DrawBorderNormal(Graphics g, ref Rectangle bounds, ColorData colors) { Pen pen = new Pen(colors.buttonShadowDark, 2); //draw top border shadowed g.DrawLine(pen, bounds.X, bounds.Y + 1, bounds.X + bounds.Width - 1, bounds.Y + 1); //draw left border shadowed g.DrawLine(pen, bounds.X + 1, bounds.Y, bounds.X + 1, bounds.Y + bounds.Height - 1); pen.Color = colors.highlight; //draw bottom border, highlighted g.DrawLine(pen, bounds.X, bounds.Y + bounds.Height - 1, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1); //draw right border, highlighted g.DrawLine(pen, bounds.X + bounds.Width - 1, bounds.Y, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1); //pen.Color = colors.buttonFace; //g.DrawLine(pen, bounds.X + 1, bounds.Y + 1, bounds.X + bounds.Width - 2, bounds.Y + 1); //g.DrawLine(pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Y + bounds.Height - 2); ////int num1 = (int) colors.buttonFace.ToKnownColor(); ////int num2 = (int) SystemColors.Control.ToKnownColor(); //pen.Color = colors.buttonFace != SystemColors.Control ? colors.buttonFace : SystemColors.ControlLight; //g.DrawLine(pen, bounds.X + 1, bounds.Y + bounds.Height - 2, bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2); //g.DrawLine(pen, bounds.X + bounds.Width - 2, bounds.Y + 1, bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2); pen.Dispose(); }
public PlainTextData() { Text = ""; Color = new ColorData(System.Drawing.Color.White); }
private void DrawBorderRaised(Graphics g, ref Rectangle bounds, ColorData colors) { bool flag = colors.buttonFace == SystemColors.Control; Pen pen = flag ? new Pen(SystemColors.ControlLightLight, 2) : new Pen(colors.highlight, 2); //top g.DrawLine(pen, bounds.X, bounds.Y + 1, bounds.X + bounds.Width - 1, bounds.Y + 1); //left g.DrawLine(pen, bounds.X + 1, bounds.Y, bounds.X + 1, bounds.Y + bounds.Height - 1); if (flag) { pen.Color = SystemColors.ControlDarkDark; } else { pen.Color = colors.buttonShadowDark; } //botom g.DrawLine(pen, bounds.X, bounds.Y + bounds.Height - 1, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1); //right g.DrawLine(pen, bounds.X + bounds.Width - 1, bounds.Y, bounds.X + bounds.Width - 1, bounds.Y + bounds.Height - 1); //if (flag) //{ // pen.Color = !colors.highContrast ? SystemColors.Control : SystemColors.ControlLight; //} //else //{ // pen.Color = colors.buttonFace; //} //g.DrawLine(pen, bounds.X + 1, bounds.Y + 1, bounds.X + bounds.Width - 2, bounds.Y + 1); //g.DrawLine(pen, bounds.X + 1, bounds.Y + 1, bounds.X + 1, bounds.Y + bounds.Height - 2); //if (flag) //{ // pen.Color = SystemColors.ControlDark; //} //else //{ // pen.Color = colors.buttonShadow; //} //g.DrawLine(pen, bounds.X + 1, bounds.Y + bounds.Height - 2, bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2); //g.DrawLine(pen, bounds.X + bounds.Width - 2, bounds.Y + 1, bounds.X + bounds.Width - 2, bounds.Y + bounds.Height - 2); //if (flag) //{ // return; //} pen.Dispose(); }
protected void DrawCheckBackground(PaintEventArgs e, Rectangle bounds, Color checkColor, Color checkBackground, bool disabledColors, ColorData colors) { // area behind check // if (Control.CheckState == CheckState.Indeterminate) { DrawDitheredFill(e.Graphics, colors.buttonFace, checkBackground, bounds); } else { DrawCheckBackground(Control.Enabled, Control.CheckState, e.Graphics, bounds, checkColor, checkBackground, disabledColors, colors); } }
internal static Rectangle DrawPopupBorder(Graphics g, Rectangle r, ColorData colors) { using var hdc = new DeviceContextHdcScope(g); return(DrawPopupBorder(hdc, r, colors)); }