From: <che...@us...> - 2009-09-10 15:33:52
|
Revision: 3084 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=3084&view=rev Author: chemelli_sf Date: 2009-09-10 15:33:42 +0000 (Thu, 10 Sep 2009) Log Message: ----------- Removed unavailable plugins from plugin configuration grid Modified Paths: -------------- trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Config.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Program.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/Direct Input Receiver/DirectInputReceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/FireDTV Receiver/FireDTVReceiver.cs trunk/plugins/IR Server Suite/IR Server Suite/IR Server Plugins/IR Server Plugin Interface/PluginBase.cs Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Config.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Config.cs 2009-09-10 11:28:34 UTC (rev 3083) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Config.cs 2009-09-10 15:33:42 UTC (rev 3084) @@ -38,542 +38,538 @@ namespace IRServer.Configuration { - internal partial class Config : Form - { - #region Constants + internal partial class Config : Form + { + #region Constants - private const int ColConfigure = 4; - private const int ColIcon = 0; - private const int ColName = 1; - private const int ColReceive = 2; - private const int ColTransmit = 3; + private const int ColConfigure = 4; + private const int ColIcon = 0; + private const int ColName = 1; + private const int ColReceive = 2; + private const int ColTransmit = 3; - #endregion Constants + #endregion Constants - #region Variables + #region Variables - private readonly PluginBase[] _transceivers; + private readonly PluginBase[] _transceivers; - private bool _abstractRemoteMode; - private string _hostComputer = String.Empty; - private IRServerMode _mode = IRServerMode.ServerMode; - private string _processPriority = String.Empty; - private BackgroundWorker monitorThread; + private bool _abstractRemoteMode; + private string _hostComputer = String.Empty; + private IRServerMode _mode = IRServerMode.ServerMode; + private string _processPriority = String.Empty; + private BackgroundWorker monitorThread; - #endregion Variables + #endregion Variables - private void Config_Load(object sender, EventArgs e) - { - monitorThreadStart(); - } + private void Config_Load(object sender, EventArgs e) + { + monitorThreadStart(); + } - private void Config_FormClosing(object sender, FormClosingEventArgs e) - { - monitorThreadStop(); - } - - private void monitorThreadStart() - { - if (monitorThread == null) - monitorThread = new BackgroundWorker(); - monitorThread.WorkerReportsProgress = true; - monitorThread.WorkerSupportsCancellation = true; - monitorThread.ProgressChanged += new ProgressChangedEventHandler(monitorThread_ProgressChanged); - monitorThread.DoWork += new DoWorkEventHandler(monitorThread_DoWork); - monitorThread.RunWorkerAsync(); - } + private void Config_FormClosing(object sender, FormClosingEventArgs e) + { + monitorThreadStop(); + } - private void monitorThreadStop() - { - monitorThread.CancelAsync(); - } + private void monitorThreadStart() + { + if (monitorThread == null) + monitorThread = new BackgroundWorker(); + monitorThread.WorkerReportsProgress = true; + monitorThread.WorkerSupportsCancellation = true; + monitorThread.ProgressChanged += new ProgressChangedEventHandler(monitorThread_ProgressChanged); + monitorThread.DoWork += new DoWorkEventHandler(monitorThread_DoWork); + monitorThread.RunWorkerAsync(); + } - private void monitorThread_DoWork(object sender, EventArgs e) - { - do - { - Program.getStatus(); - monitorThread.ReportProgress(0); - Thread.Sleep(1000); - } - while (!monitorThread.CancellationPending); - } + private void monitorThreadStop() + { + monitorThread.CancelAsync(); + } - private void monitorThread_ProgressChanged(object sender, EventArgs e) - { - setButtons(); - } + private void monitorThread_DoWork(object sender, EventArgs e) + { + do + { + Program.getStatus(); + monitorThread.ReportProgress(0); + Thread.Sleep(1000); + } + while (!monitorThread.CancellationPending); + } - private void setButtons() - { - if (Program._serviceInstalled == true) - { - toolStripServiceButton.Text = "Uninstall Service"; - } - else - { - toolStripServiceButton.Text = "Install Service"; - } - switch (Program._irsStatus) - { - case IrsStatus.NotRunning: - { - toolStripButtonApplication.Image = Resources.Start; - toolStripButtonApplication.Enabled = true; - toolStripButtonService.Image = Resources.Start; - toolStripButtonService.Enabled = Program._serviceInstalled; - break; - } - case IrsStatus.RunningApplication: - { - toolStripButtonApplication.Image = Resources.Stop; - toolStripButtonApplication.Enabled = true; - toolStripButtonService.Image = Resources.Start; - toolStripButtonService.Enabled = false; - break; - } - case IrsStatus.RunningService: - { - toolStripButtonApplication.Image = Resources.Start; - toolStripButtonApplication.Enabled = false; - toolStripButtonService.Image = Resources.Stop; - toolStripButtonService.Enabled = true; - break; - } - } - } + private void monitorThread_ProgressChanged(object sender, EventArgs e) + { + setButtons(); + } - private void CreateGrid() - { - IrssLog.Info("Creating configuration grid ..."); + private void setButtons() + { + if (Program._serviceInstalled == true) + { + toolStripServiceButton.Text = "Uninstall Service"; + } + else + { + toolStripServiceButton.Text = "Install Service"; + } + switch (Program._irsStatus) + { + case IrsStatus.NotRunning: + { + toolStripButtonApplication.Image = Resources.Start; + toolStripButtonApplication.Enabled = true; + toolStripButtonService.Image = Resources.Start; + toolStripButtonService.Enabled = Program._serviceInstalled; + break; + } + case IrsStatus.RunningApplication: + { + toolStripButtonApplication.Image = Resources.Stop; + toolStripButtonApplication.Enabled = true; + toolStripButtonService.Image = Resources.Start; + toolStripButtonService.Enabled = false; + break; + } + case IrsStatus.RunningService: + { + toolStripButtonApplication.Image = Resources.Start; + toolStripButtonApplication.Enabled = false; + toolStripButtonService.Image = Resources.Stop; + toolStripButtonService.Enabled = true; + break; + } + } + } - try - { - int row = 0; + private void CreateGrid() + { + IrssLog.Info("Creating configuration grid ..."); - gridPlugins.Rows.Clear(); - gridPlugins.Columns.SetCount(5); + try + { + int row = 0; - // Setup Column Headers - gridPlugins.Rows.Insert(row); + gridPlugins.Rows.Clear(); + gridPlugins.Columns.SetCount(5); - ColumnHeader header = new ColumnHeader(" "); - header.AutomaticSortEnabled = false; - gridPlugins[row, ColIcon] = header; + // Setup Column Headers + gridPlugins.Rows.Insert(row); - gridPlugins[row, ColName] = new ColumnHeader("Name"); - gridPlugins[row, ColReceive] = new ColumnHeader("Receive"); - gridPlugins[row, ColTransmit] = new ColumnHeader("Transmit"); - gridPlugins[row, ColConfigure] = new ColumnHeader("Configure"); - gridPlugins.FixedRows = 1; + ColumnHeader header = new ColumnHeader(" "); + header.AutomaticSortEnabled = false; + gridPlugins[row, ColIcon] = header; - foreach (PluginBase transceiver in _transceivers) - { - gridPlugins.Rows.Insert(++row); - gridPlugins.Rows[row].Tag = transceiver; + gridPlugins[row, ColName] = new ColumnHeader("Name"); + gridPlugins[row, ColReceive] = new ColumnHeader("Receive"); + gridPlugins[row, ColTransmit] = new ColumnHeader("Transmit"); + gridPlugins[row, ColConfigure] = new ColumnHeader("Configure"); + gridPlugins.FixedRows = 1; - // Icon Cell - if (transceiver.DeviceIcon != null) - { - Image iconCell = new Image(transceiver.DeviceIcon); - iconCell.Editor.EnableEdit = false; + foreach (PluginBase transceiver in _transceivers) + { + gridPlugins.Rows.Insert(++row); + gridPlugins.Rows[row].Tag = transceiver; - gridPlugins[row, ColIcon] = iconCell; - } - else - { - gridPlugins[row, ColIcon] = new Cell(); - } + // Icon Cell + if (transceiver.DeviceIcon != null) + { + Image iconCell = new Image(transceiver.DeviceIcon); + iconCell.Editor.EnableEdit = false; - // Name Cell - Cell nameCell = new Cell(transceiver.Name); + gridPlugins[row, ColIcon] = iconCell; + } + else + { + gridPlugins[row, ColIcon] = new Cell(); + } - CustomEvents nameCellController = new CustomEvents(); - nameCellController.DoubleClick += PluginDoubleClick; - nameCell.AddController(nameCellController); + // Name Cell + Cell nameCell = new Cell(transceiver.Name); - nameCell.AddController(new ToolTipText()); - nameCell.ToolTipText = String.Format("{0}\nVersion: {1}\nAuthor: {2}\n{3}", transceiver.Name, - transceiver.Version, transceiver.Author, transceiver.Description); + CustomEvents nameCellController = new CustomEvents(); + nameCellController.DoubleClick += PluginDoubleClick; + nameCell.AddController(nameCellController); - gridPlugins[row, ColName] = nameCell; + nameCell.AddController(new ToolTipText()); + nameCell.ToolTipText = String.Format("{0}\nVersion: {1}\nAuthor: {2}\n{3}", transceiver.Name, + transceiver.Version, transceiver.Author, transceiver.Description); - // Receive Cell - if (transceiver is IRemoteReceiver || transceiver is IMouseReceiver || transceiver is IKeyboardReceiver) - { - gridPlugins[row, ColReceive] = new CheckBox(); - } - else - { - gridPlugins[row, ColReceive] = new Cell(); - } + gridPlugins[row, ColName] = nameCell; - // Transmit Cell - if (transceiver is ITransmitIR) - { - CheckBox checkbox = new CheckBox(); + // Receive Cell + if (transceiver is IRemoteReceiver || transceiver is IMouseReceiver || transceiver is IKeyboardReceiver) + { + gridPlugins[row, ColReceive] = new CheckBox(); + } + else + { + gridPlugins[row, ColReceive] = new Cell(); + } - CustomEvents checkboxcontroller = new CustomEvents(); - checkboxcontroller.ValueChanged += TransmitChanged; - checkbox.Controller.AddController(checkboxcontroller); + // Transmit Cell + if (transceiver is ITransmitIR) + { + CheckBox checkbox = new CheckBox(); - gridPlugins[row, ColTransmit] = checkbox; - } - else - { - gridPlugins[row, ColTransmit] = new Cell(); - } + CustomEvents checkboxcontroller = new CustomEvents(); + checkboxcontroller.ValueChanged += TransmitChanged; + checkbox.Controller.AddController(checkboxcontroller); - // Configure Cell - if (transceiver is IConfigure) - { - Button button = new Button("Configure"); + gridPlugins[row, ColTransmit] = checkbox; + } + else + { + gridPlugins[row, ColTransmit] = new Cell(); + } - SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); - buttonClickEvent.Executed += buttonClickEvent_Executed; - button.Controller.AddController(buttonClickEvent); + // Configure Cell + if (transceiver is IConfigure) + { + Button button = new Button("Configure"); - gridPlugins[row, ColConfigure] = button; - } - else - { - gridPlugins[row, ColConfigure] = new Cell(); - } - } + SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); + buttonClickEvent.Executed += buttonClickEvent_Executed; + button.Controller.AddController(buttonClickEvent); - gridPlugins.Columns[ColIcon].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; - gridPlugins.Columns[ColName].AutoSizeMode = SourceGrid.AutoSizeMode.Default; - gridPlugins.Columns[ColReceive].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; - gridPlugins.Columns[ColTransmit].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; - gridPlugins.Columns[ColConfigure].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; - gridPlugins.AutoStretchColumnsToFitWidth = true; - gridPlugins.AutoSizeCells(); - } - catch (Exception ex) - { - IrssLog.Error(ex); - MessageBox.Show(this, ex.ToString(), "Error setting up plugin grid", MessageBoxButtons.OK, MessageBoxIcon.Error); - } + gridPlugins[row, ColConfigure] = button; + } + else + { + gridPlugins[row, ColConfigure] = new Cell(); + } } - private void Detect() - { - IrssLog.Info("Attempting to detect Input Plugins ..."); + gridPlugins.Columns[ColIcon].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; + gridPlugins.Columns[ColName].AutoSizeMode = SourceGrid.AutoSizeMode.Default; + gridPlugins.Columns[ColReceive].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; + gridPlugins.Columns[ColTransmit].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; + gridPlugins.Columns[ColConfigure].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; + gridPlugins.AutoStretchColumnsToFitWidth = true; + gridPlugins.AutoSizeCells(); + } + catch (Exception ex) + { + IrssLog.Error(ex); + MessageBox.Show(this, ex.ToString(), "Error setting up plugin grid", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } - CheckBox checkBox; - for (int row = 1; row < gridPlugins.RowsCount; row++) - { - PluginBase plugin = gridPlugins.Rows[row].Tag as PluginBase; + private void Detect() + { + IrssLog.Info("Attempting to detect Input Plugins ..."); - try - { - if (plugin == null) - throw new InvalidOperationException(String.Format("Invalid grid data, row {0} contains no plugin in tag", - row)); + CheckBox checkBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + PluginBase plugin = gridPlugins.Rows[row].Tag as PluginBase; - PluginBase.DetectionResult detected = plugin.Detect(); + try + { + if (plugin == null) + throw new InvalidOperationException(String.Format("Invalid grid data, row {0} contains no plugin in tag", + row)); - if (detected == PluginBase.DetectionResult.DevicePresent) - { - IrssLog.Info("Plugin {0}: detected", plugin.Name); - } - if (detected == PluginBase.DetectionResult.DeviceException) - { - IrssLog.Warn("Plugin {0}: exception during Detect()", plugin.Name); - } + PluginBase.DetectionResult detected = plugin.Detect(); - // Receive - checkBox = gridPlugins[row, ColReceive] as CheckBox; - if (checkBox != null) - checkBox.Checked = (detected == PluginBase.DetectionResult.DevicePresent ? true : false); + if (detected == PluginBase.DetectionResult.DevicePresent) + { + IrssLog.Info("Plugin {0}: detected", plugin.Name); + } + if (detected == PluginBase.DetectionResult.DeviceException) + { + IrssLog.Warn("Plugin {0}: exception during Detect()", plugin.Name); + } - // Transmit - checkBox = gridPlugins[row, ColTransmit] as CheckBox; - if (checkBox != null) - checkBox.Checked = (detected == PluginBase.DetectionResult.DevicePresent ? true : false); - } - catch (BadImageFormatException) - { - IrssLog.Warn("Plugin {0}: not available on current OS architecture ({1})", plugin.Name, IntPtr.Size == 8 ? "x64" : "x86"); - } - catch (Exception ex) - { - IrssLog.Error(ex); - } - } + // Receive + checkBox = gridPlugins[row, ColReceive] as CheckBox; + if (checkBox != null) + checkBox.Checked = (detected == PluginBase.DetectionResult.DevicePresent ? true : false); - IrssLog.Info("Input Plugins detection completed..."); + // Transmit + checkBox = gridPlugins[row, ColTransmit] as CheckBox; + if (checkBox != null) + checkBox.Checked = (detected == PluginBase.DetectionResult.DevicePresent ? true : false); } - - private void Advanced() + catch (Exception ex) { - IrssLog.Info("Entering advanced configuration ..."); + IrssLog.Error(ex); + } + } - Advanced advanced = new Advanced(); + IrssLog.Info("Input Plugins detection completed..."); + } - advanced.AbstractRemoteMode = _abstractRemoteMode; - advanced.Mode = _mode; - advanced.HostComputer = _hostComputer; - advanced.ProcessPriority = _processPriority; + private void Advanced() + { + IrssLog.Info("Entering advanced configuration ..."); - if (advanced.ShowDialog(this) == DialogResult.OK) - { - _abstractRemoteMode = advanced.AbstractRemoteMode; - _mode = advanced.Mode; - _hostComputer = advanced.HostComputer; - _processPriority = advanced.ProcessPriority; - } - } + Advanced advanced = new Advanced(); - #region Properties + advanced.AbstractRemoteMode = _abstractRemoteMode; + advanced.Mode = _mode; + advanced.HostComputer = _hostComputer; + advanced.ProcessPriority = _processPriority; - public bool AbstractRemoteMode - { - get { return _abstractRemoteMode; } - set { _abstractRemoteMode = value; } - } + if (advanced.ShowDialog(this) == DialogResult.OK) + { + _abstractRemoteMode = advanced.AbstractRemoteMode; + _mode = advanced.Mode; + _hostComputer = advanced.HostComputer; + _processPriority = advanced.ProcessPriority; + } + } - public IRServerMode Mode - { - get { return _mode; } - set { _mode = value; } - } + #region Properties - public string HostComputer - { - get { return _hostComputer; } - set { _hostComputer = value; } - } + public bool AbstractRemoteMode + { + get { return _abstractRemoteMode; } + set { _abstractRemoteMode = value; } + } - public string ProcessPriority - { - get { return _processPriority; } - set { _processPriority = value; } - } + public IRServerMode Mode + { + get { return _mode; } + set { _mode = value; } + } - public string[] PluginReceive - { - get - { - List<string> receivers = new List<string>(); + public string HostComputer + { + get { return _hostComputer; } + set { _hostComputer = value; } + } - CheckBox checkBox; - for (int row = 1; row < gridPlugins.RowsCount; row++) - { - checkBox = gridPlugins[row, ColReceive] as CheckBox; - if (checkBox != null && checkBox.Checked == true) - receivers.Add(gridPlugins[row, ColName].DisplayText); - } + public string ProcessPriority + { + get { return _processPriority; } + set { _processPriority = value; } + } - if (receivers.Count == 0) - return null; + public string[] PluginReceive + { + get + { + List<string> receivers = new List<string>(); - return receivers.ToArray(); - } - set - { - CheckBox checkBox; - for (int row = 1; row < gridPlugins.RowsCount; row++) - { - checkBox = gridPlugins[row, ColReceive] as CheckBox; - if (checkBox == null) - continue; + CheckBox checkBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + checkBox = gridPlugins[row, ColReceive] as CheckBox; + if (checkBox != null && checkBox.Checked == true) + receivers.Add(gridPlugins[row, ColName].DisplayText); + } - if (value == null) - checkBox.Checked = false; - else if (Array.IndexOf(value, gridPlugins[row, ColName].DisplayText) != -1) - checkBox.Checked = true; - else - checkBox.Checked = false; - } - } + if (receivers.Count == 0) + return null; + + return receivers.ToArray(); + } + set + { + CheckBox checkBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + checkBox = gridPlugins[row, ColReceive] as CheckBox; + if (checkBox == null) + continue; + + if (value == null) + checkBox.Checked = false; + else if (Array.IndexOf(value, gridPlugins[row, ColName].DisplayText) != -1) + checkBox.Checked = true; + else + checkBox.Checked = false; } + } + } - public string PluginTransmit + public string PluginTransmit + { + get + { + CheckBox checkBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) { - get - { - CheckBox checkBox; - for (int row = 1; row < gridPlugins.RowsCount; row++) - { - checkBox = gridPlugins[row, ColTransmit] as CheckBox; - if (checkBox != null && checkBox.Checked == true) - return gridPlugins[row, ColName].DisplayText; - } + checkBox = gridPlugins[row, ColTransmit] as CheckBox; + if (checkBox != null && checkBox.Checked == true) + return gridPlugins[row, ColName].DisplayText; + } - return String.Empty; - } - set - { - if (String.IsNullOrEmpty(value)) - return; + return String.Empty; + } + set + { + if (String.IsNullOrEmpty(value)) + return; - CheckBox checkBox; - for (int row = 1; row < gridPlugins.RowsCount; row++) - { - checkBox = gridPlugins[row, ColTransmit] as CheckBox; - if (checkBox == null) - continue; + CheckBox checkBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + checkBox = gridPlugins[row, ColTransmit] as CheckBox; + if (checkBox == null) + continue; - if (gridPlugins[row, ColName].DisplayText.Equals(value, StringComparison.OrdinalIgnoreCase)) - checkBox.Checked = true; - else - checkBox.Checked = false; - } - } + if (gridPlugins[row, ColName].DisplayText.Equals(value, StringComparison.OrdinalIgnoreCase)) + checkBox.Checked = true; + else + checkBox.Checked = false; } + } + } - #endregion Properties + #endregion Properties - #region Constructor + #region Constructor - /// <summary> - /// Initializes a new instance of the <see cref="Config"/> class. - /// </summary> - public Config() - { - InitializeComponent(); + /// <summary> + /// Initializes a new instance of the <see cref="Config"/> class. + /// </summary> + public Config() + { + InitializeComponent(); - try - { - _transceivers = Program.AvailablePlugins(); - } - catch (Exception ex) - { - IrssLog.Error(ex); + try + { + _transceivers = Program.AvailablePlugins(); + } + catch (Exception ex) + { + IrssLog.Error(ex); - _transceivers = null; - } + _transceivers = null; + } - if (_transceivers == null || _transceivers.Length == 0) - MessageBox.Show(this, "No IR Server Plugins found!", "IR Server Configuration", MessageBoxButtons.OK, - MessageBoxIcon.Error); - else - CreateGrid(); - } + if (_transceivers == null || _transceivers.Length == 0) + MessageBox.Show(this, "No IR Server Plugins found!", "IR Server Configuration", MessageBoxButtons.OK, + MessageBoxIcon.Error); + else + CreateGrid(); + } - #endregion Constructor + #endregion Constructor - #region Controls + #region Controls - private void buttonOK_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.OK; - Close(); - } + private void buttonOK_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.OK; + Close(); + } - private void buttonCancel_Click(object sender, EventArgs e) - { - DialogResult = DialogResult.Cancel; - Close(); - } + private void buttonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } - private void buttonClickEvent_Executed(object sender, EventArgs e) - { - CellContext context = (CellContext)sender; - Button cell = (Button)context.Cell; + private void buttonClickEvent_Executed(object sender, EventArgs e) + { + CellContext context = (CellContext)sender; + Button cell = (Button)context.Cell; - try - { - IConfigure plugin = cell.Row.Tag as IConfigure; - if (plugin != null) - plugin.Configure(this); - } - catch (Exception ex) - { - IrssLog.Error(ex); + try + { + IConfigure plugin = cell.Row.Tag as IConfigure; + if (plugin != null) + plugin.Configure(this); + } + catch (Exception ex) + { + IrssLog.Error(ex); - MessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } + MessageBox.Show(this, ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } - private void TransmitChanged(object sender, EventArgs e) - { - CellContext context = (CellContext)sender; - CheckBox cell = (CheckBox)context.Cell; + private void TransmitChanged(object sender, EventArgs e) + { + CellContext context = (CellContext)sender; + CheckBox cell = (CheckBox)context.Cell; - if (cell.Checked != true) - return; + if (cell.Checked != true) + return; - PluginBase plugin = cell.Row.Tag as PluginBase; - if (plugin == null) - return; + PluginBase plugin = cell.Row.Tag as PluginBase; + if (plugin == null) + return; - for (int row = 1; row < gridPlugins.RowsCount; row++) - { - CheckBox checkBox = gridPlugins[row, ColTransmit] as CheckBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + CheckBox checkBox = gridPlugins[row, ColTransmit] as CheckBox; - if (checkBox != null && checkBox.Checked == true && - !gridPlugins[row, ColName].DisplayText.Equals(plugin.Name, StringComparison.OrdinalIgnoreCase)) - checkBox.Checked = false; - } - } + if (checkBox != null && checkBox.Checked == true && + !gridPlugins[row, ColName].DisplayText.Equals(plugin.Name, StringComparison.OrdinalIgnoreCase)) + checkBox.Checked = false; + } + } - private void PluginDoubleClick(object sender, EventArgs e) - { - CellContext context = (CellContext)sender; - Cell cell = (Cell)context.Cell; + private void PluginDoubleClick(object sender, EventArgs e) + { + CellContext context = (CellContext)sender; + Cell cell = (Cell)context.Cell; - CheckBox checkBoxReceive = gridPlugins[cell.Row.Index, ColReceive] as CheckBox; - if (checkBoxReceive != null) - checkBoxReceive.Checked = true; + CheckBox checkBoxReceive = gridPlugins[cell.Row.Index, ColReceive] as CheckBox; + if (checkBoxReceive != null) + checkBoxReceive.Checked = true; - CheckBox checkBoxTransmit = gridPlugins[cell.Row.Index, ColTransmit] as CheckBox; - if (checkBoxTransmit != null) - checkBoxTransmit.Checked = true; - } + CheckBox checkBoxTransmit = gridPlugins[cell.Row.Index, ColTransmit] as CheckBox; + if (checkBoxTransmit != null) + checkBoxTransmit.Checked = true; + } - private void toolStripButtonDetect_Click(object sender, EventArgs e) - { - // TODO: Place on a seperate thread? - Detect(); - } + private void toolStripButtonDetect_Click(object sender, EventArgs e) + { + // TODO: Place on a seperate thread? + Detect(); + } - private void toolStripButtonAdvancedSettings_Click(object sender, EventArgs e) - { - Advanced(); - } + private void toolStripButtonAdvancedSettings_Click(object sender, EventArgs e) + { + Advanced(); + } - private void toolStripButtonHelp_Click(object sender, EventArgs e) - { - IrssHelp.Open(this); - } + private void toolStripButtonHelp_Click(object sender, EventArgs e) + { + IrssHelp.Open(this); + } - private void Config_HelpRequested(object sender, HelpEventArgs hlpevent) - { - IrssHelp.Open(sender); - } + private void Config_HelpRequested(object sender, HelpEventArgs hlpevent) + { + IrssHelp.Open(sender); + } - private void toolStripServiceButton_Click(object sender, EventArgs e) - { - toolStripServiceButton.Enabled = false; - if (Program._serviceInstalled == true) - Program.ServiceUninstall(); - else - Program.ServiceInstall(); + private void toolStripServiceButton_Click(object sender, EventArgs e) + { + toolStripServiceButton.Enabled = false; + if (Program._serviceInstalled == true) + Program.ServiceUninstall(); + else + Program.ServiceInstall(); - Program.getStatus(); - setButtons(); - toolStripServiceButton.Enabled = true; - } + Program.getStatus(); + setButtons(); + toolStripServiceButton.Enabled = true; + } - private void toolStripButtonService_Click(object sender, EventArgs e) - { - if (Program._irsStatus == IrsStatus.RunningService) - Program.ServiceStop(); - if (Program._irsStatus == IrsStatus.NotRunning) - Program.ServiceStart(); - } + private void toolStripButtonService_Click(object sender, EventArgs e) + { + if (Program._irsStatus == IrsStatus.RunningService) + Program.ServiceStop(); + if (Program._irsStatus == IrsStatus.NotRunning) + Program.ServiceStart(); + } - private void toolStripButtonApplication_Click(object sender, EventArgs e) - { - if (Program._irsStatus == IrsStatus.RunningApplication) - Program.ApplicationStop(); - if (Program._irsStatus == IrsStatus.NotRunning) - Program.ApplicationStart(); - } + private void toolStripButtonApplication_Click(object sender, EventArgs e) + { + if (Program._irsStatus == IrsStatus.RunningApplication) + Program.ApplicationStop(); + if (Program._irsStatus == IrsStatus.NotRunning) + Program.ApplicationStart(); + } - #endregion Controls + #endregion Controls - } + } } \ No newline at end of file Modified: trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Program.cs 2009-09-10 11:28:34 UTC (rev 3083) +++ trunk/plugins/IR Server Suite/IR Server Suite/IR Server/IR Server Configuration/Program.cs 2009-09-10 15:33:42 UTC (rev 3084) @@ -40,705 +40,705 @@ namespace IRServer.Configuration { - #region Enumerations + #region Enumerations + /// <summary> + /// Describes the operation mode of IR Server. + /// </summary> + internal enum IRServerMode + { /// <summary> - /// Describes the operation mode of IR Server. + /// Acts as a standard Server (Default). /// </summary> - internal enum IRServerMode - { - /// <summary> - /// Acts as a standard Server (Default). - /// </summary> - ServerMode = 0, - /// <summary> - /// Relays button presses to another IR Server. - /// </summary> - RelayMode = 1, - /// <summary> - /// Acts as a repeater for another IR Server's blasting. - /// </summary> - RepeaterMode = 2, - } + ServerMode = 0, + /// <summary> + /// Relays button presses to another IR Server. + /// </summary> + RelayMode = 1, + /// <summary> + /// Acts as a repeater for another IR Server's blasting. + /// </summary> + RepeaterMode = 2, + } + /// <summary> + /// Describes the actual status of IR Server + /// </summary> + internal enum IrsStatus + { /// <summary> - /// Describes the actual status of IR Server + /// IR Server is not running. /// </summary> - internal enum IrsStatus - { - /// <summary> - /// IR Server is not running. - /// </summary> - NotRunning, - /// <summary> - /// IR Server is running as Service. - /// </summary> - RunningService, - /// <summary> - /// IR Server is running as Application. - /// </summary> - RunningApplication - } + NotRunning, + /// <summary> + /// IR Server is running as Service. + /// </summary> + RunningService, + /// <summary> + /// IR Server is running as Application. + /// </summary> + RunningApplication + } - #endregion Enumerations + #endregion Enumerations - internal static class Program - { - #region Constants + internal static class Program + { + #region Constants - internal const string ServerName = "IRServer"; - internal const string ServerWindowName = "IRSS - " + ServerName; - internal const string ServerDisplayName = "IR Server"; + internal const string ServerName = "IRServer"; + internal const string ServerWindowName = "IRSS - " + ServerName; + internal const string ServerDisplayName = "IR Server"; - private static readonly string ConfigurationFile = Path.Combine(Common.FolderAppData, @"IR Server\IR Server.xml"); - internal static readonly string IRServerFile = Path.Combine(Common.FolderProgramFiles, @"IR Server.exe"); + private static readonly string ConfigurationFile = Path.Combine(Common.FolderAppData, @"IR Server\IR Server.xml"); + internal static readonly string IRServerFile = Path.Combine(Common.FolderProgramFiles, @"IR Server.exe"); - internal static readonly Icon _iconGray = new Icon(Resources.iconGray, new Size(16, 16)); - internal static readonly Icon _iconGreen = new Icon(Resources.iconGreen, new Size(16, 16)); - private static readonly TimeSpan defaultServiceTime = new TimeSpan(0, 0, 30); + internal static readonly Icon _iconGray = new Icon(Resources.iconGray, new Size(16, 16)); + internal static readonly Icon _iconGreen = new Icon(Resources.iconGreen, new Size(16, 16)); + private static readonly TimeSpan defaultServiceTime = new TimeSpan(0, 0, 30); - #endregion Constants + #endregion Constants - #region Variables + #region Variables - private static bool _abstractRemoteMode; - private static string _hostComputer; - private static IRServerMode _mode; - private static string[] _pluginNameReceive; - private static string _pluginNameTransmit; - private static string _processPriority; - private static NotifyIcon _notifyIcon; - private static bool _inConfiguration; - private static Thread thread; - private static ServiceController serviceController; - private static ServiceController[] serviceControllers; - private static IntPtr irsWindow; - private static int waitCount; - internal static IrsStatus _irsStatus; - internal static bool _serviceInstalled; + private static bool _abstractRemoteMode; + private static string _hostComputer; + private static IRServerMode _mode; + private static string[] _pluginNameReceive; + private static string _pluginNameTransmit; + private static string _processPriority; + private static NotifyIcon _notifyIcon; + private static bool _inConfiguration; + private static Thread thread; + private static ServiceController serviceController; + private static ServiceController[] serviceControllers; + private static IntPtr irsWindow; + private static int waitCount; + internal static IrsStatus _irsStatus; + internal static bool _serviceInstalled; - #endregion Variables + #endregion Variables - #region Interops + #region Interops - [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] - internal static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName); - [DllImport("user32.dll")] - internal static extern int SendMessage( - IntPtr hWnd, // handle to destination window - uint Msg, // message - long wParam, // first message parameter - long lParam // second message parameter - ); + [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] + internal static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName); + [DllImport("user32.dll")] + internal static extern int SendMessage( + IntPtr hWnd, // handle to destination window + uint Msg, // message + long wParam, // first message parameter + long lParam // second message parameter + ); - #endregion Interops + #endregion Interops - /// <summary> - /// The main entry point for the application. - /// </summary> - [STAThread] - private static void Main() - { - Application.EnableVisualStyles(); - Application.SetCompatibleTextRenderingDefault(true); + /// <summary> + /// The main entry point for the application. + /// </summary> + [STAThread] + private static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(true); - IrssLog.LogLevel = IrssLog.Level.Debug; - IrssLog.Open("IR Server Configuration.log"); + IrssLog.LogLevel = IrssLog.Level.Debug; + IrssLog.Open("IR Server Configuration.log"); - _notifyIcon = new NotifyIcon(); + _notifyIcon = new NotifyIcon(); - _notifyIcon.ContextMenuStrip = new ContextMenuStrip(); - _notifyIcon.ContextMenuStrip.Items.Add(new ToolStripLabel(ServerDisplayName)); - _notifyIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator()); - _notifyIcon.ContextMenuStrip.Items.Add("&Setup", null, OpenConfiguration); - _notifyIcon.ContextMenuStrip.Items.Add("&Quit", null, ClickQuit); - _notifyIcon.DoubleClick += new EventHandler(OpenConfiguration); - _notifyIcon.Icon = new System.Drawing.Icon(Resources.iconGray, new System.Drawing.Size(16, 16)); - _notifyIcon.Text = ServerDisplayName; - _notifyIcon.Visible = true; + _notifyIcon.ContextMenuStrip = new ContextMenuStrip(); + _notifyIcon.ContextMenuStrip.Items.Add(new ToolStripLabel(ServerDisplayName)); + _notifyIcon.ContextMenuStrip.Items.Add(new ToolStripSeparator()); + _notifyIcon.ContextMenuStrip.Items.Add("&Setup", null, OpenConfiguration); + _notifyIcon.ContextMenuStrip.Items.Add("&Quit", null, ClickQuit); + _notifyIcon.DoubleClick += new EventHandler(OpenConfiguration); + _notifyIcon.Icon = new System.Drawing.Icon(Resources.iconGray, new System.Drawing.Size(16, 16)); + _notifyIcon.Text = ServerDisplayName; + _notifyIcon.Visible = true; - thread = new Thread(new ThreadStart(UpdateIcon)); - thread.IsBackground = true; - thread.Start(); + thread = new Thread(new ThreadStart(UpdateIcon)); + thread.IsBackground = true; + thread.Start(); - Application.Run(); - thread.Abort(); - _notifyIcon.Visible = false; - _notifyIcon = null; - } + Application.Run(); + thread.Abort(); + _notifyIcon.Visible = false; + _notifyIcon = null; + } - private static void UpdateIcon() - { - while (thread != null && thread.IsAlive) - { - getStatus(); - _notifyIcon.Icon = getIcon(); - Thread.Sleep(1000); - } - } + private static void UpdateIcon() + { + while (thread != null && thread.IsAlive) + { + getStatus(); + _notifyIcon.Icon = getIcon(); + Thread.Sleep(1000); + } + } - internal static void getStatus() + internal static void getStatus() + { + _irsStatus = IrsStatus.NotRunning; + _serviceInstalled = false; + serviceControllers = ServiceController.GetServices(); + foreach (ServiceController serviceController in serviceControllers) + { + if (serviceController.ServiceName == ServerName) { - _irsStatus = IrsStatus.NotRunning; - _serviceInstalled = false; - serviceControllers = ServiceController.GetServices(); - foreach (ServiceController serviceController in serviceControllers) - { - if (serviceController.ServiceName == ServerName) - { - _serviceInstalled = true; - if (serviceController.Status == ServiceControllerStatus.Running) - _irsStatus = IrsStatus.RunningService; - } - } - - try - { - irsWindow = FindWindowByCaption(IntPtr.Zero, ServerWindowName); - if (irsWindow != IntPtr.Zero) - _irsStatus = IrsStatus.RunningApplication; - } - catch { } + _serviceInstalled = true; + if (serviceController.Status == ServiceControllerStatus.Running) + _irsStatus = IrsStatus.RunningService; } + } - private static Icon getIcon() - { - return (_irsStatus == IrsStatus.NotRunning) ? _iconGray : _iconGreen; - } + try + { + irsWindow = FindWindowByCaption(IntPtr.Zero, ServerWindowName); + if (irsWindow != IntPtr.Zero) + _irsStatus = IrsStatus.RunningApplication; + } + catch { } + } - private static void ClickQuit(object sender, EventArgs e) - { - Application.Exit(); - } + private static Icon getIcon() + { + return (_irsStatus == IrsStatus.NotRunning) ? _iconGray : _iconGreen; + } - private static void OpenConfiguration(object sender, EventArgs e) - { - if (_inConfiguration) - return; + private static void ClickQuit(object sender, EventArgs e) + { + Application.Exit(); + } - IrssLog.Info("Setup"); + private static void OpenConfiguration(object sender, EventArgs e) + { + if (_inConfiguration) + return; - LoadSettings(); + IrssLog.Info("Setup"); - Config config = new Config(); + LoadSettings(); - config.AbstractRemoteMode = _abstractRemoteMode; - config.Mode = _mode; - config.HostComputer = _hostComputer; - config.ProcessPriority = _processPriority; - config.PluginReceive = _pluginNameReceive; - config.PluginTransmit = _pluginNameTransmit; + Config config = new Config(); - _inConfiguration = true; + config.AbstractRemoteMode = _abstractRemoteMode; + config.Mode = _mode; + config.HostComputer = _hostComputer; + config.ProcessPriority = _processPriority; + config.PluginReceive = _pluginNameReceive; + config.PluginTransmit = _pluginNameTransmit; - if (config.ShowDialog() == DialogResult.OK) - { - if ((_abstractRemoteMode != config.AbstractRemoteMode) || - (_mode != config.Mode) || - (_hostComputer != config.HostComputer) || - (_processPriority != config.ProcessPriority) || - (_pluginNameReceive != config.PluginReceive) || - (_pluginNameTransmit != config.PluginTransmit)) - { - if ( - MessageBox.Show("IR Server will now be restarted for configuration changes to take effect", - "Restarting IR Server", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == - DialogResult.OK) - { - // Change settings ... - _abstractRemoteMode = config.AbstractRemoteMode; - _mode = config.Mode; - _hostComputer = config.HostComputer; - _processPriority = config.ProcessPriority; - _pluginNameReceive = config.PluginReceive; - _pluginNameTransmit = config.PluginTransmit; + _inConfiguration = true; - SaveSettings(); + if (config.ShowDialog() == DialogResult.OK) + { + if ((_abstractRemoteMode != config.AbstractRemoteMode) || + (_mode != config.Mode) || + (_hostComputer != config.HostComputer) || + (_processPriority != config.ProcessPriority) || + (_pluginNameReceive != config.PluginReceive) || + (_pluginNameTransmit != config.PluginTransmit)) + { + if ( + MessageBox.Show("IR Server will now be restarted for configuration changes to take effect", + "Restarting IR Server", MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == + DialogResult.OK) + { + // Change settings ... + _abstractRemoteMode = config.AbstractRemoteMode; + _mode = config.Mode; + _hostComputer = config.HostComputer; + _processPriority = config.ProcessPriority; + _pluginNameReceive = config.PluginReceive; + _pluginNameTransmit = config.PluginTransmit; - // Restart IR Server ... - RestartIRS(); - } - else - { - IrssLog.Info("Canceled settings changes"); - } - } - } + SaveSettings(); - _inConfiguration = false; - - IrssLog.Close(); + // Restart IR Server ... + RestartIRS(); + } + else + { + IrssLog.Info("Canceled settings changes"); + } } + } - private static void LoadSettings() - { - IrssLog.Info("Loading settings ..."); + _inConfiguration = false; - _abstractRemoteMode = true; - _mode = IRServerMode.ServerMode; - _hostComputer = String.Empty; - _processPriority = "No Change"; - _pluginNameReceive = null; - _pluginNameTransmit = String.Empty; + IrssLog.Close(); + } - XmlDocument doc = new XmlDocument(); + private static void LoadSettings() + { + IrssLog.Info("Loading settings ..."); - try - { - doc.Load(ConfigurationFile); - } - catch (DirectoryNotFoundException) - { - IrssLog.Error("No configuration file found ({0}), folder not found! Creating default configuration file", - ConfigurationFile); + _abstractRemoteMode = true; + _mode = IRServerMode.ServerMode; + _hostComputer = String.Empty; + _processPriority = "No Change"; + _pluginNameReceive = null; + _pluginNameTransmit = String.Empty; - Directory.CreateDirectory(Path.GetDirectoryName(ConfigurationFile)); + XmlDocument doc = new XmlDocument(); - CreateDefaultSettings(); - return; - } - catch (FileNotFoundException) - { - IrssLog.Warn("No configuration file found ({0}), creating default configuration file", ConfigurationFile); + try + { + doc.Load(ConfigurationFile); + } + catch (DirectoryNotFoundException) + { + IrssLog.Error("No configuration file found ({0}), folder not found! Creating default configuration file", + ConfigurationFile); - CreateDefaultSettings(); - return; - } - catch (Exception ex) - { - IrssLog.Error(ex); - return; - } + Directory.CreateDirectory(Path.GetDirectoryName(ConfigurationFile)); - try - { - _abstractRemoteMode = bool.Parse(doc.DocumentElement.Attributes["AbstractRemoteMode"].Value); - } - catch (Exception ex) - { - IrssLog.Warn(ex.ToString()); - } + CreateDefaultSettings(); + return; + } + catch (FileNotFoundException) + { + IrssLog.Warn("No configuration file found ({0}), creating default configuration file", ConfigurationFile); - try - { - _mode = - (IRServerMode)Enum.Parse(typeof(IRServerMode), doc.DocumentElement.Attributes["Mode"].Value, true); - } - catch (Exception ex) - { - IrssLog.Warn(ex.ToString()); - } + CreateDefaultSettings(); + return; + } + catch (Exception ex) + { + IrssLog.Error(ex); + return; + } - try - { - _hostComputer = doc.DocumentElement.Attributes["HostComputer"].Value; - } - catch (Exception ex) - { - IrssLog.Warn(ex.ToString()); - } + try + { + _abstractRemoteMode = bool.Parse(doc.DocumentElement.Attributes["AbstractRemoteMode"].Value); + } + catch (Exception ex) + { + IrssLog.Warn(ex.ToString()); + } - try - { - _processPriority = doc.DocumentElement.Attributes["ProcessPriority"].Value; - } - catch (Exception ex) - { - IrssLog.Warn(ex.ToString()); - } + try + { + _mode = + (IRServerMode)Enum.Parse(typeof(IRServerMode), doc.DocumentElement.Attributes["Mode"].Value, true); + } + catch (Exception ex) + { + IrssLog.Warn(ex.ToString()); + } - try - { - _pluginNameTransmit = doc.DocumentElement.Attributes["PluginTransmit"].Value; - } - catch (Exception ex) - { - IrssLog.Warn(ex.ToString()); - } + try + { + _hostComputer = doc.DocumentElement.Attributes["HostComputer"].Value; + } + catch (Exception ex) + { + IrssLog.Warn(ex.ToString()); + } - try - { - string receivers = doc.DocumentElement.Attributes["PluginReceive"].Value; - if (!String.IsNullOrEmpty(receivers)) - _pluginNameReceive = receivers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); - } - catch (Exception ex) - { - IrssLog.Warn(ex.ToString()); - } - } + try + { + _processPriority = doc.DocumentElement.Attributes["ProcessPriority"].Value; + } + catch (Exception ex) + { + IrssLog.Warn(ex.ToString()); + } - private static void SaveSettings() - { - IrssLog.Info("Saving settings ..."); + try + { + _pluginNameTransmit = doc.DocumentElement.Attributes["PluginTransmit"].Value; + } + catch (Exception ex) + { + IrssLog.Warn(ex.ToString()); + } - try - { - using (XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, Encoding.UTF8)) - { - writer.Formatting = Formatting.Indented; - writer.Indentation = 1; - writer.IndentChar = (char)9; - writer.WriteStartDocument(true); - writer.WriteStartElement("settings"); // <settings> + try + { + string receivers = doc.DocumentElement.Attributes["PluginReceive"].Value; + if (!String.IsNullOrEmpty(receivers)) + _pluginNameReceive = receivers.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + } + catch (Exception ex) + { + IrssLog.Warn(ex.ToString()); + } + } - writer.WriteAttributeString("AbstractRemoteMode", _abstractRemoteMode.ToString()); - writer.WriteAttributeString("Mode", Enum.GetName(typeof(IRServerMode), _mode)); - writer.WriteAttributeString("HostComputer", _hostComputer); - writer.WriteAttributeString("ProcessPriority", _processPriority); - writer.WriteAttributeString("PluginTransmit", _pluginNameTransmit); + private static void SaveSettings() + { + IrssLog.Info("Saving settings ..."); - if (_pluginNameReceive != null) - { - StringBuilder receivers = new StringBuilder(); - for (int index = 0; index < _pluginNameReceive.Length; index++) - { - receivers.Append(_pluginNameReceive[index]); + try + { + using (XmlTextWriter writer = new XmlTextWriter(ConfigurationFile, Encoding.UTF8)) + { + writer.Formatting = Formatting.Indented; + writer.Indentation = 1; + writer.IndentChar = (char)9; + writer.WriteStartDocument(true); + writer.WriteStartElement("settings"); // <settings> - if (index < _pluginNameReceive.Length - 1) - receivers.Append(','); - } - writer.WriteAttributeString("PluginReceive", receivers.ToString()); - } - else - { - writer.WriteAttributeString("PluginReceive", String.Empty); - } + writer.WriteAttributeString("AbstractRemoteMode", _abstractRemoteMode.ToString()); + writer.WriteAttributeString("Mode", Enum.GetName(typeof(IRServerMode), _mode)); + writer.WriteAttributeString("HostComputer", _hostComputer); + writer.WriteAttributeString("ProcessPriority", _processPriority); + writer.WriteAttributeString("PluginTransmit", _pluginNameTransmit); - ... [truncated message content] |