private void ImportBtnSilent_Click(object sender, RoutedEventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if ((bool)ofd.ShowDialog()) { CAEXDocument doc = CAEXDocument.LoadFromFile(ofd.FileName); doc.CAEXFile.Select(c => c.Name).ToList(); if (this.ImportLibraries(ofd.FileName, doc.CAEXFile.Select(c => c.Name).ToList(), true, out var args)) { Infos = "import o.k."; } else if (args.Cancelled) { Infos = "import cancelled"; } else { Infos = "import error"; } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Infos")); } }
/// <summary> /// The <see cref="OpenFileCommand"/> Execution Action. /// </summary> private void OpenFileCommandExecute(object parameter) { OpenFileDialog ofd = new OpenFileDialog { Title = "Open AML File", DefaultExt = ".aml", Filter = "AML Files (*.aml)|*.aml" }; var result = ofd.ShowDialog(); if (result.HasValue && (bool)result) { var template = new HashSet <string>(AMLTreeViewTemplate.CompleteInstanceHierarchyTree .Concat(AMLTreeViewTemplate.CompleteSystemUnitClassLibTree) .Concat(AMLTreeViewTemplate.ExtendedRoleClassLibTree) .Concat(AMLTreeViewTemplate.InterfaceClassLibTree) .Concat(AMLTreeViewTemplate.AttributeTypeLibTree).Distinct()); FilePath = ofd.FileName; Document = CAEXDocument.LoadFromFile(ofd.FileName); AMLDocumentTreeViewModel = new AMLTreeViewModel(Document.CAEXFile.Node, template); PropagateFileOpenEventToPlugins(FilePath); } }
public static CAEXDocument OpenCaexSafe(string path) { try { if (!File.Exists(path)) { Console.WriteLine($"Cannot find file {path}"); Console.WriteLine($"Try to create new one in {path}"); var cAEXDocument = CAEXDocument.New_CAEXDocument(); cAEXDocument.SaveToFile(path, true); return(cAEXDocument); } return(CAEXDocument.LoadFromFile(path)); } catch (Exception ex) { Console.WriteLine($"ERROR: {ex.Message}"); return(null); } }
public void LoadTest() { var document = CAEXDocument.LoadFromFile(@"D:\test.aml"); var provider = new AmlDocument(document); var ie = document.CAEXFile.InstanceHierarchy.First().InternalElement.First(); var factory = new KinematicFactory(); var kinematic = factory.Create <Kinematic>(ie, provider); }
internal void LoadDocument(string filePath) { ActiveDocument = new() { FilePath = filePath, Document = CAEXDocument.LoadFromFile(filePath), }; }
internal void Open(string filePath) { AMLDocumentTreeViewModel?.ClearAll(); Document = null; FilePath = filePath; Document = CAEXDocument.LoadFromFile(filePath); AMLDocumentTreeViewModel = new AMLTreeViewModel(Document.CAEXFile.Node, AMLTreeViewTemplate.CompleteInstanceHierarchyTree); PropagateFileOpenEventToPlugins(FilePath); }
public MainWindow() { InitializeComponent(); AMLToolkit.ViewModel.AMLLayout.DefaultLayout.ShowClassReference = false; AMLToolkit.ViewModel.AMLLayout.DefaultLayout.ShowRoleReference = false; var path = System.IO.Path.Combine(Environment.CurrentDirectory, @"TestFile/Test1.aml"); var doc = CAEXDocument.LoadFromFile(path); undoRedoManager = new AMLToolkit.Tools.AMLUndoRedoManager(); this.IHTree.TreeViewModel = new AMLToolkit.ViewModel.AMLTreeViewModel((XmlElement)doc.CAEXFile.Node, AMLToolkit.ViewModel.AMLTreeViewTemplate.CompleteInstanceHierarchyTree); this.ICTree.TreeViewModel = new AMLToolkit.ViewModel.AMLTreeViewModel((XmlElement)doc.CAEXFile.Node, AMLToolkit.ViewModel.AMLTreeViewTemplate.InterfaceClassLibTree); this.SUCTree.TreeViewModel = new AMLToolkit.ViewModel.AMLTreeViewModel((XmlElement)doc.CAEXFile.Node, AMLToolkit.ViewModel.AMLTreeViewTemplate.CompleteSystemUnitClassLibTree); this.RCTree.TreeViewModel = new AMLToolkit.ViewModel.AMLTreeViewModel((XmlElement)doc.CAEXFile.Node, AMLToolkit.ViewModel.AMLTreeViewTemplate.ExtendedRoleClassLibTree); // test layout options System.Windows.Threading.DispatcherTimer dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += new EventHandler(testFilter); dispatcherTimer.Interval = new TimeSpan(0, 0, 12); //dispatcherTimer.Start(); // test layout options System.Windows.Threading.DispatcherTimer dispatcherTimer2 = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer2.Tick += new EventHandler(testReferenceDisplay); dispatcherTimer2.Interval = new TimeSpan(0, 0, 7); //dispatcherTimer2.Start(); this.IHTree.AllowDrop = true; this.SUCTree.AllowDrop = true; AMLToolkit.ViewModel.AMLTreeViewModel.CanDragDropPredicate CanDragDrop = delegate(AMLTreeViewModel tree, AMLNodeViewModel source, AMLNodeViewModel target) { return((source.CAEXNode.Name == CAEX_ClassModel.CAEX_CLASSModel_TagNames.INTERNALELEMENT_STRING && target.CAEXNode.Name == CAEX_ClassModel.CAEX_CLASSModel_TagNames.INTERNALELEMENT_STRING) || (source.CAEXNode.Name == CAEX_ClassModel.CAEX_CLASSModel_TagNames.INTERNALELEMENT_STRING && target.CAEXNode.Name == CAEX_ClassModel.CAEX_CLASSModel_TagNames.SYSTEMUNITCLASS_STRING) || (source.CAEXNode.Name == CAEX_ClassModel.CAEX_CLASSModel_TagNames.SYSTEMUNITCLASS_STRING && target.CAEXNode.Name == CAEX_ClassModel.CAEX_CLASSModel_TagNames.SYSTEMUNITCLASS_STRING)); }; AMLToolkit.ViewModel.AMLTreeViewModel.DoDragDropAction DoDragDrop = delegate(AMLTreeViewModel tree, AMLNodeViewModel source, AMLNodeViewModel target) { AMLInsertCopyFromSourceCommand.ExcuteAndInsertCommand(undoRedoManager, target, source); }; this.IHTree.TreeViewModel.CanDragDrop = CanDragDrop; this.IHTree.TreeViewModel.DoDragDrop = DoDragDrop; this.SUCTree.TreeViewModel.DoDragDrop = DoDragDrop; this.SUCTree.TreeViewModel.CanDragDrop = CanDragDrop; }
private void loadDocument() { // load a document var caexDocument = CAEXDocument.LoadFromFile("myfile.aml"); // get the InstanceHierarchy var myIH = caexDocument.CAEXFile.InstanceHierarchy[0]; // add more content myIH.InternalElement.Append("Ie1"); }
/// <summary> /// Save CAEX-File /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_SaveCAEX_Click(object sender, EventArgs e) { myErrorListBox.Items.Clear(); saveFileDialog.Filter = @"AML files|*.aml"; if (saveFileDialog.ShowDialog() != DialogResult.OK) { return; } _fileName = saveFileDialog.FileName; _myDoc.SaveToFile(_fileName, true); _myDoc = CAEXDocument.LoadFromFile(_fileName); }
/// <summary> /// Loads a CAEX file /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Btn_OpenCAEX_Click(object sender, EventArgs e) { myErrorListBox.Items.Clear(); if (openFileDialog.ShowDialog() != DialogResult.OK) { return; } _myDoc = null; CAEXTreeView.Nodes.Clear(); _fileName = openFileDialog.FileName; lbl_FileName.Text = _fileName; _myDoc = CAEXDocument.LoadFromFile(_fileName); ShowMyTree(CAEXTreeView, _myDoc); }
/// <summary> /// Handling the event of the open CAEX button /// </summary> private void _BopenCAEX_Click(object sender, EventArgs e) { if (_openFile.ShowDialog() == DialogResult.OK) { this._CTV.PathSeparator = "/"; this.myDoc = null; this._CTV.Nodes.Clear(); this.fileName = _openFile.FileName; // Gets or sets a string containing the file name selected in the file dialog box. _FileName.Text = fileName; myDoc = CAEXDocument.LoadFromFile(fileName); this.myShowTree(_CTV, myDoc); this._CTV.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(GenerateEnable); this.Open(); } }
internal void Open(string filePath) { var template = new HashSet <string> (AMLTreeViewTemplate.CompleteInstanceHierarchyTree .Concat(AMLTreeViewTemplate.CompleteSystemUnitClassLibTree) .Concat(AMLTreeViewTemplate.ExtendedRoleClassLibTree) .Concat(AMLTreeViewTemplate.InterfaceClassLibTree) .Concat(AMLTreeViewTemplate.AttributeTypeLibTree).Distinct()); AMLDocumentTreeViewModel?.ClearAll(); Document = null; FilePath = filePath; Document = CAEXDocument.LoadFromFile(filePath); AMLDocumentTreeViewModel = new AMLTreeViewModel(Document.CAEXFile.Node, template); PropagateFileOpenEventToPlugins(FilePath); }
public void SerDesTest() { var provider = new AmlDocument(); var expected = new KinematicJointValue(provider) { Name = "foobar", Value = 1d, DefaultValue = 3d, Minimum = -10d, Maximum = 20d }; var value = new KinematicJointValue((AttributeType)expected.CaexObject, provider); Assert.Equal(expected.Name, value.Name); Assert.Equal(expected.Value, value.Value); Assert.Equal(expected.Minimum, value.Minimum); Assert.Equal(expected.Maximum, value.Maximum); var ie = provider.CaexDocument.Create <InternalElementType>(); var ih = provider.CaexDocument.Create <InstanceHierarchyType>(); ie.Attribute.Insert((AttributeType)expected.CaexObject); ih.InternalElement.Insert(ie); provider.CaexDocument.CAEXFile.InstanceHierarchy.Insert(ih); var fullPath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); provider.CaexDocument.SaveToFile(fullPath, true); var d = CAEXDocument.LoadFromFile(fullPath); var p = new AmlDocument(d); File.Delete(fullPath); value = new KinematicJointValue(d.CAEXFile.InstanceHierarchy.First().InternalElement.First().Attribute.First(), provider); Assert.Equal(expected.Name, value.Name); Assert.Equal(expected.Value, value.Value); Assert.Equal(expected.Minimum, value.Minimum); Assert.Equal(expected.Maximum, value.Maximum); }
/// <summary> /// The <see cref="OpenFileCommand"/> Execution Action. /// </summary> private void OpenFileCommandExecute(object parameter) { OpenFileDialog ofd = new OpenFileDialog { Title = "Open AML File", DefaultExt = ".aml", Filter = "AML Files (*.aml)|*.aml" }; var result = ofd.ShowDialog(); if (result.HasValue && (bool)result) { FilePath = ofd.FileName; Document = CAEXDocument.LoadFromFile(ofd.FileName); AMLDocumentTreeViewModel = new AMLTreeViewModel(Document.CAEXFile.Node, AMLTreeViewTemplate.CompleteInstanceHierarchyTree); PropagateFileOpenEventToPlugins(FilePath); } }
private static CAEXDocument LoadFile(ref string AMLFile) { PrintHelper.printCentredLine(PrintHelper.line() + "\n\n"); if (String.IsNullOrEmpty(AMLFile)) { // Ask for File PrintHelper.printCentredLine("Which File do you want to validate?\n"); AMLFile = PrintHelper.GetFile("AML-File", "*.AML"); } // look up input is actual file if (String.IsNullOrEmpty(AMLFile)) { return(null); } else { return(CAEXDocument.LoadFromFile(AMLFile)); } }