Exemplo n.º 1
0
        internal static bool SavePalette(Palette palette)
        {
            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
            sfd.DefaultExt = ".col";
            sfd.Filter     = "Colora Palette |*.col|Gimp Palette |*.gpl";
            sfd.FileName   = palette.Name;
            sfd.Title      = "Save Color Palette";
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    switch (Path.GetExtension(sfd.FileName))
                    {
                    case ".gpl":
                        saveGimpPalette(sfd.FileName, palette);
                        break;

                    default:
                        saveColoraPalette(sfd.FileName, palette);
                        break;
                    }
                    sfd.Dispose();
                    return(true);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(String.Format("{0} {1}", Properties.Resources.PaletteWindow_strErrorSave, ex.Message), "", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
            sfd.Dispose();
            return(false);
        }
Exemplo n.º 2
0
        public static string SearchSaveFile(string fileExt, string initFileDir = null, string initFileName = null)
        {
            System.Windows.Forms.SaveFileDialog ofd = new System.Windows.Forms.SaveFileDialog()
            {
                AddExtension     = true,
                CheckFileExists  = false,
                CheckPathExists  = true,
                DefaultExt       = fileExt,
                Filter           = string.Format("{0} file|*.{1}", fileExt.ToUpper(), fileExt),
                FilterIndex      = 1,
                Title            = string.Format("Сохранить {0} файл", fileExt.ToUpper()),
                InitialDirectory = initFileDir,
                FileName         = initFileName
            };
            if (!initFileName.IsNull())
            {
                ofd.FileName = initFileName;
            }

            string fileName = null;

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                fileName = ofd.FileName;
            }
            ofd.Dispose();

            return(fileName);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        private void SaveAsProject()
        {
            System.Windows.Forms.SaveFileDialog form = new System.Windows.Forms.SaveFileDialog();
            form.Filter = "Xml files (*.xml)|*.xml";

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SaveFile(form.FileName);
            }

            form.Dispose();
        }
Exemplo n.º 4
0
        private async void OutTXTMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Filter = "文本文件(*.txt)|*.txt";
            var retsfd = sfd.ShowDialog();

            if (retsfd == System.Windows.Forms.DialogResult.OK)
            {
                await CSFFile.SaveAsText(sfd.FileName);
            }
            MessageBox.Show("导出完成", "提示");
            sfd.Dispose();
        }
Exemplo n.º 5
0
 internal static bool SavePaletteFastLedWithGamma(Palette palette)
 {
     System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog();
     sfd.DefaultExt = ".h";
     sfd.Filter     = "Fastled Palette |*.h";
     sfd.FileName   = palette.Name;
     sfd.Title      = "Save FastLed Color Palette with Gamma correction";
     if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             SaveFastLedPaletteWithGamma(sfd.FileName, palette);
             sfd.Dispose();
             return(true);
         }
         catch (Exception ex)
         {
             MessageBox.Show(String.Format("{0} {1}", Properties.Resources.PaletteWindow_strErrorSave, ex.Message), "", MessageBoxButton.OK, MessageBoxImage.Error);
         }
     }
     sfd.Dispose();
     return(false);
 }
Exemplo n.º 6
0
        private async void SaveAsMenuItem_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog
            {
                FileName = "ra2md.csf",
                Filter   = "红色警戒2 字符串文件(*.csf)|*.csf"
            };
            var retsfd = sfd.ShowDialog();

            if (retsfd == System.Windows.Forms.DialogResult.OK)
            {
                FilePath = sfd.FileName;
                await CSFFile.SaveToFile(FilePath);
            }
            MessageBox.Show("保存完成", "提示");
            sfd.Dispose();
        }
