Пример #1
0
        private void KeepExisting(object sender, RoutedEventArgs e)
        {
            DesignOptimisation DOpti = (this.DataContext as DesignOptimisation);

            DOpti.newDesign = false;
            this.Close();
        }
Пример #2
0
        private void AcceptDesign(object sender, RoutedEventArgs e)
        {
            DesignOptimisation DOpti = (this.DataContext as DesignOptimisation);

            DOpti.newDesign = true;
            this.Close();
        }
Пример #3
0
        private void RunAutoDesign(object sender, RoutedEventArgs e)
        {
            Button    b  = sender as Button;
            ViewModel vm = this.DataContext as ViewModel;

            bool[] Shapes = new bool[]
            {
                RectangularCB.IsChecked ?? false,
                CircularCB.IsChecked ?? false,
                PolygonalCB.IsChecked ?? false,
            };

            bool[] Activations = new bool[]
            {
                LXCB.IsChecked ?? false,
                LYCB.IsChecked ?? false,
                NXCB.IsChecked ?? false,
                NYCB.IsChecked ?? false,
                DCB.IsChecked ?? false,
                NCircCB.IsChecked ?? false,
                RadiusCB.IsChecked ?? false,
                EdgesCB.IsChecked ?? false,
                BarDCB.IsChecked ?? false,
                LinkDCB.IsChecked ?? false,
                CGCB.IsChecked ?? false
            };

            string[] Mins = new string[]
            {
                MinXDim?.Text ?? "",
                MinYDim?.Text ?? "",
                MinNX?.SelectedValue?.ToString() ?? "",
                MinNY?.SelectedValue?.ToString() ?? "",
                MinD?.Text ?? "",
                MinNCirc?.SelectedValue?.ToString() ?? "",
                MinRadius?.Text ?? "",
                MinEdges?.Text ?? "",
                MinBarDiameter?.SelectedValue?.ToString() ?? "",
                MinLinkDiameter?.SelectedValue?.ToString() ?? "",
                MinCG?.SelectedValue?.ToString() ?? "",
            };

            string[] Maxs = new string[]
            {
                MaxXDim?.Text ?? "",
                MaxYDim?.Text ?? "",
                MaxNX?.SelectedValue?.ToString() ?? "",
                MaxNY?.SelectedValue?.ToString() ?? "",
                MaxD?.Text ?? "",
                MaxNCirc?.SelectedValue?.ToString() ?? "",
                MaxRadius?.Text ?? "",
                MaxEdges?.Text ?? "",
                MaxBarDiameter?.SelectedValue?.ToString() ?? "",
                MaxLinkDiameter?.SelectedValue?.ToString() ?? "",
                MaxCG.SelectedValue?.ToString() ?? "",
            };

            bool[] FireDesignMethods = new bool[]
            {
                TableDataCB.IsChecked ?? false,
                IsothermCB.IsChecked ?? false,
                ZoneCB.IsChecked ?? false,
                AdvancedCB.IsChecked ?? false
            };

            bool error = false;

            for (int i = 0; i < Activations.Length; i++)
            {
                if (Activations[i] && (Mins[i] == "" || Maxs[i] == ""))
                {
                    error = true;
                }
            }
            if (Activations[0] && Convert.ToDouble(Mins[0]) > Convert.ToDouble(Maxs[0]))
            {
                LXmess.Text = "Incompatible Min and Max values";
                error       = true;
            }
            if (Activations[1] && Convert.ToDouble(Mins[1]) > Convert.ToDouble(Maxs[1]))
            {
                LYmess.Text = "Incompatible Min and Max values";
                error       = true;
            }
            if (Activations[2] && Convert.ToInt32(Mins[2]) > Convert.ToInt32(Maxs[2]))
            {
                NXmess.Text = "Incompatible Min and Max values";
                error       = true;
            }
            if (Activations[3] && Convert.ToInt32(Mins[3]) > Convert.ToInt32(Maxs[3]))
            {
                NYmess.Text = "Incompatible Min and Max values";
                error       = true;
            }
            if (Activations[4] && Convert.ToDouble(Mins[4]) > Convert.ToDouble(Maxs[4]))
            {
                Dmess.Text = "Incompatible Min and Max values";
                error      = true;
            }
            if (Activations[5] && Convert.ToInt32(Mins[5]) > Convert.ToInt32(Maxs[5]))
            {
                NCircmess.Text = "Incompatible Min and Max values";
                error          = true;
            }
            if (Activations[6] && Convert.ToDouble(Mins[6]) > Convert.ToDouble(Maxs[6]))
            {
                Radiusmess.Text = "Incompatible Min and Max values";
                error           = true;
            }
            if (Activations[7] && Convert.ToInt32(Mins[7]) > Convert.ToInt32(Maxs[7]))
            {
                Edgesmess.Text = "Incompatible Min and Max values";
                error          = true;
            }

            if (Activations[8] && Convert.ToInt32(Mins[8]) > Convert.ToInt32(Maxs[8]))
            {
                Barmess.Text = "Incompatible Min and Max values";
                error        = true;
            }
            if (Activations[9] && Convert.ToInt32(Mins[9]) > Convert.ToInt32(Maxs[9]))
            {
                Linkmess.Text = "Incompatible Min and Max values";
                error         = true;
            }
            if (Activations[10] && Convert.ToInt32(Mins[10].Substring(0, 2)) > Convert.ToInt32(Maxs[10].Substring(0, 2)))
            {
                CGmess.Text = "Incompatible Min and Max values";
                error       = true;
            }

            if (!(CostCB.IsChecked ?? false) && !(CarbonCB.IsChecked ?? false))
            {
                Drivermess.Text = "You must select at least one driver";
                error           = true;
            }

            if (!error)
            {
                string[] Incrs = new string[]
                {
                    IncrXDim.Text,
                    IncrYDim.Text,
                    IncrD.Text,
                    IncrRadius.Text
                };

                double[] drivers       = new double[] { (CostCB.IsChecked ?? false)? 1 : 0, (CarbonCB.IsChecked ?? false) ? 1 : 0 };
                double[] driversWeight = new double[] { Convert.ToDouble(CostWeightTB.Text), Convert.ToDouble(CarbonWeightTB.Text) };
                bool     sq            = (SquareCB.IsChecked ?? false) && (LYCB.IsChecked ?? false);

                DesignOptimisation designO = new DesignOptimisation(vm, Shapes, Activations, Mins, Maxs, Incrs, Convert.ToInt32(MaxIter.Text),
                                                                    Convert.ToDouble(Alpha.Text), Convert.ToDouble(Variance.Text), drivers, driversWeight, sq, FireDesignMethods);
                //if (designO.newDesign)
                //    vm.SelectedColumn = designO.column;
                //this.Close();
            }
        }