/// <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(); }
/// <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(); }
/// <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); }
/// <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)); }