Beispiel #1
0
        public void UpdateLines()
        {
            VerMidLine.Y1 = VerMidLine.Y2 = MainCanvas.ActualHeight * 0.5;
            VerMidLine.X1 = 0;
            VerMidLine.X2 = MainCanvas.ActualWidth;

            HorMidLine.X1 = HorMidLine.X2 = MainCanvas.ActualWidth * 0.5;
            HorMidLine.Y1 = 0;
            HorMidLine.Y2 = MainCanvas.ActualHeight;

            foreach (LinePoint point in PointList)
            {
                var    var   = MainCanvas.FindName(point.Name + "X");
                object LineX = MainCanvas.Children[(int)var];

                ((Line)LineX).Y2 = MainCanvas.ActualHeight;

                Line LineY = (Line)MainCanvas.Children[(int)MainCanvas.FindName(point.Name + "Y")];

                ((Line)LineY).X2 = MainCanvas.ActualWidth;
            }

            LineListsBox.Items.Clear();
            for (int i = 0; i < PointListCount; i++)
            {
                LineListsBox.Items.Add("Line " + i.ToString());
            }
        }
Beispiel #2
0
 public void OnRevoke()
 {
     if (list.Count > 0)
     {
         var name = list[list.Count - 1].Name;
         var obj  = MainCanvas.FindName(name);
         if (obj != null)
         {
             MainCanvas.Children.Remove(obj as UIElement);
             MainCanvas.UnregisterName(name);
             list.RemoveAt(list.Count - 1);
             MainImage.Limit = list.Count == 0 ? new Limit() : list[list.Count - 1].Limit;
         }
     }
 }
Beispiel #3
0
        private void Command_FileOpen(object sender, ExecutedRoutedEventArgs e)
        {
            var output = AppHandler.OpenFile();

            if (output != null)
            {
                ClearCanvas();

                MainVM.CurrentComponentName = null;

                MainVM.CanvasHeightMM = MainVM.pxToMm(output.CanvasHeight);
                MainVM.CanvasWidthMM  = MainVM.pxToMm(output.CanvasWidht);

                MainVM.IdGrupa = output.Id_Grupa;

                foreach (var component in output.Components)
                {
                    var cmp = component.Key;
                    var pos = component.Value;

                    if (cmp is Label lbl)
                    {
                        if (lbl.Name.Contains("Margin"))
                        {
                            var margin = MainCanvas.FindName(lbl.Name) as Label;
                            Canvas.SetLeft(margin, pos.CanvasLeft);
                            Canvas.SetTop(margin, pos.CanvasTop);
                        }
                        else
                        {
                            AddComponentToCanvas(lbl, pos.CanvasLeft, pos.CanvasTop);
                        }
                    }

                    if (cmp is Image img)
                    {
                        AddComponentToCanvas(img, pos.CanvasLeft, pos.CanvasTop);
                    }
                }
            }
        }