Beispiel #1
0
 /* ----------------------------------------------------------------- */
 ///
 /// ToIndex
 ///
 /// <summary>
 /// Resolutions からコンボボックスのインデックスに変換します。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 public static int ToIndex(Parameter.Resolutions id)
 {
     foreach (Parameter.Resolutions x in Enum.GetValues(typeof(Parameter.Resolutions)))
     {
         if (x == id)
         {
             return((int)id);
         }
     }
     return((int)Parameter.Resolutions.Resolution300);
 }
Beispiel #2
0
        public void TestRunAsPdfWithImageParameters(
            Parameter.Resolutions resolution,
            Parameter.DownSamplings downsampling,
            Parameter.ImageFilters filter)
        {
            var setting = CreateSetting();

            setting.Resolution   = resolution;
            setting.DownSampling = downsampling;
            setting.ImageFilter  = filter;

            var suffix = string.Format("-{0}-{1}-{2}", downsampling, filter, resolution);

            AssertRun(setting, suffix);
        }
Beispiel #3
0
        /* ----------------------------------------------------------------- */
        ///
        /// UpgradeFromV1
        ///
        /// <summary>
        /// 過去のバージョンのレジストリを読み込み,現行バージョンに対応
        /// した形に変換する.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public bool UpgradeFromV1(string root)
        {
            bool status = true;

            try
            {
                // ユーザ設定を読み込む
                RegistryKey subkey = Registry.CurrentUser.OpenSubKey(root, false);
                if (subkey == null) return false;

                // パス関連
                string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                string path = subkey.GetValue(REG_LAST_OUTPUT_ACCESS, desktop) as string;
                if (path != null && path.Length > 0 && Directory.Exists(path)) _output = path;
                path = subkey.GetValue(REG_LAST_INPUT_ACCESS, desktop) as string;
                if (path != null && path.Length > 0 && Directory.Exists(path)) _input = path;
                path = subkey.GetValue(REG_USER_PROGRAM, "") as string;
                if (path != null && path.Length > 0 && File.Exists(path)) _program = path;

                // チェックボックスのフラグ関連
                int flag = (int)subkey.GetValue(REG_PAGE_ROTATION, 1);
                _rotation = (flag != 0);
                flag = (int)subkey.GetValue(REG_EMBED_FONT, 1);
                _embed = (flag != 0);
                flag = (int)subkey.GetValue(REG_GRAYSCALE, 0);
                _grayscale = (flag != 0);
                flag = (int)subkey.GetValue(REG_WEB_OPTIMIZE, 0);
                _web = (flag != 0);
                flag = (int)subkey.GetValue(REG_SAVE_SETTING, 0);
                _save = (flag != 0);
                flag = (int)subkey.GetValue(REG_CHECK_UPDATE, 1);
                _update = (flag != 0);
                flag = (int)subkey.GetValue(REG_ADVANCED_MODE, 0);
                _advance = (flag != 0);
                flag = (int)subkey.GetValue(REG_SELECT_INPUT, 0);
                _selectable = (flag != 0);

                // コンボボックスの変換
                string type = (string)subkey.GetValue(REG_FILETYPE, "");
                foreach (Parameter.FileTypes id in Enum.GetValues(typeof(Parameter.FileTypes)))
                {
                    if (Parameter.FileTypeValue(id) == type)
                    {
                        _type = id;
                        break;
                    }
                }

                string pdfver = (string)subkey.GetValue(REG_PDF_VERSION, "");
                foreach (Parameter.PDFVersions id in Enum.GetValues(typeof(Parameter.PDFVersions)))
                {
                    if (Parameter.PDFVersionValue(id).ToString() == pdfver)
                    {
                        _pdfver = id;
                        break;
                    }
                }

                string resolution = (string)subkey.GetValue(REG_RESOLUTION, "");
                foreach (Parameter.Resolutions id in Enum.GetValues(typeof(Parameter.Resolutions)))
                {
                    if (Parameter.ResolutionValue(id).ToString() == resolution)
                    {
                        _resolution = id;
                        break;
                    }
                }

                // ExistedFile: v1 は日本語名で直接指定されていた
                string exist = (string)subkey.GetValue(REG_EXISTED_FILE, "");
                if (exist == "上書き") _exist = Parameter.ExistedFiles.Overwrite;
                else if (exist == "先頭に結合") _exist = Parameter.ExistedFiles.MergeHead;
                else if (exist == "末尾に結合") _exist = Parameter.ExistedFiles.MergeTail;

                // PostProcess: v1 は日本語名で直接指定されていた
                string postproc = (string)subkey.GetValue(REG_POST_PROCESS, "");
                if (postproc == "開く") _postproc = Parameter.PostProcesses.Open;
                else if (postproc == "何もしない") _postproc = Parameter.PostProcesses.None;
                else if (postproc == "ユーザープログラム") _postproc = Parameter.PostProcesses.UserProgram;

                // DownsSampling: v1 は日本語名で直接指定されていた
                string downsampling = (string)subkey.GetValue(REG_DOWNSAMPLING, "");
                if (downsampling == "なし") _downsampling = Parameter.DownSamplings.None;
                else if (downsampling == "平均化") _downsampling = Parameter.DownSamplings.Average;
                else if (downsampling == "バイキュービック") _downsampling = Parameter.DownSamplings.Bicubic;
                else if (downsampling == "サブサンプル") _downsampling = Parameter.DownSamplings.Subsample;
            }
            catch (Exception /* err */)
            {
                status = false;
            }

            return status;
        }
