private void button1_Click(object sender, EventArgs e) { using (Bitmap bmp1 = new Bitmap(400, 500)) using (var bmplock = bmp1.Lock()) { WriteableBitmap wb = bmplock.GetWritableBitmap(); //lines int y = 0; wb.DrawLine(0, y, 100, y + 100, System.Windows.Media.Imaging.Color.FromArgb(255, 255, 0, 0)); //red wb.DrawLine(0, y + 100, 100, y + 0, System.Windows.Media.Imaging.Color.FromArgb(255, 0, 0, 255)); //blue wb.DrawLineAa(100, y, 200, y + 100, System.Windows.Media.Imaging.Color.FromArgb(255, 255, 0, 0)); wb.DrawLineAa(100, y + 100, 200, y + 0, System.Windows.Media.Imaging.Color.FromArgb(255, 0, 0, 255)); //blue //---------- y += 150; wb.DrawLineDDA(0, y, 100, y + 100, System.Windows.Media.Imaging.Color.FromArgb(255, 255, 0, 0)); //red wb.DrawLineDDA(0, y + 100, 100, y + 0, System.Windows.Media.Imaging.Color.FromArgb(255, 0, 0, 255)); //blue wb.DrawEllipse(200, 0, 300, 100, System.Windows.Media.Imaging.Color.FromArgb(255, 255, 0, 0)); // bmplock.WriteAndUnlock(); bmp1.Save("d:\\WImageTest\\a0002.png"); } }
public void DrawEllipse(double startX, double startY, double endX, double endY, Color color) { startX = Offset.X + startX * Scale; startY = Offset.Y + startY * Scale; endX = Offset.X + endX * Scale; endY = Offset.Y + endY * Scale; bmp.DrawEllipse((int)startX, (int)startY, (int)endX, (int)endY, color); }
/// <summary> /// When the mouse is moved, highlight the nearby nodes. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cnvPoints_MouseMove(object sender, MouseEventArgs e) { // Bail if nothing to draw on. if (pBitmap == null) { return; } // Get valid values for the search from the text box. int iMax = 0; txtFindMax.Foreground = Brushes.Black; if (!int.TryParse(txtFindMax.Text, out iMax)) { txtFindMax.Foreground = Brushes.Red; } double fThreshold = -1; txtFindThreshold.Foreground = Brushes.Black; if (!double.TryParse(txtFindThreshold.Text, out fThreshold)) { txtFindThreshold.Foreground = Brushes.Red; } // Compute the square threshold as we use a square distance function. var bNegative = fThreshold < 0; fThreshold = fThreshold * fThreshold; if (bNegative) { fThreshold = -fThreshold; } // Get the drawing context. using (pBitmap.GetBitmapContext()) { // Get the point to query from. var vPoint = e.GetPosition(cnvPoints); // Perform a nearest neighbour search around that point. var pIter = pTree.NearestNeighbors(new double[] { vPoint.X, vPoint.Y }, iMax, fThreshold); while (pIter.MoveNext()) { // Get the ellipse. var pEllipse = pIter.Current; // Draw it if necessary. if (pEllipse.Filled == false) { pBitmap.FillEllipse((int)pEllipse.x - 2, (int)pEllipse.y - 2, (int)pEllipse.x + 2, (int)pEllipse.y + 2, Colors.Red); pBitmap.DrawEllipse((int)pEllipse.x - 2, (int)pEllipse.y - 2, (int)pEllipse.x + 2, (int)pEllipse.y + 2, Colors.Green); pEllipse.Filled = true; } } } }
/// <summary> /// A Fast Bresenham Type Algorithm For Drawing Ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf /// x2 has to be greater than x1 and y2 has to be greater than y1. /// </summary> /// <param name="bmp">The WriteableBitmap.</param> /// <param name="x1">The x-coordinate of the bounding rectangle's left side.</param> /// <param name="y1">The y-coordinate of the bounding rectangle's top side.</param> /// <param name="x2">The x-coordinate of the bounding rectangle's right side.</param> /// <param name="y2">The y-coordinate of the bounding rectangle's bottom side.</param> /// <param name="color">The color for the line.</param> public static void DrawEllipse(this WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color) { // Add one to use mul and cheap bit shift for multiplicaltion int a = color.A + 1; int col = (color.A << 24) | ((byte)((color.R * a) >> 8) << 16) | ((byte)((color.G * a) >> 8) << 8) | ((byte)((color.B * a) >> 8)); bmp.DrawEllipse(x1, y1, x2, y2, col); }
/// <summary> /// Randomise the layout of points. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_Click(object sender, RoutedEventArgs e) { // Create a new bitmap and set it as our canvas background. pBitmap = BitmapFactory.New((int)cnvPoints.ActualWidth, (int)cnvPoints.ActualHeight); var pBrush = new ImageBrush(); pBrush.ImageSource = pBitmap; cnvPoints.Background = pBrush; // Clear the bitmap to light blue. using (pBitmap.GetBitmapContext()) pBitmap.Clear(Colors.LightBlue); // Get the number we want to generate and update the UI. var iResult = 0; if (!int.TryParse(txtPoints.Text, out iResult)) { txtPoints.Foreground = Brushes.Red; return; } if (iResult < 0) { txtPoints.Foreground = Brushes.Red; return; } txtPoints.Foreground = Brushes.Black; // Clear the tree and canvas. cnvPoints.Children.Clear(); pTree = new KDTree.KDTree <EllipseWrapper>(2); // Create a list of points and draw a ghost ellipse for each one. using (pBitmap.GetBitmapContext()) { // Generate X new random items. var pRandom = new Random(); for (int i = 0; i < iResult; ++i) { // Position it and add it to the canvas. var x = pRandom.NextDouble() * cnvPoints.ActualWidth; var y = pRandom.NextDouble() * cnvPoints.ActualHeight; // Add it to the tree. pTree.AddPoint(new double[] { x, y }, new EllipseWrapper(x, y)); // Draw a ghost visual for it. //pBitmap.DrawEllipse((int)x - 2, (int)y - 2, (int)x + 2, (int)y + 2, Colors.Green); pBitmap.DrawEllipse((int)x - 2, (int)y - 2, (int)x + 2, (int)y + 2, Colors.Orange); } } }
public override void Draw(WriteableBitmap surface) { surface.FillEllipse((int)Position.X, (int)Position.Y, (int)(Position.X + Diameter), (int)(Position.Y + Diameter), Colors.LightGreen); surface.DrawEllipse((int)Position.X, (int)Position.Y, (int)(Position.X + Diameter), (int)(Position.Y + Diameter), Colors.Black); if (Position.X < (RIGHTNET - Diameter)) { surface.FillEllipse((int)(Position.X + (Diameter * 0.6f)), (int)(Position.Y + (Diameter * 0.1f)), (int)((Position.X + (Diameter * 0.6f)) + 17), (int)((Position.Y + (Diameter * 0.1f) + 17)), Colors.White); surface.FillEllipse((int)(Position.X + (Diameter * 0.71f)), (int)(Position.Y + (Diameter * 0.11)), (int)((Position.X + (Diameter * 0.71f)) + 7), (int)((Position.Y + (Diameter * 0.11f) + 7)), Colors.Black); } else if (Position.X >= LEFTNET) { surface.FillEllipse((int)(Position.X + (Diameter * 0.2f)), (int)(Position.Y + (Diameter * 0.1f)), (int)((Position.X + (Diameter * 0.2f)) + 17), (int)((Position.Y + (Diameter * 0.1f) + 17)), Colors.White); surface.FillEllipse((int)(Position.X + (Diameter * 0.22f)), (int)(Position.Y + (Diameter * 0.11)), (int)((Position.X + (Diameter * 0.22f)) + 7), (int)((Position.Y + (Diameter * 0.11f) + 7)), Colors.Black); } surface.FillRectangle((int)Position.X, (int)Position.Y + (int)(Diameter / 2), (int)Position.X + (int)(Diameter + 1f), (int)Position.Y + (int)(Diameter + 1f), Colors.SkyBlue); base.Draw(surface); }
internal void DrawEllipse(int startX, int startY, int endX, int endY, Color color) { if (startX > endX) { int temp; temp = startX; startX = endX; endX = temp; } if (startY > endY) { int temp; temp = startY; startY = endY; endY = temp; } _bitmap.DrawEllipse(startX / _owner.Magnification, startY / _owner.Magnification, endX / _owner.Magnification, endY / _owner.Magnification, color); }
public void PlotPoints(List <Point> points, Color?color = null) { if (color == null) { color = Colors.Black; } using (writeableBmp.GetBitmapContext()) { foreach (Point p in points) { writeableBmp.DrawEllipse((int)p.X - 2, (int)p.Y - 2, (int)p.X + 2, (int)p.Y + 2, (Color)color); //var l = new Label(); //l.Content = plotPointCount++; //l.Margin = new Thickness(Math.Round(p.X),Math.Round(p.Y) - 15,0,0); //grid.Children.Add(l); } } }
/// <summary> /// Draws random ellipses /// </summary> private void DrawEllipses(WriteableBitmap writeableBmp) { // Init some size vars int w = writeableBmp.PixelWidth - 2; int h = writeableBmp.PixelHeight - 2; int wh = w >> 1; int hh = h >> 1; // Wrap updates in a GetContext call, to prevent invalidation and nested locking/unlocking during this block using (writeableBmp.GetBitmapContext()) { // Clear writeableBmp.Clear(); // Draw Ellipses for (int i = 0; i < shapeCount; i++) { writeableBmp.DrawEllipse(rand.Next(wh), rand.Next(hh), rand.Next(wh, w), rand.Next(hh, h), GetRandomColor()); } // Invalidates on exit of using block } }
/// <summary> /// A Fast Bresenham Type Algorithm For Drawing Ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf /// x2 has to be greater than x1 and y2 has to be less than y1. /// </summary> /// <param name="bmp">The WriteableBitmap.</param> /// <param name="x1">The x-coordinate of the bounding rectangle's left side.</param> /// <param name="y1">The y-coordinate of the bounding rectangle's top side.</param> /// <param name="x2">The x-coordinate of the bounding rectangle's right side.</param> /// <param name="y2">The y-coordinate of the bounding rectangle's bottom side.</param> /// <param name="color">The color for the line.</param> public static void DrawEllipse(this WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color) { var col = ConvertColor(color); bmp.DrawEllipse(x1, y1, x2, y2, col); }
/// <summary> /// Draws the different types of shapes. /// </summary> private void DrawStaticShapes() { // Wrap updates in a GetContext call, to prevent invalidation and nested locking/unlocking during this block using (writeableBmp.GetBitmapContext()) { // Init some size vars int w = this.writeableBmp.PixelWidth - 2; int h = this.writeableBmp.PixelHeight - 2; int w3rd = w / 3; int h3rd = h / 3; int w6th = w3rd >> 1; int h6th = h3rd >> 1; // Clear writeableBmp.Clear(); // Draw some points for (int i = 0; i < 200; i++) { writeableBmp.SetPixel(rand.Next(w3rd), rand.Next(h3rd), GetRandomColor()); } // Draw Standard shapes writeableBmp.DrawLine(rand.Next(w3rd, w3rd * 2), rand.Next(h3rd), rand.Next(w3rd, w3rd * 2), rand.Next(h3rd), GetRandomColor()); writeableBmp.DrawTriangle(rand.Next(w3rd * 2, w - w6th), rand.Next(h6th), rand.Next(w3rd * 2, w), rand.Next(h6th, h3rd), rand.Next(w - w6th, w), rand.Next(h3rd), GetRandomColor()); writeableBmp.DrawQuad(rand.Next(0, w6th), rand.Next(h3rd, h3rd + h6th), rand.Next(w6th, w3rd), rand.Next(h3rd, h3rd + h6th), rand.Next(w6th, w3rd), rand.Next(h3rd + h6th, 2 * h3rd), rand.Next(0, w6th), rand.Next(h3rd + h6th, 2 * h3rd), GetRandomColor()); writeableBmp.DrawRectangle(rand.Next(w3rd, w3rd + w6th), rand.Next(h3rd, h3rd + h6th), rand.Next(w3rd + w6th, w3rd * 2), rand.Next(h3rd + h6th, 2 * h3rd), GetRandomColor()); // Random polyline int[] p = new int[rand.Next(7, 10) * 2]; for (int j = 0; j < p.Length; j += 2) { p[j] = rand.Next(w3rd * 2, w); p[j + 1] = rand.Next(h3rd, 2 * h3rd); } writeableBmp.DrawPolyline(p, GetRandomColor()); // Random closed polyline p = new int[rand.Next(6, 9) * 2]; for (int j = 0; j < p.Length - 2; j += 2) { p[j] = rand.Next(w3rd); p[j + 1] = rand.Next(2 * h3rd, h); } p[p.Length - 2] = p[0]; p[p.Length - 1] = p[1]; writeableBmp.DrawPolyline(p, GetRandomColor()); // Ellipses writeableBmp.DrawEllipse(rand.Next(w3rd, w3rd + w6th), rand.Next(h3rd * 2, h - h6th), rand.Next(w3rd + w6th, w3rd * 2), rand.Next(h - h6th, h), GetRandomColor()); writeableBmp.DrawEllipseCentered(w - w6th, h - h6th, w6th >> 1, h6th >> 1, GetRandomColor()); // Draw Grid writeableBmp.DrawLine(0, h3rd, w, h3rd, Colors.Black); writeableBmp.DrawLine(0, 2 * h3rd, w, 2 * h3rd, Colors.Black); writeableBmp.DrawLine(w3rd, 0, w3rd, h, Colors.Black); writeableBmp.DrawLine(2 * w3rd, 0, 2 * w3rd, h, Colors.Black); // Invalidates on exit of using block } }
/// <summary> /// A Fast Bresenham Type Algorithm For Drawing Ellipses http://homepage.smc.edu/kennedy_john/belipse.pdf /// x2 has to be greater than x1 and y2 has to be greater than y1. /// </summary> /// <param name="bmp">The WriteableBitmap.</param> /// <param name="x1">The x-coordinate of the bounding rectangle's left side.</param> /// <param name="y1">The y-coordinate of the bounding rectangle's top side.</param> /// <param name="x2">The x-coordinate of the bounding rectangle's right side.</param> /// <param name="y2">The y-coordinate of the bounding rectangle's bottom side.</param> /// <param name="color">The color for the line.</param> public static void DrawEllipse(this WriteableBitmap bmp, int x1, int y1, int x2, int y2, Color color) { bmp.DrawEllipse(x1, y1, x2, y2, (color.A << 24) | (color.R << 16) | (color.G << 8) | color.B); }
public void DrawEllipse(double x, double y, double width, double height, Color color) { _context.DrawEllipse((int)Math.Round(x), (int)Math.Round(y), (int)Math.Round(x + width), (int)Math.Round(y + height), color.ToArgb()); }
void canvas_PointerReleased(object sender, PointerRoutedEventArgs e) { if (e.Pointer.PointerId == PenID || e.Pointer.PointerId == TouchID) { MyInkManager.ProcessPointerUp(e.GetCurrentPoint(canvas)); } TouchID = 0; PenID = 0; e.Handled = true; Pencil = null; NewLine = null; NewRectangle = null; NewEllipse = null; //to draw line on our writable bitmap not on canvas. if (itisline) { wb.DrawLineDDA((int)lineX1, (int)lineY1, (int)lineX2, (int)lineY2, clr); } //to draw line on our actual rectangle. if (itisrectangle) { if (rectX2 > rectX1 && rectY2 > rectY1) { wb.DrawRectangle((int)rectX1, (int)rectY1, (int)rectX2, (int)rectY2, clr); } else if (rectX2 < rectX1 && rectY2 < rectY1) { wb.DrawRectangle((int)rectX2, (int)rectY2, (int)rectX1, (int)rectY1, clr); } else if (rectX2 > rectX1 && rectY2 < rectY1) { wb.DrawRectangle((int)rectX1, (int)rectY2, (int)rectX2, (int)rectY1, clr); } else if (rectX2 < rectX1 && rectY2 > rectY1) { wb.DrawRectangle((int)rectX2, (int)rectY1, (int)rectX1, (int)rectY2, clr); } } // to draw a ellipse if (itisellipse) { if (elipX2 > elipX1 && elipY2 > elipY1) { wb.DrawEllipse((int)elipX1, (int)elipY1, (int)elipX2, (int)elipY2, clr); } else if (elipX2 < elipX1 && elipY2 < elipY1) { wb.DrawEllipse((int)elipX2, (int)elipY2, (int)elipX1, (int)elipY1, clr); } else if (elipX2 > elipX1 && elipY2 < elipY1) { wb.DrawEllipse((int)elipX1, (int)elipY2, (int)elipX2, (int)elipY1, clr); } else if (elipX2 < elipX1 && elipY2 > elipY1) { wb.DrawEllipse((int)elipX2, (int)elipY1, (int)elipX1, (int)elipY2, clr); } } }
private void UpdateWiimoteChanged(WiimoteChangedEventArgs args) { WiimoteState ws = args.WiimoteState; ((CheckBox)clbButtons.Items[0]).IsChecked = ws.ButtonState.A; ((CheckBox)clbButtons.Items[1]).IsChecked = ws.ButtonState.B; ((CheckBox)clbButtons.Items[2]).IsChecked = ws.ButtonState.Minus; ((CheckBox)clbButtons.Items[3]).IsChecked = ws.ButtonState.Home; ((CheckBox)clbButtons.Items[4]).IsChecked = ws.ButtonState.Plus; ((CheckBox)clbButtons.Items[5]).IsChecked = ws.ButtonState.One; ((CheckBox)clbButtons.Items[6]).IsChecked = ws.ButtonState.Two; ((CheckBox)clbButtons.Items[7]).IsChecked = ws.ButtonState.Up; ((CheckBox)clbButtons.Items[8]).IsChecked = ws.ButtonState.Down; ((CheckBox)clbButtons.Items[9]).IsChecked = ws.ButtonState.Left; ((CheckBox)clbButtons.Items[10]).IsChecked = ws.ButtonState.Right; lblAccel.Text = ws.AccelState.Values.ToString(); chkLED1.IsChecked = ws.LEDState.LED1; chkLED2.IsChecked = ws.LEDState.LED2; chkLED3.IsChecked = ws.LEDState.LED3; chkLED4.IsChecked = ws.LEDState.LED4; switch (ws.ExtensionType) { case ExtensionType.Nunchuk: lblChuk.Text = ws.NunchukState.AccelState.Values.ToString(); lblChukJoy.Text = ws.NunchukState.Joystick.ToString(); chkC.IsChecked = ws.NunchukState.C; chkZ.IsChecked = ws.NunchukState.Z; break; case ExtensionType.ClassicController: ((CheckBox)clbCCButtons.Items[0]).IsChecked = ws.ClassicControllerState.ButtonState.A; ((CheckBox)clbCCButtons.Items[1]).IsChecked = ws.ClassicControllerState.ButtonState.B; ((CheckBox)clbCCButtons.Items[2]).IsChecked = ws.ClassicControllerState.ButtonState.X; ((CheckBox)clbCCButtons.Items[3]).IsChecked = ws.ClassicControllerState.ButtonState.Y; ((CheckBox)clbCCButtons.Items[4]).IsChecked = ws.ClassicControllerState.ButtonState.Minus; ((CheckBox)clbCCButtons.Items[5]).IsChecked = ws.ClassicControllerState.ButtonState.Home; ((CheckBox)clbCCButtons.Items[6]).IsChecked = ws.ClassicControllerState.ButtonState.Plus; ((CheckBox)clbCCButtons.Items[7]).IsChecked = ws.ClassicControllerState.ButtonState.Up; ((CheckBox)clbCCButtons.Items[8]).IsChecked = ws.ClassicControllerState.ButtonState.Down; ((CheckBox)clbCCButtons.Items[9]).IsChecked = ws.ClassicControllerState.ButtonState.Left; ((CheckBox)clbCCButtons.Items[10]).IsChecked = ws.ClassicControllerState.ButtonState.Right; ((CheckBox)clbCCButtons.Items[11]).IsChecked = ws.ClassicControllerState.ButtonState.ZL; ((CheckBox)clbCCButtons.Items[12]).IsChecked = ws.ClassicControllerState.ButtonState.ZR; ((CheckBox)clbCCButtons.Items[13]).IsChecked = ws.ClassicControllerState.ButtonState.TriggerL; ((CheckBox)clbCCButtons.Items[14]).IsChecked = ws.ClassicControllerState.ButtonState.TriggerR; lblCCJoy1.Text = ws.ClassicControllerState.JoystickL.ToString(); lblCCJoy2.Text = ws.ClassicControllerState.JoystickR.ToString(); lblTriggerL.Text = ws.ClassicControllerState.TriggerL.ToString(); lblTriggerR.Text = ws.ClassicControllerState.TriggerR.ToString(); break; case ExtensionType.Guitar: ((CheckBox)clbGuitarButtons.Items[0]).IsChecked = ws.GuitarState.FretButtonState.Green; ((CheckBox)clbGuitarButtons.Items[1]).IsChecked = ws.GuitarState.FretButtonState.Red; ((CheckBox)clbGuitarButtons.Items[2]).IsChecked = ws.GuitarState.FretButtonState.Yellow; ((CheckBox)clbGuitarButtons.Items[3]).IsChecked = ws.GuitarState.FretButtonState.Blue; ((CheckBox)clbGuitarButtons.Items[4]).IsChecked = ws.GuitarState.FretButtonState.Orange; ((CheckBox)clbGuitarButtons.Items[5]).IsChecked = ws.GuitarState.ButtonState.Minus; ((CheckBox)clbGuitarButtons.Items[6]).IsChecked = ws.GuitarState.ButtonState.Plus; ((CheckBox)clbGuitarButtons.Items[7]).IsChecked = ws.GuitarState.ButtonState.StrumUp; ((CheckBox)clbGuitarButtons.Items[8]).IsChecked = ws.GuitarState.ButtonState.StrumDown; ((CheckBox)clbTouchbar.Items[0]).IsChecked = ws.GuitarState.TouchbarState.Green; ((CheckBox)clbTouchbar.Items[1]).IsChecked = ws.GuitarState.TouchbarState.Red; ((CheckBox)clbTouchbar.Items[2]).IsChecked = ws.GuitarState.TouchbarState.Yellow; ((CheckBox)clbTouchbar.Items[3]).IsChecked = ws.GuitarState.TouchbarState.Blue; ((CheckBox)clbTouchbar.Items[4]).IsChecked = ws.GuitarState.TouchbarState.Orange; lblGuitarJoy.Text = ws.GuitarState.Joystick.ToString(); lblGuitarWhammy.Text = ws.GuitarState.WhammyBar.ToString(); lblGuitarType.Text = ws.GuitarState.GuitarType.ToString(); break; case ExtensionType.Drums: ((CheckBox)clbDrums.Items[0]).IsChecked = ws.DrumsState.Red; ((CheckBox)clbDrums.Items[1]).IsChecked = ws.DrumsState.Blue; ((CheckBox)clbDrums.Items[2]).IsChecked = ws.DrumsState.Green; ((CheckBox)clbDrums.Items[3]).IsChecked = ws.DrumsState.Yellow; ((CheckBox)clbDrums.Items[4]).IsChecked = ws.DrumsState.Orange; ((CheckBox)clbDrums.Items[5]).IsChecked = ws.DrumsState.Pedal; ((CheckBox)clbDrums.Items[6]).IsChecked = ws.DrumsState.Minus; ((CheckBox)clbDrums.Items[7]).IsChecked = ws.DrumsState.Plus; lbDrumVelocity.Items.Clear(); lbDrumVelocity.Items.Add(ws.DrumsState.RedVelocity); lbDrumVelocity.Items.Add(ws.DrumsState.BlueVelocity); lbDrumVelocity.Items.Add(ws.DrumsState.GreenVelocity); lbDrumVelocity.Items.Add(ws.DrumsState.YellowVelocity); lbDrumVelocity.Items.Add(ws.DrumsState.OrangeVelocity); lbDrumVelocity.Items.Add(ws.DrumsState.PedalVelocity); lblDrumJoy.Text = ws.DrumsState.Joystick.ToString(); break; case ExtensionType.BalanceBoard: if (chkLbs.IsChecked.HasValue && chkLbs.IsChecked.Value) { lblBBTL.Text = ws.BalanceBoardState.SensorValuesLb.TopLeft.ToString(); lblBBTR.Text = ws.BalanceBoardState.SensorValuesLb.TopRight.ToString(); lblBBBL.Text = ws.BalanceBoardState.SensorValuesLb.BottomLeft.ToString(); lblBBBR.Text = ws.BalanceBoardState.SensorValuesLb.BottomRight.ToString(); lblBBTotal.Text = ws.BalanceBoardState.WeightLb.ToString(); } else { lblBBTL.Text = ws.BalanceBoardState.SensorValuesKg.TopLeft.ToString(); lblBBTR.Text = ws.BalanceBoardState.SensorValuesKg.TopRight.ToString(); lblBBBL.Text = ws.BalanceBoardState.SensorValuesKg.BottomLeft.ToString(); lblBBBR.Text = ws.BalanceBoardState.SensorValuesKg.BottomRight.ToString(); lblBBTotal.Text = ws.BalanceBoardState.WeightKg.ToString(); } lblCOG.Text = ws.BalanceBoardState.CenterOfGravity.ToString(); break; case ExtensionType.MotionPlus: lblMPRawPitch.Text = ws.MotionPlusState.GyroRaw.X.ToString(); lblMPRawRoll.Text = ws.MotionPlusState.GyroRaw.Y.ToString(); lblMPRawYaw.Text = ws.MotionPlusState.GyroRaw.Z.ToString(); chcMPYawSlow.IsChecked = ws.MotionPlusState.SlowYaw; chcMPRollSlow.IsChecked = ws.MotionPlusState.SlowRoll; chcMPPitchSlow.IsChecked = ws.MotionPlusState.SlowPitch; lblMPPitch.Text = ws.MotionPlusState.Gyro.X.ToString("000.00"); lblMPRoll.Text = ws.MotionPlusState.Gyro.Y.ToString("000.00"); lblMPYaw.Text = ws.MotionPlusState.Gyro.Z.ToString("000.00"); break; } b.Clear(Color.FromArgb(255, 255, 255, 255)); UpdateIR(ws.IRState.IRSensors[0], lblIR1, lblIR1Raw, chkFound1, Color.FromArgb(255, 255, 0, 0)); UpdateIR(ws.IRState.IRSensors[1], lblIR2, lblIR2Raw, chkFound2, Color.FromArgb(255, 0, 255, 0)); UpdateIR(ws.IRState.IRSensors[2], lblIR3, lblIR3Raw, chkFound3, Color.FromArgb(255, 255, 255, 0)); UpdateIR(ws.IRState.IRSensors[3], lblIR4, lblIR4Raw, chkFound4, Color.FromArgb(255, 255, 127, 0)); if (ws.IRState.IRSensors[0].Found && ws.IRState.IRSensors[1].Found) { b.DrawEllipse((int)(ws.IRState.RawMidpoint.X / 4), (int)(ws.IRState.RawMidpoint.Y / 4), 5, 5, Color.FromArgb(255, 0, 0, 255)); } pbIR.Source = b; pbBattery.Value = (ws.Battery > 0xc8 ? 0xc8 : (int)ws.Battery); lblBattery.Text = ws.Battery.ToString(); lblDevicePath.Text = "Device Path: " + mWiimote.HIDDevicePath; }