public ColumnCreatorView(UIApplication uiApp, EventHandlerWithWpfArg eExternalMethodWpfArg) { _uiApp = uiApp; _uiDoc = uiApp.ActiveUIDocument; _doc = _uiDoc.Document; _vm = new ColumnCreatorViewModel(eExternalMethodWpfArg, this); DataContext = _vm; InitializeComponent(); InitializeFields(); EventManager.RegisterClassHandler(typeof(TextBox), KeyDownEvent, new KeyEventHandler(TextBox_KeyDown)); }
public ColumnCreator(ColumnCreatorViewModel viewModel) { DataContext = viewModel; InitializeComponent(); }
public static void UpdatePly(ColumnCreatorView ui, ColumnCreatorViewModel vm, bool editWin = false) { var x = ConvertToNum(vm.WidthX); var y = ConvertToNum(vm.LengthY); var z = ConvertToNum(vm.HeightZ); if (x == 0 || y == 0 || z == 0) { return; } double[] ply_seams = { }; double temp_ht = 0; if (ui.BoxPlySeams.Text.Equals("")) { ply_seams = GetPlySeams(x, y, z, ui); ui.TxtPlyError.Visibility = Visibility.Collapsed; } else { ply_seams = ReadSizes(ui.BoxPlySeams.Text); if (ValidatePlySeams(ui, ply_seams, x, y, z) != 1) { return; } } if (!ui.BoxPlySeams.Text.Equals("")) { goto SkipPlyUpdate; } string strPlySeams = ""; for (var i = 0; i < ply_seams.Length; i++) { if (i != ply_seams.Length - 1) { strPlySeams += ConvertFtIn(ply_seams[i]) + ", "; } else { strPlySeams += ConvertFtIn(ply_seams[i]); } } ui.BoxPlySeams.Text = strPlySeams; SkipPlyUpdate: var pt_draw = new double[3]; pt_draw[0] = 200; pt_draw[1] = 216; pt_draw[2] = 0; ui.TreeLines.Children.Clear(); ui.TreeLines.RowDefinitions.Clear(); ui.TreeLines.RowDefinitions.Add(new RowDefinition()); ui.TreeValues.Children.Clear(); ui.TreeValues.RowDefinitions.Clear(); ui.GridWinDim.RowDefinitions.Clear(); var lineStyle = ui.FindResource("TreeLine") as Style; var textStyle = ui.FindResource("TreeTextBlock") as Style; var gcd = MultiGcd(ply_seams); var lineCount = (int)Math.Round(z / gcd); var winHeight1 = (int)ConvertToNum(vm.WinDim1); var winHeight2 = (int)ConvertToNum(vm.WinDim2); if (winHeight1 > z || winHeight2 > z) { return; } if (vm.WindowX || vm.WindowY) { if (winHeight1 != 0 && winHeight2 != 0) { gcd = Gcd(lineCount, winHeight1); lineCount = (int)Math.Round(z / gcd); } for (var i = 0; i < lineCount * 2 + 1; i++) { ui.GridWinDim.RowDefinitions.Add(new RowDefinition()); } } for (var i = 0; i < lineCount - 1; i++) { ui.TreeLines.RowDefinitions.Add(new RowDefinition()); } for (var i = 0; i < lineCount * 2 + 1; i++) { ui.TreeValues.RowDefinitions.Add(new RowDefinition()); } var sumPly = 0d; for (var i = 0; i < ply_seams.Length - 1; i++) { sumPly += ply_seams[i]; var line = new Line { X1 = 0, X2 = 1, VerticalAlignment = VerticalAlignment.Center, StrokeThickness = 2, Style = lineStyle, }; Grid.SetRow(line, ui.TreeLines.RowDefinitions.Count - (int)Math.Round(sumPly / gcd)); ui.TreeLines.Children.Add(line); } if (vm.WindowX || vm.WindowY) { var line = new Line { X1 = 0, X2 = 1, VerticalAlignment = VerticalAlignment.Center, Style = lineStyle, StrokeThickness = 2, Stroke = new SolidColorBrush(Colors.Red) }; int windowRow; if (winHeight1 == 0) { windowRow = 0; line.VerticalAlignment = VerticalAlignment.Top; } else if (winHeight2 == 0) { windowRow = ui.TreeLines.RowDefinitions.Count - 1; line.VerticalAlignment = VerticalAlignment.Bottom; } else { windowRow = (int)Math.Round((double)winHeight1 / gcd, 0); } Grid.SetRow(line, windowRow); ui.TreeLines.Children.Add(line); var winDim1Row = (int)Math.Round((double)windowRow / 2, 0); var winDim2Row = (int)Math.Round((double)(ui.GridWinDim.RowDefinitions.Count + windowRow) / 2, 0); Grid.SetRow(ui.WinDim1, winDim1Row); Grid.SetRow(ui.WinDim2, winDim2Row); ui.GridWinDim.RowDefinitions[winDim1Row].Height = new GridLength(20); ui.GridWinDim.RowDefinitions[winDim2Row].Height = new GridLength(20); } sumPly = 0d; foreach (var t in ply_seams) { sumPly += t; var value = new TextBlock { Text = ConvertFtIn(t), Style = textStyle, }; var textRow = ui.TreeValues.RowDefinitions.Count - 1 - (int)Math.Round(sumPly / gcd, 0); Grid.SetRow(value, textRow); ui.TreeValues.RowDefinitions[textRow].Height = new GridLength(20); ui.TreeValues.Children.Add(value); sumPly += t; } if (editWin) { return; } vm.WinDim1 = ConvertFtIn(z / 5); vm.WinDim2 = ConvertFtIn(z - ConvertToNum(vm.WinDim1)); }
public static void sUpdatePly(ColumnCreatorView ui, ColumnCreatorViewModel vm) { var x = ConvertToNum(vm.SWidthX); var y = ConvertToNum(vm.SLengthY); var z = ConvertToNum(vm.SHeightZ); if (x == 0 || y == 0 || z == 0) { return; } double[] ply_seams = { }; double temp_ht = 0; if (ui.SBoxPlySeams.Text.Equals("")) { ply_seams = GetPlySeams(x, y, z, ui); ui.STxtPlyError.Visibility = Visibility.Collapsed; } else { ply_seams = ReadSizes(ui.SBoxPlySeams.Text); if (sValidatePlySeams(ui, ply_seams, x, y, z) != 1) { return; } } if (!ui.SBoxPlySeams.Text.Equals("")) { goto SkipPlyUpdate; } string strPlySeams = ""; for (var i = 0; i < ply_seams.Length; i++) { if (i != ply_seams.Length - 1) { strPlySeams += ConvertFtIn(ply_seams[i]) + ", "; } else { strPlySeams += ConvertFtIn(ply_seams[i]); } } ui.SBoxPlySeams.Text = strPlySeams; SkipPlyUpdate: double[] pt_draw = new double[3]; pt_draw[0] = 200; pt_draw[1] = 216; pt_draw[2] = 0; ui.STreeLines.Children.Clear(); ui.STreeLines.RowDefinitions.Clear(); ui.STreeLines.RowDefinitions.Add(new RowDefinition()); ui.STreeValues.Children.Clear(); ui.STreeValues.RowDefinitions.Clear(); var lineStyle = ui.FindResource("TreeLine") as Style; var textStyle = ui.FindResource("TreeTextBlock") as Style; var gcd = MultiGcd(ply_seams); var lineCount = (int)z / gcd; for (var i = 0; i < lineCount - 1; i++) { ui.STreeLines.RowDefinitions.Add(new RowDefinition()); } for (var i = 0; i < lineCount * 2 + 1; i++) { ui.STreeValues.RowDefinitions.Add(new RowDefinition()); } var sumPly = 0d; for (var i = 0; i < ply_seams.Length - 1; i++) { sumPly += ply_seams[i]; var line = new Line { X1 = 0, X2 = 1, VerticalAlignment = VerticalAlignment.Center, Style = lineStyle, }; Grid.SetRow(line, ui.STreeLines.RowDefinitions.Count - (int)Math.Round(sumPly / gcd)); ui.STreeLines.Children.Add(line); } sumPly = 0d; foreach (var t in ply_seams) { sumPly += t; var value = new TextBlock { Text = ConvertFtIn(t), Style = textStyle, }; var textRow = ui.STreeValues.RowDefinitions.Count - 1 - (int)Math.Round(sumPly / gcd, 0); Grid.SetRow(value, textRow); ui.STreeValues.RowDefinitions[textRow].Height = new GridLength(20); ui.STreeValues.Children.Add(value); sumPly += t; } }