public void ConstantRateFactor_Verify() { var settingWrong1 = new ConstantRateFactor(-1); var settingWrong2 = new ConstantRateFactor(60); var setting = new ConstantRateFactor(18); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); }); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting)); Assert.Equal(SettingSerializer.Serialize(setting), "-crf 18"); }
public void CodecAudio_Verify() { var settingWrong1 = new CodecAudio(string.Empty); var settingWrong2 = new CodecAudio(" "); var setting = new CodecAudio(AudioCodecType.LibFdk_Aac); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); }); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting)); Assert.Equal(SettingSerializer.Serialize(setting), "-c:a libfdk_aac"); }
public void Map_Verify() { var settingWrong1 = new Map(string.Empty); var settingWrong2 = new Map(" "); var setting = new Map("output1"); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); }); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting)); Assert.Equal(SettingSerializer.Serialize(setting), "-map [output1]"); }
public void Channels_Verify() { var settingWrong1 = new ChannelOutput(0); var settingWrong2 = new ChannelOutput(-1); var setting = new ChannelOutput(1); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); }); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting)); Assert.Equal(SettingSerializer.Serialize(setting), "-ac 1"); }
public void WellKnownAll() { var text = SettingSerializer.ConvertToString(CommandKeyBindings); var list = SettingSerializer.ConvertToCommandKeyBindings(text); Assert.Equal(CommandKeyBindings.Count, list.Count); for (int i = 0; i < list.Count; i++) { ExpectEqual(CommandKeyBindings[i], list[i]); } }
public void StartAt_Verify() { var settingWrong1 = new StartAt(0); var settingWrong2 = new StartAt(-1); var setting = new StartAt(120); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); }); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting)); Assert.Equal(SettingSerializer.Serialize(setting), "-ss 00:02:00.0"); }
public void MovFlags_Verify() { var settingWrong1 = new MovFlags(string.Empty); var settingWrong2 = new MovFlags(" "); var setting = new MovFlags(MovFlags.EnableFastStart); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); }); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting)); Assert.Equal(SettingSerializer.Serialize(setting), "-movflags +faststart"); }
public void ProfileVideo_Verify() { var settingWrong1 = new ProfileVideo(string.Empty); var settingWrong2 = new ProfileVideo(" "); var setting = new ProfileVideo("baseline"); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); }); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting)); Assert.Equal(SettingSerializer.Serialize(setting), "-profile:v baseline"); }
public void PixelFormat_Verify() { var settingWrong1 = new PixelFormat(string.Empty); var settingWrong2 = new PixelFormat(" "); var setting = new PixelFormat("yuv420p"); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); }); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting)); Assert.Equal(SettingSerializer.Serialize(setting), "-pix_fmt yuv420p"); }
public void FormatOutput_Verify() { var settingWrong1 = new FormatOutput(string.Empty); var settingWrong2 = new FormatOutput(" "); var setting = new FormatOutput("mp4"); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); }); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting)); Assert.Equal(SettingSerializer.Serialize(setting), "-f mp4"); }
public void CodecVideo_Verify() { var settingWrong1 = new CodecVideo(string.Empty); var settingWrong2 = new CodecVideo(" "); var setting = new CodecVideo(VideoCodecType.Libx264); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong1); }); Assert.Throws <InvalidOperationException>(() => { SettingSerializer.Serialize(settingWrong2); }); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting)); Assert.Equal(SettingSerializer.Serialize(setting), "-c:v libx264"); }
public void AvoidNegativeTimestamps_Verify() { var setting1 = new AvoidNegativeTimestamps(AvoidNegativeTimestampsType.Auto); var setting2 = new AvoidNegativeTimestamps(AvoidNegativeTimestampsType.Disabled); var setting3 = new AvoidNegativeTimestamps(AvoidNegativeTimestampsType.MakeNonNegative); var setting4 = new AvoidNegativeTimestamps(AvoidNegativeTimestampsType.MakeZero); Assert.Equal("-avoid_negative_ts auto", SettingSerializer.Serialize(setting1)); Assert.Equal("-avoid_negative_ts disabled", SettingSerializer.Serialize(setting2)); Assert.Equal("-avoid_negative_ts make_non_negative", SettingSerializer.Serialize(setting3)); Assert.Equal("-avoid_negative_ts make_zero", SettingSerializer.Serialize(setting4)); }
public void FrameDropThreshold_Verify() { var setting1 = new FrameDropThreshold() { Threshold = 0 }; var setting2 = new FrameDropThreshold(0); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting1)); Assert.DoesNotThrow(() => SettingSerializer.Serialize(setting2)); Assert.Equal(SettingSerializer.Serialize(setting1), "-frame_drop_threshold 0"); Assert.Equal(SettingSerializer.Serialize(setting2), "-frame_drop_threshold 0"); }
private void WriteOutputSettings(CommandOutput output) { if (output == null) { throw new ArgumentNullException("output"); } output.Settings.SettingsList.ForEach(setting => { BuilderBase.Append(" "); BuilderBase.Append(SettingSerializer.Serialize(setting)); }); }
private void WriteResource(CommandInput resource) { if (resource == null) { throw new ArgumentNullException("resource"); } WriteResourcePreSettings(resource); var inputResource = new Input(resource.Resource); BuilderBase.Append(" "); BuilderBase.Append(SettingSerializer.Serialize(inputResource)); WriteResourcePostSettings(resource); }
private void WriteResourcePostSettings(CommandInput resource) { if (resource == null) { throw new ArgumentNullException("resource"); } resource.Settings.SettingsList.ForEach(setting => { if (!setting.IsPostSetting()) { return; } BuilderBase.Append(" "); BuilderBase.Append(SettingSerializer.Serialize(setting)); }); }
//------------------------------------------------------------- // 概要:初期化 //------------------------------------------------------------- public void Init(PlayerView playerView, PecaPlayerControl pecaPlayer, StatusBarControl statusBar) { // コマンド作成 CreateCommand(playerView, pecaPlayer, statusBar); // ショートカット設定の読み込み try { settings = SettingSerializer.LoadSettings <ShortcutSettings>("ShortcutSettings.xml"); } catch { Logger.Instance.Error("ショートカット設定ファイルの読み込みに失敗したため、デフォルト設定を読み込みます。"); LoadDefaultSettings(); } // 設定ファイルが壊れている場合 if ((settings.EventMap == null) || (settings.GestureMap == null) || (settings.KeyMap == null)) { Logger.Instance.Error("ショートカット設定ファイルが壊れているため、デフォルト設定を読み込みます。"); LoadDefaultSettings(); } }
public void AspectRatio_Verify() { var setting = new AspectRatio(Ratio.Create(1, 1)); Assert.Equal("-aspect 1:1", SettingSerializer.Serialize(setting)); }
public void AutoConvert_Verify() { var setting = new AutoConvert(); Assert.Equal("-auto_convert 1", SettingSerializer.Serialize(setting)); }
public void TrimShortest_Verify() { var setting = new TrimShortest(); Assert.Equal("-shortest", SettingSerializer.Serialize(setting)); }
public void QualityScaleAudio_Verify() { var setting = new QualityScaleAudio(1); Assert.Equal("-q:a 1", SettingSerializer.Serialize(setting)); }
public void RemoveAudio_Verify() { var setting = new RemoveAudio(); Assert.Equal("-an", SettingSerializer.Serialize(setting)); }
private static void Expect(string input, string[] expected) { var list = SettingSerializer.ConvertToList(input); Assert.Equal(expected, list); }
public void Input_Verify() { var setting = new Input(Resource.From("c:\\apple.mp4")); Assert.Equal("-i \"c:/apple.mp4\"", SettingSerializer.Serialize(setting)); }
public void OverwriteOutput_Verify() { var setting = new OverwriteOutput(); Assert.Equal("-y", SettingSerializer.Serialize(setting)); }
public void Size_Verify() { var setting = new Size(852, 480); Assert.Equal("-s 852x480", SettingSerializer.Serialize(setting)); }
public void CopyTimestamps_Verify() { var setting = new CopyTimestamps(); Assert.Equal("-copyts", SettingSerializer.Serialize(setting)); }
private async void UpdateProgram() { var programInfo = new ProgramInfoSerializer(); _mainWindowVeiwModel.CheckProgramTimer.Stop(); _mainWindowVeiwModel.IsEnabledTable = false; var net = new Net(); var setHelp = new SettingHelper(); SettingSerializer selectProgram = null; LauncherSettingSerializer launcherSet = null; try { launcherSet = setHelp.Read <LauncherSettingSerializer>(CommonConstant.KeySettings, CommonConstant.FileSettingsLauncher); selectProgram = launcherSet.InfoInstallPrograms?.FirstOrDefault(p => p.Dep == _mainWindowVeiwModel.SelectedRow.Dep); if (selectProgram == null) { MessageBox.Show(Constant.NotFoundInstallProgram); _mainWindowVeiwModel.IsEnabledTable = true; return; } } catch (Exception ex) { if (ex is DirectoryNotFoundException || ex is FileNotFoundException) { MessageBox.Show(CommonConstant.NotFoundFileSettings); } else { MessageBox.Show(CommonConstant.ErrorReadOrWriteSettings); } Application.Current.Shutdown(); return; } programInfo.dep = _mainWindowVeiwModel.SelectedRow.Dep; var request = await net.RequestAsync( Constant.UrlGetProgram, Net.Post, programInfo, _mainWindowVeiwModel.Auth, null, (s, e) => { _mainWindowVeiwModel.ProgressValue = e.BytesReceived * 100 / e.TotalBytesToReceive; }); if (request.detail != null) { _mainWindowVeiwModel.CheckProgramTimer.Start(); MessageBox.Show(ErrorParser.Parse(request.detail)); _mainWindowVeiwModel.IsEnabledTable = true; return; } var cryptBytesProgram = Convert.FromBase64String(request.data); if (Hash.Sha256Bytes(cryptBytesProgram) == request.hash) { var crypt = new Crypt(Encoding.UTF8.GetBytes(CommonConstant.Key)); crypt.RemoveAndSetIv(ref cryptBytesProgram); var bytesLauncher = crypt.Decode(cryptBytesProgram); try { setHelp.RemoveProgram(selectProgram.Path, true); setHelp.RemoveDumps <SettingSerializer, IRemoveData>(selectProgram); } catch (DirectoryNotFoundException) { MessageBox.Show(Constant.NotFoundFileOrDirectoryWithProgram); } catch (FileNotFoundException) { MessageBox.Show(Constant.NotFoundFileOrDirectoryWithProgram); } var zip = new ArchiveHelper(); var bytesProgramSetting = zip.Extract(bytesLauncher, request.hash); var getProgramSetting = setHelp.Read <SettingSerializer>(bytesProgramSetting, CommonConstant.KeySettings); getProgramSetting.Path = request.hash; var instalProgs = launcherSet.InfoInstallPrograms.ToList(); for (int i = 0; i < instalProgs.Count; i++) { if (instalProgs[i].Dep == getProgramSetting.Dep) { instalProgs[i] = getProgramSetting; break; } } setHelp.Write(launcherSet, CommonConstant.KeySettings, CommonConstant.FileSettingsLauncher); _mainWindowVeiwModel.SelectedRow.SetStateAfterUpdate(); _mainWindowVeiwModel.SelectedRow.Status = StatusHelper.InstallAndUpdated; _mainWindowVeiwModel.SelectedRow.Version = getProgramSetting.Version; _mainWindowVeiwModel.ProgressValue = 0; } else { MessageBox.Show(Constant.NoHashEqual); } _mainWindowVeiwModel.IsEnabledTable = true; _mainWindowVeiwModel.CheckProgramTimer.Start(); }
public void WriteSerializerSpecifier(ISetting setting) { BuilderBase.Append(" "); BuilderBase.Append(SettingSerializer.Serialize(setting)); }
/// <summary> /// 保存ボタン押下 /// </summary> private void saveButton_Click(object sender, System.EventArgs e) { // プレイヤー設定 PlayerSettings.DisconnectRealyOnClose = disconnectRealyOnCloseCheckBox.Checked; PlayerSettings.ReturnPositionOnStart = returnPositionOnStartCheckBox.Checked; PlayerSettings.ReturnSizeOnStart = returnSizeOnStartCheckBox.Checked; PlayerSettings.WindowSnapEnable = windowSnapEnableCheckBox.Checked; PlayerSettings.AspectRateFix = aspectRateFixCheckBox.Checked; PlayerSettings.FrameInvisible = frameInvisibleCheckBox.Checked; PlayerSettings.TopMost = topMostCheckBox.Checked; PlayerSettings.WriteFieldVisible = writeFieldVisibleCheckBox.Checked; PlayerSettings.SaveReturnPositionOnClose = saveReturnPositionCheckBox.Checked; PlayerSettings.SaveReturnSizeOnClose = saveReturnSizeCheckBox.Checked; PlayerSettings.ExitedViewerClose = exitedViewerCloseCheckBox.Checked; // チェックボックスの設定(ステータスバー) PlayerSettings.DisplayFps = displayFpsCheckBox.Checked; PlayerSettings.DisplayBitrate = displayBitrateCheckBox.Checked; PlayerSettings.DisplayListenerNumber = listenerNumberCheckBox.Checked; // 初期音量 int initVolume = 0; if (int.TryParse(initVolumeTextBox.Text, out initVolume)) { PlayerSettings.InitVolume = initVolume; } // 音量変化 int volumeChangeNone = 10; if (int.TryParse(volumeChangeNoneTextBox.Text, out volumeChangeNone)) { PlayerSettings.VolumeChangeNone = volumeChangeNone; } int volumeChangeCtrl = 5; if (int.TryParse(volumeChangeCtrlTextBox.Text, out volumeChangeCtrl)) { PlayerSettings.VolumeChangeCtrl = volumeChangeCtrl; } int volumeChangeShift = 1; if (int.TryParse(volumeChangeShiftTextBox.Text, out volumeChangeShift)) { PlayerSettings.VolumeChangeShift = volumeChangeShift; } // 動画再生開始時のコマンド if (movieStartComboBox.SelectedIndex != -1) { PlayerSettings.MovieStartCommand = movieStartCommandList[movieStartComboBox.SelectedIndex]; } // スクリーンショット PlayerSettings.ScreenshotFolder = screenshotFolderTextBox.Text; PlayerSettings.ScreenshotExtension = screenshotExtensionComboBox.SelectedItem.ToString(); PlayerSettings.ScreenshotFormat = screenshotFormatTextBox.Text; // スレッド PlayerSettings.AutoReadThread = autoReadThreadCheckBox.Checked; // FLV PlayerSettings.Gpu = flvGpuCheckBox.Checked; PlayerSettings.Rtmp = useRtmpCheckBox.Checked; double bufferTime = 1.0; if (double.TryParse(bufferTimeTextBox.Text, out bufferTime)) { PlayerSettings.BufferTime = bufferTime; } double bufferTimeMax = 1.0; if (double.TryParse(bufferTimeMaxTextBox.Text, out bufferTimeMax)) { PlayerSettings.BufferTimeMax = bufferTimeMax; } // 設定を保存 PlayerSettings.Save(); Close(); // ショートカット設定 shortcut.Settings.KeyMap = new Dictionary <KeyInput, Commands>(); shortcut.Settings.GestureMap = new Dictionary <string, Commands>(); foreach (ListViewItem item in shortcutListView.Items) { object tag1 = item.Tag; // Commands object tag2 = item.SubItems[1].Tag; // KeyInput // コマンド取得失敗 if (tag1 == null) { continue; } Commands command = (Commands)item.Tag; // ショートカット設定 if (tag2 != null) { KeyInput keyInput = (KeyInput)item.SubItems[1].Tag; shortcut.Settings.KeyMap.Add(keyInput, command); } // マウスジェスチャ設定 string gesture = item.SubItems[2].Text; if (gesture != "-") { shortcut.Settings.GestureMap.Add(gesture, command); } } SettingSerializer.SaveSettings <ShortcutSettings>("ShortcutSettings.xml", shortcut.Settings); }