Example #1
0
 private void displayPadAndBall()
 {
     canvasField.Cursor = Cursors.None;
     ball.SetValue(Canvas.TopProperty, Convert.ToDouble(pad.GetValue(Canvas.TopProperty)) - 30);
     ball.SetValue(Canvas.LeftProperty, Convert.ToDouble(pad.GetValue(Canvas.LeftProperty)) + 15);
     pad.Visibility         = Visibility.Visible;
     ball.Visibility        = Visibility.Visible;
     IsBallOnPad            = true;
     canvasField.MouseDown += canvasField_MouseDown;
 }
Example #2
0
        private void PublishRecalibration(int tab_index)
        {
            Dispatcher.Invoke(new Action(() =>
            {
                recalibrateMsg theMsg = new recalibrateMsg();
                theMsg.data           = new imgData();
                theMsg.img            = new sm.CompressedImage();
                theMsg.data.cameraID  = tab_index;
                theMsg.data.width     = (int)mouseBox.Width;
                theMsg.data.height    = (int)mouseBox.Height;
                theMsg.data.x         = (int)(double)mouseBox.GetValue(Canvas.LeftProperty); // ew gross
                theMsg.data.y         = (int)(double)mouseBox.GetValue(Canvas.TopProperty);
                theMsg.data.color     = new m.ColorRGBA();
                theMsg.data.color.r   = boxColor;
                theMsg.data.color.g   = boxColor;
                theMsg.data.color.b   = boxColor;
                theMsg.data.color.a   = boxColor;
                //theMsg.img = (sender as ROS_ImageWPF.CompressedImageControl).latestFrame;
                switch (tab_index)
                {
                case 0:
                    theMsg.img = camImage0.latestFrame;
                    recalPub0.publish(theMsg);
                    break;

                case 1:
                    theMsg.img = camImage1.latestFrame;
                    recalPub1.publish(theMsg);
                    break;

                case 2:
                    theMsg.img = camImage2.latestFrame;
                    recalPub2.publish(theMsg);
                    break;

                case 3:
                    theMsg.img = camImage3.latestFrame;
                    recalPub3.publish(theMsg);
                    break;
                }
                //ROS.spinOnce(nh);
            }));
        }
Example #3
0
        //设置直通和交换的rectangle中的不同显示
        public void SetRectanglesStatus(int flag, Rectangle rect)
        {
            Line line1 = new Line();
            line1.Stroke = new SolidColorBrush(Colors.Black);
            line1.SetValue(Canvas.TopProperty, (double)rect.GetValue(Canvas.TopProperty));
            line1.SetValue(Canvas.LeftProperty, (double)rect.GetValue(Canvas.LeftProperty));

            Line line2 = new Line();
            line2.Stroke = new SolidColorBrush(Colors.Black);
            line2.SetValue(Canvas.TopProperty, (double)rect.GetValue(Canvas.TopProperty));
            line2.SetValue(Canvas.LeftProperty, (double)rect.GetValue(Canvas.LeftProperty));

            //交换
            if (flag == 2)
            {
                line1.X1 = 0;
                line1.Y1 = rect.Height / 6;
                line1.X2 = rect.Width;
                line1.Y2 = (rect.Height * 5) / 6;

                line2.X1 = 0;
                line2.Y1 = (rect.Height * 5) / 6;
                line2.X2 = rect.Width;
                line2.Y2 = rect.Height / 6;

                MainWindow.mainwindow.canvas.Children.Add(line1);
                MainWindow.mainwindow.canvas.Children.Add(line2);

            }
            //直通
            else if (flag == 1)
            {

                line1.X1 = 0;
                line1.Y1 = rect.Height / 6;
                line1.X2 = rect.Width;
                line1.Y2 = rect.Height / 6;

                line2.X1 = 0;
                line2.Y1 = (rect.Height * 5) / 6;
                line2.X2 = rect.Width;
                line2.Y2 = (rect.Height * 5) / 6;
                MainWindow.mainwindow.canvas.Children.Add(line1);
                MainWindow.mainwindow.canvas.Children.Add(line2);

            }
        }
		public void Check_Default ()
		{
			DependencyProperty property = DependencyProperty.Register ("MyProp", typeof (int), typeof(Rectangle), new PropertyMetadata (100));
			Rectangle r = new Rectangle ();
			r.SetValue (property, 10);
			Assert.AreEqual (10, r.GetValue (property), "#1");
			r.ClearValue (property);
			Assert.AreEqual (100, r.GetValue (property), "#2");
		}
		public void Check_Default_Nullable ()
		{
			DependencyProperty property = DependencyProperty.Register ("MyPropNullable", typeof (int?), typeof(Rectangle), null);
			Rectangle r = new Rectangle ();
			r.SetValue (property, 10);
			Assert.AreEqual (10, r.GetValue (property), "#1");
			r.ClearValue (property);
			Assert.AreEqual (null, r.GetValue (property), "#2");
		}
