private void loadGraphMLToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //GraphMLGraphAdapter test, load
            DialogResult d = cdbOpenGraphML.ShowDialog();
            if (d != DialogResult.Cancel)
            {
                this.Cursor = Cursors.WaitCursor;
                Application.DoEvents();

                try
                {
                    System.IO.StreamReader file = new System.IO.StreamReader(cdbOpenGraphML.FileName);
                    string line = file.ReadToEnd();
                    oGraphMLGraphAdapter = new GraphMLGraphAdapter();
                    
                    layoutControl1.Graph = oGraphMLGraphAdapter.LoadGraphFromString(line); 
                   
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                this.Cursor = Cursors.Default;
                //Application.DoEvents();
            }
        }
Пример #2
0
    TryGetGraphFromGraphDataProvider
    (
        Object graphDataProvider,
        out IGraph graph
    )
    {
        Debug.Assert(graphDataProvider != null);

        Debug.Assert(graphDataProvider is IGraphDataProvider2 ||
            graphDataProvider is IGraphDataProvider);

        graph = null;
        GraphMLGraphAdapter oGraphMLGraphAdapter = new GraphMLGraphAdapter();

        if (graphDataProvider is IGraphDataProvider2)
        {
            String sPathToTemporaryFile = null;

            if ( !( (IGraphDataProvider2)graphDataProvider )
                .TryGetGraphDataAsTemporaryFile(out sPathToTemporaryFile) )
            {
                return (false);
            }

            try
            {
                graph = oGraphMLGraphAdapter.LoadGraphFromFile(
                    sPathToTemporaryFile);
            }
            finally
            {
                File.Delete(sPathToTemporaryFile);
            }
        }
        else
        {
            String sGraphDataAsGraphML;

            if ( !( (IGraphDataProvider)graphDataProvider ).TryGetGraphData(
                out sGraphDataAsGraphML) )
            {
                return (false);
            }

            graph = oGraphMLGraphAdapter.LoadGraphFromString(
                sGraphDataAsGraphML);
        }

        return (true);
    }
        private void youTuBeVideoCrawlerToolStripMenuItem_Click(object sender, EventArgs e)
        {
            File.Delete(TempXmlFileName);

            GetGraphData(new YouTubeVideoNetworkGraphDataProvider());
            if (File.Exists(TempXmlFileName))
            {
                System.IO.StreamReader file = new System.IO.StreamReader(TempXmlFileName);
                string line = file.ReadToEnd();
                file.Close();
                GraphMLGraphAdapter oGraphMLGraphAdapter = new GraphMLGraphAdapter();
                layoutControl1.SetAndShowGraph(oGraphMLGraphAdapter.LoadGraphFromString(line));
            }
            else
            {
                MessageBox.Show("Error: 請重新選取youTuBe Video!" , "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                m_oGraph = new Graph();
                layoutControl1.SetAndShowGraph(m_oGraph);
            }
        }
 private void youtubeCrawlerToolStripMenuItem_Click(object sender, EventArgs e)
 {
     GetGraphData(new YouTubeUserNetworkGraphDataProvider());
     System.IO.StreamReader file = new System.IO.StreamReader(TempXmlFileName);
     string line = file.ReadToEnd();
     GraphMLGraphAdapter oGraphMLGraphAdapter = new GraphMLGraphAdapter();
     layoutControl1.Graph = oGraphMLGraphAdapter.LoadGraphFromString(line); 
 }