Beispiel #4
0
        /* ----------------------------------------------------------------- */
        ///
        /// Load
        ///
        /// <summary>
        /// ParameterList クラスにロードされた内容を元に設定情報をロード
        /// する.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private void Load(ParameterManager param)
        {
            var v = param.Parameters;

            // パス関連
            string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            string s = v.Contains(REG_LAST_OUTPUT_ACCESS) ? (string)v.Find(REG_LAST_OUTPUT_ACCESS).Value : "";
            _output = (s.Length > 0) ? s : desktop;
            s = v.Contains(REG_LAST_INPUT_ACCESS) ? (string)v.Find(REG_LAST_INPUT_ACCESS).Value : "";
            _input = (s.Length > 0) ? s : desktop;
            s = v.Contains(REG_USER_PROGRAM) ? (string)v.Find(REG_USER_PROGRAM).Value : "";
            _program = s;
            s = v.Contains(REG_USER_ARGUMENTS) ? (string)v.Find(REG_USER_ARGUMENTS).Value : "%%FILE%%";
            _argument = s;

            // チェックボックスのフラグ関連
            int value = v.Contains(REG_PAGE_ROTATION) ? (int)v.Find(REG_PAGE_ROTATION).Value : 1;
            _rotation = (value != 0);
            value = v.Contains(REG_EMBED_FONT) ? (int)v.Find(REG_EMBED_FONT).Value : 1;
            _embed = (value != 0);
            value = v.Contains(REG_GRAYSCALE) ? (int)v.Find(REG_GRAYSCALE).Value : 0;
            _grayscale = (value != 0);
            value = v.Contains(REG_WEB_OPTIMIZE) ? (int)v.Find(REG_WEB_OPTIMIZE).Value : 0;
            _web = (value != 0);
            value = v.Contains(REG_SAVE_SETTING) ? (int)v.Find(REG_SAVE_SETTING).Value : 0;
            _save = (value != 0);
            value = v.Contains(REG_CHECK_UPDATE) ? (int)v.Find(REG_CHECK_UPDATE).Value : 1;
            _update = (value != 0);
            value = v.Contains(REG_ADVANCED_MODE) ? (int)v.Find(REG_ADVANCED_MODE).Value : 0;
            _advance = (value != 0);
            value = v.Contains(REG_VISIBLE) ? (int)v.Find(REG_VISIBLE).Value : 1;
            _visible = (value != 0);
            value = v.Contains(REG_SELECT_INPUT) ? (int)v.Find(REG_SELECT_INPUT).Value : 0;
            _selectable = (value != 0);

            // コンボボックスのインデックス関連
            value = v.Contains(REG_FILETYPE) ? (int)v.Find(REG_FILETYPE).Value : 0;
            foreach (int x in Enum.GetValues(typeof(Parameter.FileTypes)))
            {
                if (x == value) _type = (Parameter.FileTypes)value;
            }

            value = v.Contains(REG_PDF_VERSION) ? (int)v.Find(REG_PDF_VERSION).Value : 0;
            foreach (int x in Enum.GetValues(typeof(Parameter.PDFVersions)))
            {
                if (x == value) _pdfver = (Parameter.PDFVersions)value;
            }

            value = v.Contains(REG_RESOLUTION) ? (int)v.Find(REG_RESOLUTION).Value : 0;
            foreach (int x in Enum.GetValues(typeof(Parameter.Resolutions)))
            {
                if (x == value) _resolution = (Parameter.Resolutions)value;
            }

            value = v.Contains(REG_EXISTED_FILE) ? (int)v.Find(REG_EXISTED_FILE).Value : 0;
            foreach (int x in Enum.GetValues(typeof(Parameter.ExistedFiles)))
            {
                if (x == value) _exist = (Parameter.ExistedFiles)value;
            }

            value = v.Contains(REG_POST_PROCESS) ? (int)v.Find(REG_POST_PROCESS).Value : 0;
            foreach (int x in Enum.GetValues(typeof(Parameter.PostProcesses)))
            {
                if (x == value) _postproc = (Parameter.PostProcesses)value;
            }

            value = v.Contains(REG_DOWNSAMPLING) ? (int)v.Find(REG_DOWNSAMPLING).Value : 0;
            foreach (int x in Enum.GetValues(typeof(Parameter.DownSamplings)))
            {
                if (x == value) _downsampling = (Parameter.DownSamplings)value;
            }

            value = v.Contains(REG_IMAGEFILTER) ? (int)v.Find(REG_IMAGEFILTER).Value : 0;
            foreach (int x in Enum.GetValues(typeof(Parameter.ImageFilters)))
            {
                if (x == value) _filter = (Parameter.ImageFilters)value;
            }
        }
