Esempio n. 1
0
 private void treeView1_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (IsCtrlPressed)
     {
         // set the last tree view item selected variable which may be used elsewhere as there is no other way I have found to obtain the TreeViewItem container (may be null)
         // TreeViewItem item = (TreeViewItem)(treeView1.ItemContainerGenerator.ContainerFromIndex(treeView1.Items.CurrentPosition));
         GraphViewModel SelectedGvm = (GraphViewModel)this.treeView1.SelectedItem;
         SelectedGvm.IsSelected = false;
         //this.treeView1.Focus();
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Inits the treeview by calling MetaEdit+ and constructing the Graph tree.
        /// </summary>
        public void initializeTreeView()
        {
            GraphViewModel root = new GraphViewModel();

            root.IsNodeExpanded = true;
            Graph.ResetCaches();
            Graph[] gs = GraphHandler.Init();
            root.populate(gs, new List <Graph>());
            treeView1.ItemsSource = root.getChildren();
            treeView1.ContextMenu = this.Is50OrLater() ?
                                    treeView1.Resources["50Menu"] as System.Windows.Controls.ContextMenu:
                                    treeView1.Resources["45Menu"] as System.Windows.Controls.ContextMenu;
            bool _api = this.IsAPI();

            this.SetToolBarButtonsEnabled(_api);
            this.setView(_api);
        }
Esempio n. 3
0
 /// <summary>
 /// Run "Generate" action for the selected graph. Shows window containen all the possible generators.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonGenerate_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         GraphViewModel gvm = (GraphViewModel)treeView1.SelectedItem;
         if (gvm == null)
         {
             return;
         }
         Settings s = Settings.GetSettings();
         if (s.Version.IsEqualOrGreaterThan("5.0"))
         {
             string[]      _generators   = Launcher.Port.generatorNames(gvm.getGraph().GetMEType()).Split(new Char[] { '\r' });
             List <string> generatorList = new List <string>();
             foreach (string _generator in _generators)
             {
                 if (!_generator.StartsWith("_") && !_generator.StartsWith("!"))
                 {
                     generatorList.Add(_generator);
                 }
             }
             SelectionWindow sw = new SelectionWindow(generatorList, "Select the generator to run", false, false);
             sw.Height = 300;
             sw.WindowStartupLocation = WindowStartupLocation.CenterScreen;
             sw.ShowDialog();
             string generator = "";
             if (sw.SelectedItems.Count > 0)
             {
                 generator = sw.SelectedItems[0];
                 if (generator.Length > 0)
                 {
                     gvm.getGraph().ExecuteGenerator(generator);
                 }
             }
         }
         else
         {
             gvm.getGraph().ExecuteGenerator("Autobuild");
         }
     }
     catch (Exception err)
     {
         DialogProvider.ShowMessageDialog("API error: " + err.Message, "API error");
         this.correctErrorSituation();
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Action for the "Run Autobuild" button. Runs Autobuild for the selected graph.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ButtonRunAutobuild_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         GraphViewModel gvm = (GraphViewModel)treeView1.SelectedItem;
         if (gvm == null)
         {
             return;
         }
         gvm.getGraph().ExecuteGenerator("Autobuild");
     }
     catch (Exception err)
     {
         DialogProvider.ShowMessageDialog("API error: " + err.Message, "API error");
         this.correctErrorSituation();
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Open MetaEdit dialog in new thread
        /// </summary>
        /// <param name="DialogType"></param>
        private void StartMEDialog(int DialogType)
        {
            GraphViewModel gvm    = null;
            MEDialog       dialog = null;

            if (treeView1.SelectedItem != null)
            {
                gvm    = (GraphViewModel)treeView1.SelectedItem;
                dialog = new MEDialog(DialogType, gvm.getGraph());
            }
            else
            {
                dialog = new MEDialog(DialogType, null);
            }
            Thread _thread = new Thread(new ThreadStart(dialog.Run));

            _thread.Start();
        }
 public void populate(Graph[] graphs, List <Graph> stack)
 {
     if (!stack.Contains(this.getGraph()))
     {
         stack.Add(this.getGraph());
         foreach (Graph g in graphs)
         {
             GraphViewModel gvm = new GraphViewModel(g);
             this.addChild(gvm);
             Graph[] children = g.GetChildren();
             if (children != null && children.Count() > 0)
             {
                 Array.Sort(children);
                 gvm.populate(children, stack);
             }
         }
         stack.RemoveAt(stack.Count() - 1);
     }
 }
Esempio n. 7
0
 private void ButtonOpen_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (treeView1.SelectedItem == null)
         {
             return;
         }
         GraphViewModel          gvm  = (GraphViewModel)treeView1.SelectedItem;
         MetaEditAPI.MetaEditAPI port = Launcher.Port;
         MEAPI.AllowSetForegroundWindow();
         port.open(gvm.getGraph().ToMEOop());
     }
     catch (Exception err)
     {
         DialogProvider.ShowMessageDialog("API error: " + err.Message, "API error");
         this.correctErrorSituation();
     }
 }
 public void removeChild(GraphViewModel child)
 {
     _children.Remove(child);
     child.setParent(null);
 }
 public void addChild(GraphViewModel child)
 {
     _children.Add(child);
     child.setParent(this);
 }
 public void setParent(GraphViewModel parent)
 {
     this.parent = parent;
 }