Exemplo n.º 1
0
        public static int ValidatePlySeams(ColumnCreatorView ui, double[] ply_seams, double x, double y,
                                           double z)
        {
            var temp_ht = ply_seams.Sum();

            if (Math.Abs(temp_ht - z) > 0.001)
            {
                if (temp_ht > z)
                {
                    ui.TxtPlyError.Text = $"Remove {ConvertFtIn(temp_ht - z)}";
                }
                else if (temp_ht < z)
                {
                    ui.TxtPlyError.Text = $"Add {ConvertFtIn(z - temp_ht)}";
                }

                ui.TxtPlyError.Visibility = Visibility.Visible;
                return(0);
            }


            double ply_width_x;
            double ply_width_y;
            double min_ply_ht = 6;
            double max_ply_ht;

            ply_width_x = x + 1.5;
            ply_width_y = y + 1.5;
            if (ply_width_x > 48 || ply_width_y > 48)
            {
                max_ply_ht = 48;
            }
            else
            {
                max_ply_ht = 96;
            }
            foreach (var t in ply_seams)
            {
                if (t > max_ply_ht)
                {
                    ui.TxtPlyError.Text       = $"{ConvertFtIn(t)} ply too tall. Max: {ConvertFtIn(max_ply_ht)}";
                    ui.TxtPlyError.Visibility = Visibility.Visible;
                    return(0);
                }

                if (t < min_ply_ht)
                {
                    ui.TxtPlyError.Text       = $"{ConvertFtIn(t)} ply too small. Min: {ConvertFtIn(min_ply_ht)}";
                    ui.TxtPlyError.Visibility = Visibility.Visible;
                    return(0);
                }

                ui.TxtPlyError.Visibility = Visibility.Collapsed;
            }

            ui.TxtPlyError.Visibility = Visibility.Collapsed;
            return(1);
        }
Exemplo n.º 2
0
        public void ShowForm(UIApplication uiApp)
        {
            if (_form != null && _form == null)
            {
                return;
            }
            var evWpf = new EventHandlerWithWpfArg();

            RApplication = uiApp;
            _form        = new ColumnCreatorView(uiApp, evWpf);
            _form.Show();
        }
Exemplo n.º 3
0
        public Result OnStartup(UIControlledApplication application)
        {
            _form   = null;
            ThisApp = this;
            var panel = application.CreateRibbonPanel("Column design");

            if (panel.AddItem(new PushButtonData("ColumnCreator", "Column\ncreator",
                                                 Assembly.GetExecutingAssembly().Location,
                                                 typeof(ColumnCreator).FullName)) is PushButton buttonColumnCreator)
            {
                buttonColumnCreator.ToolTip = "Automatic creation of worksheets";
                buttonColumnCreator.Image   = new BitmapImage(new Uri(
                                                                  "pack://application:,,,/ColumnDesign;component/Resources/ColumnCreator16.png"));
                buttonColumnCreator.LargeImage = new BitmapImage(new Uri(
                                                                     "pack://application:,,,/ColumnDesign;component/Resources/ColumnCreator32.png"));
            }
            return(Result.Succeeded);
        }
Exemplo n.º 4
0
        public static void sCheckHeight(double x, double y, double z, ColumnCreatorView ui)
        {
            double big_dim;
            double max_ht;

            if (x == 0 || y == 0 || z == 0)
            {
                ui.SMaxHeight.Text = "N/A";
                return;
            }

            if (x >= y)
            {
                big_dim = x;
            }
            else
            {
                big_dim = y;
            }

            max_ht = big_dim switch
            {
Exemplo n.º 5
0
        public static double[] GetPlySeams(double x, double y, double z, ColumnCreatorView ui)
        {
            double       plyWidthX;
            double       plyWidthY;
            const double plyTopHtMin = 6;

            double[] plySeamsFun = new double[1];
            double   maxPlyHt;

            if (ui.Tabs.SelectedIndex == 0)
            {
                plyWidthX = x + 1.5;
                plyWidthY = y + 1.5;
            }
            else
            {
                plyWidthX = x;
                plyWidthY = y + 4.5;
            }

            if (plyWidthX > 48 || plyWidthY > 48)
            {
                maxPlyHt = 48;
            }
            else
            {
                maxPlyHt = 96;
            }
            var plyTopHt = z - maxPlyHt * (int)(z / maxPlyHt);
            var plyBotN  = (int)(z / maxPlyHt);

            Array.Resize(ref plySeamsFun, plyBotN + (Math.Abs(plyTopHt) != 0 ? 1 : 0));
            if (z <= maxPlyHt)
            {
                plySeamsFun[0] = z;
                return(plySeamsFun);
            }

            for (var i = 0; i < plyBotN; i++)
            {
                plySeamsFun[i] = maxPlyHt;
            }

            if (plyTopHt != 0)
            {
                plySeamsFun[plySeamsFun.Length - 1] = plyTopHt;
            }

            if (plyTopHt < plyTopHtMin && plyTopHt > 0)
            {
                plyTopHt += 48 * maxPlyHt / 96;
                plyBotN   = (int)((z - 48 * maxPlyHt / 96 - plyTopHt) / maxPlyHt);
                Array.Resize(ref plySeamsFun, plyBotN + 2);
                for (var i = 0; i < plyBotN; i++)
                {
                    plySeamsFun[i] = maxPlyHt;
                }
                plySeamsFun[plySeamsFun.Length - 2] = 48 * maxPlyHt / 96;
                plySeamsFun[plySeamsFun.Length - 1] = plyTopHt;
            }

            return(plySeamsFun);
        }
Exemplo n.º 6
0
        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));
        }
Exemplo n.º 7
0
        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;
            }
        }