public FontExamples(Bitmap fullScreenBitmap) { Font fntCourierRegular10 = Resource.GetFont(Resource.FontResources.CourierRegular10); Font fntComicSansMS16 = Resource.GetFont(Resource.FontResources.ComicSansMS16); Font fntNinaB = Resource.GetFont(Resource.FontResources.NinaB); Font fntSegoeUIRegular12 = Resource.GetFont(Resource.FontResources.SegoeUIRegular12); Font fntSmall = Resource.GetFont(Resource.FontResources.small); string strSmallFont = Resource.GetString(Resource.StringResources.strnSmallFont); string strNinaFont = Resource.GetString(Resource.StringResources.strNinaFont); string strComicSansMS16 = Resource.GetString(Resource.StringResources.strComicSansMS16); string strCourierRegular10 = Resource.GetString(Resource.StringResources.strCourierRegular10); string strSegoeUIRegular12 = Resource.GetString(Resource.StringResources.strSegoeUIRegular12); Color red = ColorUtility.ColorFromRGB(255, 0, 0); Color green = ColorUtility.ColorFromRGB(0, 255, 0); Color blue = ColorUtility.ColorFromRGB(0, 0, 255); fullScreenBitmap.Clear(); fullScreenBitmap.Flush(); fullScreenBitmap.DrawText(strSmallFont, fntSmall, red, 30, 10); fullScreenBitmap.DrawText(strSegoeUIRegular12, fntSegoeUIRegular12, blue, 30, 30); fullScreenBitmap.DrawText(strNinaFont, fntNinaB, green, 30, 60); fullScreenBitmap.DrawText(strComicSansMS16, fntComicSansMS16, red, 30, 120); fullScreenBitmap.DrawText(strCourierRegular10, fntCourierRegular10, blue, 30, 180); fullScreenBitmap.Flush(); }
/// <summary> /// Updates hints according to editMode value /// </summary> private void UpdateHint() { Font hintFont = nfResource.GetFont(nfResource.FontResources.NinaB); Color hintColor = ColorUtility.ColorFromRGB(206, 206, 206); hintTextFlow.TextRuns.Clear(); // Print editing hints if (editMode) { hintTextFlow.TextRuns.Add( nfResource.GetString(nfResource.StringResources.UseArrows), hintFont, hintColor); hintTextFlow.TextRuns.Add(TextRun.EndOfLine); hintTextFlow.TextRuns.Add( nfResource.GetString(nfResource.StringResources.PressSelect), hintFont, hintColor); } else { hintTextFlow.TextRuns.Add( nfResource.GetString(nfResource.StringResources.PressAnyKey), hintFont, hintColor); } hintTextFlow.Invalidate(); }
/// <summary> /// Constructs a ScrollPanelDemo for the specified program. /// </summary> /// <param name="program"></param> public ScrollPanelDemo(MySimpleWPFApplication program) : base(program) { // Create a stack panel for the title and scroll view. StackPanel panel = new StackPanel(Orientation.Vertical); // Create the text scroll view and set all of its properties. _viewer = new TextScrollViewer(Resource.GetString(Resource.StringResources.ScrollableText), MySimpleWPFApplication.NinaBFont, Color.Black); _viewer.Width = this.Width; // Make room for the title bar. _viewer.Height = this.Height - 25; _viewer.HScrollHeight = 10; _viewer.VScrollWidth = 10; _viewer.HorizontalAlignment = HorizontalAlignment.Left; _viewer.VerticalAlignment = VerticalAlignment.Top; // Create the title text Text title = new Text(MySimpleWPFApplication.NinaBFont, Resource.GetString(Resource.StringResources.ScrollableTextTitle)); title.ForeColor = Color.White; // Add the elements to the stack panel. panel.Children.Add(title); panel.Children.Add(_viewer); // Add the stack panel to this window. this.Child = panel; // Set the background color. this.Background = new SolidColorBrush(ColorUtility.ColorFromRGB(64, 64, 255)); }
/// <summary> /// Override the OnRender to enable manually drawing the scroll bars. /// </summary> /// <param name="dc"></param> public override void OnRender(DrawingContext dc) { base.OnRender(dc); // Make a brush and pen for drawing scroll bars. SolidColorBrush brush = new SolidColorBrush(ColorUtility.ColorFromRGB(224, 224, 224)); SolidColorBrush sliderBrush = new SolidColorBrush(ColorUtility.ColorFromRGB(64, 64, 64)); Pen pen = new Pen(ColorUtility.ColorFromRGB(64, 64, 64)); // Draw the horizontal scroll bar. int hOffset = (int)(_viewer.HorizontalOffset * _hScrollRatio); dc.DrawRectangle(brush, pen, 0, Height - _hScrollHeight, _hScrollWidth, _hScrollHeight); dc.DrawRectangle(sliderBrush, pen, (int)(_viewer.HorizontalOffset * _hScrollRatio), Height - _hScrollHeight, _vScrollWidth, _hScrollHeight); // Draw the vertical scroll bar. int vOffset = (int)(_viewer.VerticalOffset * _vScrollRatio); dc.DrawRectangle(brush, pen, Width - _vScrollWidth, 0, _vScrollWidth, _vScrollHeight); dc.DrawRectangle(sliderBrush, pen, Width - _vScrollWidth, vOffset, _vScrollWidth, _hScrollHeight); }
/// <summary> /// Creates new UniverseView for specified GameUniverse /// </summary> /// <param name="gameUniverse">GameUniverse to visualize</param> public UniverseView(GameUniverse gameUniverse) { this.gameUniverse = gameUniverse; blockPen = new Pen(Color.Black); gridPen = new Pen(ColorUtility.ColorFromRGB(25, 25, 25)); }
/// <summary> /// Handles the touch up event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected void Text_StylusUp(object sender, StylusEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, out x, out y); #else void Text_TouchUp(object sender, TouchEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, 0, out x, out y); #endif Text text = (Text)sender; // If we have already captured the touch, show the point. The // point will be in relation to the text object that captured // the touch. #if MF_FRAMEWORK_VERSION_V3_0 if (sender == Stylus.Captured) #else if (sender == TouchCapture.Captured) #endif { text.ForeColor = ColorUtility.ColorFromRGB(255, 0, 0); text.TextContent = "Captured. Tap to toggle. Up at (" + x + "," + y + ")"; } else { text.TextContent = "NOT Captured. Up detected at (" + x + "," + y + ")"; } }
public CalibrationWindow(Font font, string txt) { Height = SystemMetrics.ScreenHeight; Width = SystemMetrics.ScreenWidth; Visibility = Visibility.Visible; //Buttons.Focus(this); pen = new Pen(ColorUtility.ColorFromRGB(255, 0, 0), 1); Text text = new Text(); text.Font = font; text.ForeColor = Colors.Blue; text.TextContent = txt; text.TextWrap = true; text.SetMargin(0, 0, 0, SystemMetrics.ScreenHeight / 2); text.TextAlignment = TextAlignment.Center; text.HorizontalAlignment = HorizontalAlignment.Center; text.VerticalAlignment = VerticalAlignment.Center; Child = text; CalibrationManager.PrepareCalibrationPoints(); CalibrationManager.StartCalibration(); idx = 0; Invalidate(); }
/// <summary> /// Constructs a MyColorPalette with the specified settings. /// </summary> /// <param name="row"></param> /// <param name="column"></param> /// <param name="width"></param> /// <param name="height"></param> public MyColorPalette(int row, int column, int width, int height) : base(row, column, width, height) { color = new Color[16]; // Create the colors we will display. color[0] = ColorUtility.ColorFromRGB(255, 0, 0); color[1] = ColorUtility.ColorFromRGB(128, 0, 0); color[2] = ColorUtility.ColorFromRGB(64, 0, 0); color[3] = ColorUtility.ColorFromRGB(0, 255, 0); color[4] = ColorUtility.ColorFromRGB(0, 128, 0); color[5] = ColorUtility.ColorFromRGB(0, 64, 0); color[6] = ColorUtility.ColorFromRGB(0, 0, 255); color[7] = ColorUtility.ColorFromRGB(0, 0, 128); color[8] = ColorUtility.ColorFromRGB(0, 0, 64); color[9] = ColorUtility.ColorFromRGB(255, 255, 0); color[10] = ColorUtility.ColorFromRGB(128, 128, 0); color[11] = ColorUtility.ColorFromRGB(0, 255, 255); color[12] = ColorUtility.ColorFromRGB(0, 128, 128); color[13] = ColorUtility.ColorFromRGB(255, 0, 255); color[14] = ColorUtility.ColorFromRGB(128, 0, 128); color[15] = ColorUtility.ColorFromRGB(0, 0, 0); int i = 0; brushes = new Brush[16]; for (i = 0; i < 16; i++) { brushes[i] = new SolidColorBrush(color[i]); } }
public ConsoleUi(string windowTitle) { var panel = new StackPanel(); _timeText = new Text(_arial14, windowTitle) { TextAlignment = TextAlignment.Right, VerticalAlignment = VerticalAlignment.Top, ForeColor = ColorUtility.ColorFromRGB(255, 255, 0) }; panel.Children.Add(_timeText); var scroll = new ScrollViewer { Height = SystemMetrics.ScreenHeight - _arial14.Height, Width = SystemMetrics.ScreenWidth, ScrollingStyle = ScrollingStyle.Last, Background = null, LineHeight = _small.Height }; panel.Children.Add(scroll); _log = new TextFlow { HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Top }; scroll.Child = _log; Background = _solidBlack; Child = panel; }
public RandomClipping(Bitmap fullScreenBitmap, Font DisplayFont) { Random random = new Random(); fullScreenBitmap.Clear(); fullScreenBitmap.Flush(); Rect r0 = new Rect { x = 0, y = 0, width = fullScreenBitmap.Width, height = fullScreenBitmap.Height - 20 }; Rect r1 = new Rect { x = 20, y = 20, width = 100, height = 100 }; Rect r2 = new Rect { x = 180, y = 80, width = 100, height = 100 }; Rect r3 = new Rect { x = 20, y = 170, width = 100, height = 30 }; string additionalInfo = "Random Rectangles [No Clipping]"; for (int i = 0; i < 400; i++) { if (i == 100) { additionalInfo = "Clipping inside region [20,20,120,120]"; DullExistingLines(fullScreenBitmap, r0); ResetClippingAndDrawClippingRectangular(fullScreenBitmap, r1); fullScreenBitmap.SetClippingRectangle(r1.x, r1.y, r1.width, r1.height); fullScreenBitmap.Flush(); } if (i == 200) { additionalInfo = "Clipping inside region [180,80,280,180]"; ResetClippingAndDrawClippingRectangular(fullScreenBitmap, r2); fullScreenBitmap.SetClippingRectangle(r2.x, r2.y, r2.width, r2.height); fullScreenBitmap.Flush(); } if (i == 300) { additionalInfo = "Clipping inside region [20,170,120,200]"; ResetClippingAndDrawClippingRectangular(fullScreenBitmap, r3); fullScreenBitmap.SetClippingRectangle(r3.x, r3.y, r3.width, r3.height); fullScreenBitmap.Flush(); } int radiusX = random.Next(100); int radiusY = random.Next(100); int thicknessOutline = random.Next(5); Color colourGradientStart = ColorUtility.ColorFromRGB((byte)random.Next(255), (byte)random.Next(255), (byte)random.Next(255)); Color colourGradientEnd = ColorUtility.ColorFromRGB((byte)random.Next(255), (byte)random.Next(255), (byte)random.Next(255)); fullScreenBitmap.DrawEllipse((nanoFramework.Presentation.Media.Color)random.Next(0xFFFFFF), thicknessOutline, random.Next(fullScreenBitmap.Width), random.Next(fullScreenBitmap.Height - 20), radiusX, radiusY, colourGradientStart, 0, 0, colourGradientEnd, radiusX, radiusY, (ushort)random.Next(256)); DrawInformationBar(fullScreenBitmap, DisplayFont, additionalInfo); fullScreenBitmap.Flush(); } fullScreenBitmap.SetClippingRectangle(0, 0, fullScreenBitmap.Width, fullScreenBitmap.Height); }
/// <summary> /// Constructs a MyCanvas with the specified settings. /// </summary> /// <param name="width"></param> /// <param name="height"></param> public MyCanvas(int width, int height) : base(0, 0, width, height) { #if MF_FRAMEWORK_VERSION_V3_0 _drawingAttribs = new DrawingAttributes(); _drawingAttribs.Color = ColorUtility.ColorFromRGB(0, 0, 255); #endif }
/// <summary> /// Creates new NextBlockView element for given GameUniverse /// </summary> /// <param name="gameUniverse">GameUniverse to visualize</param> public NextBlockView(GameUniverse gameUniverse) { this._universe = gameUniverse; _blockPen = new Pen(Color.Black); _linePen = new Pen(Colors.White, 4); _fillBrush = new SolidColorBrush(ColorUtility.ColorFromRGB(164, 164, 164)); }
/// <summary> /// Constructs a MainMenuWindow for the specified program. /// </summary> /// <param name="program"></param> public MainMenuWindow(MySimpleWPFApplication program) : base(program) { // Create some colors for the text items. Color instructionTextColor = ColorUtility.ColorFromRGB(255, 255, 255); Color backgroundColor = ColorUtility.ColorFromRGB(0, 0, 0); Color upperBackgroundColor = ColorUtility.ColorFromRGB(69, 69, 69); Color unselectedItemColor = ColorUtility.ColorFromRGB(192, 192, 192); Color selectedItemColor = ColorUtility.ColorFromRGB(128, 128, 128); // The Main window contains a veritcal StackPanel. StackPanel panel = new StackPanel(Orientation.Vertical); this.Child = panel; // The top child contains a horizontal StackPanel. m_MenuItemPanel = new MenuItemPanel(this.Width, this.Height); // The top child contains the menu items. We pass in the small bitmap, // large bitmap a description and then a large bitmap to use as a common // sized bitmap for calculating the width and height of a MenuItem. MenuItem menuItem1 = new MenuItem( Resources.BitmapResources.Vertical_Stack_Panel_Icon_Small, Resources.BitmapResources.Vertical_Stack_Panel_Icon, "Vertical Stack Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem2 = new MenuItem( Resources.BitmapResources.Horizontal_Stack_Panel_Icon_Small, Resources.BitmapResources.Horizontal_Stack_Panel_Icon, "Horizontal Stack Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem3 = new MenuItem( Resources.BitmapResources.Canvas_Panel_Icon_Small, Resources.BitmapResources.Canvas_Panel_Icon, "Canvas Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem4 = new MenuItem( Resources.BitmapResources.Scrollable_Panel_Icon_Small, Resources.BitmapResources.Scrollable_Panel_Icon, "Scrollable Panel", Resources.BitmapResources.Canvas_Panel_Icon); MenuItem menuItem5 = new MenuItem( Resources.BitmapResources.Free_Drawing_Panel_Icon_Small, Resources.BitmapResources.Free_Drawing_Panel_Icon, "Free Drawing Panel", Resources.BitmapResources.Canvas_Panel_Icon); // Add each of the menu items to the menu item panel m_MenuItemPanel.AddMenuItem(menuItem1); m_MenuItemPanel.AddMenuItem(menuItem2); m_MenuItemPanel.AddMenuItem(menuItem3); m_MenuItemPanel.AddMenuItem(menuItem4); m_MenuItemPanel.AddMenuItem(menuItem5); // Add the menu item panel to the main window panel panel.Children.Add(m_MenuItemPanel); }
public ToolButton(string name, UIElement content) { this.name = name; brushPressed = new SolidColorBrush(ColorUtility.ColorFromRGB(128, 255, 0)); brushPressed.Opacity = 200; Content = content; }
public static Color InvertColor(Color color) { byte r = (byte)(255 - ((int)color >> 8 * 0) & 0xFF), g = (byte)(255 - ((int)color >> 8 * 1) & 0xFF), b = (byte)(255 - ((int)color >> 8 * 2) & 0xFF); return(ColorUtility.ColorFromRGB(r, g, b)); }
private void CreateMonoBlack() { TextLightColor = Colors.White; TextDarkColor = Colors.DarkGray; ButtonBorderColor = Colors.LightGray; ButtonLightBrush = new LinearGradientBrush(ColorUtility.ColorFromRGB(169, 169, 169), ColorUtility.ColorFromRGB(126, 126, 126), 500, 0, 500, 1000); ButtonDarkBrush = new LinearGradientBrush(ColorUtility.ColorFromRGB(105, 105, 105), ColorUtility.ColorFromRGB(10, 10, 10), 500, 0, 500, 1000); }
/// <summary> /// Handles the touch down event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> #if MF_FRAMEWORK_VERSION_V3_0 protected void Text_StylusDown(object sender, StylusEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, out x, out y); #else void Text_TouchDown(object sender, TouchEventArgs e) { int x; int y; e.GetPosition((UIElement)sender, 0, out x, out y); #endif Text text = (Text)sender; // If we have already captured the touch, show the point. #if MF_FRAMEWORK_VERSION_V3_0 if (sender == Stylus.Captured) #else if (sender == TouchCapture.Captured) #endif { // If the user tapped inside the same control that has the // touch captured, release the capture. if ((x >= 0) && (y >= 0) && (x <= text.ActualWidth) && (y <= text.ActualHeight)) { #if MF_FRAMEWORK_VERSION_V3_0 Stylus.Capture(text, CaptureMode.None); #else TouchCapture.Capture(text, CaptureMode.None); #endif text.ForeColor = ColorUtility.ColorFromRGB(0, 0, 0); text.TextContent = "Capture Released."; } // Else, show the point as captured. else { text.TextContent = "Captured. Tap to toggle. Down at (" + x + "," + y + ")"; } } // Else, show the point as captured. else { text.ForeColor = ColorUtility.ColorFromRGB(255, 0, 0); text.TextContent = "Captured. Tap to toggle. Down at (" + x + "," + y + ")"; #if MF_FRAMEWORK_VERSION_V3_0 Stylus.Capture(text); #else TouchCapture.Capture(text); #endif } }
public Led(int width, int height) { Width = width; Height = height; activeBrush = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 240, 0)); //activeBrush = new SolidColorBrush(ColorUtility.ColorFromRGB(90, 90, 255)); inactiveBrush = new SolidColorBrush(Colors.DarkGray); border = new Pen(Colors.DarkGray, 1); Invalidate(); }
private void DrawCheckbox(int x, int y, bool Checked) { Core.Screen.DrawRectangle(Colors.DarkGray, 1, x, y, _cc.ConfirmationBoxSize, _cc.ConfirmationBoxSize, 0, 0, Colors.Wheat, x, y, Colors.LightGray, x, y + 14, 256); Core.Screen.DrawLine(Colors.Wheat, 1, x, y + _cc.ConfirmationBoxSize, x + _cc.ConfirmationBoxSize, y + _cc.ConfirmationBoxSize); Core.Screen.DrawLine(Colors.Wheat, 1, x + _cc.ConfirmationBoxSize, y, x + _cc.ConfirmationBoxSize, y + _cc.ConfirmationBoxSize); if (Checked) { Core.Screen.DrawRectangle(ColorUtility.ColorFromRGB(73, 187, 0), 1, x + 4, y + 4, _cc.ConfirmationBoxSize - 8, _cc.ConfirmationBoxSize - 8, 0, 0, ColorUtility.ColorFromRGB(160, 243, 0), x, y, ColorUtility.ColorFromRGB(73, 187, 0), x, y + _cc.ConfirmationBoxSize, 256); } }
protected override void OnIsSelectedChanged(bool isSelected) { if (isSelected) { Color selectionColor = ColorUtility.ColorFromRGB(0x00, 0x94, 0xFF); this.Background = new SolidColorBrush(selectionColor); } else { this.Background = null; } }
public static Color GetMedianColor(Color c1, Color c2) { byte r1 = (byte)(((int)c1 >> 8 * 0) & 0xFF), g1 = (byte)(((int)c1 >> 8 * 1) & 0xFF), b1 = (byte)(((int)c1 >> 8 * 2) & 0xFF), r2 = (byte)(((int)c2 >> 8 * 0) & 0xFF), g2 = (byte)(((int)c2 >> 8 * 1) & 0xFF), b2 = (byte)(((int)c2 >> 8 * 2) & 0xFF); return(ColorUtility.ColorFromRGB((byte)((r1 + r2) / 2), (byte)((g1 + g2) / 2), (byte)((b1 + b2) / 2))); }
/// <summary> /// Alpha-blended Image /// </summary> /// <param name="bytes">Image32 Data</param> public Image32(byte[] bytes) { // Check Magic Key if (bytes[0] != 80 || bytes[1] != 50 || bytes[2] != 73) { throw new Exception("Invalid image format"); } // Get Number of Pixels int lPixels = BytesToInt(bytes[3], bytes[4], bytes[5], bytes[6]); // Confim Number // In future version -2 will denote version 2 if (lPixels < 0) { throw new Exception("Invalid Color Length"); } // Create Array _pixels = new ColorEX[lPixels]; // Copy out colors int lIndex = 7; for (int l = 0; l < _pixels.Length; l++) { var c = new ColorEX { X = BytesToInt(bytes[lIndex], bytes[lIndex + 1]) }; lIndex += 2; c.Y = BytesToInt(bytes[lIndex], bytes[lIndex + 1]); lIndex += 2; c.Alpha = (ushort)(bytes[lIndex++] + 1); c.Color = ColorUtility.ColorFromRGB(bytes[lIndex], bytes[lIndex + 1], bytes[lIndex + 2]); lIndex += 3; _pixels[l] = c; } // Remainder of file is flat Bitmap with RGB(255, 0, 255) transparency color try { var bBmp = new byte[bytes.Length - lIndex]; Array.Copy(bytes, (int)lIndex, bBmp, 0, bBmp.Length); _bmp = new Bitmap(bBmp, Bitmap.BitmapImageType.Bmp); _bmp.MakeTransparent(ColorUtility.ColorFromRGB(255, 0, 255)); } // ReSharper disable once EmptyGeneralCatchClause catch { } }
// ReSharper restore InconsistentNaming #endregion #region Constructor /// <summary> /// Creates a new calibration configuration /// </summary> public CalibrationConfiguration() { BackgroundGradientTop = Colors.White; BackgroundGradientBottom = Colors.White; ForeColor = ColorUtility.ColorFromRGB(0, 161, 241); CrossHairColor = ColorUtility.ColorFromRGB(246, 83, 20); InitialText = INIT_CALI_TEXT; CalibrationText = CNFG_CALI_TEXT; ConfirmationText = CONF_CALI_TEXT; ConfirmationTimeout = 30; ConfirmationBoxSize = 20; Font = Resources.GetFont(Resources.FontResources.droid12); ConfirmationBoxSpacing = 50; }
public Appbar(string name, int size, Font timeFont, Font menuFont, DockLocation dock, bool displayTime) { Name = name; _timeFont = timeFont; _font = menuFont; _dock = dock; _timeFormat = TimeFormat.Hour12; _displayTime = displayTime; Metrics(size); _bkg = ColorUtility.ColorFromRGB(30, 30, 30); _fore = Colors.White; _elli = new Bitmap(4, 4); _elliRect = new rect(Left, Top, 64, 64); UpdateEllipsis(); }
public Button(UIElement content) { brushUnpressed = new SolidColorBrush(Colors.Black); brushUnpressed.Opacity = 10; brushPressed = new SolidColorBrush(ColorUtility.ColorFromRGB(128, 255, 0)); brushPressed.Opacity = 200; brushTransparent = new SolidColorBrush(Colors.Red); brushTransparent.Opacity = Bitmap.OpacityTransparent; border = new Pen(Colors.DarkGray, 1); Content = content; }
public MFTestResults Color_ColorFromRGBTest2() { MFTestResults testResult = MFTestResults.Pass; Color c = ColorUtility.ColorFromRGB(0, 0, 0); if (Colors.Black != c) { Log.Comment("Failure : expected Black(" + c.ToString() + ") but got " + Colors.Black.ToString()); testResult = MFTestResults.Fail; } c = ColorUtility.ColorFromRGB(0, 128, 0); if (Colors.Green != c) { Log.Comment("Failure : expected Green(" + c.ToString() + ") but got " + Colors.Green.ToString()); testResult = MFTestResults.Fail; } c = ColorUtility.ColorFromRGB(0, 0, 255); if (Colors.Blue != c) { Log.Comment("Failure : expected Blue(" + c.ToString() + ") but got " + Colors.Blue.ToString()); testResult = MFTestResults.Fail; } c = ColorUtility.ColorFromRGB(0x80, 0x80, 0x80); if (Colors.Gray != c) { testResult = MFTestResults.Fail; } c = ColorUtility.ColorFromRGB(255, 255, 255); if (Color.White != c) { Log.Comment("Failure : expected White(" + c.ToString() + ") but got " + Colors.Black.ToString()); testResult = MFTestResults.Fail; } Color darkBlue = (Color)0x8B0000; c = ColorUtility.ColorFromRGB(0x00, 0x00, 0x8B); if (darkBlue != c) { Log.Comment("Failure : expected darkBlue(" + c.ToString() + ") but got " + Colors.Black.ToString()); testResult = MFTestResults.Fail; } return(testResult); }
public MFTestResults Color_Test1() { MFTestResults testResult = MFTestResults.Pass; Color darkBlue = ColorUtility.ColorFromRGB(0x00, 0x00, 0x8B); if (darkBlue != (Color)0x8B0000) { testResult = MFTestResults.Fail; } if (darkBlue != (Color)9109504) { testResult = MFTestResults.Fail; } return(testResult); }
/// <summary> /// Overrides the base class OnRender method, to handle drawing. /// </summary> /// <param name="dc"></param> public override void OnRender(DrawingContext dc) { // Call the base class. base.OnRender(dc); // Create a solid black brush. SolidColorBrush brush = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 0, 0)); // Make the brush transparent. Display only the outside edge, which // uses the pen. brush.Opacity = 0; // Draw the border around the outside. dc.DrawRectangle(brush, new Pen(Color.Black), 0, 0, dc.Width, dc.Height); }
public static Color GetMedianColor(Color c1, Color c2, Color c3) { byte r1 = (byte)(((int)c1 >> 8 * 0) & 0xFF), g1 = (byte)(((int)c1 >> 8 * 1) & 0xFF), b1 = (byte)(((int)c1 >> 8 * 2) & 0xFF), r2 = (byte)(((int)c2 >> 8 * 0) & 0xFF), g2 = (byte)(((int)c2 >> 8 * 1) & 0xFF), b2 = (byte)(((int)c2 >> 8 * 2) & 0xFF), r3 = (byte)(((int)c3 >> 8 * 0) & 0xFF), g3 = (byte)(((int)c3 >> 8 * 1) & 0xFF), b3 = (byte)(((int)c3 >> 8 * 2) & 0xFF); return(ColorUtility.ColorFromRGB((byte)((r1 + r2 + r3) / 3), (byte)((g1 + g2 + g3) / 3), (byte)((b1 + b2 + b3) / 3))); }
private void Initialize() { MatrixFont = Primitives.Resource.GetFont(Resource.FontResources.MatrixFont); BackgroundColour = Color.Black; TextColour = ColorUtility.ColorFromRGB(0x66, 0xff, 00); LetterAdvanceWidth = MatrixFont.CharWidth('c'); LetterAdvanceHeight = MatrixFont.Height; xOffset = 1; yOffset = 1; //BaselineOrigin = new PointAndChar(2, 2, " "); Drops = new int[(int)(FullScreenBitmap.Width / LetterAdvanceWidth)]; for (var x = 0; x < Drops.Length; x++) { Drops[x] = 1; } }