Пример #1
0
 public void SetUp()
 {
     _line    = new CanvasLine();
     _line.X1 = 0;
     _line.Y1 = 0;
     _line.X2 = 10;
     _line.Y2 = 10;
 }
Пример #2
0
            public void MouseDownWire(object sender, MouseButtonEventArgs e)
            {
                if (CanvasObject.First == null)
                {
                    this.Ellipse.Fill  = new SolidColorBrush(Colors.Red);
                    CanvasObject.First = this;
                }
                else
                {
                    var strokeBrush = default(Brush);

                    switch (MainWindow.WallType)
                    {
                    case WallType.Wall:
                        strokeBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#1B72AF"));
                        break;

                    case WallType.Door:
                        strokeBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#836890"));
                        break;

                    case WallType.Window:
                        strokeBrush = (SolidColorBrush)(new BrushConverter().ConvertFrom("#BC342F"));
                        break;
                    }
                    var line = new Line
                    {
                        Stroke          = strokeBrush,
                        X1              = CanvasObject.First.CoordX + 10,
                        Y1              = CanvasObject.First.CoordY + 10,
                        X2              = this.CoordX + 10,
                        Y2              = this.CoordY + 10,
                        StrokeThickness = 10
                    };

                    var canvasLine = new CanvasLine
                    {
                        CoordX1 = CanvasObject.First.CoordX,
                        CoordY1 = CanvasObject.First.CoordY,
                        CoordX2 = this.CoordX,
                        CoordY2 = this.CoordY,

                        IndexX1  = CanvasObject.First.IndexX,
                        IndexY1  = CanvasObject.First.IndexY,
                        IndexX2  = this.IndexX,
                        IndexY2  = this.IndexY,
                        WallType = MainWindow.WallType,
                        Line     = line
                    };

                    CanvasObject.Canvas.Children.Add(canvasLine.Line);
                    CanvasObject.CanvasLines.Add(canvasLine);

                    CanvasObject.First.Ellipse.Fill = Brushes.Blue;
                    CanvasObject.First = null;
                }
            }
Пример #3
0
 public UMLOpenArrow(CanvasGroup group)
     : base(group)
 {
     _arrowhead = new CanvasLine (group);
     _arrowhead.WidthUnits= 1.0;
     _arrowhead.FillColorGdk = UMLEdge.OUTLINE_COLOR;
     _arrowhead.Lower (1);
     Redraw ();
     _arrowhead.Show ();
 }
Пример #4
0
        private CanvasLine RenderLine(AxisGridLine axisGridLine, Rect viewExtent, Size controlSize)
        {
            var scaledPosition = _valueScaler.Scale(axisGridLine.Position, viewExtent.Left, viewExtent.Width, 0d, controlSize.Width);

            var canvasLine = new CanvasLine()
            {
                X1 = scaledPosition,
                Y1 = 0,
                X2 = scaledPosition,
                Y2 = controlSize.Height - MarginHeight
            };

            return(canvasLine);
        }
