private void toolStripMenuItem1_Click(object sender, EventArgs e) { ArrayList errorArray = featureModel.CheckConfiguredModel(); string[] array = (string[])errorArray.ToArray(typeof(string)); //this.statusTextBox.Lines = array; SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "Feature Configuration Files (*.featureconfig)|*.featureconfig|All Files (*.*)|*.*"; saveFileDialog.FilterIndex = 1; saveFileDialog.OverwritePrompt = true; if (saveFileDialog.ShowDialog() == DialogResult.OK) { featureModel.SaveModel(saveFileDialog.FileName); } }
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); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Called when the user clicks on an item /// </summary> /// <param name="e"></param> /// ------------------------------------------------------------------------------------ protected override void OnClick(EventArgs e) { base.OnClick(e); TV_HITTESTINFO hitTestInfo = new TV_HITTESTINFO(); hitTestInfo.pt = PointToClient(Control.MousePosition); SendMessage(Handle, TreeViewMessages.TVM_HITTEST, 0, ref hitTestInfo); if ((hitTestInfo.flags & TVHit.OnItemIcon) == TVHit.OnItemIcon) { TreeNode node = GetNodeAt(hitTestInfo.pt); if (node != null && rootFeature.Items != null && CheckIfNodeIsChangeable(node)) { foreach (object o in this.rootFeature.Items) { string fullpathname = rootFeature.name; if (o.GetType() == typeof(FeatureType)) { fullpathname = string.Format("{0}\\{1}", fullpathname, ((FeatureType)o).name); if (fullpathname == node.FullPath) { if (node.ImageIndex == (int)CheckState.Unchecked) { ((FeatureType)o).configuration = ConfigType.Unspecified; } else if (node.ImageIndex == (int)CheckState.Checked) { ((FeatureType)o).configuration = ConfigType.Excluded; UnSelectChildNodesInObjectModelRecursive((FeatureType)o); UnSelectChildNodesInTreeViewRecursive(node); } else if (node.ImageIndex == (int)CheckState.QuestionMark) { ((FeatureType)o).configuration = ConfigType.Included; } else { ((FeatureType)o).configuration = ConfigType.Excluded; } break; } else { if (((FeatureType)o).Items != null) { if (((FeatureType)o).Items.Length > 0) { GetSubFeaturesOfObjectModelRecursive(o, fullpathname, node); } } } } else if (o.GetType() == typeof(FeatureSetType)) { fullpathname = string.Format("{0}\\FeatureSet [{1}...{2}]", fullpathname, ((FeatureSetType)o).min, ((FeatureSetType)o).max); if (((FeatureSetType)o).Feature.Length > 0) { GetSubFeaturesOfObjectModelRecursive(o, fullpathname, node); } } } ChangeNodeState(node); } } ArrayList errorArray = featureModel.CheckConfiguredModel(); string[] array = (string[])errorArray.ToArray(typeof(string)); //this.statusTextBox.Lines = array; }