/// <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);
                    }
                });
            }
        }
Exemplo n.º 2
0
        public static void SaveSetting(ConvertSetting setting)
        {
            _setting = setting;
            string content = JsonConvert.SerializeObject(setting, Formatting.Indented);

            File.WriteAllText(settingFileName, content);
        }
Exemplo n.º 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;
        }
Exemplo n.º 4
0
 public byte[] ReadBytes(ConvertSetting convertSetting)
 {
     int count = ReadInt32(convertSetting);
     if (count > 0)
     {
         return ReadBytes(count);
     }
     return null;
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 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;
 }
Exemplo n.º 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();
        }
Exemplo n.º 8
0
    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);
        }
    }
Exemplo n.º 9
0
 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);
            }
        }
Exemplo n.º 11
0
 public ushort ReadUInt16(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(2);
     if (bytes == null) return 0;
     return convertSetting.Converter.ToUInt16(bytes);
 }
Exemplo n.º 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();
        }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 15
0
 public static void WriteUInt64(byte[] buffer, int offset, ulong value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 17
0
 public static void WriteInt16(byte[] buffer, int offset, short value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
Exemplo n.º 18
0
 public decimal ReadDecimal(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(16);
     if (bytes == null) return 0;
     return convertSetting.Converter.ToDecimal(bytes);
 }
Exemplo n.º 19
0
 public DateTime ReadDateTime(ConvertSetting convertSetting)
 {
     return new DateTime(ReadInt64(convertSetting));
 }
Exemplo n.º 20
0
 public char ReadChar(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(2);
     if (bytes == null) return Char.MinValue;
     return convertSetting.Converter.ToChar(bytes);
 }
Exemplo n.º 21
0
 public void ReadString(ConvertSetting convertSetting, ReadCompletedEventHandler resultCompleted, ReadErrorEventHandler resultError, object state)
 {
     ReadInt32(convertSetting, new ReadCompletedEventHandler(ReadStringLengthCompleted), null, new ReadStringState(resultCompleted, resultError, state));
 }
Exemplo n.º 22
0
 public ulong ReadUInt64(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(8);
     if (bytes == null) return 0;
     return convertSetting.Converter.ToUInt64(bytes);
 }
Exemplo n.º 23
0
 public uint ReadUInt32(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(4);
     if (bytes == null) return 0;
     return convertSetting.Converter.ToUInt32(bytes);
 }
Exemplo n.º 24
0
 public static void WriteDecimal(byte[] buffer, int offset, decimal value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
Exemplo n.º 25
0
 public static void WriteGuid(byte[] buffer, int offset, Guid value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
Exemplo n.º 26
0
 public double ReadDouble(ConvertSetting convertSetting)
 {
     byte[] bytes = ReadBytes(8);
     if (bytes == null) return 0;
     return convertSetting.Converter.ToDouble(bytes);
 }
Exemplo n.º 27
0
 public static void WriteSingle(byte[] buffer, int offset, float value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
Exemplo n.º 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));
 }
Exemplo n.º 29
0
 public static void WriteStructure(byte[] buffer, int offset, object value, int length, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value, length));
 }
Exemplo n.º 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;
 }
Exemplo n.º 31
0
 public static DateTime ReadDateTime(byte[] buffer, int offset, ConvertSetting convertSetting)
 {
     return new DateTime(ReadInt64(buffer, offset, convertSetting));
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 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);
 }
Exemplo n.º 36
0
 public static void WriteDateTime(byte[] buffer, int offset, DateTime value, ConvertSetting convertSetting)
 {
     WriteBytes(buffer, offset, convertSetting.Converter.GetBytes(value));
 }
Exemplo n.º 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);
 }
Exemplo n.º 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();
     }
 }