Пример #5
0
 public UMLActor(UMLDiagram ownerDiagram, DI.GraphNode actorGraphNode)
     : base(ownerDiagram, actorGraphNode)
 {
     // old ctor
     _head = new CanvasEllipse (ChildrensRoot);
     _head.OutlineColor = DEFAULT_OUTLINE_COLOR;
     _head.FillColor = DEFAULT_FILL_COLOR;
     //
     _arms = new CanvasLine (ChildrensRoot);
     _arms.WidthUnits = 1.0;
     _arms.FillColor = DEFAULT_OUTLINE_COLOR;
     //
     _body = new CanvasLine (ChildrensRoot);
     _body.WidthUnits = 1.0;
     _body.FillColor = DEFAULT_OUTLINE_COLOR;
     //
     _legs = new CanvasLine (ChildrensRoot);
     _legs.WidthUnits= 1.0;
     _legs.FillColor = DEFAULT_OUTLINE_COLOR;
     // /old ctor
     _modelElement = (UML.Actor) MonoUML.Widgets.Helper.GetSemanticElement (actorGraphNode);
     DI.GraphElement nestedDiagElem;
     DI.SimpleSemanticModelElement nestedBridge;
     //
     DI.DiagramElement elem = (DI.DiagramElement) actorGraphNode.Contained[0];
     nestedDiagElem = elem as DI.GraphElement;
     if (nestedDiagElem != null)
     {
         nestedBridge = nestedDiagElem.SemanticModel as DI.SimpleSemanticModelElement;
         if (nestedBridge.TypeInfo == "Name")
         {
             string fontModifier = (_modelElement.IsAbstract ? "italic" : "");
             _nameUMLEntry = new UMLEntry (this, (DI.GraphNode)nestedDiagElem, ownerDiagram.CanvasRoot, true, _modelElement.Name, fontModifier);
             base.AddFreeEntry (_nameUMLEntry);
             _nameUMLEntry.Show ();
             _nameDIGraphNode = nestedDiagElem;
         }
     }
     else
     {
         //TODO: Create both, entry and DI nested element
     }
     _nameUMLEntry.TextChanged += CallHub;
     Redraw ();
 }
        public void SetUp()
        {
            _gridLines   = new List <AxisGridLine>();
            _viewExtent  = new Rect();
            _controlSize = new Size();
            _line        = new CanvasLine();
            _label       = new CanvasLabel();

            _mockXLineRenderer  = new Mock <IXAxisGridLineRenderer>();
            _mockYLineRenderer  = new Mock <IYAxisGridLineRenderer>();
            _mockXLabelRenderer = new Mock <IXAxisGridLabelRenderer>();
            _mockYLabelRenderer = new Mock <IYAxisGridLabelRenderer>();

            _renderer = new AxisGridRenderer(
                _mockXLineRenderer.Object,
                _mockYLineRenderer.Object,
                _mockXLabelRenderer.Object,
                _mockYLabelRenderer.Object);
        }
Пример #7
0
 public override void Clear()
 {
     _arrowhead.Hide ();
     _arrowhead.Destroy ();
     _arrowhead = null;
 }
 public void DrawOnCanvas()
 {
     if (FociList == null)
     {
         return;
     }
     CanvasLines.Clear();
     foreach (FocusModel focus in FociList)
     {
         //Draw relatives
         if (DrawPositionLines && focus.CoordinatesRelativeTo != null)
         {
             CanvasLine newline = new CanvasLine(
                 focus.FocusTop.X,
                 focus.FocusTop.Y,
                 focus.CoordinatesRelativeTo.FocusBottom.X,
                 focus.CoordinatesRelativeTo.FocusBottom.Y,
                 System.Windows.Media.Brushes.Gold, false, null, focus);
             CanvasLines.Add(newline);
         }
         //Draw Prerequisites
         foreach (PrerequisitesSetModel set in focus.Prerequisite)
         {
             //Draw line from top of first Focus
             CanvasLine newline = new CanvasLine(
                 set.Focus.FocusTop.X,
                 set.Focus.FocusTop.Y,
                 set.Focus.FocusTop.X,
                 set.Focus.FocusTop.Y - PRE_LINE_HEIGHT,
                 System.Windows.Media.Brushes.Teal, set.isRequired(), set);
             CanvasLines.Add(newline);
             foreach (FocusModel model in set.FociList)
             {
                 FocusModel Prerequisite = model;
                 if (Prerequisite == null)
                 {
                     continue;
                 }
                 //Draw horizontal lines to prerequisite pos
                 newline = new CanvasLine(set.Focus.FocusTop.X,
                                          set.Focus.FocusTop.Y - PRE_LINE_HEIGHT, Prerequisite.FocusBottom.X,
                                          set.Focus.FocusTop.Y - PRE_LINE_HEIGHT, System.Windows.Media.Brushes.Teal,
                                          set.isRequired(), set);
                 CanvasLines.Add(newline);
                 //Draw line to prerequisite bottom
                 newline = new CanvasLine(Prerequisite.FocusBottom.X,
                                          set.Focus.FocusTop.Y - PRE_LINE_HEIGHT, Prerequisite.FocusBottom.X,
                                          Prerequisite.FocusBottom.Y, System.Windows.Media.Brushes.Teal,
                                          set.isRequired(), set);
                 CanvasLines.Add(newline);
             }
         }
         //Draw Mutually exclusives
         foreach (MutuallyExclusiveSetModel set in focus.MutualyExclusive)
         {
             CanvasLine newline = new CanvasLine(
                 set.Focus1.FocusRight.X,
                 set.Focus1.FocusRight.Y,
                 set.Focus2.FocusLeft.X,
                 set.Focus2.FocusLeft.Y,
                 System.Windows.Media.Brushes.Red, false, set);
             if (!CanvasLines.Any(line => line.X1 == newline.X1 &&
                                  line.X2 == newline.X2 &&
                                  line.Y1 == newline.Y1 &&
                                  line.Y2 == newline.Y2))
             {
                 CanvasLines.Add(newline);
             }
         }
     }
     RaisePropertyChanged(() => CanvasLines);
     Messenger.Default.Send(new NotificationMessage("DrawOnCanvas"));
 }
