//============================================================================= public override void Draw(DrawingContext dc, ICoordinateSystem cs, IGeomDisplaySettings geomDisplaySettings = null) { if (dc == null) { return; } if (cs == null) { return; } if (m_Sheet == null) { return; } IGeomDisplaySettings displaySettings = geomDisplaySettings; if (displaySettings == null) { displaySettings = new DefaultGeomDisplaySettings(); } if (displaySettings == null) { return; } Brush penBrush = new SolidColorBrush(FillColor); if (m_AttachedRacksHeightError) { Color tieBeamErrorColor = Colors.Red; Color colorValue; if (CurrentGeometryColorsTheme.CurrentTheme.GetGeometryColor(eColorType.eFill_TieBeamWithError, out colorValue)) { tieBeamErrorColor = colorValue; } penBrush = new SolidColorBrush(tieBeamErrorColor); } Pen pen = new Pen(penBrush, 2.0); pen.DashStyle = new DashStyle(new List <double> { 2 }, 1); // // If fill with transparent color then circle fill area will act in HitTest. // Fill with null brush will disable circle HitTest on click in fill area. //Color fillColor = displaySettings.GetFillColor(this); //Brush fillBrush = new SolidColorBrush(fillColor); //fillBrush.Opacity = displaySettings.FillBrushOpacity; // Point TopLeft_ScreenPoint = GetLocalPoint(cs, m_TopLeft_GlobalPoint); Point BottomRight_ScreenPoint = GetLocalPoint(cs, BottomRight_GlobalPoint); dc.DrawLine(pen, TopLeft_ScreenPoint, BottomRight_ScreenPoint); }
//============================================================================= public override void Draw(DrawingContext dc, ICoordinateSystem cs, IGeomDisplaySettings geomDisplaySettings = null) { if (dc == null) { return; } if (cs == null) { return; } if (m_Sheet == null) { return; } if (eWallPosition.eUndefined == m_WallPosition) { return; } IGeomDisplaySettings displaySettings = geomDisplaySettings; // if NULL then get settings from the sheet if (displaySettings == null) { displaySettings = m_Sheet; } // if (displaySettings == null) { displaySettings = new DefaultGeomDisplaySettings(); } if (displaySettings == null) { return; } Pen _pen = this.BorderPen; // // If fill with transparent color then circle fill area will act in HitTest. // Fill with null brush will disable circle HitTest on click in fill area. Color fillColor = displaySettings.GetFillColor(this); Brush fillBrush = new SolidColorBrush(fillColor); fillBrush.Opacity = displaySettings.FillBrushOpacity; // Point sreenPnt01 = GetLocalPoint(cs, TopLeft_GlobalPoint); Point sreenPnt02 = GetLocalPoint(cs, BottomRight_GlobalPoint); dc.DrawRectangle(fillBrush, _pen, new Rect(sreenPnt01, sreenPnt02)); }
//============================================================================= public override void Draw(DrawingContext dc, ICoordinateSystem cs, IGeomDisplaySettings geomDisplaySettings = null) { // STEP 1. // Draw sheet content with opacity. DrawingSheet boundSheet = this.BoundSheet; if (boundSheet != null) { dc.PushOpacity(0.3); // Point zeroLocalPnt = GetLocalPoint(cs, this.TopLeft_GlobalPoint); int LengthInPixels = Utils.GetWholeNumber(GetWidthInPixels(cs, Length_X)); int WidthInPixels = Utils.GetWholeNumber(GetHeightInPixels(cs, Length_Y)); dc.PushClip(new RectangleGeometry(new Rect(zeroLocalPnt.X, zeroLocalPnt.Y, LengthInPixels, WidthInPixels))); // Vector globalOffsetVec = new Vector(this.TopLeft_GlobalPoint.X, this.TopLeft_GlobalPoint.Y); double lengthVal = Length_X; double heightVal = Length_Y; if ((m_bDontChangeBoundSheetSize || !this.IsInit) && Utils.FGT(m_OldSize.Width, 0.0) && Utils.FGT(m_OldSize.Height, 0.0)) { lengthVal = m_OldSize.Width; heightVal = m_OldSize.Height; } if (m_bDontChangeBoundSheetSize || !this.IsInit) { if (!m_IsCenterGripPointMoving) { globalOffsetVec.X = m_OldTopLeftPoint.X; globalOffsetVec.Y = m_OldTopLeftPoint.Y; } globalOffsetVec -= m_AdditionalOffset; } int boundSheetLengthInPixels = Utils.GetWholeNumber(GetWidthInPixels(cs, lengthVal)); int boundSheetWidthInPixels = Utils.GetWholeNumber(GetHeightInPixels(cs, heightVal)); Point topLeftScreenPoint = GetLocalPoint(cs, new Point(0.0, 0.0) + globalOffsetVec); Vector offsetInPixels = topLeftScreenPoint - new Point(0.0, 0.0); ImageCoordinateSystem ics = new ImageCoordinateSystem(boundSheetLengthInPixels, boundSheetWidthInPixels, offsetInPixels, new Size(boundSheet.Length, boundSheet.Width), 0.0); // DefaultGeomDisplaySettings displaySettings = new DefaultGeomDisplaySettings(); displaySettings.DisplayText = false; // if (boundSheet.Rectangles != null) { foreach (BaseRectangleGeometry geom in boundSheet.Rectangles) { if (geom == null) { continue; } // Dont display SheetElevationGeometry, because it displayed in pixels fixed size if (geom is SheetElevationGeometry) { continue; } geom.Draw(dc, ics, displaySettings); } } // Pop clip dc.Pop(); // Pop opacity dc.Pop(); } // STEP 2. // Draw sheet borders and name. base.Draw(dc, cs, geomDisplaySettings); }
//============================================================================= public override void Draw(DrawingContext dc, ICoordinateSystem cs, IGeomDisplaySettings geomDisplaySettings = null) { if (dc == null) { return; } if (cs == null) { return; } if (m_Sheet == null) { return; } IGeomDisplaySettings displaySettings = geomDisplaySettings; if (displaySettings == null) { displaySettings = new DefaultGeomDisplaySettings(); } if (displaySettings == null) { return; } Pen borderPen = this.BorderPen; // // If fill with transparent color then circle fill area will act in HitTest. // Fill with null brush will disable circle HitTest on click in fill area. Color fillColor = displaySettings.GetFillColor(this); Color textColor = displaySettings.GetTextColor(this); // Brush fillBrush = new SolidColorBrush(fillColor); fillBrush.Opacity = displaySettings.FillBrushOpacity; // Draw circle double circleRadiusInPixels = SHEET_ELEVATION_GEOMETRY_RADIUS_IN_PIXELS; // GetWidthInPixels(cs, SHEET_ELEVATION_GEOMETRY_RADIUS); Point TopLeft_ScreenPoint = GetLocalPoint(cs, m_TopLeft_GlobalPoint); dc.DrawEllipse(fillBrush, borderPen, TopLeft_ScreenPoint, circleRadiusInPixels, circleRadiusInPixels); // draw text if (displaySettings.DisplayText && !string.IsNullOrEmpty(Text)) { Brush br = new SolidColorBrush(textColor); br.Opacity = displaySettings.FillBrushOpacity; // FontFamily textFontFamily = new FontFamily("Arial"); Typeface textTypeFace = new Typeface(textFontFamily, FontStyles.Normal, displaySettings.TextWeight, FontStretches.Normal); FormattedText formattedText = new FormattedText(Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, textTypeFace, displaySettings.TextFontSize, br); formattedText.TextAlignment = TextAlignment.Center; Point Text_ScreenPoint = GetLocalPoint(cs, TopLeft_GlobalPoint); Text_ScreenPoint.Y -= formattedText.Height / 2; dc.DrawText(formattedText, Text_ScreenPoint); } }
//============================================================================= public override void Draw(DrawingContext dc, ICoordinateSystem cs, IGeomDisplaySettings geomDisplaySettings = null) { if (dc == null) { return; } if (cs == null) { return; } if (m_Sheet == null) { return; } IGeomDisplaySettings displaySettings = geomDisplaySettings; if (displaySettings == null) { displaySettings = new DefaultGeomDisplaySettings(); } if (displaySettings == null) { return; } Pen pen = this.BorderPen; // // If fill with transparent color then circle fill area will act in HitTest. // Fill with null brush will disable circle HitTest on click in fill area. Color fillColor = displaySettings.GetFillColor(this); Brush fillBrush = new SolidColorBrush(fillColor); fillBrush.Opacity = displaySettings.FillBrushOpacity; // Draw shutter rectangle without SwingDoor Point TopLeft_ScreenPoint = GetLocalPoint(cs, m_TopLeft_GlobalPoint); Point BottomRight_ScreenPoint = GetLocalPoint(cs, BottomRight_GlobalPoint); dc.DrawRectangle(fillBrush, pen, new Rect(TopLeft_ScreenPoint, BottomRight_ScreenPoint)); // draw Swing Door if (m_SwingDoor) { double doorLength = SwingDoorLength; double doorLengthInPixels = GetWidthInPixels(cs, doorLength); PathGeometry swingDoorGeom = new PathGeometry(); if (this.IsHorizontal) { if (Utils.FLE(m_TopLeft_GlobalPoint.Y, 0.0)) { // shutter is placed at top border PathFigure leftDoorFigure = new PathFigure(); leftDoorFigure.StartPoint = GetLocalPoint(cs, BottomLeft_GlobalPoint); leftDoorFigure.Segments.Add(new LineSegment(GetLocalPoint(cs, BottomLeft_GlobalPoint + doorLength * new Vector(0.0, 1.0)), true)); leftDoorFigure.Segments.Add(new ArcSegment( GetLocalPoint(cs, BottomLeft_GlobalPoint + doorLength * new Vector(1.0, 0.0)), new Size(doorLengthInPixels, doorLengthInPixels), 0.0, false, SweepDirection.Counterclockwise, true) ); swingDoorGeom.Figures.Add(leftDoorFigure); PathFigure rightDoorFigure = new PathFigure(); rightDoorFigure.StartPoint = GetLocalPoint(cs, BottomRight_GlobalPoint); rightDoorFigure.Segments.Add(new LineSegment(GetLocalPoint(cs, BottomRight_GlobalPoint + doorLength * new Vector(0.0, 1.0)), true)); rightDoorFigure.Segments.Add(new ArcSegment( GetLocalPoint(cs, BottomRight_GlobalPoint + doorLength * new Vector(-1.0, 0.0)), new Size(doorLengthInPixels, doorLengthInPixels), 0.0, false, SweepDirection.Clockwise, true) ); swingDoorGeom.Figures.Add(rightDoorFigure); } else { // shutter is placed at bot border PathFigure leftDoorFigure = new PathFigure(); leftDoorFigure.StartPoint = GetLocalPoint(cs, m_TopLeft_GlobalPoint); leftDoorFigure.Segments.Add(new LineSegment(GetLocalPoint(cs, m_TopLeft_GlobalPoint + doorLength * new Vector(0.0, -1.0)), true)); leftDoorFigure.Segments.Add(new ArcSegment( GetLocalPoint(cs, m_TopLeft_GlobalPoint + doorLength * new Vector(1.0, 0.0)), new Size(doorLengthInPixels, doorLengthInPixels), 0.0, false, SweepDirection.Clockwise, true) ); swingDoorGeom.Figures.Add(leftDoorFigure); PathFigure rightDoorFigure = new PathFigure(); rightDoorFigure.StartPoint = GetLocalPoint(cs, TopRight_GlobalPoint); rightDoorFigure.Segments.Add(new LineSegment(GetLocalPoint(cs, TopRight_GlobalPoint + doorLength * new Vector(0.0, -1.0)), true)); rightDoorFigure.Segments.Add(new ArcSegment( GetLocalPoint(cs, TopRight_GlobalPoint + doorLength * new Vector(-1.0, 0.0)), new Size(doorLengthInPixels, doorLengthInPixels), 0.0, false, SweepDirection.Counterclockwise, true) ); swingDoorGeom.Figures.Add(rightDoorFigure); } } else { if (Utils.FLE(m_TopLeft_GlobalPoint.X, 0.0)) { // shutter is placed at left border PathFigure topDoorFigure = new PathFigure(); topDoorFigure.StartPoint = GetLocalPoint(cs, TopRight_GlobalPoint); topDoorFigure.Segments.Add(new LineSegment(GetLocalPoint(cs, TopRight_GlobalPoint + doorLength * new Vector(1.0, 0.0)), true)); topDoorFigure.Segments.Add(new ArcSegment( GetLocalPoint(cs, TopRight_GlobalPoint + doorLength * new Vector(0.0, 1.0)), new Size(doorLengthInPixels, doorLengthInPixels), 0.0, false, SweepDirection.Clockwise, true) ); swingDoorGeom.Figures.Add(topDoorFigure); PathFigure botDoorFigure = new PathFigure(); botDoorFigure.StartPoint = GetLocalPoint(cs, BottomRight_GlobalPoint); botDoorFigure.Segments.Add(new LineSegment(GetLocalPoint(cs, BottomRight_GlobalPoint + doorLength * new Vector(1.0, 0.0)), true)); botDoorFigure.Segments.Add(new ArcSegment( GetLocalPoint(cs, BottomRight_GlobalPoint + doorLength * new Vector(0.0, -1.0)), new Size(doorLengthInPixels, doorLengthInPixels), 0.0, false, SweepDirection.Counterclockwise, true) ); swingDoorGeom.Figures.Add(botDoorFigure); } else { // shutter is placed at right border PathFigure topDoorFigure = new PathFigure(); topDoorFigure.StartPoint = GetLocalPoint(cs, m_TopLeft_GlobalPoint); topDoorFigure.Segments.Add(new LineSegment(GetLocalPoint(cs, m_TopLeft_GlobalPoint + doorLength * new Vector(-1.0, 0.0)), true)); topDoorFigure.Segments.Add(new ArcSegment( GetLocalPoint(cs, m_TopLeft_GlobalPoint + doorLength * new Vector(0.0, 1.0)), new Size(doorLengthInPixels, doorLengthInPixels), 0.0, false, SweepDirection.Counterclockwise, true) ); swingDoorGeom.Figures.Add(topDoorFigure); PathFigure botDoorFigure = new PathFigure(); botDoorFigure.StartPoint = GetLocalPoint(cs, BottomLeft_GlobalPoint); botDoorFigure.Segments.Add(new LineSegment(GetLocalPoint(cs, BottomLeft_GlobalPoint + doorLength * new Vector(-1.0, 0.0)), true)); botDoorFigure.Segments.Add(new ArcSegment( GetLocalPoint(cs, BottomLeft_GlobalPoint + doorLength * new Vector(0.0, -1.0)), new Size(doorLengthInPixels, doorLengthInPixels), 0.0, false, SweepDirection.Clockwise, true) ); swingDoorGeom.Figures.Add(botDoorFigure); } } // Draw transparent rectangle over all swing door. // Otherwise, user cant select shutter by click swing door. dc.DrawGeometry(Brushes.Transparent, null, swingDoorGeom); // Draw swing door with pen dc.DrawGeometry(null, pen, swingDoorGeom); } }