mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-05 15:38:29 -04:00
8bebf0c394
Convert to IActivate, IDeactivate scheme, thanks andrew add support for rfcomm* interfaces on linux fix guage off screen draw mono issue. remove use of BackStageViewContentPanel andrews spacer changes - not using dues to screen space issue change configpanel constructor to load xml directly remove IMavlink Interface fix hsi off screen draw issue on mono modify hud to use sprite fonts, instead of drawing via GDI+ modify progress reporter to use a 10hz timer to update screen, using invoke/begininvoke fails on mono at 50hz (over 100ms per call). fix targetalt and target airspeed jumping issue. lots of cleanup on tab switching, ie stoping timers/other 3dr radio status led update update ardurover car icon speedup georef image screen. tested on over 1000 images.
105 lines
2.7 KiB
C#
105 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Drawing;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
using ArdupilotMega.Utilities;
|
|
using ArdupilotMega.Controls.BackstageView;
|
|
|
|
namespace ArdupilotMega.Controls
|
|
{
|
|
public partial class MainSwitcher : UserControl
|
|
{
|
|
List<Screen> screens = new List<Screen>();
|
|
Screen current;
|
|
|
|
public MainSwitcher()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
public void AddScreen(Screen Screen)
|
|
{
|
|
// add to list
|
|
screens.Add(Screen);
|
|
|
|
// hide it
|
|
Screen.Control.Visible = false;
|
|
}
|
|
|
|
public void ShowScreen(string name)
|
|
{
|
|
|
|
if (current != null)
|
|
{
|
|
// hide current screen
|
|
current.Visible = false;
|
|
|
|
// remove reference
|
|
this.Controls.Remove(current.Control);
|
|
|
|
// check if we need to remove the current control
|
|
if (!current.Persistent)
|
|
{
|
|
if (current.Control is IDeactivate)
|
|
{
|
|
((IDeactivate)(current.Control)).Deactivate();
|
|
}
|
|
|
|
// cleanup
|
|
current.Control.Close();
|
|
|
|
current.Control.Dispose();
|
|
|
|
current.Control = (MyUserControl)Activator.CreateInstance(current.Control.GetType());
|
|
}
|
|
}
|
|
|
|
// find next screen
|
|
Screen nextscreen = screens.Single(s => s.Name == name);
|
|
|
|
nextscreen.Control.Location = new Point(0, 0);
|
|
|
|
nextscreen.Control.Dock = DockStyle.Fill;
|
|
|
|
nextscreen.Control.Size = this.Size;
|
|
|
|
nextscreen.Visible = true;
|
|
|
|
if (nextscreen.Control is IActivate)
|
|
{
|
|
((IActivate)(nextscreen.Control)).Activate();
|
|
}
|
|
|
|
this.Controls.Add(nextscreen.Control);
|
|
|
|
ThemeManager.ApplyThemeTo(nextscreen.Control);
|
|
|
|
current = nextscreen;
|
|
}
|
|
|
|
protected override void OnPaintBackground(PaintEventArgs e)
|
|
{
|
|
base.OnPaintBackground(e);
|
|
}
|
|
|
|
public class Screen
|
|
{
|
|
public string Name;
|
|
public MyUserControl Control;
|
|
public bool Visible { get { return Control.Visible; } set { Control.Visible = value; } }
|
|
public bool Persistent;
|
|
|
|
public Screen(string Name, MyUserControl Control, bool Persistent = false)
|
|
{
|
|
this.Name = Name;
|
|
this.Control = Control;
|
|
this.Persistent = Persistent;
|
|
}
|
|
}
|
|
}
|
|
}
|