Beispiel #5
0
 /* ----------------------------------------------------------------- */
 ///
 /// ResolutionString
 ///
 /// <summary>
 /// Resolutions の各値に対応する文字列を取得します。
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 public static string ResolutionString(Parameter.Resolutions id)
 {
     return(Parameter.ResolutionValue(id).ToString());
 }
Beispiel #6
0
        /* ----------------------------------------------------------------- */
        ///
        /// LoadIndices
        ///
        /// <summary>
        /// CubePdf.Settings.Document オブジェクトから CubePDF メイン画面で
        /// 表示されているコンボボックスのインデックス関連の情報を抽出して、
        /// 対応する変数にロードします。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private void LoadIndices(CubePdf.Settings.Document document)
        {
            var filetype = document.Root.Find(_RegFileType);
            if (filetype != null)
            {
                foreach (int item in Enum.GetValues(typeof(Parameter.FileTypes)))
                {
                    if (item == (int)filetype.Value)
                    {
                        _type = (Parameter.FileTypes)filetype.Value;
                        break;
                    }
                }
            }

            var pdfversion = document.Root.Find(_RegPdfVersion);
            if (pdfversion != null)
            {
                foreach (int item in Enum.GetValues(typeof(Parameter.PdfVersions)))
                {
                    if (item == (int)pdfversion.Value)
                    {
                        _pdfver = (Parameter.PdfVersions)pdfversion.Value;
                        break;
                    }
                }
            }

            var resolution = document.Root.Find(_RegResolution);
            if (resolution != null)
            {
                foreach (int item in Enum.GetValues(typeof(Parameter.Resolutions)))
                {
                    if (item == (int)resolution.Value)
                    {
                        _resolution = (Parameter.Resolutions)resolution.Value;
                        break;
                    }
                }
            }

            var exist = document.Root.Find(_RegExistedFile);
            if (exist != null)
            {
                foreach (int item in Enum.GetValues(typeof(Parameter.ExistedFiles)))
                {
                    if (item == (int)exist.Value)
                    {
                        _exist = (Parameter.ExistedFiles)exist.Value;
                        break;
                    }
                }
            }

            var postproc = document.Root.Find(_RegPostProcess);
            if (postproc != null)
            {
                foreach (int item in Enum.GetValues(typeof(Parameter.PostProcesses)))
                {
                    if (item == (int)postproc.Value)
                    {
                        _postproc = (Parameter.PostProcesses)postproc.Value;
                        break;
                    }
                }
            }

            var downsampling = document.Root.Find(_RegDownSampling);
            if (downsampling != null)
            {
                foreach (int item in Enum.GetValues(typeof(Parameter.DownSamplings)))
                {
                    if (item == (int)downsampling.Value)
                    {
                        _downsampling = (Parameter.DownSamplings)downsampling.Value;
                        break;
                    }
                }
            }

            var filter = document.Root.Find(_RegImageFilter);
            if (filter != null)
            {
                foreach (int item in Enum.GetValues(typeof(Parameter.ImageFilters)))
                {
                    if (item == (int)filter.Value)
                    {
                        _filter = (Parameter.ImageFilters)filter.Value;
                        break;
                    }
                }
            }

            var save = document.Root.Find(_RegSaveSetting);
            if (save != null)
            {
                foreach (int item in Enum.GetValues(typeof(Parameter.SaveSettings)))
                {
                    if (item == (int)save.Value)
                    {
                        _save = (Parameter.SaveSettings)save.Value;
                        break;
                    }
                }
            }
        }
