//****Die Methode zeichnet und animieret einen Rechteck****//
 void Rechteck(int breite, int hoehe)
 {
     try
     {
         System.Windows.Shapes.Rectangle rechteck = new System.Windows.Shapes.Rectangle();
         Canvas.SetLeft(rechteck, start.X);
         Canvas.SetRight(rechteck, start.Y);
         //breite und hohe
         rechteck.Width  = breite;
         rechteck.Height = hoehe;
         rechteck.Stroke = pinselBrush;
         //und hinzufügen
         canvas.Children.Add(rechteck);
         rechteck.Fill = pinselBrush;
         DoubleAnimation animation = new DoubleAnimation();
         animation.From           = rechteck.Width;
         animation.To             = rechteck.Width / 2;
         animation.AutoReverse    = true;
         animation.RepeatBehavior = new RepeatBehavior(10);
         rechteck.BeginAnimation(WidthProperty, animation);
         rechteck.BeginAnimation(HeightProperty, animation);
     }
     catch (Exception)
     {
         Console.WriteLine("Es hat ein problem gegeben");
     }
 }
Esempio n. 2
0
        private void Canvas_MouseDown(object sender, MouseButtonEventArgs e)
        {
            startPoint = e.GetPosition(MarkerCanvas);

            var blah = new System.Windows.Shapes.Rectangle();

            rect = new System.Windows.Shapes.Rectangle
            {
                Stroke          = Brushes.LightBlue,
                StrokeThickness = 2
            };
            Canvas.SetLeft(rect, startPoint.X);
            Canvas.SetTop(rect, startPoint.X);
            MarkerCanvas.Children.Add(rect);
        }
        private void RefreshRectangleSelection()
        {
            if (X == System.Drawing.Point.Empty || Y == System.Drawing.Point.Empty)
            {
                return;
            }

            GuiCanvas.Children.Clear();

            System.Windows.Shapes.Rectangle rect = new System.Windows.Shapes.Rectangle
            {
                Stroke          = new SolidColorBrush(Colors.Red),
                Fill            = new SolidColorBrush(Colors.Transparent),
                Width           = GetAreaWidth,
                Height          = GetAreaHeight,
                StrokeThickness = 3
            };
            rect.MouseLeftButtonUp += GuiCanvas_MouseLeftButtonUp;

            Canvas.SetLeft(rect, X.X);
            Canvas.SetTop(rect, X.Y);

            GuiCanvas.Children.Add(rect);
        }
Esempio n. 4
0
	public System.Windows.Shapes.Rectangle ShowPositioningEntry (String TypeOfPositioning, String AddOnText)
		{
		//Point RootScreenPosition = RootUIElement.PointToScreen
		//            (new Point (0, 0));
		
		this.Left = (TargetPictureWidth * PositionPercentageLeft) / 100;
		this.Top = (TargetPictureHeight * PositionPercentageTop) / 100;
		this.Width = (TargetPictureWidth * (PositionPercentageRight - PositionPercentageLeft)) / 100;
		this.Height = (TargetPictureHeight * (PositionPercentageBottom - PositionPercentageTop)) / 100;

		System.Windows.Shapes.Rectangle PositionableEntry = new System.Windows.Shapes.Rectangle ();
		PositionableEntry.Width = (int)Width;
		PositionableEntry.Height = (int) Height;
		if (TypeOfPositioning == "Text")
			PositionableEntry.Stroke = (Brush) BRConverter.ConvertFromString ("Black");
		else
			PositionableEntry.Stroke = (Brush) BRConverter.ConvertFromString ("Red");
		PositionableEntry.StrokeThickness = 3;
		if (BlockRotation != 0)
			{
			RotateTransform TransformParameter = new RotateTransform (BlockRotation);
			PositionableEntry.RenderTransformOrigin = new Point ( - Left / Width, - Top / Height);
			PositionableEntry.RenderTransform = TransformParameter;
			}
		Canvas.SetLeft (PositionableEntry, (int) Left);
		Canvas.SetTop (PositionableEntry, Top);
		PositionableEntry.Tag = this;
		PositionableEntry.ToolTip = TypeOfPositioning + " " + AddOnText;
		PositionableEntry.MouseDown += new MouseButtonEventHandler (PositionableEntry_MouseDown);
		return PositionableEntry;
		}
Esempio n. 5
0
 private void Canvas_MouseUp(object sender, MouseButtonEventArgs e)
 {
     rect = null;
 }