From: <an...@us...> - 2007-02-13 15:51:18
|
Revision: 117 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=117&view=rev Author: and-81 Date: 2007-02-13 07:50:16 -0800 (Tue, 13 Feb 2007) Log Message: ----------- Modified Paths: -------------- trunk/plugins/TV3MceBlaster/ExternalChannelConfig.cs trunk/plugins/TV3MceBlaster/Forms/ExternalChannels.cs trunk/plugins/TV3MceBlaster/Forms/ExternalChannels.designer.cs trunk/plugins/TV3MceBlaster/Forms/PluginSetup.cs trunk/plugins/TV3MceBlaster/Forms/StbSetup.Designer.cs trunk/plugins/TV3MceBlaster/Forms/StbSetup.cs trunk/plugins/TV3MceBlaster/TV3MceBlaster.cs Modified: trunk/plugins/TV3MceBlaster/ExternalChannelConfig.cs =================================================================== --- trunk/plugins/TV3MceBlaster/ExternalChannelConfig.cs 2007-02-13 13:29:30 UTC (rev 116) +++ trunk/plugins/TV3MceBlaster/ExternalChannelConfig.cs 2007-02-13 15:50:16 UTC (rev 117) @@ -16,6 +16,8 @@ string _fileName; + int _cardID = -1; + int _pauseTime = 250; bool _sendSelect = false; MceIrApi.BlasterPort _extBlastPort = MceIrApi.BlasterPort.Both; @@ -39,6 +41,12 @@ get { return _fileName; } } + public int CardId + { + get { return _cardID; } + set { _cardID = value; } + } + public int PauseTime { get { return _pauseTime; } @@ -105,10 +113,12 @@ #region Constructor - public ExternalChannelConfig(string fileName) + public ExternalChannelConfig(int cardId, string fileName) { _fileName = fileName; + _cardID = cardId; + if (!File.Exists(_fileName)) { for (int i = 0; i < 10; i++) Modified: trunk/plugins/TV3MceBlaster/Forms/ExternalChannels.cs =================================================================== --- trunk/plugins/TV3MceBlaster/Forms/ExternalChannels.cs 2007-02-13 13:29:30 UTC (rev 116) +++ trunk/plugins/TV3MceBlaster/Forms/ExternalChannels.cs 2007-02-13 15:50:16 UTC (rev 117) @@ -19,7 +19,6 @@ #region Variables - TabPage[] _tvCardTabs; StbSetup[] _tvCardStbSetups; #endregion Variables @@ -35,31 +34,30 @@ private void ExternalChannels_Load(object sender, EventArgs e) { - int cards = TV3MceBlaster.ExternalChannelConfigs.Length; - string cardName; - string cardNumber; + IList cards = TvDatabase.Card.ListAll(); - _tvCardTabs = new TabPage[cards]; - _tvCardStbSetups = new StbSetup[cards]; + _tvCardStbSetups = new StbSetup[cards.Count]; comboBoxCopyFrom.Items.Clear(); - for (int index = 0; index < cards; index++) + TabPage tempPage; + int index = 0; + + foreach (TvDatabase.Card card in cards) { - cardNumber = (index + 1).ToString(); - cardName = "TV Card " + cardNumber; + comboBoxCopyFrom.Items.Add(card.IdCard); - comboBoxCopyFrom.Items.Add(cardName); - - _tvCardStbSetups[index] = new StbSetup(index); - _tvCardStbSetups[index].Name = "StbSetup" + cardNumber; + _tvCardStbSetups[index] = new StbSetup(card.IdCard); + _tvCardStbSetups[index].Name = string.Format("StbSetup{0}", index); _tvCardStbSetups[index].Dock = DockStyle.Fill; _tvCardStbSetups[index].TabIndex = 0; - _tvCardTabs[index] = new TabPage(cardName); - _tvCardTabs[index].Controls.Add(_tvCardStbSetups[index]); + tempPage = new TabPage(string.Format("TV Card {0}", index + 1)); + tempPage.Controls.Add(_tvCardStbSetups[index]); - this.tabControlTVCards.TabPages.Add(_tvCardTabs[index]); + this.tabControlTVCards.TabPages.Add(tempPage); + + index++; } comboBoxCopyFrom.SelectedIndex = 0; @@ -106,11 +104,11 @@ private void buttonOK_Click(object sender, EventArgs e) { foreach (StbSetup setup in _tvCardStbSetups) + { setup.Save(); + TV3MceBlaster.GetExternalChannelConfig(setup.CardId).SaveExternalChannelConfig(); + } - foreach (ExternalChannelConfig config in TV3MceBlaster.ExternalChannelConfigs) - config.SaveExternalChannelConfig(); - this.DialogResult = DialogResult.OK; this.Close(); } @@ -241,7 +239,7 @@ private void buttonCopyFrom_Click(object sender, EventArgs e) { - _tvCardStbSetups[tabControlTVCards.SelectedIndex].SetToCard(comboBoxCopyFrom.SelectedIndex); + _tvCardStbSetups[tabControlTVCards.SelectedIndex].SetToCard((int)comboBoxCopyFrom.SelectedItem); } private void buttonCancel_Click(object sender, EventArgs e) Modified: trunk/plugins/TV3MceBlaster/Forms/ExternalChannels.designer.cs =================================================================== --- trunk/plugins/TV3MceBlaster/Forms/ExternalChannels.designer.cs 2007-02-13 13:29:30 UTC (rev 116) +++ trunk/plugins/TV3MceBlaster/Forms/ExternalChannels.designer.cs 2007-02-13 15:50:16 UTC (rev 117) @@ -48,7 +48,7 @@ // buttonOK // this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.buttonOK.Location = new System.Drawing.Point(400, 408); + this.buttonOK.Location = new System.Drawing.Point(400, 416); this.buttonOK.Name = "buttonOK"; this.buttonOK.Size = new System.Drawing.Size(56, 24); this.buttonOK.TabIndex = 5; @@ -62,7 +62,7 @@ | System.Windows.Forms.AnchorStyles.Right))); this.groupBoxQuickSetup.Controls.Add(this.buttonQuickSet); this.groupBoxQuickSetup.Controls.Add(this.comboBoxQuickSetup); - this.groupBoxQuickSetup.Location = new System.Drawing.Point(8, 352); + this.groupBoxQuickSetup.Location = new System.Drawing.Point(8, 360); this.groupBoxQuickSetup.Name = "groupBoxQuickSetup"; this.groupBoxQuickSetup.Size = new System.Drawing.Size(288, 48); this.groupBoxQuickSetup.TabIndex = 1; @@ -97,7 +97,7 @@ this.groupBoxTest.Controls.Add(this.labelCh); this.groupBoxTest.Controls.Add(this.buttonTest); this.groupBoxTest.Controls.Add(this.numericUpDownTest); - this.groupBoxTest.Location = new System.Drawing.Point(304, 352); + this.groupBoxTest.Location = new System.Drawing.Point(304, 360); this.groupBoxTest.Name = "groupBoxTest"; this.groupBoxTest.Size = new System.Drawing.Size(216, 48); this.groupBoxTest.TabIndex = 2; @@ -144,7 +144,7 @@ // buttonCopyFrom // this.buttonCopyFrom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.buttonCopyFrom.Location = new System.Drawing.Point(8, 408); + this.buttonCopyFrom.Location = new System.Drawing.Point(8, 416); this.buttonCopyFrom.Name = "buttonCopyFrom"; this.buttonCopyFrom.Size = new System.Drawing.Size(144, 21); this.buttonCopyFrom.TabIndex = 3; @@ -157,7 +157,7 @@ this.comboBoxCopyFrom.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.comboBoxCopyFrom.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxCopyFrom.FormattingEnabled = true; - this.comboBoxCopyFrom.Location = new System.Drawing.Point(160, 408); + this.comboBoxCopyFrom.Location = new System.Drawing.Point(160, 416); this.comboBoxCopyFrom.Name = "comboBoxCopyFrom"; this.comboBoxCopyFrom.Size = new System.Drawing.Size(120, 21); this.comboBoxCopyFrom.TabIndex = 4; @@ -170,14 +170,14 @@ this.tabControlTVCards.Location = new System.Drawing.Point(8, 8); this.tabControlTVCards.Name = "tabControlTVCards"; this.tabControlTVCards.SelectedIndex = 0; - this.tabControlTVCards.Size = new System.Drawing.Size(512, 336); + this.tabControlTVCards.Size = new System.Drawing.Size(512, 344); this.tabControlTVCards.TabIndex = 0; // // buttonCancel // this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; - this.buttonCancel.Location = new System.Drawing.Point(464, 408); + this.buttonCancel.Location = new System.Drawing.Point(464, 416); this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Size = new System.Drawing.Size(56, 24); this.buttonCancel.TabIndex = 6; @@ -191,7 +191,7 @@ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.CancelButton = this.buttonCancel; - this.ClientSize = new System.Drawing.Size(528, 439); + this.ClientSize = new System.Drawing.Size(528, 447); this.Controls.Add(this.buttonCancel); this.Controls.Add(this.tabControlTVCards); this.Controls.Add(this.comboBoxCopyFrom); @@ -200,7 +200,7 @@ this.Controls.Add(this.groupBoxQuickSetup); this.Controls.Add(this.buttonOK); this.MinimizeBox = false; - this.MinimumSize = new System.Drawing.Size(536, 466); + this.MinimumSize = new System.Drawing.Size(536, 474); this.Name = "ExternalChannels"; this.ShowIcon = false; this.ShowInTaskbar = false; Modified: trunk/plugins/TV3MceBlaster/Forms/PluginSetup.cs =================================================================== --- trunk/plugins/TV3MceBlaster/Forms/PluginSetup.cs 2007-02-13 13:29:30 UTC (rev 116) +++ trunk/plugins/TV3MceBlaster/Forms/PluginSetup.cs 2007-02-13 15:50:16 UTC (rev 117) @@ -94,8 +94,7 @@ TV3MceBlaster.InConfiguration = true; - if (TV3MceBlaster.ExternalChannelConfigs == null) - TV3MceBlaster.LoadExternalConfigs(); + TV3MceBlaster.LoadExternalConfigs(); base.OnSectionActivated(); } @@ -154,8 +153,15 @@ private void buttonSTB_Click(object sender, EventArgs e) { - ExternalChannels externalChannels = new ExternalChannels(); - externalChannels.ShowDialog(this); + if (TvDatabase.Card.ListAll().Count == 0) + { + MessageBox.Show(this, "There are no capture cards installed in the TV server", "No TV Cards", MessageBoxButtons.OK, MessageBoxIcon.Stop); + } + else + { + ExternalChannels externalChannels = new ExternalChannels(); + externalChannels.ShowDialog(this); + } } private void buttonNewIR_Click(object sender, EventArgs e) Modified: trunk/plugins/TV3MceBlaster/Forms/StbSetup.Designer.cs =================================================================== --- trunk/plugins/TV3MceBlaster/Forms/StbSetup.Designer.cs 2007-02-13 13:29:30 UTC (rev 116) +++ trunk/plugins/TV3MceBlaster/Forms/StbSetup.Designer.cs 2007-02-13 15:50:16 UTC (rev 117) @@ -50,6 +50,7 @@ this.listViewExternalCommands = new System.Windows.Forms.ListView(); this.columnHeaderExternal = new System.Windows.Forms.ColumnHeader(); this.columnHeaderCommand = new System.Windows.Forms.ColumnHeader(); + this.labelCardName = new System.Windows.Forms.Label(); this.groupBoxOptions.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRepeatDelay)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPauseTime)).BeginInit(); @@ -76,7 +77,7 @@ this.groupBoxOptions.Controls.Add(this.comboBoxBlasterPort); this.groupBoxOptions.Controls.Add(this.labelMS); this.groupBoxOptions.Controls.Add(this.checkBoxSendSelect); - this.groupBoxOptions.Location = new System.Drawing.Point(296, 8); + this.groupBoxOptions.Location = new System.Drawing.Point(296, 16); this.groupBoxOptions.Name = "groupBoxOptions"; this.groupBoxOptions.Size = new System.Drawing.Size(200, 296); this.groupBoxOptions.TabIndex = 1; @@ -265,7 +266,7 @@ this.groupBoxCommands.Controls.Add(this.buttonSet); this.groupBoxCommands.Controls.Add(this.comboBoxCommands); this.groupBoxCommands.Controls.Add(this.listViewExternalCommands); - this.groupBoxCommands.Location = new System.Drawing.Point(8, 8); + this.groupBoxCommands.Location = new System.Drawing.Point(8, 16); this.groupBoxCommands.Name = "groupBoxCommands"; this.groupBoxCommands.Size = new System.Drawing.Size(280, 296); this.groupBoxCommands.TabIndex = 0; @@ -324,15 +325,27 @@ this.columnHeaderCommand.Text = "Command"; this.columnHeaderCommand.Width = 170; // + // labelCardName + // + this.labelCardName.Dock = System.Windows.Forms.DockStyle.Top; + this.labelCardName.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.labelCardName.Location = new System.Drawing.Point(0, 0); + this.labelCardName.Name = "labelCardName"; + this.labelCardName.Size = new System.Drawing.Size(504, 16); + this.labelCardName.TabIndex = 2; + this.labelCardName.Text = "Unknown TV Card"; + this.labelCardName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + // // StbSetup // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.labelCardName); this.Controls.Add(this.groupBoxOptions); this.Controls.Add(this.groupBoxCommands); this.MinimumSize = new System.Drawing.Size(504, 310); this.Name = "StbSetup"; - this.Size = new System.Drawing.Size(504, 310); + this.Size = new System.Drawing.Size(504, 318); this.groupBoxOptions.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownRepeatDelay)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.numericUpDownPauseTime)).EndInit(); @@ -366,5 +379,6 @@ private System.Windows.Forms.ColumnHeader columnHeaderCommand; private System.Windows.Forms.Label labelBlasterSpeed; private System.Windows.Forms.ComboBox comboBoxBlasterSpeed; + private System.Windows.Forms.Label labelCardName; } } Modified: trunk/plugins/TV3MceBlaster/Forms/StbSetup.cs =================================================================== --- trunk/plugins/TV3MceBlaster/Forms/StbSetup.cs 2007-02-13 13:29:30 UTC (rev 116) +++ trunk/plugins/TV3MceBlaster/Forms/StbSetup.cs 2007-02-13 15:50:16 UTC (rev 117) @@ -16,8 +16,28 @@ public partial class StbSetup : UserControl { + #region Constants + + const string parameterInfo = +@"%1 = Current channel number digit (-1 for Select/Pre-Change) +%2 = Full channel number string +%3 = Blaster port (0 = Both, 1 = Port 1, 2 = Port 2)"; + + #endregion Constants + + #region Variables + + int _cardId; + + #endregion Variables + #region Properties + public int CardId + { + get { return _cardId; } + } + public int PauseTime { get { return Decimal.ToInt32(numericUpDownPauseTime.Value); } @@ -82,25 +102,25 @@ #endregion Properties - #region Variables - - const string parameterInfo = -@"%1 = Current channel number digit (-1 for Select/Pre-Change) -%2 = Full channel number string -%3 = Blaster port (0 = Both, 1 = Port 1, 2 = Port 2)"; - - int _card; - - #endregion Variables - #region Constructor - public StbSetup(int card) + public StbSetup(int cardId) { InitializeComponent(); - _card = card; + _cardId = cardId; + foreach (TvDatabase.Card card in TvDatabase.Card.ListAll()) + { + if (card.IdCard == _cardId) + { + labelCardName.Text = card.Name; + if (!card.Enabled) + labelCardName.Text += " (Disabled)"; + break; + } + } + // Setup commands combo box comboBoxCommands.Items.Add("Run Program"); comboBoxCommands.Items.Add("Serial Command"); @@ -133,17 +153,20 @@ item = new ListViewItem(subItems); listViewExternalCommands.Items.Add(item); - SetToCard(_card); + SetToCard(_cardId); } #endregion Constructor #region Public Methods - public void SetToCard(int card) + public void SetToCard(int cardId) { - ExternalChannelConfig config = TV3MceBlaster.ExternalChannelConfigs[card]; + ExternalChannelConfig config = TV3MceBlaster.GetExternalChannelConfig(cardId); + if (config == null) + return; + // Setup command list. for (int i = 0; i < 10; i++) listViewExternalCommands.Items[i].SubItems[1].Text = config.Digits[i]; @@ -173,10 +196,12 @@ numericUpDownRepeatDelay.Value = new Decimal(config.RepeatPauseTime); } - public void SetToConfig(int card) + public void SetToConfig(int cardId) { - ExternalChannelConfig config = TV3MceBlaster.ExternalChannelConfigs[card]; + ExternalChannelConfig config = TV3MceBlaster.GetExternalChannelConfig(cardId); + config.CardId = cardId; + config.PauseTime = Decimal.ToInt32(numericUpDownPauseTime.Value); config.SendSelect = checkBoxSendSelect.Checked; config.ExtBlastPort = (MceIrApi.BlasterPort)Enum.Parse(typeof(MceIrApi.BlasterPort), (string)comboBoxBlasterPort.SelectedItem); @@ -273,7 +298,7 @@ public void Save() { - SetToConfig(_card); + SetToConfig(_cardId); } #endregion Public Methods Modified: trunk/plugins/TV3MceBlaster/TV3MceBlaster.cs =================================================================== --- trunk/plugins/TV3MceBlaster/TV3MceBlaster.cs 2007-02-13 13:29:30 UTC (rev 116) +++ trunk/plugins/TV3MceBlaster/TV3MceBlaster.cs 2007-02-13 15:50:16 UTC (rev 117) @@ -105,11 +105,6 @@ set { _logVerbose = value; } } - public static ExternalChannelConfig[] ExternalChannelConfigs - { - get { return _externalChannelConfigs; } - } - public static bool InConfiguration { get { return _inConfiguration; } @@ -163,7 +158,7 @@ if (analogChannel == null) return; - + if (tvEvent.EventType == TvServerEventType.StartZapChannel) { if (LogVerbose) @@ -173,13 +168,13 @@ } } - static bool ProcessExternalChannel(string externalChannel, int card) + static bool ProcessExternalChannel(string externalChannel, int cardId) { bool returnCode = true; try { - ExternalChannelConfig config = ExternalChannelConfigs[card - 1]; + ExternalChannelConfig config = GetExternalChannelConfig(cardId); // Clean up the "externalChannel" string into "channel". StringBuilder channel = new StringBuilder(); @@ -539,18 +534,38 @@ /// </summary> public static void LoadExternalConfigs() { - int cardCount = TvDatabase.Card.ListAll().Count; + IList cards = TvDatabase.Card.ListAll(); - if (cardCount == 0) - cardCount = 1; + if (cards.Count == 0) + return; - _externalChannelConfigs = new ExternalChannelConfig[cardCount]; + _externalChannelConfigs = new ExternalChannelConfig[cards.Count]; - for (int index = 0; index < cardCount; index++) - ExternalChannelConfigs[index] = new ExternalChannelConfig(AppDataFolder + "ExternalChannelConfig" + (index + 1).ToString() + ".xml"); + int index = 0; + foreach (TvDatabase.Card card in cards) + { + _externalChannelConfigs[index++] = new ExternalChannelConfig(card.IdCard, string.Format("{0}ExternalChannelConfig{1}.xml", AppDataFolder, card.IdCard)); + } } /// <summary> + /// Given a card ID returns the configuration for that card. + /// </summary> + /// <param name="cardId">ID of card to retreive configuration for.</param> + /// <returns>Card configuration, null if it doesn't exist.</returns> + public static ExternalChannelConfig GetExternalChannelConfig(int cardId) + { + if (_externalChannelConfigs == null) + return null; + + foreach (ExternalChannelConfig config in _externalChannelConfigs) + if (config.CardId == cardId) + return config; + + return null; + } + + /// <summary> /// Splits a Run command into it's component parts. /// </summary> /// <param name="runCommand">The command to be split</param> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |