/// <summary> /// 変換が完了しなかった場合に変換後ファイルを削除する /// </summary> /// <param name="replaceParam"></param> protected virtual void DeleteNotCompleteFile(Dictionary <string, string> replaceParam) { var dstFileName = ConvertSetting.GetDestinationFileName(replaceParam); if (string.IsNullOrEmpty(dstFileName)) { // 変換後ファイル名が指定されていない場合は判断できないので存在しない扱いとする return; } var dstFilePath = Path.Combine(DestinationFolder, dstFileName); if (File.Exists(dstFilePath)) { // プロセス終了後に開放されるラグ時間があるため、一定時間待機後に未完了ファイルを削除する Task.Run(async() => { await Task.Delay(Constant.FileMoveDelayMiliSecond); try { File.Delete(dstFilePath); LogWindow.LogMessage($"未完了ファイルを削除しました。 File={dstFilePath}", LogWindow.MessageType.Information); } catch (IOException ex) { LogWindow.LogMessage($"未完了ファイルの削除に失敗しました。 File={dstFilePath} ex={ex}", LogWindow.MessageType.Error); } }); } }
public static void SaveSetting(ConvertSetting setting) { _setting = setting; string content = JsonConvert.SerializeObject(setting, Formatting.Indented); File.WriteAllText(settingFileName, content); }
private void frmSetting_Load(object sender, EventArgs e) { ConvertSetting setting = SettingManager.GetSetting(); this.nudTaskParallelLimit.Value = setting.TaskParallelLimit; this.chkEnableLog.Checked = setting.EnableLog; this.chkEnableDebug.Checked = setting.EnableDebug; }
public byte[] ReadBytes(ConvertSetting convertSetting) { int count = ReadInt32(convertSetting); if (count > 0) { return ReadBytes(count); } return null; }
public ResultReadDataNode(int count, BinaryConverter converter, Encoding encoding, ReadCompletedEventHandler Completed, ReadErrorEventHandler Error, ReadCompletedEventHandler resultCompleted, ReadErrorEventHandler resultError, object state) : base(new byte[count], 0, count, Completed, Error, state) { this.ConvertSetting = new ConvertSetting(converter, encoding); this.ResultCompleted = resultCompleted; this.ResultError = resultError; }
public ResultReadDataNode(int count, ConvertSetting convertSetting, ReadCompletedEventHandler Completed, ReadErrorEventHandler Error, ReadCompletedEventHandler resultCompleted, ReadErrorEventHandler resultError, object state) : base(new byte[count], 0, count, Completed, Error, state) { this.ConvertSetting = convertSetting; this.ResultCompleted = resultCompleted; this.ResultError = resultError; }
private void btnOK_Click(object sender, EventArgs e) { ConvertSetting setting = new ConvertSetting(); setting.TaskParallelLimit = (int)this.nudTaskParallelLimit.Value; setting.EnableLog = this.chkEnableLog.Checked; setting.EnableDebug = this.chkEnableDebug.Checked; SettingManager.SaveSetting(setting); this.DialogResult = DialogResult.OK; this.Close(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); ConvertSetting convertSetting = target as ConvertSetting; if (GUILayout.Button("Convert")) { TextAsset textAsset = convertSetting.seetSource; DataType type = convertSetting.targetDataType; Convert(textAsset, type); } }
public static ConvertSetting GetSetting() { if (File.Exists(settingFileName)) { string content = File.ReadAllText(settingFileName); ConvertSetting setting = (ConvertSetting)JsonConvert.DeserializeObject(content, typeof(ConvertSetting)); return(setting); } else { return(new ConvertSetting()); } }
/// <summary> /// 既に変換済みフォルダが存在するか確認する /// </summary> /// <param name="filePath"></param> protected virtual bool IsAlreadyExistCompleteFolder(Dictionary <string, string> replaceParam) { var dstFileName = ConvertSetting.GetDestinationFileName(replaceParam); if (string.IsNullOrEmpty(dstFileName)) { // 変換後ファイル名が指定されていない場合は判断できないので存在しない扱いとする LogWindow.LogMessage($"変換後ファイル名が指定されていないため変換済みチェックはしません。dstFileName={dstFileName}", LogWindow.MessageType.Warning); return(false); } else if (File.Exists(Path.Combine(DestinationFolder, dstFileName))) { LogWindow.LogMessage($"変換後ファイルが既に存在するのでスキップします。File={Path.Combine(DestinationFolder, dstFileName)} ", LogWindow.MessageType.Warning); return(true); } else { return(false); } }
public ushort ReadUInt16(ConvertSetting convertSetting) { byte[] bytes = ReadBytes(2); if (bytes == null) return 0; return convertSetting.Converter.ToUInt16(bytes); }
private void ConvertVideo() { string strFilePath = this.txtFile.Text; string saveFolder = this.txtSaveFolder.Text; if (string.IsNullOrEmpty(strFilePath)) { MessageBox.Show("Please choose the file for converting!"); return; } string[] filePaths = strFilePath.Split('|'); foreach (string filePath in filePaths) { FileInfo file = new FileInfo(filePath); string strStartTime = DateTime.Now.ToString("HH:mm:ss"); string strTime = "00:00:00"; VideoInfo videoInfo = VideoHelper.GetVideoInfo(filePath); if (!this.lvMessage.Items.ContainsKey(file.Name)) { ListViewItem li = new ListViewItem(); li.Tag = videoInfo; li.Name = file.Name; li.Text = file.Name; li.SubItems.Add("Ready"); //Message li.SubItems.Add(videoInfo.DurationString); //Duration li.SubItems.Add(""); //Current Time li.SubItems.Add(""); //Start Time li.SubItems.Add("0%"); //Progress this.lvMessage.Items.Add(li); } else { ListViewItem li = this.lvMessage.Items[file.Name]; li.Tag = videoInfo; li.SubItems[1].Text = "Ready"; //Message li.SubItems[2].Text = videoInfo.DurationString; //Duration li.SubItems[3].Text = strTime; //Current Time li.SubItems[4].Text = ""; //Start Time li.SubItems[4].Tag = null; li.SubItems[5].Text = "0%"; //Progress li.BackColor = Color.White; } } this.btnExecute.Enabled = false; this.convertHandler.FilePaths = filePaths.ToList(); switch (this.cboVideoType.Text) { case nameof(VideoType.Original): this.convertHandler.Option.FileType = ""; break; case nameof(VideoType.Custom): this.convertHandler.Option.FileType = this.txtFileType.Text; break; default: this.convertHandler.Option.FileType = this.cboVideoType.Text; break; } int?width = default(int?); int?height = default(int?); switch (this.cboResolution.Text) { case nameof(VideoResolution.P1080): width = 1920; height = 1080; break; case nameof(VideoResolution.P720): width = 1280; height = 720; break; case nameof(VideoResolution.P480): width = 720; height = 480; break; case nameof(VideoResolution.P360): width = 480; height = 360; break; case nameof(VideoResolution.Custom): if (this.nudWidth.Value > 0) { width = (int)this.nudWidth.Value; } if (this.nudHeight.Value > 0) { height = (int)this.nudHeight.Value; } break; } this.convertHandler.Option.SaveFolder = this.txtSaveFolder.Text; this.convertHandler.Option.ResolutionWidth = width; this.convertHandler.Option.ResolutionHeight = height; if (this.cboQuality.Text == VideoQuality.Custom.ToString()) { this.convertHandler.Option.Quality = (int)this.nudQuality.Value; } else { this.convertHandler.Option.Quality = (int)Enum.Parse(typeof(VideoQuality), this.cboQuality.Text); } this.convertHandler.Subscribe(this); ConvertSetting setting = SettingManager.GetSetting(); this.convertHandler.Setting = setting; LogHelper.EnableDebug = setting.EnableDebug; FeedbackHelper.EnableLog = setting.EnableLog; this.convertHandler.Convert(); }
public static Guid ReadGuid(byte[] buffer, int offset, ConvertSetting convertSetting) { byte[] bytes = ReadBytes(buffer, offset, 16); if (bytes == null) return Guid.Empty; return convertSetting.Converter.ToGuid(bytes); }
public static decimal ReadDecimal(byte[] buffer, int offset, ConvertSetting convertSetting) { byte[] bytes = ReadBytes(buffer, offset, 16); if (bytes == null) return 0; return convertSetting.Converter.ToDecimal(bytes); }
public static void WriteUInt64(byte[] buffer, int offset, ulong value, ConvertSetting convertSetting) { WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value)); }
public static void WriteString(byte[] buffer, int offset, string value, ConvertSetting convertSetting) { if (value != null && value.Length > 0) { byte[] bts = convertSetting.Converter.GetBytes(value); WriteInt32(buffer, offset, bts.Length, convertSetting); WriteBytes(buffer, offset, bts); } else { WriteInt32(buffer, offset, 0, convertSetting); } }
public static void WriteInt16(byte[] buffer, int offset, short value, ConvertSetting convertSetting) { WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value)); }
public decimal ReadDecimal(ConvertSetting convertSetting) { byte[] bytes = ReadBytes(16); if (bytes == null) return 0; return convertSetting.Converter.ToDecimal(bytes); }
public DateTime ReadDateTime(ConvertSetting convertSetting) { return new DateTime(ReadInt64(convertSetting)); }
public char ReadChar(ConvertSetting convertSetting) { byte[] bytes = ReadBytes(2); if (bytes == null) return Char.MinValue; return convertSetting.Converter.ToChar(bytes); }
public void ReadString(ConvertSetting convertSetting, ReadCompletedEventHandler resultCompleted, ReadErrorEventHandler resultError, object state) { ReadInt32(convertSetting, new ReadCompletedEventHandler(ReadStringLengthCompleted), null, new ReadStringState(resultCompleted, resultError, state)); }
public ulong ReadUInt64(ConvertSetting convertSetting) { byte[] bytes = ReadBytes(8); if (bytes == null) return 0; return convertSetting.Converter.ToUInt64(bytes); }
public uint ReadUInt32(ConvertSetting convertSetting) { byte[] bytes = ReadBytes(4); if (bytes == null) return 0; return convertSetting.Converter.ToUInt32(bytes); }
public static void WriteDecimal(byte[] buffer, int offset, decimal value, ConvertSetting convertSetting) { WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value)); }
public static void WriteGuid(byte[] buffer, int offset, Guid value, ConvertSetting convertSetting) { WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value)); }
public double ReadDouble(ConvertSetting convertSetting) { byte[] bytes = ReadBytes(8); if (bytes == null) return 0; return convertSetting.Converter.ToDouble(bytes); }
public static void WriteSingle(byte[] buffer, int offset, float value, ConvertSetting convertSetting) { WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value)); }
public void ReadDouble(ConvertSetting convertSetting, ReadCompletedEventHandler resultCompleted, ReadErrorEventHandler resultError, object state) { ReadBytes(new ResultReadDataNode(8, convertSetting, new ReadCompletedEventHandler(ReadDoubleCompleted), null, resultCompleted, resultError, state)); }
public static void WriteStructure(byte[] buffer, int offset, object value, int length, ConvertSetting convertSetting) { WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value, length)); }
public static string ReadString(byte[] buffer, int offset, ConvertSetting convertSetting) { int count = ReadInt32(buffer, offset, convertSetting); if (count > 0) return ReadString(buffer, offset, count, convertSetting); else return null; }
public static DateTime ReadDateTime(byte[] buffer, int offset, ConvertSetting convertSetting) { return new DateTime(ReadInt64(buffer, offset, convertSetting)); }
public static string ReadString(byte[] buffer, int offset, int count, ConvertSetting convertSetting) { byte[] bytes = ReadBytes(buffer, offset, count); if (bytes == null) return null; return convertSetting.Converter.ToString(bytes, convertSetting.Encoding); }
public static double ReadDouble(byte[] buffer, int offset, ConvertSetting convertSetting) { byte[] bytes = ReadBytes(buffer, offset, 8); if (bytes == null) return 0; return convertSetting.Converter.ToDouble(bytes); }
public static uint ReadUInt32(byte[] buffer, int offset, ConvertSetting convertSetting) { byte[] bytes = ReadBytes(buffer, offset, 4); if (bytes == null) return 0; return convertSetting.Converter.ToUInt32(bytes); }
public static long ReadInt64(byte[] buffer, int offset, ConvertSetting convertSetting) { byte[] bytes = ReadBytes(buffer, offset, 8); if (bytes == null) return 0; return convertSetting.Converter.ToInt64(bytes); }
public static void WriteDateTime(byte[] buffer, int offset, DateTime value, ConvertSetting convertSetting) { WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value)); }
public static float ReadSingle(byte[] buffer, int offset, ConvertSetting convertSetting) { byte[] bytes = ReadBytes(buffer, offset, 4); if (bytes == null) return 0; return convertSetting.Converter.ToSingle(bytes); }
public void ReadString(int count, ConvertSetting convertSetting, ReadCompletedEventHandler resultCompleted, ReadErrorEventHandler resultError, object state) { ResultReadDataNode dataNode = new ResultReadDataNode(count, convertSetting, new ReadCompletedEventHandler(ReadStringCompleted), null, resultCompleted, resultError, state); if (count > 0) { ReadBytes(dataNode); } else { dataNode.DoResultCompleted(); } }