/// <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);
        }
示例#3
0
        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;
        }
示例#4
0
 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;
 }
示例#7
0
        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);
            }
        }
示例#11
0
 public ushort ReadUInt16(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(2);
     if (bytes == null) return 0;
     return convertSetting.Converter.ToUInt16(bytes);
 }
示例#12
0
        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();
        }
示例#13
0
 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);
 }
示例#14
0
 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);
 }
示例#15
0
 public static void WriteUInt64(byte[] buffer, int offset, ulong value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
示例#16
0
 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);
     }
 }
示例#17
0
 public static void WriteInt16(byte[] buffer, int offset, short value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
示例#18
0
 public decimal ReadDecimal(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(16);
     if (bytes == null) return 0;
     return convertSetting.Converter.ToDecimal(bytes);
 }
示例#19
0
 public DateTime ReadDateTime(ConvertSetting convertSetting)
 {
     return new DateTime(ReadInt64(convertSetting));
 }
示例#20
0
 public char ReadChar(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(2);
     if (bytes == null) return Char.MinValue;
     return convertSetting.Converter.ToChar(bytes);
 }
示例#21
0
 public void ReadString(ConvertSetting convertSetting, ReadCompletedEventHandler resultCompleted, ReadErrorEventHandler resultError, object state)
 {
     ReadInt32(convertSetting, new ReadCompletedEventHandler(ReadStringLengthCompleted), null, new ReadStringState(resultCompleted, resultError, state));
 }
示例#22
0
 public ulong ReadUInt64(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(8);
     if (bytes == null) return 0;
     return convertSetting.Converter.ToUInt64(bytes);
 }
示例#23
0
 public uint ReadUInt32(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(4);
     if (bytes == null) return 0;
     return convertSetting.Converter.ToUInt32(bytes);
 }
示例#24
0
 public static void WriteDecimal(byte[] buffer, int offset, decimal value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
示例#25
0
 public static void WriteGuid(byte[] buffer, int offset, Guid value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
示例#26
0
 public double ReadDouble(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(8);
     if (bytes == null) return 0;
     return convertSetting.Converter.ToDouble(bytes);
 }
示例#27
0
 public static void WriteSingle(byte[] buffer, int offset, float value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
示例#28
0
 public void ReadDouble(ConvertSetting convertSetting, ReadCompletedEventHandler resultCompleted, ReadErrorEventHandler resultError, object state)
 {
     ReadBytes(new ResultReadDataNode(8, convertSetting, new ReadCompletedEventHandler(ReadDoubleCompleted), null, resultCompleted, resultError, state));
 }
示例#29
0
 public static void WriteStructure(byte[] buffer, int offset, object value, int length, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value, length));
 }
示例#30
0
 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;
 }
示例#31
0
 public static DateTime ReadDateTime(byte[] buffer, int offset, ConvertSetting convertSetting)
 {
     return new DateTime(ReadInt64(buffer, offset, convertSetting));
 }
示例#32
0
 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);
 }
示例#33
0
 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);
 }
示例#34
0
 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);
 }
示例#35
0
 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);
 }
示例#36
0
 public static void WriteDateTime(byte[] buffer, int offset, DateTime value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
示例#37
0
 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);
 }
示例#38
0
 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();
     }
 }