Exemplo n.º 7
0
        public void ImportExcelMethodHandler(object object_0, ImportExcelArgs importExcelArgs_0)
        {
            ExcelAccess excelAccess = new ExcelAccess();

            excelAccess.Open();
            excelAccess.MergeCells(1, 1, 1, this.body_0.Cols);
            excelAccess.SetFont(1, 1, 1, this.body_0.Cols, this.title_0.Font);
            excelAccess.SetCellText(1, 1, 1, this.body_0.Cols, this.title_0.Text);
            excelAccess.SetCellText((DataTable)this.DataSource, 3, 1, true);
            System.Windows.Forms.FileDialog fileDialog = new System.Windows.Forms.SaveFileDialog();
            fileDialog.AddExtension = true;
            fileDialog.DefaultExt   = ".xls";
            fileDialog.Title        = "保存到Excel文件";
            fileDialog.Filter       = "Microsoft Office Excel 工作簿(*.xls)|*.xls|模板(*.xlt)|*.xlt";
            if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK &&
                excelAccess.SaveAs(fileDialog.FileName, true))
            {
                System.Windows.Forms.MessageBox.Show("数据成功保存到Excel文件!", "JLK.Utility.Excel",
                                                     System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Asterisk);
            }
            fileDialog.Dispose();
            excelAccess.Close();
        }
Exemplo n.º 8
0
        public void ImportExcelMethodHandler(Object obj, ImportExcelArgs ev)
        {
            #region 实现...

            ExcelAccess excel = new ExcelAccess();
            excel.Open();

            excel.MergeCells(1, 1, 1, this._body.Cols);             //合并单元格写标题,并设置字体
            excel.SetFont(1, 1, 1, this._body.Cols, this._title.Font);
            excel.SetCellText(1, 1, 1, this._body.Cols, this._title.Text);

            //打印网格及网格线
            excel.SetCellText((System.Data.DataTable) this.DataSource, 3, 1, true);

            System.Windows.Forms.FileDialog fileDlg = new System.Windows.Forms.SaveFileDialog();
            fileDlg.AddExtension = true;
            fileDlg.DefaultExt   = ".xls";

            //fileDlg.InitialDirectory = System.IO.Directory.GetCurrentDirectory();
            fileDlg.Title  = "保存到Excel文件";
            fileDlg.Filter = "Microsoft Office Excel 工作簿(*.xls)|*.xls|模板(*.xlt)|*.xlt";

            if (fileDlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (excel.SaveAs(fileDlg.FileName, true))
                {
                    System.Windows.Forms.MessageBox.Show("数据成功保存到Excel文件!", "GoldPrinter", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Information);
                }
            }

            fileDlg.Dispose();

            excel.Close();

            #endregion
        }
Exemplo n.º 9
0
        private void OnSaveJobsToBatchFile()
        {
            if (_jobs.Count == 0)
            {
                LogWarning("No job in the list.");
                return;
            }

            SaveConfig();

            var saveFileDialog = new System.Windows.Forms.SaveFileDialog();

            saveFileDialog.InitialDirectory = System.Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
            saveFileDialog.Filter           = "Windows batch file (*.cmd)|*.cmd";
            saveFileDialog.FileName         = "UMM_encode_job.cmd";
            var success = saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK;

            saveFileDialog.Dispose();
            if (!success)
            {
                return;
            }

            var fileStream   = File.Open(saveFileDialog.FileName, FileMode.Create, FileAccess.Write);
            var streamWriter = new StreamWriter(fileStream);

            foreach (var job in _jobs)
            {
                job.SaveJobToBatchFile(streamWriter);
            }

            streamWriter.Close();
            streamWriter.Dispose();
            fileStream.Close();
            fileStream.Dispose();
        }
