/// <summary> /// Loads the specified file into a new instance of <see cref="ExternalChannelConfig"/> class. /// </summary> /// <param name="fileName">Name of the file to load.</param> /// <returns>A new <see cref="ExternalChannelConfig"/> class instance.</returns> public static ExternalChannelConfig Load(string fileName) { ExternalChannelConfig newECC = new ExternalChannelConfig(fileName); XmlDocument doc = new XmlDocument(); doc.Load(fileName); newECC.PauseTime = GetInt(doc, "PauseTime", DefaultPauseTime); newECC.UsePreChangeCommand = GetBool(doc, "UsePreChangeCommand", DefaultUsePreChangeCommand); newECC.SendSelect = GetBool(doc, "SendSelect", DefaultSendSelect); newECC.DoubleChannelSelect = GetBool(doc, "DoubleChannelSelect", DefaultDoubleChannelSelect); newECC.RepeatChannelCommands = GetInt(doc, "RepeatChannelCommands", DefaultRepeatChannelCommands); newECC.ChannelDigits = GetInt(doc, "ChannelDigits", DefaultChannelDigits); newECC.RepeatPauseTime = GetInt(doc, "RepeatDelay", DefaultRepeatPauseTime); newECC.SelectCommand = GetString(doc, "SelectCommand", String.Empty); newECC.PreChangeCommand = GetString(doc, "PreChangeCommand", String.Empty); for (int index = 0; index < 10; index++) { newECC.Digits[index] = GetString(doc, "Digit" + index, String.Empty); } return(newECC); }
/// <summary> /// Load external channel configurations. /// </summary> private static void LoadExternalConfigs() { ArrayList cards = new ArrayList(); TVDatabase.GetCards(ref cards); if (cards.Count == 0) { Log.Warn("TV2BlasterPlugin: Cannot load external channel configurations, there are no TV cards registered"); cards.Add(0); } _externalChannelConfigs = new ExternalChannelConfig[cards.Count]; int index = 0; foreach (int cardId in cards) { string fileName = Path.Combine(ExtCfgFolder, String.Format("ExternalChannelConfig{0}.xml", cardId)); try { _externalChannelConfigs[index] = ExternalChannelConfig.Load(fileName); } catch (Exception ex) { Log.Error(ex); _externalChannelConfigs[index] = new ExternalChannelConfig(fileName); } _externalChannelConfigs[index].CardId = cardId; index++; } }
/// <summary> /// Loads the specified file into a new instance of <see cref="ExternalChannelConfig"/> class. /// </summary> /// <param name="fileName">Name of the file to load.</param> /// <returns>A new <see cref="ExternalChannelConfig"/> class instance.</returns> public static ExternalChannelConfig Load(string fileName) { ExternalChannelConfig newECC = new ExternalChannelConfig(fileName); XmlDocument doc = new XmlDocument(); doc.Load(fileName); newECC.PauseTime = GetInt(doc, "PauseTime", DefaultPauseTime); newECC.UsePreChangeCommand = GetBool(doc, "UsePreChangeCommand", DefaultUsePreChangeCommand); newECC.SendSelect = GetBool(doc, "SendSelect", DefaultSendSelect); newECC.DoubleChannelSelect = GetBool(doc, "DoubleChannelSelect", DefaultDoubleChannelSelect); newECC.RepeatChannelCommands = GetInt(doc, "RepeatChannelCommands", DefaultRepeatChannelCommands); newECC.ChannelDigits = GetInt(doc, "ChannelDigits", DefaultChannelDigits); newECC.RepeatPauseTime = GetInt(doc, "RepeatDelay", DefaultRepeatPauseTime); newECC.SelectCommand = GetString(doc, "SelectCommand", String.Empty); newECC.PreChangeCommand = GetString(doc, "PreChangeCommand", String.Empty); for (int index = 0; index < 10; index++) newECC.Digits[index] = GetString(doc, "Digit" + index, String.Empty); return newECC; }
/// <summary> /// Load external channel configurations. /// </summary> internal static void LoadExternalConfigs() { IList<Card> cards = Card.ListAll(); if (cards.Count == 0) { Log.Info("Cannot load external channel configurations, there are no TV cards registered"); Card dummyCard = new Card(0, "device path", "Dummy TV Card", 0, false, DateTime.Now, "recording folder", 0, false, 0, "timeshifting folder", 0, 0, 0); cards.Add(dummyCard); } _externalChannelConfigs = new ExternalChannelConfig[cards.Count]; int index = 0; foreach (Card card in cards) { string fileName = Path.Combine(ExtCfgFolder, String.Format("ExternalChannelConfig{0}.xml", card.IdCard)); try { _externalChannelConfigs[index] = ExternalChannelConfig.Load(fileName); } catch (Exception ex) { _externalChannelConfigs[index] = new ExternalChannelConfig(fileName); Log.Error(ex.ToString()); } _externalChannelConfigs[index].CardId = card.IdCard; index++; } }