private static CECTray _instance;
public static CECTray Instance
{
- get { return _instance ?? (_instance = new CECTray()); }
+ get
+ {
+ if (_instance == null)
+ {
+ _instance = new CECTray();
+ _instance.Initialise();
+ }
+ return _instance;
+ }
}
[STAThread]
/// </summary>
class ApplicationController
{
- public ApplicationController(CECSettings settings, string uiName, string processName, string filename, string workingDirectory)
+ public ApplicationController(CECController controller, string uiName, string processName, string filename, string workingDirectory)
{
- Settings = settings;
+ Controller = controller;
UiName = uiName;
ProcessName = processName;
ApplicationFilename = filename;
IsInternal = false;
}
- public static ApplicationController FromString(CECSettings settings, string serialisedConfig)
+ public static ApplicationController FromString(CECController controller, CECSettings settings, string serialisedConfig)
{
var splitString = serialisedConfig.Split(';');
if (splitString.Length != 4)
throw new InvalidDataException("incorrect number of parameters");
- return new ApplicationController(settings, splitString[0], splitString[1], splitString[2], splitString[3]);
+ return new ApplicationController(controller, splitString[0], splitString[1], splitString[2], splitString[3]);
}
public string AsString()
get { return _buttonConfig ?? (_buttonConfig = new CecButtonConfig(this)); }
}
- public CECSettings Settings;
+ public CECSettings Settings
+ {
+ get { return Controller.Settings; }
+ }
protected DataGridView CecButtonGridView;
public virtual ApplicationAction DefaultValue(CecKeypress key)
private bool _applicationRunning;
+ protected readonly CECController Controller;
+
#endregion
}
}
{
if (item.Length > 0)
{
- var app = ApplicationController.FromString(_controller.Settings, item);
+ var app = ApplicationController.FromString(_controller, _controller.Settings, item);
if (app != null)
_controllers.Add(app.ProcessName, app);
}
get
{
var defaultValues = new Dictionary<string, ApplicationController>();
- WMCController wmcController = new WMCController(_controller.Settings);
+ WMCController wmcController = new WMCController(_controller);
defaultValues.Add(wmcController.ProcessName, wmcController);
- XBMCController xbmcController = new XBMCController(_controller.Settings);
+ XBMCController xbmcController = new XBMCController(_controller);
defaultValues.Add(xbmcController.ProcessName, xbmcController);
return defaultValues;
}
else if (_cecController != null)
{
- ApplicationController newController = new ApplicationController(_settings, tbUiName.Text, tbProcessName.Text, tbFilename.Text, tbWorkingDir.Text);
+ ApplicationController newController = new ApplicationController(_cecController, tbUiName.Text, tbProcessName.Text, tbFilename.Text, tbWorkingDir.Text);
if (_cecController.RegisterApplication(newController))
newController.Settings.Persist();
}
Dispose();
}
- private ApplicationController _controller;
- private CECController _cecController;
- private CECSettings _settings;
+ private readonly ApplicationController _controller;
+ private readonly CECController _cecController;
+ private readonly CECSettings _settings;
}
}
{
internal class WMCController : ApplicationController
{
- public WMCController(CECSettings settings) :
- base(settings,
+ public WMCController(CECController controller) :
+ base(controller,
Resources.application_windows_media_center,
"ehshell",
"ehshell.exe",
{
internal class XBMCController : ApplicationController
{
- public XBMCController(CECSettings settings) :
- base(settings,
+ public XBMCController(CECController controller) :
+ base(controller,
Resources.application_xbmc,
"XBMC",
"XBMC.exe",
this.MaximizeBox = false;
this.Name = "CECTray";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Load += new System.EventHandler(this.CECTrayLoad);
this.Resize += new System.EventHandler(this.CECTrayResize);
this.trayIconMenu.ResumeLayout(false);
this.LogOutput.ResumeLayout(false);
set { base.Text = value; }
}
- private void CECTrayLoad(object sender, EventArgs e)
+ public void Initialise()
{
Controller.Initialise();
}
private CECController _controller;
public CECController Controller
{
- get { return _controller ?? (_controller = new CECController(this)); }
+ get
+ {
+ return _controller ?? (_controller = new CECController(this));
+ }
}
public Control.ControlCollection TabControls
{