public override void Unload() { if (m_window != null) { for (int i = 0; i < DrawArgs.RootWidget.ChildWidgets.Count; i++) { if (DrawArgs.RootWidget.ChildWidgets[i].Name == m_window.Name) { DrawArgs.RootWidget.ChildWidgets.RemoveAt(i); m_window = null; break; } } } if (m_toolbarItem != null) { ParentApplication.WorldWindow.MenuBar.RemoveToolsMenuButton(m_toolbarItem); m_toolbarItem.Dispose(); m_toolbarItem = null; } base.Unload(); }
public override void Load() { try { m_window = new WorldWind.NewWidgets.FormWidget("Time Control"); m_window.Name = "Time Control"; m_window.ClientSize = new System.Drawing.Size(300, 183); // Bug in FormWidget required anchor to be set before Location and parent widget m_window.Anchor = WorldWind.NewWidgets.WidgetEnums.AnchorStyles.Left | WorldWind.NewWidgets.WidgetEnums.AnchorStyles.Bottom; m_window.ParentWidget = DrawArgs.NewRootWidget; m_window.Location = new System.Drawing.Point(0, DrawArgs.NewRootWidget.ClientSize.Height - 183); m_window.Text = "Double Click to Re-Open"; m_window.BorderEnabled = false; m_window.AutoHideHeader = true; m_window.BackgroundColor = System.Drawing.Color.FromArgb(0, 0, 0, 0); m_window.HeaderEnabled = true; m_window.Visible = false; time = new WorldWind.NewWidgets.PictureBox(); time.Name = "Time"; time.ImageUri = basePath + "\\Data\\Icons\\Time\\time off.png"; time.ClientLocation = new System.Drawing.Point(12, 59); time.ClientSize = new System.Drawing.Size(42, 42); time.Visible = true; time.ParentWidget = m_window; time.OnMouseEnterEvent += new EventHandler(time_OnMouseEnterEvent); time.OnMouseLeaveEvent += new EventHandler(time_OnMouseLeaveEvent); time.OnMouseUpEvent += new MouseEventHandler(time_OnMouseUpEvent); time.CountHeight = false; time.CountWidth = true; m_window.ChildWidgets.Add(time); play = new WorldWind.NewWidgets.PictureBox(); play.Name = "Play"; if (TimeKeeper.Enabled) { play.ImageUri = basePath + "\\Data\\Icons\\Time\\play on.png"; } else { play.ImageUri = basePath + "\\Data\\Icons\\Time\\play off.png"; } play.ClientLocation = new System.Drawing.Point(50, 1); play.ClientSize = new System.Drawing.Size(82, 82); play.Visible = true; play.ParentWidget = m_window; play.OnMouseEnterEvent += new EventHandler(play_OnMouseEnterEvent); play.OnMouseLeaveEvent += new EventHandler(play_OnMouseLeaveEvent); play.OnMouseUpEvent += new System.Windows.Forms.MouseEventHandler(play_OnMouseUpEvent); play.CountHeight = true; play.CountWidth = true; m_window.ChildWidgets.Add(play); close = new WorldWind.NewWidgets.PictureBox(); close.Name = "Close"; close.ImageUri = basePath + "\\Data\\Icons\\Time\\close off.png"; close.ClientLocation = new System.Drawing.Point(29, 3); close.ClientSize = new System.Drawing.Size(22, 22); close.Visible = true; close.ParentWidget = m_window; close.OnMouseEnterEvent += new EventHandler(close_OnMouseEnterEvent); close.OnMouseLeaveEvent += new EventHandler(close_OnMouseLeaveEvent); close.OnMouseUpEvent += new MouseEventHandler(close_OnMouseUpEvent); close.CountHeight = false; close.CountWidth = false; m_window.ChildWidgets.Add(close); rewind = new WorldWind.NewWidgets.PictureBox(); rewind.Name = "Rewind"; rewind.ImageUri = basePath + "\\Data\\Icons\\Time\\repeat off.png"; rewind.ClientLocation = new System.Drawing.Point(16, 26); rewind.ClientSize = new System.Drawing.Size(32, 32); rewind.Visible = true; rewind.ParentWidget = m_window; rewind.OnMouseEnterEvent += new EventHandler(rewind_OnMouseEnterEvent); rewind.OnMouseLeaveEvent += new EventHandler(rewind_OnMouseLeaveEvent); rewind.OnMouseUpEvent += new MouseEventHandler(rewind_OnMouseUpEvent); rewind.CountHeight = false; rewind.CountWidth = false; m_window.ChildWidgets.Add(rewind); pause = new WorldWind.NewWidgets.PictureBox(); pause.Name = "Pause"; if (TimeKeeper.Enabled) { pause.ImageUri = basePath + "\\Data\\Icons\\Time\\pause off.png"; } else { pause.ImageUri = basePath + "\\Data\\Icons\\Time\\pause on.png"; } pause.ClientLocation = new System.Drawing.Point(35, 88); pause.ClientSize = new System.Drawing.Size(64, 64); pause.Visible = true; pause.ParentWidget = m_window; pause.OnMouseEnterEvent += new EventHandler(pause_OnMouseEnterEvent); pause.OnMouseLeaveEvent += new EventHandler(pause_OnMouseLeaveEvent); pause.OnMouseUpEvent += new System.Windows.Forms.MouseEventHandler(pause_OnMouseUpEvent); pause.CountHeight = true; pause.CountWidth = false; m_window.ChildWidgets.Add(pause); slow = new WorldWind.NewWidgets.PictureBox(); slow.Name = "Slow"; slow.ImageUri = basePath + "\\Data\\Icons\\Time\\slow off.png"; slow.ClientLocation = new System.Drawing.Point(97, 88); slow.ClientSize = new System.Drawing.Size(64, 64); slow.Visible = true; slow.ParentWidget = m_window; slow.OnMouseEnterEvent += new EventHandler(slow_OnMouseEnterEvent); slow.OnMouseLeaveEvent += new EventHandler(slow_OnMouseLeaveEvent); slow.OnMouseUpEvent += new System.Windows.Forms.MouseEventHandler(slow_OnMouseUpEvent); slow.CountHeight = false; slow.CountWidth = false; m_window.ChildWidgets.Add(slow); fast = new WorldWind.NewWidgets.PictureBox(); fast.Name = "Fast"; fast.ImageUri = basePath + "\\Data\\Icons\\Time\\fast off.png"; fast.ClientLocation = new System.Drawing.Point(158, 88); fast.ClientSize = new System.Drawing.Size(64, 64); fast.Visible = true; fast.ParentWidget = m_window; fast.OnMouseEnterEvent += new EventHandler(fast_OnMouseEnterEvent); fast.OnMouseLeaveEvent += new EventHandler(fast_OnMouseLeaveEvent); fast.OnMouseUpEvent += new System.Windows.Forms.MouseEventHandler(fast_OnMouseUpEvent); fast.CountHeight = false; fast.CountWidth = false; m_window.ChildWidgets.Add(fast); timeLabel = new WorldWind.NewWidgets.TextLabel(); timeLabel.Name = "Current Time"; timeLabel.ClientLocation = new System.Drawing.Point(134, 65); timeLabel.ClientSize = new System.Drawing.Size(140, 60); timeLabel.Visible = true; timeLabel.ParentWidget = m_window; timeLabel.Text = GetCurrentTimeString(); TimeKeeper.Elapsed += new System.Timers.ElapsedEventHandler(TimeKeeper_Elapsed); timeLabel.CountHeight = false; timeLabel.CountWidth = true; timeLabel.WordBreak = true; m_window.ChildWidgets.Add(timeLabel); DrawArgs.NewRootWidget.ChildWidgets.Add(m_window); m_toolbarItem = new WorldWind.NewWidgets.WidgetMenuButton( "Time Controller", basePath + "\\Data\\Icons\\Time\\time off.png", m_window); ParentApplication.WorldWindow.MenuBar.AddToolsMenuButton(m_toolbarItem); } catch (Exception ex) { Log.Write(ex); } base.Load(); }