/* ----------------------------------------------------------------- */ /// /// Invoke /// /// <summary> /// Invokes the conversion directly. /// </summary> /// /* ----------------------------------------------------------------- */ private static void Invoke(SettingsFolder settings) { using (var src = new MainFacade(settings)) { src.UpdateExtension(); src.Convert(); } }
/* ----------------------------------------------------------------- */ /// /// Show /// /// <summary> /// Shows the main window. /// </summary> /// /* ----------------------------------------------------------------- */ private static void Show(SettingsFolder settings) { var view = new MainForm(); using (var vm = new MainViewModel(settings)) { view.Bind(vm); Application.Run(view); } }
/* ----------------------------------------------------------------- */ /// /// MainViewModel /// /// <summary> /// オブジェクトを初期化します。 /// </summary> /// /// <param name="settings">設定情報</param> /// <param name="context">同期用コンテキスト</param> /// /* ----------------------------------------------------------------- */ public MainViewModel(SettingsFolder settings, SynchronizationContext context) : base(new Messenger(), context) { Model = new MainFacade(settings); Settings = new SettingsViewModel(settings.Value, Messenger, Context); Metadata = new MetadataViewModel(settings.Value.Metadata, Messenger, Context); Encryption = new EncryptionViewModel(settings.Value.Encryption, Messenger, Context); settings.PropertyChanged += WhenPropertyChanged; }
/* ----------------------------------------------------------------- */ /// /// CreateImageConverter /// /// <summary> /// Initializes a new instance of the ImageConverter class with /// the specified settings. /// </summary> /// /* ----------------------------------------------------------------- */ private static Ghostscript.Converter CreateImageConverter(SettingsFolder src) { var key = KeyValuePair.Create(src.Value.Format, src.Value.Grayscale); var map = GetFormatMap(); Debug.Assert(map.ContainsKey(key)); return(new ImageConverter(GetFormatMap()[key], src.IO) { AntiAlias = true, }); }
/* ----------------------------------------------------------------- */ /// /// CreateDocumentConverter /// /// <summary> /// Initializes a new instance of the DocumentConverter class with /// the specified settings. /// </summary> /// /* ----------------------------------------------------------------- */ private static Ghostscript.DocumentConverter CreateDocumentConverter(SettingsFolder src) { var dest = PdfConverter.SupportedFormats.Contains(src.Value.Format) ? CreatePdfConverter(src) : new DocumentConverter(src.Value.Format, src.IO); dest.ColorMode = src.Value.Grayscale ? ColorMode.Grayscale : ColorMode.Rgb; dest.Downsampling = src.Value.Downsampling; dest.EmbedFonts = src.Value.EmbedFonts; return(dest); }
/* ----------------------------------------------------------------- */ /// /// Create /// /// <summary> /// Initializes a new instance of the Ghostscript.Converter class /// with the specified settings. /// </summary> /// /// <param name="src">User settings.</param> /// /// <returns>Ghostscript.Converter object.</returns> /// /* ----------------------------------------------------------------- */ public static Ghostscript.Converter Create(SettingsFolder src) { var asm = Assembly.GetExecutingAssembly(); var dir = src.IO.Get(asm.Location).DirectoryName; var dest = DocumentConverter.SupportedFormats.Contains(src.Value.Format) ? CreateDocumentConverter(src) : CreateImageConverter(src); dest.Quiet = false; dest.WorkDirectory = src.WorkDirectory; dest.Log = src.IO.Combine(src.WorkDirectory, "console.log"); dest.Resolution = src.Value.Resolution; dest.Orientation = src.Value.Orientation; dest.Resources.Add(src.IO.Combine(dir, "lib")); return(dest); }
/* ----------------------------------------------------------------- */ /// /// CreateUserProgramMessage /// /// <summary> /// Creates a message to show the OpenFileDialog. /// </summary> /// /// <param name="src">User settings.</param> /// /// <returns>OpenFileEventArgs object.</returns> /// /* ----------------------------------------------------------------- */ public static OpenFileEventArgs CreateUserProgramMessage(this SettingsFolder src) { var io = src.IO; var path = src.Value.UserProgram; var dest = new OpenFileEventArgs { Title = Properties.Resources.TitleBroseUserProgram, FileName = GetFileName(path, io), Multiselect = false, Filter = ViewResource.UserProgramFilters.GetFilter(), }; if (src.Value.ExplicitDirectory) { dest.InitialDirectory = GetDirectoryName(path, io); } return(dest); }
/* ----------------------------------------------------------------- */ /// /// CreateDestination /// /// <summary> /// Creates a message to show the SaveFileDialog. /// </summary> /// /// <param name="src">User settings.</param> /// /// <returns>SaveFileEventArgs object.</returns> /// /* ----------------------------------------------------------------- */ public static SaveFileEventArgs CreateDestinationMessage(this SettingsFolder src) { var io = src.IO; var path = src.Value.Destination; var dest = new SaveFileEventArgs { Title = Properties.Resources.TitleBroseDestination, FileName = GetFileName(path, io), OverwritePrompt = false, Filter = ViewResource.DestinationFilters.GetFilter(), FilterIndex = ViewResource.DestinationFilters.GetFilterIndex(path, io), }; if (src.Value.ExplicitDirectory) { dest.InitialDirectory = GetDirectoryName(path, io); } return(dest); }
/* ----------------------------------------------------------------- */ /// /// ProcessLauncher /// /// <summary> /// オブジェクトを初期化します。 /// </summary> /// /// <param name="settings">設定情報</param> /// /* ----------------------------------------------------------------- */ public ProcessLauncher(SettingsFolder settings) { IO = settings.IO; Value = settings.Value; }
/* ----------------------------------------------------------------- */ /// /// FileDecorator /// /// <summary> /// Initializes a new instance of the FileDecorator class with the /// specified settings. /// </summary> /// /// <param name="settings">User settings.</param> /// /* ----------------------------------------------------------------- */ public FileDecorator(SettingsFolder settings) { Settings = settings; }
/* ----------------------------------------------------------------- */ /// /// CreatePdfConverter /// /// <summary> /// Initializes a new instance of the PdfConverter class with the /// specified settings. /// </summary> /// /* ----------------------------------------------------------------- */ private static Ghostscript.PdfConverter CreatePdfConverter(SettingsFolder src) => new PdfConverter(src.IO) { Version = src.Value.FormatOption.GetVersion(), Compression = src.Value.ImageCompression ? Encoding.Jpeg : Encoding.Flate, };
/* ----------------------------------------------------------------- */ /// /// GetValue /// /// <summary> /// Gets the string value from the specified arguments. /// </summary> /// /* ----------------------------------------------------------------- */ public static string GetValue(this SettingsFolder src, RegistryKey root, string name) => root.GetValue <string>($@"Software\{src.Assembly.Company}\{src.Assembly.Product}", name);
/* ----------------------------------------------------------------- */ /// /// MainViewModel /// /// <summary> /// オブジェクトを初期化します。 /// </summary> /// /// <param name="settings">設定情報</param> /// /* ----------------------------------------------------------------- */ public MainViewModel(SettingsFolder settings) : this(settings, SynchronizationContext.Current) { }
/* ----------------------------------------------------------------- */ /// /// MainFacade /// /// <summary> /// オブジェクトを初期化します。 /// </summary> /// /// <param name="settings">設定情報</param> /// /* ----------------------------------------------------------------- */ public MainFacade(SettingsFolder settings) { Settings = settings; Locale.Set(settings.Value.Language); }