/// <summary> /// Fill listview with data of a non channel file /// Disable Drag and Drop and the connext menu /// </summary> /// <param name="otherFile">Other file</param> public void WriteOtherFile(OtherFile otherFile) { _currentMapFile = null; try { listView1.BeginUpdate(); CreateOtherFileListView(otherFile); _isChannelFile = false; DataTable dt = otherFile.DataTable; foreach (DataRow dr in dt.Rows) { var lvi = new ListViewItem(dr[0].ToString()); for (var i = 1; i < dt.Columns.Count; i++) lvi.SubItems.Add(dr[i].ToString()); listView1.Items.Add(lvi); } } finally { listView1.EndUpdate(); } }
/// <summary> /// Fill listview with Map file channels. /// Enable to Drag and Drop List View items and the connext menu /// </summary> /// <param name="mapFile">Map file</param> public void WriteChannelsMapFile(MapFile mapFile) { const string NUMBER_FORMAT = "X4"; _currentMapFile = mapFile; var channels = mapFile.Channels; var showExtra = ((mapFile.MapType != SCMFileContentType.mapAirA) && (mapFile.MapType != SCMFileContentType.mapCableA)); channels.SortByChanelNum(); try { listView1.BeginUpdate(); CreateChannelListView(showExtra); _isChannelFile = true; for (var i = 0; i < mapFile.Channels.Count; i++) { var ch = channels[i]; if (!ch.IsOk()) { continue; } ListViewItem lvi = new ListViewItem(ch.Number.ToString(CultureInfo.InvariantCulture)); // # lvi.Name = ch.Name; lvi.SubItems.Add(ch.Name); // Name lvi.SubItems.Add(ch.ChannelType); // Type lvi.SubItems.Add(ch.IsEncrypted ? "S" : ""); // Enc if (showExtra) { lvi.SubItems.Add(ch.Locked ? "1" : string.Empty); lvi.SubItems.Add(ch.Frequency.ToString(CultureInfo.InvariantCulture)); // Freq lvi.SubItems.Add(ch.ServiceID.ToString(NUMBER_FORMAT)); // sid lvi.SubItems.Add(ch.Multiplex_TSID.ToString(NUMBER_FORMAT)); // tsid lvi.SubItems.Add(ch.Multiplex_ONID.ToString(NUMBER_FORMAT)); // onid lvi.SubItems.Add(ch.Network.ToString(NUMBER_FORMAT)); // net lvi.SubItems.Add(ch.FavoriteList1 ? "1" : string.Empty); lvi.SubItems.Add(ch.FavoriteList2 ? "1" : string.Empty); lvi.SubItems.Add(ch.FavoriteList3 ? "1" : string.Empty); lvi.SubItems.Add(ch.FavoriteList4 ? "1" : string.Empty); } #if DEBUG lvi.SubItems.Add(ch.FilePosition.ToString(CultureInfo.InvariantCulture)); // Position inside channel file #endif lvi.Checked = !ch.Deleted; lvi.Tag = ch; // Store channel object in each item lvi.Font = ch.Deleted ? _deletedItemFont : _normalItemFont; listView1.Items.Add(lvi); } } finally { listView1.EndUpdate(); } channels.SortByFilePosition(); }
public void Clear() { listView1.Items.Clear(); _currentMapFile = null; _isChannelFile = false; }
public MapFile GetMapFile(string filename) { MapFile mapFile = null; var filetype = GetFileType(filename); if (LOG.IsInfoEnabled) LOG.Debug("Get MapFile " + filetype); if (_mapfiles.ContainsKey(filetype)) mapFile = _mapfiles[filetype]; else { if (filetype != SCMFileContentType.unknown) mapFile = new MapFile(filename, filetype); if (mapFile != null) { mapFile.ReadFrom(_tempDirectory); _mapfiles.Add(filetype, mapFile); } } return mapFile; }
/// <summary> /// Fill listview with Map file channels. /// Enable to Drag and Drop List View items and the connext menu /// </summary> /// <param name="mapFile">Map file</param> public void WriteChannelsMapFile(MapFile mapFile) { const string NUMBER_FORMAT = "X4"; _currentMapFile = mapFile; var channels = mapFile.Channels; var showExtra = ((mapFile.MapType != SCMFileContentType.mapAirA) && (mapFile.MapType != SCMFileContentType.mapCableA)); channels.SortByChanelNum(); try { listView1.BeginUpdate(); CreateChannelListView(showExtra); _isChannelFile = true; for (var i = 0; i < mapFile.Channels.Count; i++) { var ch = channels[i]; if (!ch.IsOk()) continue; ListViewItem lvi = new ListViewItem(ch.Number.ToString(CultureInfo.InvariantCulture)); // # lvi.Name = ch.Name; lvi.SubItems.Add(ch.Name); // Name lvi.SubItems.Add(ch.ChannelType); // Type lvi.SubItems.Add(ch.IsEncrypted ? "S" : ""); // Enc if (showExtra) { lvi.SubItems.Add(ch.Locked ? "1" : string.Empty); lvi.SubItems.Add(ch.Frequency.ToString(CultureInfo.InvariantCulture)); // Freq lvi.SubItems.Add(ch.ServiceID.ToString(NUMBER_FORMAT)); // sid lvi.SubItems.Add(ch.Multiplex_TSID.ToString(NUMBER_FORMAT)); // tsid lvi.SubItems.Add(ch.Multiplex_ONID.ToString(NUMBER_FORMAT)); // onid lvi.SubItems.Add(ch.Network.ToString(NUMBER_FORMAT)); // net lvi.SubItems.Add(ch.FavoriteList1 ? "1" : string.Empty); lvi.SubItems.Add(ch.FavoriteList2 ? "1" : string.Empty); lvi.SubItems.Add(ch.FavoriteList3 ? "1" : string.Empty); lvi.SubItems.Add(ch.FavoriteList4 ? "1" : string.Empty); } #if DEBUG lvi.SubItems.Add(ch.FilePosition.ToString(CultureInfo.InvariantCulture)); // Position inside channel file #endif lvi.Checked = !ch.Deleted; lvi.Tag = ch; // Store channel object in each item lvi.Font = ch.Deleted ? _deletedItemFont : _normalItemFont; listView1.Items.Add(lvi); } } finally { listView1.EndUpdate(); } channels.SortByFilePosition(); }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if ((treeView1.Nodes.Count <= 0) || (e.Node == treeView1.Nodes[0])) return; _currentFilename = e.Node.Text; try { Cursor.Current = Cursors.WaitCursor; // Reorder current map file if its loaded if (_mapFile != null) ucSingleEdit1.SaveState(); ucSingleEdit1.Clear(); _mapFile = null; _otherFile = null; if (SCMFile.IsSupportedFile(_currentFilename)) { if (SCMFile.IsChannelMapFile(_currentFilename)) { WriteStatus("Reading channels..."); if (OpenMapFile(_currentFilename)) WriteChanels(); } else { WriteStatus("Reading file..."); if (OpenOtherFile(_currentFilename)) WriteOtherFile(); } } else WriteStatus("File not supported."); } finally { Cursor.Current = Cursors.Default; } }
private bool OpenMapFile(string filename) { try { _mapFile = _scmFile.GetMapFile(filename); } catch (Exception ex) { ShowError(ex, "Open Map file"); return false; } return (_mapFile != null); }
private void mnConvertToTxt_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { MapFile mapfile = new MapFile(Path.GetFileName(ofd.FileName), SCMFileContentType.unknown); mapfile.ReadFrom(Path.GetDirectoryName(ofd.FileName)); mapfile.ConvertToTxt(Path.ChangeExtension(ofd.FileName, ".txt")); } }