From: <an...@us...> - 2007-06-10 17:28:50
|
Revision: 504 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=504&view=rev Author: and-81 Date: 2007-06-10 10:28:47 -0700 (Sun, 10 Jun 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/IR Server Suite/Applications/IR Server/Config.Designer.cs trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs trunk/plugins/IR Server Suite/Applications/IR Server/IR Server.csproj trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs trunk/plugins/IR Server Suite/Common/IrssUtils/TransceiverInfo.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLirc Receiver.cs trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLircServer.cs Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Config.Designer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/Config.Designer.cs 2007-06-10 08:51:02 UTC (rev 503) +++ trunk/plugins/IR Server Suite/Applications/IR Server/Config.Designer.cs 2007-06-10 17:28:47 UTC (rev 504) @@ -33,22 +33,16 @@ this.buttonOK = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button(); this.toolTips = new System.Windows.Forms.ToolTip(this.components); - this.buttonConfigureTransceiver = new System.Windows.Forms.Button(); - this.textBoxPlugin = new System.Windows.Forms.TextBox(); this.checkBoxRunAtBoot = new System.Windows.Forms.CheckBox(); this.radioButtonServer = new System.Windows.Forms.RadioButton(); this.radioButtonRelay = new System.Windows.Forms.RadioButton(); this.radioButtonRepeater = new System.Windows.Forms.RadioButton(); - this.listViewTransceiver = new System.Windows.Forms.ListView(); - this.columnHeaderTransceiver = new System.Windows.Forms.ColumnHeader(); - this.columnHeaderCanReceive = new System.Windows.Forms.ColumnHeader(); - this.columnHeaderCanTransmit = new System.Windows.Forms.ColumnHeader(); this.groupBoxTransceiver = new System.Windows.Forms.GroupBox(); + this.gridPlugins = new SourceGrid.Grid(); this.groupBoxMode = new System.Windows.Forms.GroupBox(); this.labelComputer = new System.Windows.Forms.Label(); this.comboBoxComputer = new System.Windows.Forms.ComboBox(); this.buttonHelp = new System.Windows.Forms.Button(); - this.labelCurrentPlugin = new System.Windows.Forms.Label(); this.groupBoxTransceiver.SuspendLayout(); this.groupBoxMode.SuspendLayout(); this.SuspendLayout(); @@ -76,34 +70,6 @@ this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); // - // buttonConfigureTransceiver - // - this.buttonConfigureTransceiver.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonConfigureTransceiver.Enabled = false; - this.buttonConfigureTransceiver.Location = new System.Drawing.Point(344, 224); - this.buttonConfigureTransceiver.Name = "buttonConfigureTransceiver"; - this.buttonConfigureTransceiver.Size = new System.Drawing.Size(72, 24); - this.buttonConfigureTransceiver.TabIndex = 2; - this.buttonConfigureTransceiver.Text = "Configure"; - this.toolTips.SetToolTip(this.buttonConfigureTransceiver, "Configure the remote control transceiver"); - this.buttonConfigureTransceiver.UseVisualStyleBackColor = true; - this.buttonConfigureTransceiver.Click += new System.EventHandler(this.buttonConfigureTransceiver_Click); - // - // textBoxPlugin - // - this.textBoxPlugin.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.textBoxPlugin.BackColor = System.Drawing.SystemColors.ControlLight; - this.textBoxPlugin.Font = new System.Drawing.Font("Microsoft Sans Serif", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.textBoxPlugin.Location = new System.Drawing.Point(104, 224); - this.textBoxPlugin.Name = "textBoxPlugin"; - this.textBoxPlugin.ReadOnly = true; - this.textBoxPlugin.Size = new System.Drawing.Size(232, 24); - this.textBoxPlugin.TabIndex = 1; - this.textBoxPlugin.Text = "None set"; - this.textBoxPlugin.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.toolTips.SetToolTip(this.textBoxPlugin, "Currently selected Remote Transceiver"); - // // checkBoxRunAtBoot // this.checkBoxRunAtBoot.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); @@ -151,56 +117,12 @@ this.radioButtonRepeater.UseVisualStyleBackColor = true; this.radioButtonRepeater.CheckedChanged += new System.EventHandler(this.radioButtonRepeater_CheckedChanged); // - // listViewTransceiver - // - this.listViewTransceiver.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.listViewTransceiver.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] { - this.columnHeaderTransceiver, - this.columnHeaderCanReceive, - this.columnHeaderCanTransmit}); - this.listViewTransceiver.FullRowSelect = true; - this.listViewTransceiver.GridLines = true; - this.listViewTransceiver.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.listViewTransceiver.HideSelection = false; - this.listViewTransceiver.Location = new System.Drawing.Point(8, 24); - this.listViewTransceiver.MultiSelect = false; - this.listViewTransceiver.Name = "listViewTransceiver"; - this.listViewTransceiver.ShowGroups = false; - this.listViewTransceiver.ShowItemToolTips = true; - this.listViewTransceiver.Size = new System.Drawing.Size(408, 192); - this.listViewTransceiver.TabIndex = 0; - this.listViewTransceiver.UseCompatibleStateImageBehavior = false; - this.listViewTransceiver.View = System.Windows.Forms.View.Details; - this.listViewTransceiver.DoubleClick += new System.EventHandler(this.listViewTransceiver_DoubleClick); - // - // columnHeaderTransceiver - // - this.columnHeaderTransceiver.Text = "Name"; - this.columnHeaderTransceiver.Width = 240; - // - // columnHeaderCanReceive - // - this.columnHeaderCanReceive.Text = "Receiver"; - this.columnHeaderCanReceive.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.columnHeaderCanReceive.Width = 70; - // - // columnHeaderCanTransmit - // - this.columnHeaderCanTransmit.Text = "Blaster"; - this.columnHeaderCanTransmit.TextAlign = System.Windows.Forms.HorizontalAlignment.Center; - this.columnHeaderCanTransmit.Width = 70; - // // groupBoxTransceiver // this.groupBoxTransceiver.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) | System.Windows.Forms.AnchorStyles.Left) | System.Windows.Forms.AnchorStyles.Right))); - this.groupBoxTransceiver.Controls.Add(this.labelCurrentPlugin); - this.groupBoxTransceiver.Controls.Add(this.textBoxPlugin); - this.groupBoxTransceiver.Controls.Add(this.listViewTransceiver); - this.groupBoxTransceiver.Controls.Add(this.buttonConfigureTransceiver); + this.groupBoxTransceiver.Controls.Add(this.gridPlugins); this.groupBoxTransceiver.Location = new System.Drawing.Point(8, 8); this.groupBoxTransceiver.Name = "groupBoxTransceiver"; this.groupBoxTransceiver.Size = new System.Drawing.Size(424, 256); @@ -208,6 +130,22 @@ this.groupBoxTransceiver.TabStop = false; this.groupBoxTransceiver.Text = "Device plugin"; // + // gridPlugins + // + this.gridPlugins.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.gridPlugins.BackColor = System.Drawing.SystemColors.Window; + this.gridPlugins.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; + this.gridPlugins.Location = new System.Drawing.Point(16, 24); + this.gridPlugins.Name = "gridPlugins"; + this.gridPlugins.OptimizeMode = SourceGrid.CellOptimizeMode.ForRows; + this.gridPlugins.SelectionMode = SourceGrid.GridSelectionMode.Row; + this.gridPlugins.Size = new System.Drawing.Size(392, 216); + this.gridPlugins.TabIndex = 0; + this.gridPlugins.TabStop = true; + this.gridPlugins.ToolTipText = ""; + // // groupBoxMode // this.groupBoxMode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) @@ -230,7 +168,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.labelComputer.Location = new System.Drawing.Point(160, 24); this.labelComputer.Name = "labelComputer"; - this.labelComputer.Size = new System.Drawing.Size(256, 64); + this.labelComputer.Size = new System.Drawing.Size(248, 64); this.labelComputer.TabIndex = 3; this.labelComputer.Text = "Button Relay / IR Repeater mode host computer:"; this.labelComputer.TextAlign = System.Drawing.ContentAlignment.BottomLeft; @@ -245,7 +183,7 @@ this.comboBoxComputer.FormattingEnabled = true; this.comboBoxComputer.Location = new System.Drawing.Point(160, 88); this.comboBoxComputer.Name = "comboBoxComputer"; - this.comboBoxComputer.Size = new System.Drawing.Size(256, 21); + this.comboBoxComputer.Size = new System.Drawing.Size(248, 21); this.comboBoxComputer.TabIndex = 4; // // buttonHelp @@ -259,16 +197,6 @@ this.buttonHelp.UseVisualStyleBackColor = true; this.buttonHelp.Click += new System.EventHandler(this.buttonHelp_Click); // - // labelCurrentPlugin - // - this.labelCurrentPlugin.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.labelCurrentPlugin.Location = new System.Drawing.Point(8, 224); - this.labelCurrentPlugin.Name = "labelCurrentPlugin"; - this.labelCurrentPlugin.Size = new System.Drawing.Size(96, 24); - this.labelCurrentPlugin.TabIndex = 3; - this.labelCurrentPlugin.Text = "Current plugin:"; - this.labelCurrentPlugin.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; - // // Config // this.AcceptButton = this.buttonOK; @@ -287,9 +215,7 @@ this.Name = "Config"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "IR Server - Configuration"; - this.Load += new System.EventHandler(this.Config_Load); this.groupBoxTransceiver.ResumeLayout(false); - this.groupBoxTransceiver.PerformLayout(); this.groupBoxMode.ResumeLayout(false); this.ResumeLayout(false); @@ -301,12 +227,6 @@ private System.Windows.Forms.Button buttonCancel; private System.Windows.Forms.ToolTip toolTips; private System.Windows.Forms.GroupBox groupBoxTransceiver; - private System.Windows.Forms.Button buttonConfigureTransceiver; - private System.Windows.Forms.ListView listViewTransceiver; - private System.Windows.Forms.ColumnHeader columnHeaderTransceiver; - private System.Windows.Forms.ColumnHeader columnHeaderCanReceive; - private System.Windows.Forms.ColumnHeader columnHeaderCanTransmit; - private System.Windows.Forms.TextBox textBoxPlugin; private System.Windows.Forms.GroupBox groupBoxMode; private System.Windows.Forms.CheckBox checkBoxRunAtBoot; private System.Windows.Forms.ComboBox comboBoxComputer; @@ -315,6 +235,6 @@ private System.Windows.Forms.RadioButton radioButtonServer; private System.Windows.Forms.RadioButton radioButtonRepeater; private System.Windows.Forms.Label labelComputer; - private System.Windows.Forms.Label labelCurrentPlugin; + private SourceGrid.Grid gridPlugins; } } \ No newline at end of file Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs 2007-06-10 08:51:02 UTC (rev 503) +++ trunk/plugins/IR Server Suite/Applications/IR Server/Config.cs 2007-06-10 17:28:47 UTC (rev 504) @@ -60,12 +60,67 @@ get { return comboBoxComputer.Text; } set { comboBoxComputer.Text = value; } } - public string Plugin + public string PluginReceive { - get { return textBoxPlugin.Text; } - set { textBoxPlugin.Text = value; } + get + { + SourceGrid.Cells.CheckBox checkBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + checkBox = gridPlugins[row, 1] as SourceGrid.Cells.CheckBox; + if (checkBox != null && checkBox.Checked) + return gridPlugins[row, 0].DisplayText; + } + + return String.Empty; + } + set + { + SourceGrid.Cells.CheckBox checkBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + checkBox = gridPlugins[row, 1] as SourceGrid.Cells.CheckBox; + if (checkBox == null) + continue; + + if (gridPlugins[row, 0].DisplayText.Equals(value, StringComparison.InvariantCultureIgnoreCase)) + checkBox.Checked = true; + else + checkBox.Checked = false; + } + } } + public string PluginTransmit + { + get + { + SourceGrid.Cells.CheckBox checkBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + checkBox = gridPlugins[row, 2] as SourceGrid.Cells.CheckBox; + if (checkBox != null && checkBox.Checked) + return gridPlugins[row, 0].DisplayText; + } + return String.Empty; + } + set + { + SourceGrid.Cells.CheckBox checkBox; + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + checkBox = gridPlugins[row, 2] as SourceGrid.Cells.CheckBox; + if (checkBox == null) + continue; + + if (gridPlugins[row, 0].DisplayText.Equals(value, StringComparison.InvariantCultureIgnoreCase)) + checkBox.Checked = true; + else + checkBox.Checked = false; + } + } + } + #endregion Properties #region Constructor @@ -76,28 +131,13 @@ // Add transceivers to list ... _transceivers = Program.AvailablePlugins(); - - listViewTransceiver.Items.Clear(); - if (_transceivers == null || _transceivers.Length == 0) { MessageBox.Show(this, "No IR Server Plugins found!", "IR Server Configuration", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { - foreach (IIRServerPlugin transceiver in _transceivers) - { - ListViewItem listViewItem = new ListViewItem( - new string[] { - transceiver.Name, - transceiver.CanReceive.ToString(), - transceiver.CanTransmit.ToString() - }); - - listViewItem.ToolTipText = String.Format("{0}\nVersion: {1}\nAuthor: {2}\n{3}", transceiver.Name, transceiver.Version, transceiver.Author, transceiver.Description); - - listViewTransceiver.Items.Add(listViewItem); - } + CreateGrid(); } try @@ -115,17 +155,98 @@ if (computer != Environment.MachineName) comboBoxComputer.Items.Add(computer); } - } #endregion Constructor - private void Config_Load(object sender, EventArgs e) + void CreateGrid() { - if (_transceivers != null && !String.IsNullOrEmpty(textBoxPlugin.Text)) - foreach (IIRServerPlugin tx in _transceivers) - if (tx.Name == textBoxPlugin.Text) - buttonConfigureTransceiver.Enabled = tx.CanConfigure; + int row = 0; + gridPlugins.Rows.Clear(); + + gridPlugins.Columns.SetCount(4); + + gridPlugins.Rows.Insert(row); + SourceGrid.Cells.ColumnHeader headerCell; + + headerCell = new SourceGrid.Cells.ColumnHeader("Name"); + gridPlugins[row, 0] = headerCell; + + headerCell = new SourceGrid.Cells.ColumnHeader("Receive"); + gridPlugins[row, 1] = headerCell; + + headerCell = new SourceGrid.Cells.ColumnHeader("Transmit"); + gridPlugins[row, 2] = headerCell; + + headerCell = new SourceGrid.Cells.ColumnHeader("Configure"); + gridPlugins[row, 3] = headerCell; + + gridPlugins.FixedRows = 1; + + row++; + + foreach (IIRServerPlugin transceiver in _transceivers) + { + gridPlugins.Rows.Insert(row); + + SourceGrid.Cells.Cell nameCell = new SourceGrid.Cells.Cell(transceiver.Name); + + SourceGrid.Cells.Controllers.CustomEvents nameCellController = new SourceGrid.Cells.Controllers.CustomEvents(); + nameCellController.DoubleClick += new EventHandler(PluginDoubleClick); + nameCell.AddController(nameCellController); + + nameCell.ToolTipText = string.Format("{0}\nVersion: {1}\nAuthor: {2}\n{3}", transceiver.Name, transceiver.Version, transceiver.Author, transceiver.Description); + + gridPlugins[row, 0] = nameCell; + + if (transceiver.CanReceive) + { + SourceGrid.Cells.CheckBox checkbox = new SourceGrid.Cells.CheckBox(); + + SourceGrid.Cells.Controllers.CustomEvents checkboxcontroller = new SourceGrid.Cells.Controllers.CustomEvents(); + checkboxcontroller.ValueChanged += new EventHandler(ReceiveChanged); + checkbox.Controller.AddController(checkboxcontroller); + + gridPlugins[row, 1] = checkbox; + } + else + gridPlugins[row, 1] = new SourceGrid.Cells.Cell(); + + if (transceiver.CanTransmit) + { + SourceGrid.Cells.CheckBox checkbox = new SourceGrid.Cells.CheckBox(); + + SourceGrid.Cells.Controllers.CustomEvents checkboxcontroller = new SourceGrid.Cells.Controllers.CustomEvents(); + checkboxcontroller.ValueChanged += new EventHandler(TransmitChanged); + checkbox.Controller.AddController(checkboxcontroller); + + gridPlugins[row, 2] = checkbox; + } + else + gridPlugins[row, 2] = new SourceGrid.Cells.Cell(); + + if (transceiver.CanConfigure) + { + SourceGrid.Cells.Button button = new SourceGrid.Cells.Button("Configure"); + + SourceGrid.Cells.Controllers.Button buttonClickEvent = new SourceGrid.Cells.Controllers.Button(); + buttonClickEvent.Executed += new EventHandler(buttonClickEvent_Executed); + button.Controller.AddController(buttonClickEvent); + + gridPlugins[row, 3] = button; + } + else + gridPlugins[row, 3] = new SourceGrid.Cells.Cell(); + + row++; + } + + gridPlugins.Columns[0].AutoSizeMode = SourceGrid.AutoSizeMode.Default; + gridPlugins.Columns[1].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; + gridPlugins.Columns[2].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; + gridPlugins.Columns[3].AutoSizeMode = SourceGrid.AutoSizeMode.EnableAutoSize; + gridPlugins.AutoStretchColumnsToFitWidth = true; + gridPlugins.AutoSizeCells(); } #region Controls @@ -153,24 +274,64 @@ this.Close(); } - private void buttonConfigureTransceiver_Click(object sender, EventArgs e) + private void buttonClickEvent_Executed(object sender, EventArgs e) { - if (String.IsNullOrEmpty(textBoxPlugin.Text)) + SourceGrid.CellContext context = (SourceGrid.CellContext)sender; + SourceGrid.Cells.Button cell = (SourceGrid.Cells.Button)context.Cell; + + string plugin = gridPlugins[cell.Row.Index, 0].DisplayText; + + foreach (IIRServerPlugin transceiver in _transceivers) + if (transceiver.Name == plugin) + transceiver.Configure(); + } + + private void ReceiveChanged(object sender, EventArgs e) + { + SourceGrid.CellContext context = (SourceGrid.CellContext)sender; + SourceGrid.Cells.CheckBox cell = (SourceGrid.Cells.CheckBox)context.Cell; + + if (!cell.Checked) return; - foreach (IIRServerPlugin tx in _transceivers) - if (tx.Name == textBoxPlugin.Text) - if (tx.CanConfigure) - tx.Configure(); + string plugin = gridPlugins[cell.Row.Index, 0].DisplayText; + + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + SourceGrid.Cells.CheckBox checkBox = gridPlugins[row, 1] as SourceGrid.Cells.CheckBox; + if (checkBox != null && checkBox.Checked && !gridPlugins[row, 0].DisplayText.Equals(plugin, StringComparison.InvariantCultureIgnoreCase)) + checkBox.Checked = false; + } } + private void TransmitChanged(object sender, EventArgs e) + { + SourceGrid.CellContext context = (SourceGrid.CellContext)sender; + SourceGrid.Cells.CheckBox cell = (SourceGrid.Cells.CheckBox)context.Cell; - private void listViewTransceiver_DoubleClick(object sender, EventArgs e) + if (!cell.Checked) + return; + + string plugin = gridPlugins[cell.Row.Index, 0].DisplayText; + + for (int row = 1; row < gridPlugins.RowsCount; row++) + { + SourceGrid.Cells.CheckBox checkBox = gridPlugins[row, 2] as SourceGrid.Cells.CheckBox; + if (checkBox != null && checkBox.Checked && !gridPlugins[row, 0].DisplayText.Equals(plugin, StringComparison.InvariantCultureIgnoreCase)) + checkBox.Checked = false; + } + } + private void PluginDoubleClick(object sender, EventArgs e) { - textBoxPlugin.Text = (sender as ListView).FocusedItem.Text; + SourceGrid.CellContext context = (SourceGrid.CellContext)sender; + SourceGrid.Cells.Cell cell = (SourceGrid.Cells.Cell)context.Cell; - foreach (IIRServerPlugin tx in _transceivers) - if (tx.Name == textBoxPlugin.Text) - buttonConfigureTransceiver.Enabled = tx.CanConfigure; + SourceGrid.Cells.CheckBox checkBoxReceive = gridPlugins[cell.Row.Index, 1] as SourceGrid.Cells.CheckBox; + if (checkBoxReceive != null) + checkBoxReceive.Checked = true; + + SourceGrid.Cells.CheckBox checkBoxTransmit = gridPlugins[cell.Row.Index, 2] as SourceGrid.Cells.CheckBox; + if (checkBoxTransmit != null) + checkBoxTransmit.Checked = true; } private void buttonHelp_Click(object sender, EventArgs e) @@ -185,23 +346,21 @@ } } - #endregion Controls - private void radioButtonServer_CheckedChanged(object sender, EventArgs e) { comboBoxComputer.Enabled = false; } - private void radioButtonRelay_CheckedChanged(object sender, EventArgs e) { comboBoxComputer.Enabled = true; } - private void radioButtonRepeater_CheckedChanged(object sender, EventArgs e) { comboBoxComputer.Enabled = true; } + #endregion Controls + } } Modified: trunk/plugins/IR Server Suite/Applications/IR Server/IR Server.csproj =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/IR Server.csproj 2007-06-10 08:51:02 UTC (rev 503) +++ trunk/plugins/IR Server Suite/Applications/IR Server/IR Server.csproj 2007-06-10 17:28:47 UTC (rev 504) @@ -57,6 +57,18 @@ </DocumentationFile> </PropertyGroup> <ItemGroup> + <Reference Include="DevAge.Core, Version=4.6.2660.128, Culture=neutral, PublicKeyToken=faad465d84242dbf, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>SourceGrid\DevAge.Core.dll</HintPath> + </Reference> + <Reference Include="DevAge.Windows.Forms, Version=4.6.2660.128, Culture=neutral, PublicKeyToken=faad465d84242dbf, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>SourceGrid\DevAge.Windows.Forms.dll</HintPath> + </Reference> + <Reference Include="SourceGrid, Version=4.7.2662.1973, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>SourceGrid\SourceGrid.dll</HintPath> + </Reference> <Reference Include="System" /> <Reference Include="System.Data" /> <Reference Include="System.Drawing" /> Modified: trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-06-10 08:51:02 UTC (rev 503) +++ trunk/plugins/IR Server Suite/Applications/IR Server/IRServer.cs 2007-06-10 17:28:47 UTC (rev 504) @@ -68,9 +68,12 @@ string _localPipeName = String.Empty; bool _registered = false; - string _pluginName = String.Empty; - IIRServerPlugin _plugin = null; + string _pluginNameReceive = String.Empty; + IIRServerPlugin _pluginReceive = null; + string _pluginNameTransmit = String.Empty; + IIRServerPlugin _pluginTransmit = null; + bool _inConfiguration = false; #endregion Variables @@ -86,8 +89,6 @@ _notifyIcon.ContextMenuStrip.Items.Add(new ToolStripMenuItem("&Quit", null, new EventHandler(ClickQuit))); _notifyIcon.Icon = Properties.Resources.Icon16; _notifyIcon.Text = "IR Server"; - - } #endregion Constructor @@ -97,30 +98,36 @@ /// <summary> /// Start the server /// </summary> - /// <returns>returns true if successful</returns> + /// <returns>success</returns> internal bool Start() { try { - IrssLog.Debug("Starting IR Server ..."); + IrssLog.Info("Starting IR Server ..."); LoadSettings(); - // Try to load the IR Plugin, if it fails (for whatever reason) then run configuration. - _plugin = null; - while (_plugin == null) + // Load IR Plugins ... + _pluginReceive = null; + _pluginTransmit = null; + + if (String.IsNullOrEmpty(_pluginNameReceive) && String.IsNullOrEmpty(_pluginNameTransmit)) { - _plugin = Program.GetPlugin(_pluginName); + IrssLog.Warn("No transmit/receive plugin loaded"); + } + else + { + if (!String.IsNullOrEmpty(_pluginNameReceive)) + _pluginReceive = Program.GetPlugin(_pluginNameReceive); + else + IrssLog.Warn("No receiver plugin loaded"); - if (_plugin == null) - { - IrssLog.Warn("Failed to load plugin \"{0}\"", _pluginName); - - if (Configure()) - SaveSettings(); - else - return false; - } + if (_pluginNameTransmit.Equals(_pluginNameReceive, StringComparison.InvariantCultureIgnoreCase)) + _pluginTransmit = _pluginReceive; + else if (!String.IsNullOrEmpty(_pluginNameTransmit)) + _pluginTransmit = Program.GetPlugin(_pluginNameTransmit); + else + IrssLog.Warn("No transmit plugin loaded"); } StartMessageQueue(); @@ -166,32 +173,39 @@ } } - // Start transceiver ... - if (!_plugin.Start()) + // Start plugin(s) ... + if (_pluginReceive != null) { - IrssLog.Error("Failed to start transceiver plugin: \"{0}\"", _pluginName); - - if (PipeAccess.ServerRunning) - PipeAccess.StopServer(); - return false; + if (_pluginReceive.Start()) + IrssLog.Info("Receiver plugin started: \"{0}\"", _pluginNameReceive); + else + IrssLog.Error("Failed to start receive plugin: \"{0}\"", _pluginNameReceive); } + if (!_pluginNameTransmit.Equals(_pluginNameReceive, StringComparison.InvariantCultureIgnoreCase)) + { + if (_pluginTransmit != null) + { + if (_pluginTransmit.Start()) + IrssLog.Info("Transmit plugin started: \"{0}\"", _pluginNameTransmit); + else + IrssLog.Error("Failed to start transmit plugin: \"{0}\"", _pluginNameTransmit); + } + } - IrssLog.Info("Transceiver plugin started: \"{0}\"", _pluginName); + if (_pluginReceive != null && _pluginReceive.CanReceive) + _pluginReceive.RemoteButtonCallback += new RemoteButtonHandler(RemoteButtonPressed); - if (_plugin.CanReceive) - _plugin.RemoteButtonCallback += new RemoteButtonHandler(RemoteButtonPressed); - _notifyIcon.Visible = true; IrssLog.Info("IR Server started"); + + return true; } catch (Exception ex) { IrssLog.Error(ex.ToString()); return false; } - - return true; } /// <summary> @@ -203,18 +217,28 @@ _notifyIcon.Visible = false; - if (_plugin.CanReceive) - _plugin.RemoteButtonCallback -= new RemoteButtonHandler(RemoteButtonPressed); + if (_pluginReceive != null && _pluginReceive.CanReceive) + _pluginReceive.RemoteButtonCallback -= new RemoteButtonHandler(RemoteButtonPressed); - // Stop Plugin + // Stop Plugin(s) try { - _plugin.Stop(); + if (_pluginReceive != null) + _pluginReceive.Stop(); } catch (Exception ex) { IrssLog.Error(ex.ToString()); } + try + { + if (_pluginTransmit != null) + _pluginTransmit.Stop(); + } + catch (Exception ex) + { + IrssLog.Error(ex.ToString()); + } // Stop Message Queue try @@ -257,18 +281,20 @@ try { - Config config = new Config(); - config.Mode = _mode; - config.HostComputer = _hostComputer; - config.Plugin = _pluginName; + Config config = new Config(); + config.Mode = _mode; + config.HostComputer = _hostComputer; + config.PluginReceive = _pluginNameReceive; + config.PluginTransmit = _pluginNameTransmit; if (config.ShowDialog() == DialogResult.OK) { - _mode = config.Mode; - _hostComputer = config.HostComputer; - _pluginName = config.Plugin; + _mode = config.Mode; + _hostComputer = config.HostComputer; + _pluginNameReceive = config.PluginReceive; + _pluginNameTransmit = config.PluginTransmit; - _inConfiguration = false; + _inConfiguration = false; return true; } @@ -726,16 +752,16 @@ { IrssLog.Debug("Blast IR"); - if (!_plugin.CanTransmit) + if (_pluginTransmit == null || !_pluginTransmit.CanTransmit) return false; int portLen = BitConverter.ToInt32(data, 0); if (portLen > 0) - _plugin.SetPort(Encoding.ASCII.GetString(data, 4, portLen)); + _pluginTransmit.SetPort(Encoding.ASCII.GetString(data, 4, portLen)); int speedLen = BitConverter.ToInt32(data, 4 + portLen); if (speedLen > 0) - _plugin.SetSpeed(Encoding.ASCII.GetString(data, 4 + portLen + 4, speedLen)); + _pluginTransmit.SetSpeed(Encoding.ASCII.GetString(data, 4 + portLen + 4, speedLen)); byte[] fileData = new byte[data.Length - (4 + portLen + 4 + speedLen)]; for (int index = (4 + portLen + 4 + speedLen); index < data.Length; index++) @@ -748,7 +774,7 @@ fileStream.Flush(); fileStream.Close(); - bool result = _plugin.Transmit(tempFile); + bool result = _pluginTransmit.Transmit(tempFile); File.Delete(tempFile); @@ -767,7 +793,7 @@ Thread.Sleep(500); - if (!_plugin.CanLearn) + if (_pluginTransmit == null || !_pluginTransmit.CanLearn) { IrssLog.Debug("Active transceiver doesn't support learn"); return null; @@ -780,7 +806,7 @@ { string tempFile = Path.GetTempFileName(); - LearnStatus status = _plugin.Learn(tempFile); + LearnStatus status = _pluginTransmit.Learn(tempFile); switch (status) { case LearnStatus.Success: @@ -948,16 +974,25 @@ { response.Name = received.Name + " Success"; - // Transceiver Info ... TransceiverInfo transceiverInfo = new TransceiverInfo(); - transceiverInfo.Name = _plugin.Name; - transceiverInfo.Ports = _plugin.AvailablePorts; - transceiverInfo.Speeds = _plugin.AvailableSpeeds; - transceiverInfo.CanConfigure = _plugin.CanConfigure; - transceiverInfo.CanLearn = _plugin.CanLearn; - transceiverInfo.CanReceive = _plugin.CanReceive; - transceiverInfo.CanTransmit = _plugin.CanTransmit; + if (_pluginReceive != null) + { + transceiverInfo.Name = _pluginReceive.Name; + transceiverInfo.CanReceive = _pluginReceive.CanReceive; + } + + if (_pluginTransmit != null) + { + if (String.IsNullOrEmpty(transceiverInfo.Name)) + transceiverInfo.Name = _pluginTransmit.Name; + + transceiverInfo.Ports = _pluginTransmit.AvailablePorts; + transceiverInfo.Speeds = _pluginTransmit.AvailableSpeeds; + transceiverInfo.CanLearn = _pluginTransmit.CanLearn; + transceiverInfo.CanTransmit = _pluginTransmit.CanTransmit; + } + response.Data = TransceiverInfo.ToBytes(transceiverInfo); } @@ -1032,13 +1067,13 @@ void ClickSetup(object sender, EventArgs e) { - IrssLog.Info("Setup"); - if (_inConfiguration) return; Stop(); + IrssLog.Info("Setup"); + if (Configure()) SaveSettings(); @@ -1046,11 +1081,11 @@ } void ClickQuit(object sender, EventArgs e) { - IrssLog.Info("Quit"); - if (_inConfiguration) return; + IrssLog.Info("Quit"); + if (_mode == IRServerMode.ServerMode) { PipeMessage message = new PipeMessage(Common.ServerPipeName, Environment.MachineName, "Server Shutdown", null); @@ -1068,17 +1103,19 @@ XmlDocument doc = new XmlDocument(); doc.Load(ConfigurationFile); - _mode = (IRServerMode)Enum.Parse(typeof(IRServerMode), doc.DocumentElement.Attributes["Mode"].Value); - _hostComputer = doc.DocumentElement.Attributes["HostComputer"].Value; - _pluginName = doc.DocumentElement.Attributes["Plugin"].Value; + _mode = (IRServerMode)Enum.Parse(typeof(IRServerMode), doc.DocumentElement.Attributes["Mode"].Value); + _hostComputer = doc.DocumentElement.Attributes["HostComputer"].Value; + _pluginNameReceive = doc.DocumentElement.Attributes["PluginReceive"].Value; + _pluginNameTransmit = doc.DocumentElement.Attributes["PluginTransmit"].Value; } catch (Exception ex) { IrssLog.Error(ex.ToString()); - _mode = IRServerMode.ServerMode; - _hostComputer = String.Empty; - _pluginName = String.Empty; + _mode = IRServerMode.ServerMode; + _hostComputer = String.Empty; + _pluginNameReceive = String.Empty; + _pluginNameTransmit = String.Empty; } } void SaveSettings() @@ -1094,7 +1131,8 @@ writer.WriteAttributeString("Mode", Enum.GetName(typeof(IRServerMode), _mode)); writer.WriteAttributeString("HostComputer", _hostComputer); - writer.WriteAttributeString("Plugin", _pluginName); + writer.WriteAttributeString("PluginReceive", _pluginNameReceive); + writer.WriteAttributeString("PluginTransmit", _pluginNameTransmit); writer.WriteEndElement(); // </settings> writer.WriteEndDocument(); Modified: trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs =================================================================== --- trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2007-06-10 08:51:02 UTC (rev 503) +++ trunk/plugins/IR Server Suite/Applications/IR Server/Program.cs 2007-06-10 17:28:47 UTC (rev 504) @@ -17,7 +17,7 @@ { [STAThread] - static int Main() + static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); @@ -26,12 +26,12 @@ try { if (Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName).Length != 1) - return 1; + return; } catch (Exception ex) { Console.WriteLine(ex.Message); - return 1; + return; } // Open log file @@ -46,27 +46,17 @@ catch (Exception ex) { Console.WriteLine(ex.Message); - return 1; + return; } // Start Server IRServer irServer = new IRServer(); if (irServer.Start()) - { Application.Run(); - IrssLog.Close(); - return 0; - } - else - { - MessageBox.Show("Failed to start IR Server, refer to log file for more details.", "IR Server", MessageBoxButtons.OK, MessageBoxIcon.Error); - - IrssLog.Close(); - return 1; - } - + IrssLog.Close(); + return; } /// <summary> Modified: trunk/plugins/IR Server Suite/Common/IrssUtils/TransceiverInfo.cs =================================================================== --- trunk/plugins/IR Server Suite/Common/IrssUtils/TransceiverInfo.cs 2007-06-10 08:51:02 UTC (rev 503) +++ trunk/plugins/IR Server Suite/Common/IrssUtils/TransceiverInfo.cs 2007-06-10 17:28:47 UTC (rev 504) @@ -17,7 +17,6 @@ string[] _speeds; string _name; - bool _canConfigure; bool _canLearn; bool _canReceive; bool _canTransmit; @@ -54,15 +53,6 @@ } /// <summary> - /// Can this transceiver be configured. - /// </summary> - public bool CanConfigure - { - get { return _canConfigure; } - set { _canConfigure = value; } - } - - /// <summary> /// Can this transceiver learn IR Commands. /// </summary> public bool CanLearn @@ -98,8 +88,7 @@ _ports = new string[] { "None" }; _speeds = new string[] { "None" }; - _name = "Unknown"; - _canConfigure = false; + _name = String.Empty; _canLearn = false; _canReceive = false; _canTransmit = false; @@ -136,16 +125,15 @@ speeds.Append(','); } - string data = String.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", + string data = String.Format("{0},{1},{2},{3},{4},{5},{6},{7}", transceiverInfo.Name, // 0 - transceiverInfo.CanConfigure, // 1 - transceiverInfo.CanLearn, // 2 - transceiverInfo.CanReceive, // 3 - transceiverInfo.CanTransmit, // 4 - transceiverInfo.Ports.Length, // 5 - ports.ToString(), // 6 - transceiverInfo.Speeds.Length, // 7 - speeds.ToString() // 8 + transceiverInfo.CanLearn, // 1 + transceiverInfo.CanReceive, // 2 + transceiverInfo.CanTransmit, // 3 + transceiverInfo.Ports.Length, // 4 + ports.ToString(), // 5 + transceiverInfo.Speeds.Length, // 6 + speeds.ToString() // 7 ); return Encoding.ASCII.GetBytes(data); @@ -171,14 +159,13 @@ TransceiverInfo transceiverInfo = new TransceiverInfo(); transceiverInfo.Name = data[0]; - transceiverInfo.CanConfigure = bool.Parse(data[1]); - transceiverInfo.CanLearn = bool.Parse(data[2]); - transceiverInfo.CanReceive = bool.Parse(data[3]); - transceiverInfo.CanTransmit = bool.Parse(data[4]); + transceiverInfo.CanLearn = bool.Parse(data[1]); + transceiverInfo.CanReceive = bool.Parse(data[2]); + transceiverInfo.CanTransmit = bool.Parse(data[3]); int index; - int portIndex = 5; + int portIndex = 4; int portCount = int.Parse(data[portIndex]); transceiverInfo.Ports = new string[portCount]; for (index = portIndex + 1; index <= portIndex + portCount; index++) Modified: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLirc Receiver.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLirc Receiver.cs 2007-06-10 08:51:02 UTC (rev 503) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLirc Receiver.cs 2007-06-10 17:28:47 UTC (rev 504) @@ -105,9 +105,35 @@ _server.CommandEvent -= new WinLircServer.CommandEventHandler(CommandHandler); } - public bool Transmit(string file) { return false; } - public LearnStatus Learn(string file) { return LearnStatus.Failure; } + public bool Transmit(string file) + { + string password, remoteName, buttonName, repeats; + try + { + XmlDocument doc = new XmlDocument(); + doc.Load(file); + + password = doc.DocumentElement.Attributes["Password"].Value; + remoteName = doc.DocumentElement.Attributes["RemoteName"].Value; + buttonName = doc.DocumentElement.Attributes["ButtonName"].Value; + repeats = doc.DocumentElement.Attributes["Repeats"].Value; + + string output = String.Format("{0} {1} {2} {3}\n", password, remoteName, buttonName, repeats); + _server.Transmit(output); + + return true; + } + catch + { + return false; + } + } + public LearnStatus Learn(string file) + { + return LearnStatus.Failure; + } + public bool SetPort(string port) { return true; } public bool SetSpeed(string speed) { return true; } Modified: trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLircServer.cs =================================================================== --- trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLircServer.cs 2007-06-10 08:51:02 UTC (rev 503) +++ trunk/plugins/IR Server Suite/IR Server Plugins/WinLirc Receiver/WinLircServer.cs 2007-06-10 17:28:47 UTC (rev 504) @@ -33,6 +33,7 @@ namespace WinLircReceiver { + /// <summary> /// WinLIRC server class implementing communication with WinLIRC /// all remotes are supported as long as WinLIRC supports them @@ -115,6 +116,11 @@ return (processes.Length > 0); } + public void Transmit(string transmit) + { + _socket.Send(Encoding.ASCII.GetBytes(transmit)); + } + #endregion #region Private Methods @@ -223,4 +229,5 @@ } #endregion } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |