/// <summary> /// Export the feature model diagram /// </summary> /// <param name="sender"></param> /// <param name="e"></param> internal void OnExportDiagramClick(object sender, EventArgs e) { foreach (object selectedObject in this.CurrentSelection) { if (selectedObject is FeatureModelDSLDiagram) { FeatureModelDSLDiagram diagram = (selectedObject as FeatureModelDSLDiagram); string featureModelName = (diagram.ModelElement as FeatureModel).Name + ".png"; FrmTextInputDialog frmTextInputDialog = new FrmTextInputDialog("Export Diagram", "Export to (complete file path):", featureModelName); if (frmTextInputDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { Bitmap picture = diagram.CreateBitmap(diagram.NestedChildShapes, Diagram.CreateBitmapPreference.FavorClarityOverSmallSize); string saveLocation = frmTextInputDialog.InputText; if (!saveLocation.EndsWith(".png")) { saveLocation += ".png"; } if (File.Exists(saveLocation)) { if (MessageBox.Show(saveLocation + " already exists.\r\nDo you want to replace it?", "Confirm Export Diagram location", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.Yes) { SaveDiagramBitmapToFile(picture, saveLocation); } } else { SaveDiagramBitmapToFile(picture, saveLocation); } } break; } } }
/// <summary> /// Creates or updates the Confeaturator tree. /// </summary> private void RefreshConfeaturatorTree() { try { SingleDiagramDocView diagramDocView = DesignerHelper.GetDiagramDocView(serviceProvider); FeatureModelDSLDiagram diagram = diagramDocView.CurrentDiagram as FeatureModelDSLDiagram; if (diagram != null) { FeatureModel featureModel = diagram.Subject as FeatureModel; if (featureModel != null) { Feature rootFeature = FeatureModel.GetCrossDiagramRootFeature(featureModel); trvFeatures.Nodes.Clear(); if (rootFeature != null) { addedFeatures = new List <string>(); FeatureModelTreeNode rootNode = CreateFeatureModelTreeNode(rootFeature); trvFeatures.Nodes.Add(rootNode); rootNode.Expand(); rootNode.Kind = FeatureModelNodeKind.Root; rootNode.Status = FeatureModelNodeStatus.CheckedAndDisabled; trvFeatures.SelectedNode = rootNode; } else { Util.ShowError("Feature model was loaded but root feature is null."); } } else { Util.ShowError("Could not load feature model into Confeaturator. Please ensure you have a valid feature model file opened."); } } else { Util.ShowError("Please have the feature model diagram you want to refresh into Confeaturator open and active in Visual Studio."); } } catch (Exception ex) { Util.ShowError("Error loading feature model into Confeaturator: " + ex.Message); } }
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value) { // Default behavior if ((context == null) || (provider == null) || (context.Instance == null)) { return(base.EditValue(context, provider, value)); } ModelElement modelElement = (context.Instance as ModelElement); edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)); if (edSvc != null) { FrmFeatureModelDiagramSelector form = new FrmFeatureModelDiagramSelector(modelElement.Store); if (edSvc.ShowDialog(form) == DialogResult.OK) { using (Transaction transaction = modelElement.Store.TransactionManager.BeginTransaction("UpdatingFeatureModelFileValue")) { if (modelElement is FeatureShape) { FeatureShape featureShape = modelElement as FeatureShape; (featureShape.ModelElement as Feature).DefinitionFeatureModelFile = form.SelectedFeatureModelFile; } else if (modelElement is FeatureModelDSLDiagram) { FeatureModelDSLDiagram featureModelDslDiagram = modelElement as FeatureModelDSLDiagram; (featureModelDslDiagram.ModelElement as FeatureModel).ParentFeatureModelFile = form.SelectedFeatureModelFile; } transaction.Commit(); } } } // Default behavior return(base.EditValue(context, provider, value)); }