private void btnDeleteSelectedObject_Click(object sender, RoutedEventArgs e) { if (this.currentSpatialObjectSelected != null) { if (this.currentSpatialObjectSelected is Ellipse) //if is city { Location locToDelete = getLocationDataFromEllName(this.currentSpatialObjectSelected.Name); //delete in oracle WebserviceManager.DeleteLocation(locToDelete.Id); } else if (this.currentSpatialObjectSelected is Line) //if is street { Street locToDelete = getStreetDataFromEllName(this.currentSpatialObjectSelected.Name); //delete in oracle WebserviceManager.DeleteStreet(locToDelete.Id); } //delte in canvas this.canSpatialData.Children.Remove(this.currentSpatialObjectSelected); this.currentSpatialObjectSelected = null; } else { this.printError("Keinen Ort bzw. keine Straße ausgewählt!"); } }
private void ShapeDialog_Loaded(object sender, System.Windows.RoutedEventArgs e) { if (Document.Editor.My.Computer.Info.OSVersion >= "6.0") { if (Document.Editor.My.Settings.Options_EnableGlass) { AppHelper.ExtendGlassFrame(this, new Thickness(-1, -1, -1, -1)); } } TypeComboBox.Items.Add("Circle"); TypeComboBox.Items.Add("Square"); TypeComboBox.SelectedIndex = 0; if (TypeComboBox.SelectedIndex == 0) { Shape = new System.Windows.Shapes.Ellipse(); Shape.Height = 32; Shape.Width = 32; int int2 = Convert.ToInt32(BorderSizeTextBox.Value); Shape.StrokeThickness = int2; Shape.Stroke = Brushes.Black; } else if (TypeComboBox.SelectedIndex == 1) { Shape = new System.Windows.Shapes.Rectangle(); Shape.Height = 32; Shape.Width = 32; int int2 = Convert.ToInt32(BorderSizeTextBox.Value); Shape.StrokeThickness = int2; Shape.Stroke = Brushes.Black; } ScrollViewer1.Content = Shape; }
public void DrawOver(Canvas container) { VisualElement = CreateEllipse(); Canvas.SetLeft(VisualElement, 40); Canvas.SetTop(VisualElement, 40); container.Children.Add(VisualElement); }
public Stand(int _ID, String _Name, String _Info, Shape _Shape) { ST_ID = _ID; ST_Name = _Name; ST_Info = _Info; ST_Shape = _Shape; }
private void MainWindow_MouseDown(object sender, MouseButtonEventArgs e) { isDrawing = false; moveFirst = true; isMoving = true; System.Windows.Shapes.Shape rect = (System.Windows.Shapes.Shape)(sender); chosenFigUI = rect; for (int i = 0; i < printedFigures.Count; i++) { if (printedFigures[i].hash == chosenFigUI.GetHashCode()) { chosenFig = printedFigures[i]; x = chosenFig.firstPoint; y = chosenFig.secondPoint; break; } } if (frame != null && inkCanvas.Children.IndexOf(frame) != -1) { inkCanvas.Children.Remove(frame); } inkCanvas.Children.Remove(chosenFigUI); inkCanvas.Children.Add(chosenFigUI); printedFigures.Remove(chosenFig); printedFigures.Add(chosenFig); DrawFrame(chosenFig); }
private void drawRectangle(MouseEventArgs e) { Polygon rect = new Polygon(); rect.Stroke = new SolidColorBrush(Color.FromArgb(parameters.LineColor.a, parameters.LineColor.r, parameters.LineColor.g, parameters.LineColor.b)); rect.StrokeThickness = parameters.Thickness; PointCollection myPointCollection = new PointCollection(); foreach (var item in new Geometry.Rectangle( new Geometry.Point(startPoint.X, startPoint.Y), new Geometry.Point(e.GetPosition(inkPanel).X, e.GetPosition(inkPanel).Y)).Points(parameters)) { myPointCollection.Add(new Point(item.x, item.y)); } rect.Points = myPointCollection; if (checkBoxFill.IsChecked == true) { rect.Fill = new SolidColorBrush(Color.FromArgb( parameters.FillColor.a, parameters.FillColor.r, parameters.FillColor.g, parameters.FillColor.b)); } inkPanel.Children.Add(rect); currentShape = rect; }
private void rect_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { System.Windows.Shapes.Shape button = (System.Windows.Shapes.Shape)sender; DeviceButton DB = (DeviceButton)button.Tag; OnButtonClick(DB); }
public sub_line(DestinationAlgorithms _dest_alg, horizontal_line _horiz_line, double startY, int from_id, int to_id) { this._dest_alg = _dest_alg; this._horiz_line = _horiz_line; this.from_id = from_id; this.to_id = to_id; SubLineHorizontal = new Line(); SubLineHorizontal.Stroke = Brushes.Blue; SubLineHorizontal.StrokeThickness = 0.2; ((Line)SubLineHorizontal).X1 = 50; ((Line)SubLineHorizontal).Y1 = startY; ((Line)SubLineHorizontal).X2 = 9950; ((Line)SubLineHorizontal).Y2 = startY; posY = startY; if (_horiz_line.SubLinesHorizontal == null) _horiz_line.SubLinesHorizontal = new List<sub_line>(); _horiz_line.SubLinesHorizontal.Add(this); label_horizontal = new Label(); label_horizontal.HorizontalContentAlignment = HorizontalAlignment.Center; label_horizontal.HorizontalContentAlignment = HorizontalAlignment.Center; label_horizontal.FontSize = 8; label_horizontal.Content = from_id + "-" + to_id; label_horizontal.Width = 30; _dest_alg.GantCanvas.Children.Add(SubLineHorizontal); _dest_alg.GantCanvas.Children.Add(label_horizontal); Canvas.SetZIndex(SubLineHorizontal, 0); Canvas.SetZIndex(label_horizontal, 2); Canvas.SetLeft(label_horizontal, 25); Canvas.SetTop(label_horizontal, startY - 12); }
private void rect1_MouseDown(object sender, MouseButtonEventArgs e) { Shape s = (Shape)sender; startx = Canvas.GetLeft(s); starty = Canvas.GetTop(s); s.MouseMove += rect1_MouseMove; s.CaptureMouse(); e.Handled = true; Point p = e.GetPosition((IInputElement)canvas1); deltax = p.X - Canvas.GetLeft(s); deltay = p.Y - Canvas.GetTop(s); if (last != null) { if (last.Effect != null) { last.Effect = null; Canvas.SetZIndex(last, 0); } } last = s; DropShadowEffect ef = new DropShadowEffect(); ef.Color = Colors.Red; ef.BlurRadius = 30; ef.ShadowDepth = 0; s.Effect = ef; Canvas.SetZIndex(last, 10); }
internal void setOnBoard(Shape shape, Point position) { removeFromBoard(shape); Canvas.SetLeft(shape, position.X); Canvas.SetTop(shape, position.Y); plane.Children.Add(shape); }
internal void removeFromBoard(Shape shape) { if (plane.Children.Contains(shape)) { plane.Children.Remove(shape); } }
/// <summary> /// This gets called when the template has been applied and we have our visual tree /// </summary> public override void OnApplyTemplate() { m_paintArea = Template.FindName("PART_PaintArea", this) as Shape; m_mainContent = Template.FindName("PART_MainContent", this) as ContentPresenter; base.OnApplyTemplate(); }
protected override void Show() { rubberband = CreateRubberband(); rubberband.Stroke = Brushes.Navy; rubberband.StrokeThickness = 1 / ZoomFactor; AdornerCanvas.Cursor = Cursors.Pen; }
private void Control_MouseDown(object sender, MouseButtonEventArgs e) { var shape = (sender as Shape); if (shape.Name.Contains("Play")) { mouseUpBrush = elPlay.Fill; mouseUpEllipse = elPlay; elPlay.OpacityMask = pathPlay.OpacityMask = Brushes.Black; elPlay.Fill = Brushes.Blue; } if (shape.Name.Contains("Stop")) { mouseUpBrush = elStop.Fill; mouseUpEllipse = elStop; elStop.OpacityMask = pathStop.OpacityMask = Brushes.Black; elStop.Fill = Brushes.Blue; } if (shape.Name.Contains("Pause")) { mouseUpBrush = elPause.Fill; mouseUpEllipse = elPause; elPause.OpacityMask = pathPause.OpacityMask = Brushes.Black; elPause.Fill = Brushes.Blue; } }
public Shape(Factory factory, SolidColorBrush color, int thickness, Point point1, Point point2) { this.factory = factory; figure = DrawFigure(); SetParameters(color, thickness, point1, point2); }
private void ConfiguraComponenteVisualArticulacao(Shape forma, int diametroArticulacao, int larguraDesenho, Brush corDesenho) { forma.Height = diametroArticulacao; forma.Width = diametroArticulacao; forma.StrokeThickness = larguraDesenho; forma.Stroke = corDesenho; }
public virtual void ReceiveObject(object obj) { if (obj is Shape) { _symbolShape = obj as Shape; UpdateSymbolShape(); } }
private void OnShapeVertexMouseDown(object sender, MouseButtonEventArgs e) { System.Windows.Shapes.Shape vertexShape = (System.Windows.Shapes.Shape)sender; this.controlledVertexIndex = this.vertexShapeToVertexIndex[vertexShape]; Point relativeMousePos = e.GetPosition(vertexShape); this.mouseOffset = new Vector(relativeMousePos.X - vertexShape.Width * 0.5, relativeMousePos.Y - vertexShape.Height * 0.5); }
public void Add(Shape Bob) { Bob.MouseLeftButtonDown += new MouseButtonEventHandler(Bob_MouseLeftButtonDown); Bob.MouseLeftButtonUp += new MouseButtonEventHandler(Bob_MouseLeftButtonUp); Bob.MouseMove += new MouseEventHandler(Bob_MouseMove); _shapes.Add(Bob); }
private void AddEventHandlers(System.Windows.Shapes.Shape shape) { shape.MouseRightButtonDown += DeleteShape; shape.MouseEnter += MouseEnterShape; shape.MouseLeave += MouseLeaveShape; shape.PreviewMouseLeftButtonDown += MouseLeftButtonDownShape; shape.MouseLeftButtonUp += MouseLeftButtonUpShape; }
public Rondje(double x, double y, double width, double height, Shape Rondje) { this.height = height; this.x = x; this.y = y; this.width = width; this.Graphics = Rondje; }
public Vierkant(double x, double y, double width, double height, Shape rectangle) { this.height = height; this.x = x; this.y = y; this.width = width; this.Graphics = rectangle; }
public static void SetStyle(Shape shape, ElementBase element) { shape.Fill = new SolidColorBrush(element.BackgroundColor); shape.Stroke = new SolidColorBrush(element.BorderColor); shape.StrokeThickness = element.BorderThickness; if (element.BackgroundPixels != null) shape.Fill = PainterHelper.CreateBrush(element.BackgroundPixels); }
public override void OnApplyTemplate() { stateIndicator = GetTemplateChild("PART_StateIndicator") as Shape; if (stateIndicator != null) { stateIndicator.SetBinding(Shape.FillProperty, new Binding("State") { Converter = StateConverter, Source = this }); } }
private void ConfigurarComponenteVisualArticulacao(Shape pForma, int pDiametroArticulacao, int pLarguraDesenho, Brush pCorDesenho, bool pPreencheComGradiente, bool pColorirGradienteMesmaCorDoPincel) { pForma.Height = pDiametroArticulacao; pForma.Width = pDiametroArticulacao; pForma.StrokeThickness = pLarguraDesenho; if (pPreencheComGradiente) { pForma.Stroke = Brushes.Black; RadialGradientBrush lGradiente = new RadialGradientBrush(); lGradiente.GradientOrigin = new Point(0.5, 0.5); lGradiente.Center = new Point(0.5, 0.5); lGradiente.RadiusX = 0.5; lGradiente.RadiusY = 0.5; Color lCor1; Color lCor2; if (pColorirGradienteMesmaCorDoPincel) { if (pCorDesenho == Brushes.Green) { lCor1 = Colors.Lime; lCor2 = Colors.DarkGreen; } else if (pCorDesenho == Brushes.Blue) { lCor1 = Colors.RoyalBlue; lCor2 = Colors.DarkBlue; } else { lCor1 = Colors.OrangeRed; lCor2 = Colors.DarkRed; } } else { lCor1 = Colors.OrangeRed; lCor2 = Colors.DarkRed; } //lCor1 = Colors.Lime; //lCor2 = Colors.DarkGreen; lGradiente.GradientStops.Add(new GradientStop(lCor1, 0.5)); lGradiente.GradientStops.Add(new GradientStop(lCor2, 1)); pForma.Fill = lGradiente; } else { pForma.Stroke = pCorDesenho; } }
public PathPoint(Point point, Object @object, Object parentObject, Action<Point> setLambda, Action save, Shape shape) { this._point = point; this._setLambda = setLambda; this.Object = @object; this.ParentObject = parentObject; this._shape = shape; this._save = save; }
/// <summary>${WP_mapping_ShapeElement_Constructors_D}</summary> protected ShapeElement(Shape shape) { shape.Stretch = Stretch.None; shape.RenderTransform = new ScaleTransform(); base.Content = this.shape = shape; pathIsInvalid = true; this.ClipBox = Rectangle2D.Empty; }
public void DrawOver(Canvas container) { VisualElement = CreateX(); //Canvas.SetLeft(VisualElement, x); //Canvas.SetTop(VisualElement, y); Canvas.SetLeft(VisualElement, 40); Canvas.SetTop(VisualElement, 50); container.Children.Add(VisualElement); }
void Bob_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (sender == _tracked) { _tracked.Opacity *= 2.0; _tracked.ReleaseMouseCapture(); _tracked = null; } }
public bool areColliding(Shape shape1, Point position1, Shape shape2, Point position2) { if (Math.Pow(position1.X - position2.X, 2) + Math.Pow(position1.Y - position2.Y, 2) <= Math.Pow((shape1.Width + shape2.Width) / 2, 2)) { return true; } return false; }
public ShapeCursorTarget(Shape shape, Canvas canvas, Point center, int width, int height) { this.canvas = canvas; this.Shape = shape; this.Shape.Fill = this.NonSelectedFill = Brushes.DarkBlue; this.Shape.Stroke = this.NonSelectedStroke = Brushes.WhiteSmoke; this.SelectedFill = Brushes.OrangeRed; this.SelectedStroke = Brushes.OrangeRed; SetBounds(center, width, height); }
public MoveShapeAdorner(Canvas canvas, Shape adornedElement) : base(adornedElement) { Point point = Mouse.GetPosition(adornedElement); mouseLeft = point.X; mouseTop = point.Y; this.canvas = canvas; canvas.MouseMove += new System.Windows.Input.MouseEventHandler(Canvas_MouseMove); }
public edge_view(graph_view _graph, node_view from_node, node_view to_node, string weight) { this._graph = _graph; if (from_node != to_node) { Line = new Line(); Line.MouseEnter += new MouseEventHandler(Line_MouseEnter); Line.MouseLeave += new MouseEventHandler(Line_MouseLeave); Line.MouseLeftButtonDown += new MouseButtonEventHandler(Line_MouseLeftButtonDown); Line.Stroke = Brushes.Black; Line.StrokeThickness = 1; ((Line)Line).X1 = 0; ((Line)Line).Y1 = 0; LeftLine = new Line(); RightLine = new Line(); RightLine.Stroke = LeftLine.Stroke = Brushes.Black; RightLine.StrokeThickness = LeftLine.StrokeThickness = 6; _graph.GRCanvas.Children.Add(LeftLine); _graph.GRCanvas.Children.Add(RightLine); if (Lines == null) { Lines = new List<Shape>(); Lines.Add(Line); Lines.Add(LeftLine); Lines.Add(RightLine); } textBox1 = new TextBox(); textBox1.Width = 50; br = new SolidColorBrush(Colors.Transparent); textBox1.BorderBrush = br; textBox1.VerticalContentAlignment = VerticalAlignment.Center; textBox1.HorizontalContentAlignment = HorizontalAlignment.Center; textBox1.FontSize = 14; TxtBox1_TextChanged(null, null); textBox1.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(TxtBox1_PreviewMouseLeftButtonDown); textBox1.TextChanged += new TextChangedEventHandler(TxtBox1_TextChanged); textBox1.Text = weight; edge_weight = int.Parse(textBox1.Text); opaqueBrush = new SolidColorBrush(Colors.Black); opaqueBrush.Opacity = 0; textBox1.Background = opaqueBrush; _graph.GRCanvas.Children.Add(textBox1); _graph.GRCanvas.Children.Add(Line); Canvas.SetZIndex(Line, 0); Canvas.SetZIndex(textBox1, 2); this.from_node = from_node; this.to_node = to_node; to_node.pointPositionChange += new graph_view.PointPositionChanged(OnPointPositionChanged); from_node.pointPositionChange += new graph_view.PointPositionChanged(OnPointPositionChanged); OnPointPositionChanged(to_node); OnPointPositionChanged(from_node); } else MessageBox.Show("Граф задачі має бути ациклічним!"); }
protected Shape(SerializationInfo info, StreamingContext context) { this.color = (SolidColorBrush)info.GetValue("color", typeof(SolidColorBrush)); this.thickness = (int)info.GetValue("thickness", typeof(int)); this.point1 = (Point)info.GetValue("point1", typeof(Point)); this.point2 = (Point)info.GetValue("point2", typeof(Point)); this.factory = (Factory)info.GetValue("factory", typeof(Factory)); figure = DrawFigure(); SetParameters(color, thickness, point1, point2); }
public StepShape(Shape shape) { _shape = shape; //_moving = false; _moveBackwardsHeight = false; _moveBackwardsWidth = false; CreateBoundingBox(); //BindEvents(); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); _levelOne = this.GetTemplateChild("PART_LevelOne") as Shape; _levelTwo = this.GetTemplateChild("PART_LevelTwo") as Shape; _levelThree = this.GetTemplateChild("PART_LevelThree") as Shape; _levelFour = this.GetTemplateChild("PART_LevelFour") as Shape; _levelFive = this.GetTemplateChild("PART_LevelFive") as Shape; RenderLevel(); }
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); if (e.OriginalSource is Shape) { clickSource = (Shape)e.OriginalSource; AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(clickSource); adornerLayer.Add(new MoveShapeAdorner(moveElementsCanvas, clickSource)); Mouse.Capture(clickSource); } }
private void FillShape(Shape shape) { switch (this.Color) { case ElementColor.Red: shape.Fill = new SolidColorBrush(Colors.Red); break; case ElementColor.Blue: shape.Fill = new SolidColorBrush(Colors.Blue); break; } }
//Set the map modification object type internal void setMapModObjectType() { if (mapModName.Equals("rectangle")) { mapModObject = new System.Windows.Shapes.Rectangle(); mapModObject.StrokeThickness = 3; } if (mapModName.Equals("circle")) { mapModObject = new System.Windows.Shapes.Ellipse(); mapModObject.StrokeThickness = 3; } if (mapModName.Equals("ramp") || mapModName.Equals("camp") || mapModName.Equals("stairs")) { mapModObject = new System.Windows.Shapes.Rectangle(); ImageBrush mapModImg = new ImageBrush(); MapMods mapModi = (MapMods)Enum.Parse(typeof(MapMods), mapModName); mapModImg.ImageSource = TechnicalServices.getImage(mapModi); mapModObject.Fill = mapModImg; } if (mapModName.Equals("text")) { textInput = MainWindow.getAdditionalTextInput(); if (textInput == null || textInput.Equals("")) { textInput = "Enter text"; } else { textInput = MainWindow.getAdditionalTextInput(); } System.Drawing.Font font = new System.Drawing.Font("Times New Roman", 35.0f); System.Drawing.Bitmap bitmap = DrawText(textInput, font, System.Drawing.Color.Black, System.Drawing.Color.Transparent); ToBitmapImage(bitmap); BitmapImage bitmapimg = ToBitmapImage(bitmap); mapModObject = new System.Windows.Shapes.Rectangle(); ImageBrush mapModImg = new ImageBrush(); mapModImg.ImageSource = bitmapimg; mapModObject.Fill = mapModImg; } if (mapModName.Equals("line")) { return; } }
private void drawEllipse(MouseEventArgs e, bool isEraser) { double R1, R2, l, r, b, t; l = startPoint.X; t = startPoint.Y; r = e.GetPosition(inkPanel).X; b = e.GetPosition(inkPanel).Y; R1 = (r - l) / 2.0; R2 = (t - b) / 2.0; Geometry.Point center = new Geometry.Point((l + r) / 2.0, (b + t) / 2.0); Polygon el = new Polygon(); el.Stroke = new SolidColorBrush(Color.FromArgb(parameters.LineColor.a, parameters.LineColor.r, parameters.LineColor.g, parameters.LineColor.b)); el.StrokeThickness = parameters.Thickness; PointCollection myPointCollection = new PointCollection(); /* * foreach (var item in new Geometry.Ellipse( * center, R1, R2).Points(parameters)) * { * myPointCollection.Add(new Point(item.x, item.y)); * }*/ var item = new Geometry.Ellipse(center, R1, R2).Points(parameters); for (double Angle = 0; Angle <= 2 * Math.PI; Angle = Angle + 0.01) { myPointCollection.Add(new Point(0.5 * (l + r) + R1 * Math.Cos(Angle), 0.5 * (b + t) + R2 * Math.Sin(Angle))); } el.Points = myPointCollection; if (checkBoxFill.IsChecked == true) { el.Fill = new SolidColorBrush(Color.FromArgb( parameters.FillColor.a, parameters.FillColor.r, parameters.FillColor.g, parameters.FillColor.b)); } inkPanel.Children.Add(el); currentShape = el; }
private void OnShapeEdgeMouseDown(object sender, MouseButtonEventArgs e) { System.Windows.Shapes.Shape edgeShape = (System.Windows.Shapes.Shape)sender; this.controlledEdgeIndex = this.edgeShapeToEdgeIndex[edgeShape]; ShapeEdge edge = this.shape.Structure.Edges[this.controlledEdgeIndex.Value]; this.initialEdgeWidth = this.shape.EdgeWidths[this.controlledEdgeIndex.Value]; Point mousePos = e.GetPosition(this.shapeCanvas); this.initialDistanceFromEdgeLine = new Vector(mousePos.X, mousePos.Y).DistanceToLine( this.shape.VertexPositions[edge.Index1], this.shape.VertexPositions[edge.Index2]); }
public static void PositionGeometry(XamlShapes.Shape renderedGeometry, IViewport viewport) { CounterScaleLineWidth(renderedGeometry, viewport.Resolution); var matrixTransform = new XamlMedia.MatrixTransform { Matrix = CreateTransformMatrix1(viewport) }; renderedGeometry.RenderTransform = matrixTransform; if (renderedGeometry.Fill != null) { renderedGeometry.Fill.Transform = matrixTransform.Inverse as XamlMedia.MatrixTransform; } }
private void MouseLeftButtonDownShape(object sender, MouseButtonEventArgs e) { System.Windows.Shapes.Shape selectedShape = sender as System.Windows.Shapes.Shape; foreach (AnnoShapeModel shapeModel in AnnoShapeModelCollection) { if (shapeModel.Shape == selectedShape) { ShellView.ShapeDataGrid.SelectedItem = shapeModel; ShellViewModel.AnnSelectionChanged(shapeModel); } } e.Handled = true; }
public static void SetShapeFormat(Paint paintStroke, Paint paintFill, System.Windows.Shapes.Shape shape) { if (paintStroke != null) { SolidColorBrush stroke = new SolidColorBrush(); stroke.Color = paintStroke.Color; shape.Stroke = stroke; } if (paintFill != null) { SolidColorBrush fill = new SolidColorBrush(); fill.Color = paintFill.Color; shape.Fill = fill; } }
private void DeleteShape(object sender, MouseButtonEventArgs e) { System.Windows.Shapes.Shape selectedRectangle = sender as System.Windows.Shapes.Shape; foreach (AnnoShapeModel shapeModel in AnnoShapeModelCollection) { if (shapeModel.Shape == selectedRectangle) { GetCamWindowView().ImageCanvas.Children.Remove(selectedRectangle); AnnoShapeModelCollection.Remove(shapeModel); break; } } }
public Shape(Color color, Point vertex1, Point vertex2) { drawBase = GenerateDrawBase(); this.color = color; this.vertex1 = vertex1; SetVertex2X(vertex2); SetVertex2Y(vertex2); SetPosition(); SetSides(); SetFill(); angle = 0; }
// Highlight Shape protected virtual void UpdateShapeAppearance() { System.Windows.Shapes.Shape shape = Shape as System.Windows.Shapes.Shape; if (shape == null) { return; } if (base.Selected) { oldBrush = shape.Stroke; shape.Stroke = SelectedBrush; } else { if (oldBrush != null) { shape.Stroke = oldBrush; } } }
private void drawLine(MouseEventArgs e) { Polygon line = new Polygon(); line.Stroke = new SolidColorBrush(Color.FromArgb(parameters.LineColor.a, parameters.LineColor.r, parameters.LineColor.g, parameters.LineColor.b)); line.StrokeThickness = parameters.Thickness; PointCollection myPointCollection = new PointCollection(); foreach (var item in new Geometry.Line( new Geometry.Point(startPoint.X, startPoint.Y), new Geometry.Point(e.GetPosition(inkPanel).X, e.GetPosition(inkPanel).Y)).Points(parameters)) { myPointCollection.Add(new Point(item.x, item.y)); } line.Points = myPointCollection; inkPanel.Children.Add(line); currentShape = line; }
private void TypeComboBox_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { if (TypeComboBox.SelectedIndex == 0) { Shape = new System.Windows.Shapes.Ellipse(); int @int = Convert.ToInt32(SizeTextBox.Value); Shape.Height = @int; Shape.Width = @int; int int2 = Convert.ToInt32(BorderSizeTextBox.Value); Shape.StrokeThickness = int2; Shape.Stroke = Brushes.Black; } else if (TypeComboBox.SelectedIndex == 1) { Shape = new System.Windows.Shapes.Rectangle(); int @int = Convert.ToInt32(SizeTextBox.Value); Shape.Height = @int; Shape.Width = @int; int int2 = Convert.ToInt32(BorderSizeTextBox.Value); Shape.StrokeThickness = int2; Shape.Stroke = Brushes.Black; } ScrollViewer1.Content = Shape; }
public void DoBinding(WallInfo wallInfo, Autodesk.Revit.DB.DisplayUnit?unitSystem, double beamLength = 0) { familyNameLabel.Visibility = System.Windows.Visibility.Visible; familyName.Visibility = System.Windows.Visibility.Visible; typeNameLabel.Visibility = System.Windows.Visibility.Visible; typeName.Visibility = System.Windows.Visibility.Visible; familyName.Content = wallInfo.FamilyName; typeName.Content = wallInfo.TypeName; wallViewer.Children.Clear(); double scale = 1.2; double actualWidth = wallViewer.MinWidth; double actualHeight = wallViewer.MinHeight; if (wallViewer.ActualWidth > 0) { actualWidth = wallViewer.ActualWidth; } if (wallViewer.ActualHeight > 0) { actualHeight = wallViewer.ActualHeight; } double horizontalMargin = actualWidth / 8; double verticalMargin = actualHeight / 6; double width = actualWidth - 2 * horizontalMargin; double height = actualHeight - 2 * verticalMargin; horizontalMargin += (width - width * scale) / 2.0; verticalMargin += (height - height * scale) / 2.0; double horizontalShift = horizontalMargin; double verticalShift = verticalMargin; XYZ xyz_min = wallInfo.Contour.GetMinimumBoundary(); XYZ xyz_max = wallInfo.Contour.GetMaximumBoundary(); width = Math.Abs(xyz_max.X - xyz_min.X); height = Math.Abs(xyz_max.Y - xyz_min.Y); double stretchCoeff = 0; if (height > width) { stretchCoeff = (actualHeight - 2 * verticalMargin) / height; horizontalShift += ((actualWidth - 2 * horizontalMargin) - (width * stretchCoeff)) / 2.0; } else { stretchCoeff = (actualWidth - 2 * horizontalMargin) / width; verticalShift += ((actualHeight - 2 * verticalMargin) - (height * stretchCoeff)) / 2; } if (xyz_min.X < 0) { horizontalShift -= stretchCoeff * xyz_min.X; } if (xyz_min.Y < 0) { verticalShift -= stretchCoeff * xyz_min.Y; } System.Windows.Shapes.Shape contour = null; List <System.Windows.Shapes.Shape> openings = new List <System.Windows.Shapes.Shape>(); Polygon polygon = null; PointCollection points = null; if (wallInfo.Contour != null && wallInfo.Contour.Points.Count > 2) { polygon = new Polygon(); points = new PointCollection(); foreach (XYZ xyz in wallInfo.Contour.Points) { points.Add(new Point(xyz.X * stretchCoeff, xyz.Y * stretchCoeff)); } polygon.Points = points; polygon.Fill = Brushes.LightSlateGray; polygon.Stretch = Stretch.None; polygon.Stroke = Brushes.Black; polygon.StrokeThickness = 1; contour = polygon; } foreach (Autodesk.Revit.DB.CodeChecking.Engineering.Shape opening in wallInfo.Openings) { polygon = new Polygon(); points = new PointCollection(); foreach (XYZ xyz in opening.Points) { points.Add(new Point(xyz.X * stretchCoeff, xyz.Y * stretchCoeff)); } polygon.Points = points; polygon.Fill = Brushes.White; polygon.Stretch = Stretch.None; polygon.Stroke = Brushes.Black; polygon.StrokeThickness = 1; openings.Add(polygon); } if (contour != null) { Canvas.SetLeft(contour, horizontalShift); Canvas.SetTop(contour, verticalShift); wallViewer.Children.Add(contour); } foreach (System.Windows.Shapes.Shape opening in openings) { Canvas.SetLeft(opening, horizontalShift); Canvas.SetTop(opening, verticalShift); wallViewer.Children.Add(opening); } double viewerWidth, viewerHeight; wallViewer.GetViewerWidthAndHeight(out viewerWidth, out viewerHeight); double dimHeight = Math.Abs(xyz_max.Y - xyz_min.Y); double dimWidth = Math.Abs(xyz_max.X - xyz_min.X); if (viewerWidth / 2.0 > horizontalShift) { horizontalShift += dimWidth * stretchCoeff; } double offset = 0.0; if (viewerHeight / 2.0 > verticalShift) { offset = dimHeight * stretchCoeff; } else { verticalShift -= dimHeight * stretchCoeff; } double x = horizontalShift + 10; Point start = new Point(x, verticalShift); Point end = new Point(x, start.Y + dimHeight * stretchCoeff); CreateDimensionLine(dimHeight, start, end, stretchCoeff, unitSystem); double y = verticalShift + dimHeight * stretchCoeff + 10; start = new Point(horizontalShift - (dimWidth * stretchCoeff), y); end = new Point(start.X + dimWidth * stretchCoeff, y); CreateDimensionLine(dimWidth, start, end, stretchCoeff, unitSystem); }
/// <summary> /// Draw selected shape on canvas /// </summary> private void DrawShape() { Shape Rendershape = null; switch (Shape1) { case SelectedShape.Circle: Rendershape = new Ellipse() { Height = 100, Width = 100 }; RadialGradientBrush Ellipsebrush = new RadialGradientBrush(); Ellipsebrush.GradientStops.Add(new GradientStop(Color.FromArgb(0, 255, 255, 255), 0)); Rendershape.Stroke = SelectedColorRect.Stroke; Rendershape.StrokeThickness = 2; Rendershape.Fill = Ellipsebrush; break; case SelectedShape.Rectangle: Rendershape = new Rectangle() { Height = 100, Width = 100, RadiusX = 2, RadiusY = 2 }; RadialGradientBrush Rectbrush = new RadialGradientBrush(); Rectbrush.GradientStops.Add(new GradientStop(Color.FromArgb(0, 255, 255, 255), 0)); Rendershape.Stroke = SelectedColorRect.Stroke; Rendershape.StrokeThickness = 2; Rendershape.Fill = Rectbrush; break; case SelectedShape.Line: Rendershape = new Rectangle() { Height = 1, Width = 100, RadiusX = 12, RadiusY = 12 }; RadialGradientBrush Linebrush = new RadialGradientBrush(); Linebrush.GradientStops.Add(new GradientStop(Color.FromRgb(0, 0, 0), 0)); Rendershape.Fill = Linebrush; Rendershape.Stroke = SelectedColorRect.Stroke; Rendershape.StrokeThickness = 2; break; case SelectedShape.Triangle: PointCollection myPointCollection = new PointCollection(); myPointCollection.Add(new System.Windows.Point(0, 0)); myPointCollection.Add(new System.Windows.Point(50, 100)); myPointCollection.Add(new System.Windows.Point(100, 0)); Rendershape = new Polygon() { Height = 100, Width = 100, Points = myPointCollection }; Rendershape.Stroke = SelectedColorRect.Stroke; Rendershape.StrokeThickness = 2; break; default: return; } InkCanvas.SetTop(Rendershape, 300); InkCanvas.SetLeft(Rendershape, 300); m_inkCanvas.Children.Add(Rendershape); }
public static void Set(this System.Windows.Shapes.Shape shape, Point coordinates) { }
private void SetStrokeDashArray(Shapes.Shape shape, DoubleCollection collection) { shape.StrokeDashArray = collection; }
private void inkPanel_PreviewMouseDown(object sender, MouseButtonEventArgs e) { startPoint = e.GetPosition(inkPanel); inkPanel.EditingMode = InkCanvasEditingMode.None; currentShape = new Line(); }