Example #6
0
		public void ComplexTarget13 ()
		{
			bool complete = false;
			Storyboard sb = (Storyboard) XamlReader.Load (
@"<Storyboard xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
              xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
	<DoubleAnimation Duration=""0:0:0.05"" Storyboard.TargetName=""target"" Storyboard.TargetProperty=""(UIElement.Height)"" To=""50"" />
</Storyboard>");
			sb.Completed += delegate { complete = true; };
			Rectangle g = new Rectangle ();
			Storyboard.SetTarget (sb, g);
			Enqueue (() => { TestPanel.Children.Add (g); TestPanel.Resources.Add ("a", sb); });
			Enqueue (() => sb.Begin ());
			EnqueueConditional (() => complete);
			Enqueue (() => Assert.AreEqual (Double.NaN, g.GetValue (Rectangle.HeightProperty)));
			Enqueue (() => { TestPanel.Children.Clear (); TestPanel.Resources.Clear (); });
			EnqueueTestComplete ();
		}
        private void EncodeCanvas(Canvas canvas, Rectangle icon, string name, string filePath)
        {
            RenderTargetBitmap targetBitmap =
                new RenderTargetBitmap((int)canvas.Width,
                                       (int)canvas.Height,
                                       96d, 96d,
                                       PixelFormats.Pbgra32);
            var isolatedVisual = new DrawingVisual();
            var canvasLeft = (icon.GetValue(Canvas.LeftProperty) as double?) ?? 0d;
            canvasLeft = double.IsNaN(canvasLeft) ? 0d : canvasLeft;
            var canvasTop = (icon.GetValue(Canvas.TopProperty) as double?) ?? 0d;
            canvasTop = double.IsNaN(canvasTop) ? 0d : canvasTop;
            using (var drawing = isolatedVisual.RenderOpen())
            {
                drawing.DrawRectangle(new VisualBrush(icon), null, new Rect(new Point(canvasLeft, canvasTop), new Size((int)icon.Width, (int)icon.Height)));
            }
            targetBitmap.Render(isolatedVisual);

            // add the RenderTargetBitmap to a Bitmapencoder
            var encoder = new PngBitmapEncoder();
            encoder.Frames.Add(BitmapFrame.Create(targetBitmap));

            // save file to disk
            string fileOut = filePath + "\\" + name;
            using (var fs = File.Open(fileOut, FileMode.OpenOrCreate))
            {
                encoder.Save(fs);
            }
        }
        public void DrawAnnotations()
        {
            RemoveAllAnnotations();
            var xAxis = Chart.XAxis as DateTimeAxis;
            if (xAxis == null || xAxis.ActualRange == null) return;
            foreach (var sensor in _viewModel.SensorsToCheckMethodsAgainst)
            {
                var lastLeft = -1d;
                foreach (var source in sensor.CurrentState.Changes.Where(change => change.Key >= xAxis.ActualRange.EffectiveMinimum && change.Key <= xAxis.ActualRange.EffectiveMaximum).OrderBy(x => x.Key))
                {
                    var changes = source.Value.Aggregate("",
                                                     (current, next) =>
                                                     string.Format("\r\n{0}",
                                                                   ChangeReason.ChangeReasons.FirstOrDefault(
                                                                       x => x.ID == next)));
                    var rect = new Rectangle
                                   {
                                       Width = 5,
                                       Height = 5,
                                       ToolTip =
                                       string.Format("[{0}] {1}{2}", sensor.Name, source.Key, changes),
                                       StrokeThickness = 0d,
                                       Fill = new SolidColorBrush(sensor.Colour),
                                       Opacity = 0.7d
                                   };
                    rect.SetValue(Canvas.TopProperty, 20d);
                    rect.SetValue(Canvas.LeftProperty, xAxis.GetDataValueAsRenderPositionWithoutZoom(source.Key) - rect.Width / 2);
                    if ((double)rect.GetValue(Canvas.LeftProperty) - lastLeft > 2d)
                    {
                        _annotations.Add(rect);
                        lastLeft = (double)rect.GetValue(Canvas.LeftProperty);
                    }

                }
            }
            Debug.Print("There are {0} annotations to draw", _annotations.Count);
            foreach (var annotation in _annotations)
            {
                _canvas.Children.Add(annotation);
            }
        }