Пример #9
0
 /*
 protected override void OnSizeAllocated (Gdk.Rectangle allocation)
 {
     Console.WriteLine("size allocated " + allocation.Width + " " + allocation.Height);
     PixelsPerUnit = 300; //Math.Min(allocation.Width, allocation.Height);
 }
  * */
 private void MakeLine(double x1, double y1, double x2, double y2)
 {
     CanvasLine line = new CanvasLine(Root());
     line.Points = new CanvasPoints(new double[]{x1, y1, x2, y2});
     line.WidthPixels = 0;
     line.FillColor = "grey";
 }
Пример #10
0
        public void SetUp()
        {
            _controlSize   = new Size();
            _viewExtent    = new Rect();
            _axisGridLine  = new AxisGridLine();
            _axisGridLines = new List <AxisGridLine> {
                _axisGridLine
            };
            _plotDto  = new PlotDto();
            _plotDtos = new List <PlotDto> {
                _plotDto
            };
            _columnDto = new ColumnDto()
            {
                Name = "test"
            };
            _xGridLine   = new CanvasLine();
            _yGridLine   = new CanvasLine();
            _plotItem    = new CanvasCircle();
            _xGridLabel  = new CanvasLabel();
            _yGridLabel  = new CanvasLabel();
            _xTitleLabel = new CanvasLabel();
            _yTitleLabel = new CanvasLabel();

            _mockQueryBus = new Mock <IQueryBus>();
            _mockQueryBus.Setup(p => p.Execute(It.IsAny <GetViewExtentQuery>()))
            .Returns(_viewExtent);
            _mockQueryBus.Setup(p => p.Execute(It.IsAny <GetXAxisGridLinesQuery>()))
            .Returns(_axisGridLines);
            _mockQueryBus.Setup(p => p.Execute(It.IsAny <GetYAxisGridLinesQuery>()))
            .Returns(_axisGridLines);
            _mockQueryBus.Setup(p => p.Execute(It.IsAny <GetPlotsQuery>()))
            .Returns(_plotDtos);
            _mockQueryBus.Setup(p => p.Execute(It.IsAny <GetXAxisColumnQuery>()))
            .Returns(_columnDto);
            _mockQueryBus.Setup(p => p.Execute(It.IsAny <GetYAxisColumnQuery>()))
            .Returns(_columnDto);

            _mockGridRenderer = new Mock <IAxisGridRenderer>();
            _mockGridRenderer.Setup(p => p.RenderXAxisGridLines(_axisGridLines, _viewExtent, _controlSize))
            .Returns(new List <CanvasLine> {
                _xGridLine
            });
            _mockGridRenderer.Setup(p => p.RenderYAxisGridLines(_axisGridLines, _viewExtent, _controlSize))
            .Returns(new List <CanvasLine> {
                _yGridLine
            });
            _mockGridRenderer.Setup(p => p.RenderXAxisGridLabels(_axisGridLines, _viewExtent, _controlSize))
            .Returns(new List <CanvasLabel> {
                _xGridLabel
            });
            _mockGridRenderer.Setup(p => p.RenderYAxisGridLabels(_axisGridLines, _viewExtent, _controlSize))
            .Returns(new List <CanvasLabel> {
                _yGridLabel
            });

            _mockPlotRenderer = new Mock <IPlotRenderer>();
            _mockPlotRenderer.Setup(p => p.RenderPlots(_controlSize, _viewExtent, _plotDtos))
            .Returns(new List <CanvasItem> {
                _plotItem
            });

            _mockTitleRenderer = new Mock <IAxisTitleRenderer>();
            _mockTitleRenderer.Setup(p => p.RenderXAxisTitle(_controlSize, _columnDto.Name))
            .Returns(_xTitleLabel);
            _mockTitleRenderer.Setup(p => p.RenderYAxisTitle(_controlSize, _columnDto.Name))
            .Returns(_yTitleLabel);

            _query = new GetAllItemsQuery(
                _mockQueryBus.Object,
                _mockGridRenderer.Object,
                _mockPlotRenderer.Object,
                _mockTitleRenderer.Object);
        }
