public void AddRecording(RecordingInfo recInfo) { ObservableCollection<RecordingInfo> recordings = GetRecordings(); using (StreamWriter writer = new StreamWriter(JsonPath, true)) { recordings.Add(recInfo); writer.WriteLine(JsonConvert.SerializeObject(recordings, Formatting.Indented)); } if (model != null) { model.RecordingList = recordings; } }
public void Execute(object parameter) { // record button clicked if (parameter != null) { recordingInfo = new RecordingInfo { Name = System.IO.Path.GetRandomFileName().Replace(".", string.Empty), Location = @Properties.Settings.Default.SaveLocation, Width = viewModel.MainWindowModel.Width, Height = viewModel.MainWindowModel.Height }; // begin the countdown counter = new SettingsModel().CountdownSecond; counterCurrent = counter; notificationBalloon = Notification.Instance.ShowNotificationBalloon("Press " + new SettingsModel().HotKeyAsString + " stop process.", "Process starting...", counter * 1000 + 2000); notificationModel = (notificationBalloon.DataContext as NotificationViewModel).Model; countdownTimer = new Timer { Interval = 1000 }; countdownTimer.Elapsed += CountdownTimerEvent; countdownTimer.Start(); // Making selection click-through viewModel.MainWindowModel.Foreground = "#00000000"; viewModel.MainWindowModel.Background = "#00000000"; viewModel.MainWindowModel.RecordButton.IsVisible = false; } // contextmenu item dorecord clicked else { if (viewModel.MainWindowModel.IsRecording) { Stop(); return; } if (viewModel.MainWindowModel.SelectionVisibility == Visibility.Hidden) { viewModel.ShowSelection(); } else { viewModel.HideSelection(); } } }
public Uploader(RecordingInfo recordingInfo) { RecordingInfo = recordingInfo; Files = new List<UploaderFileModel>(); foreach (string format in RecordingInfo.Formats) { try { UploaderFileModel uFile = new UploaderFileModel(); uFile.Filename = RecordingInfo.Path + "." + format; uFile.Stream = File.Open(RecordingInfo.Path + "." + format, FileMode.Open, FileAccess.Read); Files.Add(uFile); totalFileBytes += uFile.Stream.Length; } catch { string format1 = format; Application.Current.Dispatcher.Invoke(() => { Notification.Instance.ShowNotificationBalloon("File error", "Error loading " + RecordingInfo.Path + "." + format1 + " for upload."); }); } } /*if (RecordingInfo.Recorder == "VLC") { UploaderFileModel audioFile = new UploaderFileModel { Filename = RecordingInfo.Path + ".mp3", Stream = File.Open(RecordingInfo.Path + ".mp3", FileMode.Open, FileAccess.Read), }; Files.Add(audioFile); }*/ Values = new NameValueCollection { { "name", RecordingInfo.Name }, { "duration", RecordingInfo.Duration.ToString() }, { "dimension", RecordingInfo.Dimension.ToString() }, { "date", RecordingInfo.Date.ToString("yyyy-MM-dd H:mm:ss") }, { "recorder", RecordingInfo.Recorder }, }; Worker = new BackgroundWorker(); InitializeWebRequest(); }
public void DeleteRecording(RecordingInfo recInfo) { string path = recInfo.Path; // remove files if (File.Exists(path + ".mp4")) File.Delete(path + ".mp4"); if (File.Exists(path + ".webm")) File.Delete(path + ".webm"); // remove entry from json file ObservableCollection<RecordingInfo> recordings = GetRecordings(); using (StreamWriter writer = new StreamWriter(JsonPath)) { try { var itemToRemove = recordings.Single(r => r.Url == recInfo.Url); recordings.Remove(itemToRemove); writer.WriteLine(JsonConvert.SerializeObject(recordings, Formatting.Indented)); } catch (Exception ex) { Notification.Instance.ShowBalloonyTip("Delete local file failed.", ex.Message); } } // remove remotely using (var wb = new WebClient()) { var data = new NameValueCollection(); data["actionKey"] = recInfo.ActionKey; try { wb.UploadValues(recInfo.Url, data); } catch (Exception ex) { Notification.Instance.ShowBalloonyTip("Remote file deletion failed.", ex.Message); } } if (model != null) { model.RecordingList = recordings; } }