示例#1
0
        /// <summary>
        /// Creates a new instance of a Networkvisualizer which renders the specified network in real-time
        /// </summary>
        /// <param name='n'>
        /// N.
        /// </param>
        /// <param name='layout'>
        /// Layout.
        /// </param>
        public static void Start(Network network, ILayoutProvider layout, NetworkColorizer colorizer = null, int width=800, int height=600)
        {
            // The actual rendering needs to be done in a separate thread placed in the single thread appartment state
            _mainThread = new Thread(new ThreadStart(new Action(delegate() {
                    NetworkVisualizer p =  new NetworkVisualizer(network, layout, colorizer, width, height);
                    p.Run(80f);
            })));

            _mainThread.SetApartmentState(ApartmentState.STA);
            _mainThread.Name = "STA Thread for NETGen Visualizer";

            // Fire up the thread
            _mainThread.Start();
        }
示例#2
0
        /// <summary>
        /// Creates a new instance of a Networkvisualizer which renders the specified network in real-time
        /// </summary>
        /// <param name='n'>
        /// N.
        /// </param>
        /// <param name='layout'>
        /// Layout.
        /// </param>
        public static void Start(Network network, LayoutProvider layout, NetworkColorizer colorizer = null, int width = 800, int height = 600)
        {
            // The actual rendering needs to be done in a separate thread placed in the single thread appartment state
            _mainThread = new Thread(new ThreadStart(new Action(delegate() {
                Instance = new NetworkVisualizer(network, layout, colorizer, width, height);
                _initialized.Set();
                Instance.Run(80f);
            })));

            _mainThread.SetApartmentState(ApartmentState.STA);
            _mainThread.Name = "STA Thread for NETGen Visualizer";

            // Fire up the thread
            _mainThread.Start();
            _initialized.WaitOne();
        }
示例#3
0
        /// <summary>
        /// Private constructor, instances are created by the static function CreateDisplay()
        /// </summary>
        private NetworkDisplay(NetworkVisualizer visualizer, int fps, LayoutOptions options)
        {
            if(options !=null)
                LayoutOptions = options;
            else
                LayoutOptions = new LayoutOptions();

            NetworkVisualizer = visualizer;

            NetworkDisplay.DisplayCounter++;

            // start event queue in new main thread
            _mainThread = new Thread(new ThreadStart(new Action(delegate() {
                InitializeComponent();
                visualizer.SetGraphics(drawPanel.CreateGraphics(), drawPanel.DisplayRectangle);

                this.Text = visualizer.Network.Name;

                drawPanel.Paint += new PaintEventHandler(drawPanel_Paint);
                drawPanel.MouseDown += new MouseEventHandler(drawPanel_MouseDown);
                drawPanel.MouseUp += new MouseEventHandler(drawPanel_MouseUp);
                drawPanel.MouseMove += new MouseEventHandler(drawPanel_MouseMove);
                drawPanel.MouseClick += new MouseEventHandler(drawPanel_MouseClick);

                this.MouseWheel += new MouseEventHandler(drawPanel_MouseWheel);

                // Add the layout options to the menu
                LayoutOptions.ItemAdded += new GUI.LayoutOptions.ItemAddedDelegate(LayoutOptions_ItemAdded);
                foreach (string name in LayoutOptions.LayoutNames)
                {
                    ToolStripItem i = layoutToolStripMenuItem.DropDownItems.Add(name);
                    i.Click += new EventHandler(i_Click);
                }

                System.Threading.Timer t = new System.Threading.Timer(timerCallbackFunction, null, 50, 1000 / fps);

                Application.Run(this);
            })));

            // Set the main thread to Single Thread Apartment
            _mainThread.SetApartmentState(ApartmentState.STA);
            _mainThread.Name = "STA Thread for NETGen Display";

            // Startup the thread ...
            _mainThread.Start();
        }
示例#4
0
 /// <summary>
 /// Creates a new Network Display frontend and starts rendering using the specified network visualizer
 /// </summary>
 /// <returns>
 /// The network display instance
 /// </returns>
 /// <param name='visualizer'>
 /// The network visualizer that takes care of layouting and rendering the network
 /// </param>
 /// <param name='fps'>
 /// The number of frames per seconds that will be rendered, default is 25
 /// </param>
 /// <param name='options'>
 /// The layouting options that shall be available from the menu
 /// </param>
 public static NetworkDisplay CreateDisplay(NetworkVisualizer visualizer, int fps = 25, LayoutOptions options = null)
 {
     return new NetworkDisplay(visualizer, fps, options);
 }