Exemplo n.º 10
0
        /// <summary>
        /// Экспорт списка событий
        /// </summary>
        /// <param name="IndList">список идексов необходимых событий</param>
        /// <returns>true в </returns>
        public bool ExportEvents(List <int> IndList)
        {
            string workfile;

            System.Windows.Forms.SaveFileDialog SFD = new System.Windows.Forms.SaveFileDialog();
            SFD.AddExtension     = true;
            SFD.DefaultExt       = "cln";
            SFD.Filter           = "Calendar files (*.cln)|*.cln|All files (*.*)|*.*";
            SFD.InitialDirectory = System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments);
            //string SrcFile = WorkDirectory + "\\eventlist.dat";
            if (SFD.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                workfile = SFD.FileName;
            }
            else
            {
                return(false);
            }
            SFD.Dispose();


            FileStream FS;

            try
            {
                FS = new FileStream(workfile, FileMode.Create, FileAccess.Write);
            }
            catch
            {
                return(false);
            }

            // тип
            for (int i = 0; i < 4; i++)
            {
                FS.WriteByte((byte)typeFile[i]);
            }

            // версия
            FS.Write(vers, 0, 4);

            // кол-во
            int count = IndList.Count;

            byte[] buf = BitConverter.GetBytes(count);
            FS.Write(buf, 0, 4);


            int PointsOffset = 12;  // начало перечисления смещений

            //int DataOffset = PointsOffset + 4 * count;

            // массив смещений от начала файла забиваем нолями
            for (int i = 0; i < count * 4; i++)
            {
                FS.WriteByte(0);
            }


            // перебераем все события списка
            for (int i = 0; i < count; i++)
            {
                // i-е смещение
                FS.Seek(PointsOffset + i * 4, SeekOrigin.Begin);
                buf = BitConverter.GetBytes((int)FS.Length);
                FS.Write(buf, 0, 4);

                // событие в массив байт
                //buf = EventStructToByteArray(i);
                buf = EventStructToByteArray(IndList[i]);

                // дописать
                FS.Seek(0, SeekOrigin.End);
                FS.Write(buf, 0, buf.Length);
            }

            FS.Close();

            return(true);
        }
