public MainPresenter(IMainView view) { if (view == null) { throw new ArgumentNullException("view"); } // Load configuration this.configuration = Configuration.Load(); // Initialize recorder this.displayProvider = new DisplayProvider(); this.displaySettings = new DisplaySettings() { Mouse = this.displayProvider.MouseSettings, Tracking = this.displayProvider.TrackingSettings, Watermark = this.displayProvider.WatermarkSettings, }; this.soundProvider = new SoundProvider(); this.soundSettings = new SoundSettings() { DeviceId = this.soundProvider.DeviceId, Format = this.soundProvider.Format, }; this.recorder = new Recorder(); this.recorder.Error += new RecordErrorEventHandler(recorder_Error); // Initialize view this.view = view; this.InitializeView(); // Apply configuration this.ApplyConfiguration(null); // Update View this.view.AllowUpdate = true; // this.UpdateView(); }
private void ApplyConfiguration(Configuration oldConfiguration) { // General GeneralSettings general = this.configuration.General; this.view.HideFromTaskbar = general.HideFromTaskbar; // Display (Mouse, Tracking and Watermark) this.DisplaySettings = new DisplaySettings() { Mouse = configuration.Mouse, Tracking = configuration.Tracking, Watermark = configuration.Watermark, }; this.view.TrackingSettings = configuration.Tracking; // Hot Keys HotKeySettings hotKey = this.configuration.HotKeys; this.view.CancelHotKey = hotKey.Cancel; this.view.PauseHotKey = hotKey.Pause; this.view.RecordHotKey = hotKey.Record; this.view.StopHotKey = hotKey.Stop; this.UpdateHotKeys(oldConfiguration != null ? oldConfiguration.HotKeys : null); // Sound SoundSettings sound = this.configuration.Sound; SoundDevice[] soundDevices = SoundProvider.GetDevices(); this.view.SoundDevices = soundDevices; string soundDeviceId = sound.DeviceId; SoundDevice soundDevice = null; if (!string.IsNullOrEmpty(soundDeviceId)) { soundDevice = SoundProvider.GetDeviceOrDefault(soundDeviceId); if (soundDevice != null) { // Update configuration if device id is invalid sound.DeviceId = soundDevice.Id; } } this.view.SoundDevice = soundDevice; this.SoundSettings = this.configuration.Sound; // Get updated (valid) configuration from recorder this.configuration.Sound = this.SoundSettings; // Video this.recorder.VideoSettings = this.configuration.Video; // Get updated (valid) configuration from recorder this.configuration.Video = this.recorder.VideoSettings; this.UpdateView(); }
private void ChangeSoundDevice(SoundDevice soundDevice) { // Check recording state RecordingState state = this.recorder.State; // Debug.Assert(state == RecordingState.Idle); if (state != RecordingState.Idle) { return; } SoundSettings soundSettings = this.SoundSettings; if (soundDevice != null) { soundSettings.DeviceId = soundDevice.Id; if (soundSettings.Format == null) { soundSettings.Format = SoundProvider.SuggestFormat(soundDevice.Id, null, null, null); this.configuration.Sound.DeviceId = soundDevice.Id; } } else { soundSettings.DeviceId = null; this.configuration.Sound = soundSettings; } this.SoundSettings = soundSettings; }
private Configuration() { var properties = Properties.Settings.Default; // Read configuration section elements // General string outputDir = properties.General_OutputDirectory; if (string.IsNullOrEmpty(outputDir)) { string myDocuments = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); try { outputDir = Path.Combine(myDocuments, outputDirInMyDocs); } catch (ArgumentException) { outputDir = myDocuments; } } GeneralSettings general = new GeneralSettings(); general.MinimizeOnRecord = properties.General_MinimizeOnRecord; general.HideFromTaskbar = properties.General_HideFromTaskbarIfMinimized; general.OutputDirectory = outputDir; // Hot Keys HotKeySettings hotKeys = new HotKeySettings(); hotKeys.Cancel = properties.HotKeys_Cancel; hotKeys.Global = properties.HotKeys_Global; hotKeys.Pause = properties.HotKeys_Pause; hotKeys.Record = properties.HotKeys_Record; hotKeys.Stop = properties.HotKeys_Stop; // Mouse MouseSettings mouse = new MouseSettings(); mouse.HighlightCursor = properties.Mouse_HighlightCursor; mouse.HighlightCursorColor = properties.Mouse_HighlightCursorColor; mouse.HighlightCursorRadious = properties.Mouse_HighlightCursorRadious; mouse.RecordCursor = properties.Mouse_RecordCursor; // Sound SoundSettings sound = new SoundSettings(); sound.DeviceId = properties.Sound_DeviceId; sound.Format = properties.Sound_Format; // Tracking TrackingSettings tracking = new TrackingSettings(); tracking.Bounds = properties.Tracking_Bounds; tracking.Type = properties.Tracking_Type; // Video VideoSettings video = new VideoSettings(); video.Compressor = properties.Video_Compressor; video.Fps = properties.Video_Fps; video.Quality = properties.Video_Quality; // Watermark WatermarkSettings waterMark = new WatermarkSettings(); waterMark.Alignment = properties.Watermark_Alignment; waterMark.Color = properties.Watermark_Color; waterMark.Display = properties.Watermark_Display; waterMark.Font = properties.Watermark_Font; waterMark.Margin = properties.Watermark_Margin; waterMark.Outline = properties.Watermark_Outline; waterMark.OutlineColor = properties.Watermark_OutlineColor; waterMark.RightToLeft = properties.Watermark_RightToLeft; waterMark.Text = properties.Watermark_Text; // Set properties this.General = general; this.HotKeys = hotKeys; this.Mouse = mouse; this.Sound = sound; this.Tracking = tracking; this.Video = video; this.Watermark = waterMark; }