public void Load(string file) { var thread = new Thread( () => { FHXObject root = FHXParserWrapper.FromFile(file); FHXParserWrapper.BuildDeltaVHierarchy(root); RootLoaded(root); }); thread.Start(); var thread2 = new Thread( () => { pbPercent.Maximum = 100; pbPercent.Minimum = 0; while (this.IsActive) { pbPercent.Value = FHXParserWrapper.State == "Parsing" ? FHXParserWrapper.ParsingPercent : FHXParserWrapper.BuildingPercent; labelPercent.Content = FHXParserWrapper.ParsingPercent.ToString() + "%"; labelState.Content = FHXParserWrapper.State; Thread.Sleep(100); } }); thread2.Start(); }
private void ChargerFichier(string file) { var t = new Thread(() => { this.Root = FHXParserWrapper.FromFile(file); FHXParserWrapper.BuildDeltaVHierarchy(this.Root); this.tvMain.Dispatcher.BeginInvoke(new Action(delegate { this.tvMain.Items.Add(this.Root.ToTreeViewItem(true, false)); })); }); t.Start(); }
private void ConvertJson(object sender, RoutedEventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "FHX file (*.fhx)|*.fhx"; if (openFileDialog.ShowDialog() == true) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "JSON file (*.json)|*.json"; if (saveFileDialog.ShowDialog() == true) { var t = new Thread(() => { FHXObject o = FHXParserWrapper.FromFile(openFileDialog.FileName); FHXParserWrapper.BuildDeltaVHierarchy(o); FHXJsonConverter.ToJson(o, saveFileDialog.FileName); MessageBox.Show("Fichier converti"); }); t.Start(); } } }
public static void TestNodes() { //Load File string file = @"D:\FHX\SITE_COMMUNS.fhx"; FHXObject Root = FHXParserWrapper.FromFile(file); FHXParserWrapper.BuildDeltaVHierarchy(Root); //Test Areas FHXStructureHandler h = new FHXStructureHandler(Root); FHXNode r = new FHXNode("Root"); foreach (FHXNode n in h.Areas) { r.Children.Add(n); foreach (FHXNode m in h.ModulesArea(n.Label)) { n.Children.Add(m); } } Console.WriteLine(r.Label); }
private void Compare(object sender, RoutedEventArgs e) { string n1 = ""; string n2 = ""; OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Title = Properties.Resources.OpenFirstFile; if (openFileDialog1.ShowDialog() == true) { n1 = openFileDialog1.FileName; } OpenFileDialog openFileDialog2 = new OpenFileDialog(); openFileDialog2.Title = Properties.Resources.OpenSecondFile; if (openFileDialog2.ShowDialog() == true) { n2 = openFileDialog2.FileName; } if (n1 == "" || n2 == "") { return; } FHXObject a = FHXParserWrapper.FromFile(n1); //a = a.Children.Single(i => i.Type == "MODULE"); FHXObject b = FHXParserWrapper.FromFile(n2); //b = b.Children.Single(i => i.Type == "MODULE"); if (a == null || b == null) { MessageBox.Show(Properties.Resources.ErrorLoading); return; } double coef = 37.0 / 11940138.0; double sec = coef * (double)(a.GetAllParameters().Count *b.GetAllParameters().Count); string unit = "s"; if (sec > 60.0) { sec = sec / 60.0; unit = "m"; } else if (sec > 3600.0) { sec = sec / 3600.0; unit = "h"; } string sMessageBoxText = string.Format("La procédure prendra environ {0}{1}. Continuer ?", sec, unit); string sCaption = "Valider la comparaison"; MessageBoxButton btnMessageBox = MessageBoxButton.YesNoCancel; MessageBoxImage icnMessageBox = MessageBoxImage.Warning; MessageBoxResult rsltMessageBox = MessageBox.Show(sMessageBoxText, sCaption, btnMessageBox, icnMessageBox); switch (rsltMessageBox) { case MessageBoxResult.Yes: results = FHXComparator.CompareObjects(a, b); this.gridResults.ItemsSource = results.Results; this.gridResults.Columns[1].Visibility = Visibility.Hidden; break; case MessageBoxResult.No: return; case MessageBoxResult.Cancel: return; } }