コード例 #1
0
        public void editModelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (SelectedModel == null)
                MessageBox.Show("Select model to edit.");
            else
            {
                DiscreteChoiceModel m = SelectedModel;

                if (m is TimeSliceDCM)
                {
                    TimeSliceDcmForm f = new TimeSliceDcmForm(m as TimeSliceDCM);
                    if (f.ShowDialog() == DialogResult.OK)
                        f.ResultingModel.Update();
                }
                else if (m is FeatureBasedDCM)
                {
                    FeatureBasedDcmForm f = new FeatureBasedDcmForm(m as FeatureBasedDCM);
                    if (f.ShowDialog() == DialogResult.OK)
                        f.ResultingModel.Update();
                }
                else if (m is KernelDensityDCM)
                {
                    KernelDensityDcmForm f = new KernelDensityDcmForm(m as KernelDensityDCM);
                    if (f.ShowDialog() == DialogResult.OK)
                        f.ResultingModel.Update();
                }

                RefreshModels(m.Id);
            }
        }
コード例 #2
0
        public void addModelToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Type[] modelTypes = Assembly.GetAssembly(typeof(DiscreteChoiceModel)).GetTypes().Where(t => !t.IsAbstract && t.IsSubclassOf(typeof(DiscreteChoiceModel))).ToArray();
            if (modelTypes.Length == 0)
                MessageBox.Show("No model type are available.");
            else if (Area.GetAll().Count == 0)
                MessageBox.Show("No areas available to model. Import one first.");
            else
            {
                DynamicForm modelForm = new DynamicForm("Select model type...", DynamicForm.CloseButtons.OkCancel);
                modelForm.AddDropDown("Model type:", modelTypes, null, "model_type", false);
                if (modelForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    Type modelType = modelForm.GetValue<Type>("model_type");
                    DiscreteChoiceModel model = null;

                    if (modelType == typeof(KernelDensityDCM))
                    {
                        KernelDensityDcmForm f = new KernelDensityDcmForm();
                        if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            model = f.ResultingModel;
                    }
                    else if (modelType == typeof(FeatureBasedDCM))
                    {
                        FeatureBasedDcmForm f = new FeatureBasedDcmForm();
                        if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            model = f.ResultingModel;
                    }
                    else if (modelType == typeof(TimeSliceDCM))
                    {
                        TimeSliceDcmForm f = new TimeSliceDcmForm();
                        if (f.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                            model = f.ResultingModel;
                    }

                    if (model != null)
                        RefreshModels(model.Id);
                }
            }
        }