Esempio n. 1
0
        /// <summary>
        /// Event fired when the graph selection is changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_SelectionChangedEvt(vtkObject sender, vtkObjectEventArgs e)
        {
            //Get the selection
            vtkDataRepresentation dr   = view.GetRepresentation(0);
            vtkAnnotationLink     al   = dr.GetAnnotationLink();
            vtkSelection          sel  = al.GetCurrentSelection();
            vtkAbstractArray      arr  = null;
            vtkSelectionNode      node = sel.GetNode(0);

            if (null != node)
            {
                arr = node.GetSelectionList();
            }

            vtkIdTypeArray arr1 = (vtkIdTypeArray)arr;

            // Short circuit if nothing is selected...
            int numSelected = (int)arr1.GetNumberOfTuples();

            if (0 == numSelected)
            {
                return;
            }

            vtkStringArray arr2 = ((vtkStringArray)g.GetVertexData().GetAbstractArray("label"));

            //get a pseudo random name if more than one are selected
            string name = arr2.GetValue(
                (int)arr1.GetValue(System.DateTime.Now.Millisecond % numSelected));

            //reset the small arrayList
            arrListSmall = new System.Collections.ArrayList();
            int hops;

            try
            {
                hops = System.Convert.ToInt32(toolStripTextBox3.Text);
            }
            catch (Exception)
            {
                hops = 1;
            }

            toolStripTextBox1.Text = name;
            toolStripTextBox1.Invalidate();
            this.Update();

            //Start the loading graphic and add another renderer on top for the spinning logo
            vtkRenderWindow win = this.renderWindowControl1.RenderWindow;

            win.AddRenderer(logoRenderer);
            win.Render();
            this.webBrowser1.Url = new Uri("http://en.wikipedia.org/wiki/" + name.Replace(" ", "_"));
            //Start the work
            addLinks(g, name, hops);
            //Remove the spinning logo after the work is done
            win.RemoveRenderer(logoRenderer);
            win.Render();
        }
Esempio n. 2
0
        /// <summary>
        /// Open the explorer window of the selected file
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void view_SelectionChangedEvt(vtkObject sender, vtkObjectEventArgs e)
        {
            // Get the selection
            //
            vtkDataRepresentation dr   = view.GetRepresentation(0);
            vtkAnnotationLink     al   = dr.GetAnnotationLink();
            vtkSelection          sel  = al.GetCurrentSelection();
            vtkStringArray        arr1 = null;
            vtkSelectionNode      node = sel.GetNode(0);

            if (null != node)
            {
                arr1 = (vtkStringArray)node.GetSelectionList();
            }

            string path = "";

            if (null != arr1)
            {
                // If it is a directory open it, if not cut off the end
                // and open the directory
                //
                if (Directory.Exists(arr1.GetValue(0)))
                {
                    path = arr1.GetValue(0);
                }
                else
                {
                    path = Regex.Replace(arr1.GetValue(0),
                                         "\\\\[^\\\\]+\\.[^\\\\]*$", "");
                }
            }

            if (path != SelectedPath)
            {
                SelectedPath = path;

                System.Diagnostics.Debug.WriteLine(SelectedPath);

                if ("" != SelectedPath)
                {
                    //Create the process
                    System.Diagnostics.ProcessStartInfo psi =
                        new System.Diagnostics.ProcessStartInfo("cmd.exe",
                                                                "/C explorer " + SelectedPath);
                    psi.CreateNoWindow  = true;
                    psi.UseShellExecute = false;
                    System.Diagnostics.Process p =
                        System.Diagnostics.Process.Start(psi);
                }
            }
        }