Beispiel #7
0
        /* ----------------------------------------------------------------- */
        ///
        /// UpgradeFromV1
        ///
        /// <summary>
        /// 過去のバージョンのレジストリを読み込み、現行バージョンに対応
        /// した形に変換します。
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public bool UpgradeFromV1(string root)
        {
            bool status = true;

            try
            {
                // ユーザ設定を読み込む
                RegistryKey subkey = Registry.CurrentUser.OpenSubKey(root, false);
                if (subkey == null) return false;

                // パス関連
                string desktop = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                string path = subkey.GetValue(_RegLastAccess, desktop) as string;
                if (path != null && path.Length > 0 && Directory.Exists(path)) _output = path;
                path = subkey.GetValue(_RegLastInputAccess, desktop) as string;
                if (path != null && path.Length > 0 && Directory.Exists(path)) _input = path;
                path = subkey.GetValue(_RegUserProgram, "") as string;
                if (path != null && path.Length > 0 && File.Exists(path)) _program = path;

                // チェックボックスのフラグ関連
                int flag = (int)subkey.GetValue(_RegPageRotation, 1);
                _rotation = (flag != 0);
                flag = (int)subkey.GetValue(_RegEmbedFont, 1);
                _embed = (flag != 0);
                flag = (int)subkey.GetValue(_RegGrayscale, 0);
                _grayscale = (flag != 0);
                flag = (int)subkey.GetValue(_RegWebOptimize, 0);
                _web = (flag != 0);
                flag = (int)subkey.GetValue(_RegSaveSetting, 0);
                _save = (flag != 0) ? Parameter.SaveSettings.Save : Parameter.SaveSettings.None;
                flag = (int)subkey.GetValue(_RegCheckUpdate, 1);
                _update = (flag != 0);
                flag = (int)subkey.GetValue(_RegAdvancedMode, 0);
                _advance = (flag != 0);
                flag = (int)subkey.GetValue(_RegSelectInput, 0);
                _selectable = (flag != 0);

                // コンボボックスの変換
                string type = (string)subkey.GetValue(_RegFileType, "");
                foreach (Parameter.FileTypes id in Enum.GetValues(typeof(Parameter.FileTypes)))
                {
                    if (Parameter.FileTypeValue(id) == type)
                    {
                        _type = id;
                        break;
                    }
                }

                string pdfver = (string)subkey.GetValue(_RegPdfVersion, "");
                foreach (Parameter.PdfVersions id in Enum.GetValues(typeof(Parameter.PdfVersions)))
                {
                    if (Parameter.PdfVersionValue(id).ToString() == pdfver)
                    {
                        _pdfver = id;
                        break;
                    }
                }

                string resolution = (string)subkey.GetValue(_RegResolution, "");
                foreach (Parameter.Resolutions id in Enum.GetValues(typeof(Parameter.Resolutions)))
                {
                    if (Parameter.ResolutionValue(id).ToString() == resolution)
                    {
                        _resolution = id;
                        break;
                    }
                }

                // ExistedFile: v1 は日本語名で直接指定されていた
                string exist = (string)subkey.GetValue(_RegExistedFile, "");
                if (exist == "上書き") _exist = Parameter.ExistedFiles.Overwrite;
                else if (exist == "先頭に結合") _exist = Parameter.ExistedFiles.MergeHead;
                else if (exist == "末尾に結合") _exist = Parameter.ExistedFiles.MergeTail;

                // PostProcess: v1 は日本語名で直接指定されていた
                string postproc = (string)subkey.GetValue(_RegPostProcess, "");
                if (postproc == "開く") _postproc = Parameter.PostProcesses.Open;
                else if (postproc == "何もしない") _postproc = Parameter.PostProcesses.None;
                else if (postproc == "ユーザープログラム") _postproc = Parameter.PostProcesses.UserProgram;

                // DownsSampling: v1 は日本語名で直接指定されていた
                string downsampling = (string)subkey.GetValue(_RegDownSampling, "");
                if (downsampling == "なし") _downsampling = Parameter.DownSamplings.None;
                else if (downsampling == "平均化") _downsampling = Parameter.DownSamplings.Average;
                else if (downsampling == "バイキュービック") _downsampling = Parameter.DownSamplings.Bicubic;
                else if (downsampling == "サブサンプル") _downsampling = Parameter.DownSamplings.Subsample;
            }
            catch (Exception /* err */)
            {
                status = false;
            }

            return status;
        }