示例#1
0
        private void toolStripButtonReset_Click(object sender, EventArgs e)
        {
            triStateTreeView.Nodes.Clear();
            triStateTreeView.Visible = false;

            this.saveModelToXmlFileToolStripMenuItem.Enabled = false;
            //this.statusTextBox.Text = "";

            FeatureModelConfigurator.Properties.Settings settings = new FeatureModelConfigurator.Properties.Settings();
            string path = Application.StartupPath;

            try
            {
                featureModel.ValidateXmlFile(string.Concat(path, "\\", settings.xmlschemapath));

                if (featureModel.Validity)
                {
                    featureModel.CreateTreeViewFromXmlFile(this.triStateTreeView);
                    this.triStateTreeView.Visible = true;

                    //
                    this.toolStripStatusLabel.Text = "Model reset";

                    //
                    this.saveModelToXmlFileToolStripMenuItem.Enabled = true;
                }

                else
                {
                    this.toolStripStatusLabel.Text = "Model reset failed";
                }
            }
            catch (Exception exception)
            {
                System.Windows.Forms.MessageBox.Show(exception.Message, "Feature Reset Model Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        private void loadModelFromXmlFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.toolStripStatusLabel.Text = "Ready";

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter          = "Feature Configuration Files (*.featureconfig)|*.featureconfig|All Files (*.*)|*.*";
            openFileDialog.AddExtension    = true;
            openFileDialog.CheckFileExists = true;

            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                //this.statusTextBox.Text = "";

                FeatureModelConfigurator.Properties.Settings settings = new FeatureModelConfigurator.Properties.Settings();
                string path = Application.StartupPath;

                FeatureModel oldFeatureModel = featureModel;
                featureModel = new FeatureModel(openFileDialog.FileName);

                try
                {
                    featureModel.ValidateXmlFile(string.Concat(path, "\\", settings.xmlschemapath));

                    if (featureModel.Validity)
                    {
                        this.triStateTreeView.InitializeFeatureModel(ref featureModel);
                        //this.triStateTreeView.InitializeStatusTextBox(ref this.statusTextBox);

                        // Set Text of Gpoupbox with model filename
                        this.featureModelGroupBox.Text = openFileDialog.FileName;

                        featureModel.CreateTreeViewFromXmlFile(this.triStateTreeView);
                        this.triStateTreeView.Visible = true;

                        //
                        this.toolStripStatusLabel.Text = string.Format("Model from '{0}' successfully loaded", openFileDialog.FileName);

                        //
                        this.saveModelToXmlFileToolStripMenuItem.Enabled = true;


                        this.toolStripButtonReset.Enabled  = true;
                        this.toolStripButtonSave.Enabled   = true;
                        this.toolStripButtonSaveAs.Enabled = true;
                        this.toolStripButtonClose.Enabled  = true;
                        this.variabilityFMCheckBox.Enabled = true;

                        //
                        ArrayList errorArray = featureModel.CheckConfiguredModel();
                        string[]  array      = (string[])errorArray.ToArray(typeof(string));
                        //this.statusTextBox.Lines = array;
                    }

                    else
                    {
                        //this.statusTextBox.Text = string.Format("XML-File '{0}' is not valid!", featureModel.FileName);
                        this.toolStripStatusLabel.Text = "Loading failed";
                        featureModel = oldFeatureModel;
                    }
                }
                catch (Exception exception)
                {
                    System.Windows.Forms.MessageBox.Show(exception.Message, "Feature Model Loading Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }