/// <summary> /// Sets view model. /// </summary> /// <param name="viewModel">VM.</param> public virtual void SetViewModel(Tum.PDE.VSPluginDSL.ViewModel.VSPluginDSLMainViewModel viewModel) { try { this.ViewModel = viewModel; this.DataContext = viewModel; viewModel.Ribbon = this.Ribbon; viewModel.RestoreLayout(); } catch (System.Exception ex) { System.Windows.MessageBox.Show("Error during initialization: " + ex.Message); } // Register known windows DslEditorServices::IUIVisualizerService popupVisualizer = ViewModel.GlobalServiceProvider.Resolve<DslEditorServices::IUIVisualizerService>(); popupVisualizer.TryRegister("SelectElementPopup", typeof(DslEditorPopups::SelectElementPopup)); popupVisualizer.TryRegister("DeleteElementsPopup", typeof(DslEditorPopups::DeleteElementsPopup)); popupVisualizer.TryRegister("SelectElementWithRSTypePopup", typeof(DslEditorPopups::SelectElementWithRSTypePopup)); popupVisualizer.TryRegister("SelectRSTypePopup", typeof(DslEditorPopups::SelectRSTypePopup)); /* try { // load plugins LoadPlugins(); } catch (System.Exception ex) { System.Windows.MessageBox.Show("Error during plugin loading: " + ex.Message); }*/ }
/// <summary> /// Constuctor. /// </summary> /// <param name="modelData">Document data.</param> /// <param name="bHookUpEvents">True if events listeners should be initialized.</param> /// <param name="options">Options.</param> protected FamilyTreeDSLViewModelStoreBase(DslEditorModeling::ModelData modelData, Tum.PDE.ToolFramework.Modeling.Visualization.Base.ViewModelOptions options) : base(modelData, true, null) { this.Options = options; if( this.Options == null ) this.Options = new FamilyTreeDSLViewModelOptions(); }
/// <summary> /// Handle the given unhandled exception. /// </summary> /// <param name="ex">Exception.</param> /// <param name="data">Current model data. If this is not null an a model is opened, the model is saved to a temporare file.</param> protected virtual void HandleException(System.Exception ex, Tum.PDE.ToolFramework.Modeling.ModelData data) { //MessageBox.Show("An unhandled error occured: " + ex.Message); HandleException(ex); if (data != null) this.SaveModelTemporarly(data); SaveException(ex); }
/// <summary> /// Saves the currently opened model (ModelData.Instance.CurrentModelContext.RootElement) to a temporarly file. /// </summary> /// <param name="modelData">Current model data.</param> protected virtual void SaveModelTemporarly(Tum.PDE.ToolFramework.Modeling.ModelData modelData) { if (modelData.CurrentModelContext != null) if (modelData.CurrentModelContext.RootElement != null) if (modelData.CurrentModelContext.RootElement is Tum.PDE.ToolFramework.Modeling.IParentModelElement) { try { string filename = (modelData.CurrentModelContext.RootElement as Tum.PDE.ToolFramework.Modeling.IParentModelElement).DomainFilePath; int counter = 0; while (true) { if (!(System.IO.File.Exists(filename + "_temp" + counter + ".xml"))) break; counter++; } modelData.CurrentModelContext.Save(filename + "_temp" + counter + ".xml"); System.Windows.MessageBox.Show("An unhandled error occured. The model was saved to " + filename + "_temp" + counter + ".xml", "Unhandled error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } catch { } } }
/// <summary> /// Constructor. /// </summary> /// <param name="modelData">Document data.</param> /// <param name="options">Options.</param> public FamilyTreeDSLViewModelStore(DslEditorModeling::ModelData modelData, Tum.PDE.ToolFramework.Modeling.Visualization.Base.ViewModelOptions options) : base(modelData, options) { }
/// <summary> /// Constructor. /// </summary> /// <param name="modelData">Document data.</param> /// <param name="options">Options.</param> protected ViewModelStore(ModelData modelData, Tum.PDE.ToolFramework.Modeling.Visualization.Base.ViewModelOptions options) : this(modelData, true) { this.options = options; }
/// <summary> /// Converts the given html document to its flow document representation. /// </summary> /// <param name="htmlDocument">Html document to convert.</param> /// <param name="conversionResult">Conversion result to store error and warning messages.</param> /// <param name="vModellDirectory">Directory of the v-modell.</param> /// <returns>Flow document representing the given html document.</returns> public static string ConvertToFlowDocument(HtmlDocument htmlDocument, Tum.PDE.ToolFramework.Modeling.ValidationResult conversionResult, string vModellDirectory) { string flowDocument = HtmlToXamlConverter.ConvertHtmlToXaml(htmlDocument, conversionResult, vModellDirectory); return flowDocument; }
/// <summary> /// Parses the given flow document by creating the corresponding html data as well as the html document. /// </summary> /// <param name="document">Flow document to parse</param> /// <param name="conversionResult">Conversion result to store error and warning messages.</param> private void ParseFlowDocument(FlowDocument document, Tum.PDE.ToolFramework.Modeling.ValidationResult conversionResult) { if (document == null) return; string html = XamlToHtmlConverter.ConvertXamlToHtml(document, conversionResult); this.htmlData = html; ParseHtml(conversionResult); }
/// <summary> /// Parses the current html data by creating the corresponding HtmlDocument as well as its FlowDocument representation. /// </summary> /// <param name="conversionResult">Conversion result to store error and warning messages.</param> /// <remarks>The created FlowDument is stored as a string for later use.</remarks> private void ParseHtml(Tum.PDE.ToolFramework.Modeling.ValidationResult conversionResult) { this.isParsed = true; if (String.IsNullOrEmpty(this.htmlData)) { this.htmlDocument = new HtmlDocument(); this.flowDocumentData = string.Empty; return; } this.htmlDocument = ConvertToHtmlDocument(this.htmlData); this.flowDocumentData = ConvertToFlowDocument(this.HtmlDocument, conversionResult, this.VModellDirectory); }
/// <summary> /// Constructor /// </summary> /// <param name="type">Kind of the message.</param> /// <param name="description">Message string.</param> public ConversionMessage(Tum.PDE.ToolFramework.Modeling.ModelValidationViolationType type, string description) { this.type = type; this.description = description; }
/// <summary> /// Constructor. /// </summary> /// <param name="modelData">Document data.</param> /// <param name="options">Options.</param> public TestLanguageViewModelStore(DslEditorModeling::ModelData modelData, Tum.PDE.ToolFramework.Modeling.Visualization.Base.ViewModelOptions options) : base(modelData, options) { }