Beispiel #1
0
 public void PositionOnYAxis(double y, CoordinateSystem coordinateSystem)
 {
     SetLabelText(TextBlock, y);
     double width = TextBlock.ActualWidth;
     double height = TextBlock.ActualHeight;
     var coordinates = coordinateSystem
         .ToPhysical(new Point(0, y))
         .Plus(new Point(-width - 2, -height / 2));
     MoveLabel(TextBlock, coordinates);
 }
Beispiel #2
0
 public void PositionOnXAxis(double x, CoordinateSystem coordinateSystem)
 {
     SetLabelText(TextBlock, x);
     double width = TextBlock.ActualWidth;
     var coordinates = coordinateSystem
         .ToPhysical(new Point(x, 0))
         .OffsetX(-width / 2);
     if (x.EqualsWithPrecision(0))
     {
         coordinates = coordinates.OffsetX(-width / 2 - 2);
     }
     MoveLabel(TextBlock, coordinates);
 }
Beispiel #3
0
        public Drawing(Canvas canvas)
        {
            Check.NotNull(canvas, "canvas");

            ActionManager = new ActionManager();
            StyleManager = new StyleManager(this);

            Figures = new RootFigureList(this);

            OnAttachToCanvas += Drawing_OnAttachToCanvas;
            OnDetachFromCanvas += Drawing_OnDetachFromCanvas;

            Canvas = canvas;

            CoordinateSystem = new CoordinateSystem(this);
            CoordinateGrid = new CartesianGrid() { Drawing = this, Visible = Settings.Instance.ShowGrid };
            Figures.Add(CoordinateGrid);
            Version = Settings.CurrentDrawingVersion;
        }
 void AddNewLines(int count, CoordinateSystem coordinateSystem)
 {
     for (int i = 0; i < count; i++)
     {
         var newLine = new Line()
         {
             Visibility = this.Visible.ToVisibility()
         };
         Canvas.SetZIndex(newLine, (int)ZOrder.Grid);
         Lines.Add(newLine);
         Drawing.Canvas.Children.Add(newLine);
         newLine.Apply(this.Style.GetWpfStyle());
     }
 }
 void RemoveExcessLines(int count, CoordinateSystem coordinateSystem)
 {
     for (int i = Lines.Count - count; i < Lines.Count; i++)
     {
         Drawing.Canvas.Children.Remove(Lines[i]);
     }
     Lines.RemoveRange(Lines.Count - count, count);
 }
 void MoveLineY(Line line, double y, CoordinateSystem coordinateSystem)
 {
     line.Move(
         coordinateSystem.MinimalVisibleX,
         y,
         coordinateSystem.MaximalVisibleX,
         y,
         coordinateSystem);
 }
 void MoveLineX(Line line, double x, CoordinateSystem coordinateSystem)
 {
     line.Move(
         x,
         coordinateSystem.MinimalVisibleY,
         x,
         coordinateSystem.MaximalVisibleY,
         coordinateSystem);
 }