public bool LoadPlaylist(Playlist newPlaylist) { if (newPlaylist.currentList.files.Count() == 0) { CMBox.Show("Warning", "Empty playlist", Style.Warning, Buttons.OK); return(false); } else { episodeList.Clear(); nextEpisode = new EpisodeInfo(); currentEpisode = new EpisodeInfo(); previousEpisode = new EpisodeInfo(); episodeList.AddRange(newPlaylist.currentList.files); currentEpisode = episodeList[0]; if (episodeList.Count() > 1) { nextEpisode = episodeList[1]; } return(true); } }
public void Load() { if (!File.Exists(this.path)) { return; } try { using Stream fStream = new FileStream(this.path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); recents = (RecentList)XmlFormatter.Deserialize(fStream); } catch (Exception ex) { try { File.Delete(this.path); recents = new RecentList { fileList = new List <string>() }; using Stream fStream = new FileStream(this.path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); XmlFormatter.Serialize(fStream, recents); CMBox.Show("Error", "Couldn't load recents and file was reset, Error: " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); } catch (Exception e) { CMBox.Show("Error", "Couldn't load or reset recents, Error: " + e.Message, Style.Error, Buttons.OK, ex.ToString()); } } }
private void Cleartextbox() { CIDBox.Clear(); CFNBox.Clear(); CSNBox.Clear(); CABox.Clear(); CMBox.Clear(); MIDBox.Clear(); MNBox.Clear(); MRBox.Clear(); MGBox.Clear(); MCBox.Clear(); MPBox.Clear(); MRentBox.Clear(); MRDBox.Clear(); RMIDBox.Clear(); CRIDBox.Clear(); MRIDBox.Clear(); RentDBox.Clear(); ReturnDBox.Clear(); CIDBox.Focus(); }
public VolumeControl() { InitializeComponent(); this.Loaded += delegate { try { Thumb thumb = (VolumeSlider.Template.FindName("PART_Track", VolumeSlider) as Track).Thumb; thumb.MouseEnter += new MouseEventHandler(VolumeSlider_MouseEnter); } catch (Exception ex) { CMBox.Show("Error", "Couldn't initialize thumb", MessageCustomHandler.Style.Error, Buttons.OK, ex.ToString()); } LinearGradientBrush linearGradientBrush = new LinearGradientBrush(); linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb((byte)255, (byte)123, (byte)223, (byte)246), 0)); linearGradientBrush.GradientStops.Add(new GradientStop(Color.FromArgb((byte)255, (byte)120, (byte)187, (byte)239), 1)); VolumeSlider.Background = linearGradientBrush; VolumeSlider.BorderBrush = linearGradientBrush; VolumeSlider.ValueChanged += (s, e) => { labelVolume.Content = $"{Convert.ToInt32(e.NewValue)}%"; }; labelVolume.Foreground = linearGradientBrush; }; }
public bool Save(string filePath) { try { using Stream fStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); XmlFormatter.Serialize(fStream, currentList); return(true); } catch (Exception ex) { CMBox.Show("Error", "Couldn't save playlist, Error: " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); return(false); } }
private void ContextListURLsOpen_Click(object sender, EventArgs e) { if (ListURLs.SelectedItems.Count == 1) { string url = ListURLs.SelectedItems[0].SubItems[0].Text; if (!string.IsNullOrWhiteSpace(url)) { Process.Start(url); } } else { CMBox.Show("Warning", "One Website must be selected", Style.Warning, Buttons.OK); } }
private void FormatAutoToolTipContent() { if (!string.IsNullOrEmpty(this.AutoToolTipFormat)) { string Content = this.AutoToolTip.Content.ToString().Replace(",", ""); try { this.AutoToolTip.Content = TimeSpan.FromSeconds(Convert.ToDouble(Content)).ToString(); } catch (Exception ex) { CMBox.Show("Error in slider", Content, MessageCustomHandler.Style.Error, Buttons.OK, ex.ToString()); } } }
private void BtnAddURL_Click(object sender, EventArgs e) { string urlToAdd = TxtAddURL.Text; bool result = Uri.TryCreate(urlToAdd, UriKind.Absolute, out Uri uriResult) && (uriResult.Scheme == Uri.UriSchemeHttp || uriResult.Scheme == Uri.UriSchemeHttps); if (result) { Sites.URLs.Add(new WebSite(urlToAdd, true, "waiting")); RefreshUrlList(); SaveURLs(); TxtAddURL.Text = string.Empty; } else { CMBox.Show("Warning", "Invalid URL, check and try again", Style.Warning, Buttons.OK); } }
public VideoPosition(string Path) { if (!Directory.Exists(Path)) { try { Directory.CreateDirectory(Path); } catch (Exception ex) { CMBox.Show("Error", "Couldn't set video position directory, Error: " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); return; } } this.path = Path; }
public void Save() { try { if (File.Exists(path)) { File.Delete(path); } using Stream fStream = new FileStream(this.path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); XmlFormatter.Serialize(fStream, recents); } catch (Exception ex) { CMBox.Show("Error", "Couldn't save recents, Error: " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); return; } }
public void Save() { try { if (File.Exists(filePath)) { File.Delete(filePath); } using Stream fStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); XmlFormatter.Serialize(fStream, mainSettings); NeedsSaving = false; } catch (Exception ex) { CMBox.Show("Error", "Couldn't save settings, Error: " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); } }
public void Disconnect() { try { if (Processing[0]) { return; } else { Processing[0] = true; } bool Raise = Connected; Connected = false; if (Handle != null) { Handle.Close(); } if (SendQueue != null) { SendQueue.Clear(); } SendBuffer = new byte[0] { }; ReadBuffer = new byte[0] { }; if (Raise) { OnStateChanged(false); } if (Items != null) { Items[0].Dispose(); Items[1].Dispose(); } CUserState = null; CEndPoint = null; } catch (Exception ex) { CMBox.Show("Error", "Error disconnecting, " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); } }
public void SavePosition(int Position) { try { if (this.name == null || this.name.Length == 0) { return; } string filePath = Path.Combine(this.path, this.name + ".ini"); File.WriteAllText(filePath, Position.ToString(), Encoding.ASCII); } catch (Exception ex) { CMBox.Show("Error", "Couldn't save video position, Error: " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); ErrorSaving = true; return; } }
public void Load() { if (!File.Exists(filePath)) { return; } try { using Stream fStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); mainSettings = (MainSettings)XmlFormatter.Deserialize(fStream); } catch (Exception ex) { try { File.Delete(filePath); Jump = 10; Volume = 100; IsMute = false; AutoPlay = false; AutoPlayTime = 15; Rate = 1; AutoAudio = true; AutoSubtitle = true; Acceleration = true; SubtitleDisable = false; using Stream fStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); XmlFormatter.Serialize(fStream, mainSettings); NeedsSaving = false; CMBox.Show("Error", "Couldn't load settings and file was reset, Error: " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); } catch (Exception e) { CMBox.Show("Error", "Couldn't settings or reset recents, Error: " + e.Message, Style.Error, Buttons.OK, ex.ToString()); } } }
public void Disconnect() { try { if (Processing) { return; } else { Processing = true; } if (Handle != null) { Handle.Close(); } if (CClients != null) { lock (CClients) { while (CClients.Count > 0) { CClients[0].Disconnect(); if (CClients.Count > 0) { CClients.RemoveAt(0); } } } } if (Item != null) { Item.Dispose(); } CListening = false; OnStateChanged(false); } catch (Exception ex) { CMBox.Show("Error", "Error disconnecting, " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); } }
public string GetPosition(string filePath) { try { if (!File.Exists(filePath)) { return("0"); } long position = File.ReadAllText(filePath, Encoding.ASCII).ToInt32(); var positionSpan = TimeSpan.FromSeconds(position); return(string.Format("{0:D2}h:{1:D2}m:{2:D2}s", positionSpan.Hours, positionSpan.Minutes, positionSpan.Seconds)); } catch (Exception ex) { CMBox.Show("Error", "Couldn't get video position, Error: " + ex.Message, MessageCustomHandler.Style.Error, Buttons.OK, ex.ToString()); return("-1"); } }
private void MenuOpen_Click(object sender, RoutedEventArgs e) { if (InfoList.Items.Count <= 0) // Ignore if no items { return; } if (InfoList.SelectedItems.Count <= 0) // Ignore if no selected items { return; } if (InfoList.SelectedItems.Count > 1) { CMBox.Show("Warning", "Multiple items selected not supported", MessageCustomHandler.Style.Warning, Buttons.OK); return; } EpisodeInfo selectedEpisode = null; // Make the item to be used by all senders foreach (ListViewItem item in InfoList.SelectedItems) { selectedEpisode = tvShow.episodeList.Find(x => $"{x.Name} - {x.Episode}" == item.Content.ToString()); break; } if (sender is MenuItem menuItem) { if (menuItem.Name.EndsWith("File")) // Open file { //Process.Start(selectedEpisode.FilePath); ((MainWindow)this.Owner).OpenFile(selectedEpisode.FilePath); } else if (menuItem.Name.EndsWith("Dir")) // open directory { Process.Start(new System.IO.FileInfo(selectedEpisode.FilePath).DirectoryName); } } }
public bool Load(string filePath) { if (!File.Exists(filePath)) { CMBox.Show("Error", "Couldn't load playlist, Error: File not found", Style.Error, Buttons.OK); return(false); } else { try { using Stream fStream = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); currentList = (PlaylistFile)XmlFormatter.Deserialize(fStream); return(true); } catch (Exception ex) { CMBox.Show("Error", "Couldn't load playlist, Error: " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); return(false); } } }
public long GetPosition() { try { string filePath = Path.Combine(this.path, this.name + ".ini"); if (!File.Exists(filePath)) { return(0); } string position = "0"; if (duration > 180) { position = File.ReadAllText(filePath, Encoding.ASCII); } int finalPosition = position.ToInt32(); if ((duration - finalPosition) < 180) { if (duration > 180) { finalPosition = duration - 180; } else { finalPosition = 0; } } return(finalPosition * 1000); } catch (Exception ex) { CMBox.Show("Error", "Couldn't get video position, Error: " + ex.Message, Style.Error, Buttons.OK, ex.ToString()); return(0); } }
public byte[] Serialize(params object[] data) { if (data == null) { CMBox.Show("Error", "Invalid data on sterilizing", Style.Error, Buttons.OK); return(new byte[0]); } MemoryStream Stream = new MemoryStream(); BinaryWriter Writer = new BinaryWriter(Stream, Encoding.UTF8); Writer.Write(Convert.ToByte(data.Length)); for (int I = 0; I <= data.Length - 1; I++) { byte Current = Table[data[I].GetType()]; Writer.Write(Current); switch (Current) { case 0: Writer.Write((bool)data[I]); break; case 1: Writer.Write((byte)data[I]); break; case 2: Writer.Write(((byte[])data[I]).Length); Writer.Write((byte[])data[I]); break; case 3: Writer.Write((char)data[I]); break; case 4: Writer.Write(((char[])data[I]).ToString()); break; case 5: Writer.Write((decimal)data[I]); break; case 6: Writer.Write((double)data[I]); break; case 7: Writer.Write((int)data[I]); break; case 8: Writer.Write((long)data[I]); break; case 9: Writer.Write((sbyte)data[I]); break; case 10: Writer.Write((short)data[I]); break; case 11: Writer.Write((float)data[I]); break; case 12: Writer.Write((string)data[I]); break; case 13: Writer.Write((uint)data[I]); break; case 14: Writer.Write((ulong)data[I]); break; case 15: Writer.Write((ushort)data[I]); break; case 16: Writer.Write(((DateTime)data[I]).ToBinary()); break; } } Writer.Close(); return(Stream.ToArray()); }