Exemplo n.º 11
0
 public void Dispose()
 {
     _hostDialog.Dispose();
 }
        private async void Save_File_Create_B_Click(object sender, RoutedEventArgs e)
        {
            if (Selected_File == "" || BNK_FSB_Voices.Count == 0)
            {
                Message_Feed_Out("音声ファイルが選択されていません。");
                return;
            }
            if (Project_Name_T.Text == "")
            {
                Message_Feed_Out("プロジェクト名が設定されていません。");
                return;
            }
            if (Project_Name_T.Text.Contains("  "))
            {
                Message_Feed_Out("プロジェクト名に空白を連続で使用することはできません。");
                return;
            }
            try
            {
                Directory.CreateDirectory(Voice_Set.Special_Path + "/Temp/" + Project_Name_T.Text);
                Directory.Delete(Voice_Set.Special_Path + "/Temp", true);
                if (Project_Name_T.Text.Contains("/") || Project_Name_T.Text.Contains("\\"))
                {
                    throw new Exception("プロジェクト名に'/'を付けることはできません。");
                }
            }
            catch (Exception e1)
            {
                Message_Feed_Out("プロジェクト名に不適切な文字が含まれています。");
                Sub_Code.Error_Log_Write(e1.Message);
                return;
            }
            System.Windows.Forms.SaveFileDialog sfd = new System.Windows.Forms.SaveFileDialog()
            {
                Title            = "セーブファイルの保存先を指定してください。",
                Filter           = "セーブファイル(*.wvs)|*.wvs",
                InitialDirectory = Directory.GetCurrentDirectory()
            };
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                IsBusy = true;
                try
                {
                    string Ex = Path.GetExtension(Selected_File);
                    if (Ex == ".fsb")
                    {
                        Message_T.Text = "音声ファイルを抽出しています...";
                        await Task.Delay(50);

                        Fmod_File_Extract_V2.FSB_Extract_To_Directory(Selected_File, Voice_Set.Local_Path + "/Projects/" + Project_Name_T.Text + "/All_Voices_Temp");
                        Message_T.Text = ".wavファイルをエンコードしています...";
                        await Task.Delay(50);

                        await Multithread.Convert_To_Wav(Voice_Set.Local_Path + "/Projects/" + Project_Name_T.Text + "/All_Voices_Temp", Voice_Set.Local_Path + "/Projects/" + Project_Name_T.Text + "/All_Voices", true, true, false, false);

                        Directory.Delete(Voice_Set.Local_Path + "/Projects/" + Project_Name_T.Text + "/All_Voices_Temp", true);
                    }
                    else if (Ex == ".bnk")
                    {
                        Message_T.Text = ".wavまたは.oggに変換しています...";
                        await Task.Delay(50);

                        if (IsPCKMode)
                        {
                            Wwise_File_Extract_V1 Wwise_PCK = new Wwise_File_Extract_V1(Selected_File);
                            await Wwise_PCK.Async_Wwise_Extract_To_WEM_Directory(Voice_Set.Local_Path + "/Projects/" + Project_Name_T.Text + "/All_Voices");

                            await Wwise_PCK.Async_Wwise_Extract_To_OGG_Directory(Voice_Set.Local_Path + "/Projects/" + Project_Name_T.Text + "/All_Voices");

                            Wwise_PCK.Pck_Clear();
                        }
                        else
                        {
                            Wwise_File_Extract_V2 Wwise_BNK = new Wwise_File_Extract_V2(Selected_File);
                            Wwise_BNK.Wwise_Extract_To_WEM_Directory_V2(Voice_Set.Local_Path + "/Projects/" + Project_Name_T.Text + "/All_Voices");
                            Wwise_BNK.Bank_Clear();
                        }
                        Message_T.Text = "不要な音声ファイルを削除しています...";
                        await Task.Delay(50);

                        string[] All_Files = Directory.GetFiles(Voice_Set.Local_Path + "/Projects/" + Project_Name_T.Text + "/All_Voices", "*", SearchOption.TopDirectoryOnly);
                        foreach (string File_Now in All_Files)
                        {
                            if (!Need_Files.Contains(Path.GetFileNameWithoutExtension(File_Now)))
                            {
                                Sub_Code.File_Delete_V2(File_Now);
                            }
                        }
                        string[] Files = Directory.GetFiles(Voice_Set.Local_Path + "/Projects/" + Project_Name_T.Text + "/All_Voices", "*.wem", SearchOption.TopDirectoryOnly);
                        foreach (string File_Now in Files)
                        {
                            Sub_Code.File_Delete_V2(File_Now);
                        }
                    }
                    StreamWriter stw = File.CreateText(sfd.FileName + ".tmp");
                    stw.WriteLine(Project_Name_T.Text + "|IsNotChangeProjectNameMode=true");
                    for (int Number = 0; Number < BNK_FSB_Voices.Count; Number++)
                    {
                        foreach (string Name in BNK_FSB_Voices[Number])
                        {
                            stw.WriteLine(Number + "|" + Sub_Code.File_Get_FileName_No_Extension(Voice_Set.Local_Path + "\\Projects\\" + Project_Name_T.Text + "\\All_Voices\\" + Name));
                        }
                    }
                    stw.Close();
                    Sub_Code.File_Encrypt(sfd.FileName + ".tmp", sfd.FileName, "SRTTbacon_Create_Voice_Save", true);
                    Message_Feed_Out("保存しました。\nProjectsフォルダに該当する音声が入っています。");
                    Flash.Flash_Start();
                }
                catch (Exception e1)
                {
                    Sub_Code.Error_Log_Write(e1.Message);
                    Message_Feed_Out("エラーが発生しました。");
                }
                IsBusy = false;
            }
            sfd.Dispose();
        }
Exemplo n.º 13
0
        /// <summary>
        /// 
        /// </summary>
        private void SaveAsProject()
        {
            System.Windows.Forms.SaveFileDialog form = new System.Windows.Forms.SaveFileDialog();
            form.Filter = "Xml files (*.xml)|*.xml";

            if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                SaveFile(form.FileName);
            }

            form.Dispose();
        }