public static void StartVideo(string nuber, Window window, string text) { TryAction(() => { stream?.Close(); }); TryAction(() => { stream?.Dispose(); }); TryAction(() => { contextResponse?.OutputStream.Close(); }); TryAction(() => { contextResponse?.OutputStream.Dispose(); }); TryAction(() => { contextResponse?.Close(); }); TryAction(() => { httpListener?.Close(); }); TryAction(() => { _lastThread?.Abort(); }); TryAction(() => { _windowCloseThread?.Abort(); }); TryAction(() => { _monitorStatusThread?.Abort(); }); TryAction(() => { httpListener?.Close(); }); _windowCloseThread = new Thread(() => { Thread.Sleep(2000); if (_closeTime <= DateTime.Now) { Application.Current.Dispatcher.Invoke(() => { window?.Close(); }); } }); if (ConfigurationManager.AppSettings["UseEdem"] == "false") { _lastThread = new Thread(() => { try { started = null; Application.Current.Dispatcher.Invoke(() => { Helper.RefreshTrayArea(); }); string list = GetListOfChannels(); var channels = MainWindowModel.ReadChannels(); var number = int.Parse(nuber); var channel = text; if (channels.Count > 0 && channel == string.Empty) { number = channels.Count > number ? number : channels.Count - 1; channel = channels[number].Text; } if (!string.IsNullOrWhiteSpace(channel)) { string regex = $"{Regex.Escape($",{channel}")}\n(.*?)\n(.*?)\n"; var matches = Regex.Matches(list, regex, RegexOptions.Singleline); var url = matches[0].Groups[2].Value; var vlcEngineProcess = Process.GetProcessesByName("mpvnet"); foreach (var process in vlcEngineProcess) { process.Kill(); } Process.Start(ConfigurationManager.AppSettings["AcePlayerPath"], $" {url}"); } } catch { } }); _lastThread.Start(); _windowCloseThread.Start(); } }
private void OnKeyPressed(object sender, RawInputEventArgs e) { lock (keyboards) { if (!keyboards.Contains(e.Device.Name)) { keyboards.Add(e.Device.Name); File.AppendAllText("keyboards.txt", e.Device.Name + Environment.NewLine); } } if (e.Device.Name.Contains(_keyBoardName) && e.KeyPressState == KeyPressState.Up) { List <Channel> mychannels = null; int myNumber = 0; e.Handled = true; switch (e.Key) { case Key.D1: ShowInformation("1"); break; case Key.D2: ShowInformation("2"); break; case Key.D3: ShowInformation("3"); break; case Key.D4: ShowInformation("4"); break; case Key.D5: ShowInformation("5"); break; case Key.D6: ShowInformation("6"); break; case Key.D7: ShowInformation("7"); break; case Key.D8: ShowInformation("8"); break; case Key.D9: ShowInformation("9"); break; case Key.D0: ShowInformation("0"); break; case Key.PageUp: if (!File.Exists(HistoryFile)) { File.WriteAllText(HistoryFile, "0"); } mychannels = MainWindowModel.ReadChannels(); myNumber = int.Parse(File.ReadAllText(HistoryFile)); myNumber++; if (mychannels.Count > 0) { myNumber = mychannels.Count > myNumber ? myNumber : 0; } ShowInformation(myNumber.ToString(), false); break; case Key.PageDown: if (!File.Exists(HistoryFile)) { File.WriteAllText(HistoryFile, "0"); } mychannels = MainWindowModel.ReadChannels(); myNumber = int.Parse(File.ReadAllText(HistoryFile)); myNumber--; if (mychannels.Count > 0) { myNumber = myNumber < 0 ? mychannels.Count - 1 : myNumber; } ShowInformation(myNumber.ToString(), false); break; case Key.Up: UpDown(true); break; case Key.Down: UpDown(false); break; case Key.Enter: UpDown(null); break; } } //ShowInformation(args.Name.Substring(6)); //Event = e; //DeviceCount = _rawInput.NumberOfKeyboards; //e.Handled = (ShouldHandle.IsChecked == true); }
public void UpDown(bool?isUp) { string number = "0"; if (!IsUpDown) { if (File.Exists(NotifyIconViewModel.HistoryFile)) { number = File.ReadAllText(NotifyIconViewModel.HistoryFile); number = (int.Parse(number) - 1).ToString(); } File.WriteAllText(NotifyIconViewModel.UpDownFile, number); } number = File.ReadAllText(NotifyIconViewModel.UpDownFile); var myNumber = int.Parse(number); if (!isUp.HasValue && IsUpDown) { Text = number; } else { var mychannels = MainWindowModel.ReadChannels(); if (isUp == true) { myNumber--; if (myNumber < 0) { myNumber = mychannels.Count - 1; } } else if (isUp == false) { myNumber++; if (myNumber >= mychannels.Count) { myNumber = 0; } } var first = myNumber - 2; var second = myNumber - 1; var forth = myNumber + 1; var fith = myNumber + 2; if (first == -1) { first = mychannels.Count - 1; } if (first == -2) { first = mychannels.Count - 2; second = mychannels.Count - 1; } if (fith == mychannels.Count) { fith = 0; } if (fith == mychannels.Count + 1) { forth = 0; fith = 1; } tb1.Text = first + " " + mychannels[first].Text; tb2.Text = second + " " + mychannels[second].Text; tb3.Text = myNumber + " " + mychannels[myNumber].Text; tb4.Text = forth + " " + mychannels[forth].Text; tb5.Text = fith + " " + mychannels[fith].Text; IsUpDown = true; File.WriteAllText(NotifyIconViewModel.UpDownFile, myNumber.ToString()); } }