Пример #11
0
		private void ShowGrid ()
		{
			if (_grid_components.Count > 0)
				return;
			CanvasLine l;
			double x = 0.0, y = 0.0;
			double width = (double) _canvas.Width;
			double height = (double) _canvas.Height;
			
			// Columns
			while (x <= width)
			{
				l = new CanvasLine (_back_group);
				_grid_components.Add (l);

				l.Points = new CanvasPoints (new double [] {x, 0, x, height});
				l.FillColor = DEFAULT_GRID_COLOR;
				l.WidthUnits = DEFAULT_GRID_WIDTH;
				x += DEFAULT_GRID_SPACE;
			}

			// Rows
			while (y <= height)
			{
				l = new CanvasLine (_back_group);
				_grid_components.Add (l);

				l.Points = new CanvasPoints (new double [] {0, y, width, y});
				l.FillColor = DEFAULT_GRID_COLOR;
				l.WidthUnits = DEFAULT_GRID_WIDTH;
				y += DEFAULT_GRID_SPACE;
			}
		}
Пример #12
0
 // there's no need to specify the location, because every segment will
 // be placed in the canvas in the method Redraw.
 private CanvasLine CreateLine()
 {
     CanvasLine line = new CanvasLine (this);
     line.CanvasEvent += new CanvasEventHandler (LineEventHandler);
     line.FillColorGdk = OUTLINE_COLOR;
     line.WidthUnits = WIDTH_UNITS;
     line.Lower (1);
     line.Show ();
     return line;
 }
Пример #13
0
 private void BreakSegment(CanvasLine segment, double x, double y)
 {
     // if there is another control point near, don't break the line
     UMLControlPoint cp = null;
     DI.Point wp;
     for(int i = 0; i < _graphEdge.Waypoints.Count; i ++)
     {
         wp = (DI.Point) _graphEdge.Waypoints [i];
         if( Math.Abs (wp.X - x) < 3 && Math.Abs (wp.Y - y) < 3)
         {
             cp = (UMLControlPoint) _control_points [i];
             break;
         }
     }
     if (cp == null)
     {
         int pos = _line_segments.IndexOf (segment) + 1;
         // creates a new line segment
         CanvasLine newSegment = CreateLine ();
         _line_segments.Insert (pos, newSegment);
         // creates a new way point
         _graphEdge.Waypoints.Insert (pos, new DI.Point (x, y));
         // creates a new control point
         cp = new UMLControlPoint (_ownerDiagram.CanvasRoot);
         cp.Moveable = true;
         cp.X = x;
         cp.Y = y;
         cp.ButtonReleased += new UMLElementButtonEventHandler (CPButtonReleased);
         cp.Moved += new MovedHandler (CPMoved);
         cp.Show ();
         cp.Raise (1);
         _control_points.Insert (pos, cp);
         base.UMLControlPoint = true;
     }
     // Redraw the edge
     cp.SetPressed ();
     ForceRedraw ();
     _ownerDiagram.EnableControlPointMotion (this, cp);
 }
Пример #14
0
 private void BreakSegment(CanvasLine segment, CanvasEventArgs args)
 {
     EventButton eb = new EventButton (args.Event.Handle);
     BreakSegment (segment, eb.X, eb.Y);
 }