Esempio n. 1
0
        /* ----------------------------------------------------------------- */
        ///
        /// Show
        ///
        /// <summary>
        /// Shows the main window.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private static void Show(SettingFolder settings)
        {
            var view = new MainWindow();

            view.Bind(new MainViewModel(settings));
            Application.Run(view);
        }
Esempio n. 2
0
 /* ----------------------------------------------------------------- */
 ///
 /// FileTransfer
 ///
 /// <summary>
 /// Initializes a new instance of the FileTransfer class with the
 /// specified arguments.
 /// </summary>
 ///
 /// <param name="src">User settings.</param>
 /// <param name="temp">Temp directory.</param>
 ///
 /* ----------------------------------------------------------------- */
 public FileTransfer(SettingFolder src, string temp)
 {
     Settings = src;
     Temp     = GetTempDirectory(temp);
     Target   = Settings.IO.Get(src.Value.Destination);
     Value    = Settings.IO.Combine(Temp, GetName());
 }
Esempio n. 3
0
 /* ----------------------------------------------------------------- */
 ///
 /// SettingViewModel
 ///
 /// <summary>
 /// Initializes a new instance of the SettingViewModel class with
 /// the specified arguments.
 /// </summary>
 ///
 /// <param name="settings">User settings.</param>
 /// <param name="aggregator">Message aggregator.</param>
 /// <param name="context">Synchronization context.</param>
 ///
 /* ----------------------------------------------------------------- */
 public SettingViewModel(SettingFolder settings, Aggregator aggregator,
                         SynchronizationContext context) : base(aggregator, context)
 {
     _io    = settings.IO;
     _model = settings.Value;
     _model.PropertyChanged += (s, e) => OnPropertyChanged(e);
 }
Esempio n. 4
0
 /* ----------------------------------------------------------------- */
 ///
 /// ProcessLauncher
 ///
 /// <summary>
 /// Initializes a new instance of the ProcessLauncher class with
 /// the specified settings.
 /// </summary>
 ///
 /// <param name="src">User settings.</param>
 ///
 /* ----------------------------------------------------------------- */
 public ProcessLauncher(SettingFolder src)
 {
     Settings  = src;
     _handlers = new Dictionary <PostProcess, Action <IEnumerable <string> > >
     {
         { PostProcess.Open, Open },
         { PostProcess.OpenDirectory, OpenDirectory },
         { PostProcess.Others, RunUserProgram },
     };
 }
Esempio n. 5
0
        /* ----------------------------------------------------------------- */
        ///
        /// CreateImageConverter
        ///
        /// <summary>
        /// Initializes a new instance of the ImageConverter class with
        /// the specified settings.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private static Ghostscript.Converter CreateImageConverter(SettingFolder src)
        {
            var key = KeyValuePair.Create(src.Value.Format, src.Value.Grayscale);

            Debug.Assert(FormatMap.ContainsKey(key));
            return(new ImageConverter(FormatMap[key], src.IO)
            {
                AntiAlias = true
            });
        }
Esempio n. 6
0
        /* ----------------------------------------------------------------- */
        ///
        /// MainViewModel
        ///
        /// <summary>
        /// Initializes a new instance of the MainViewModel class with the
        /// specified arguments.
        /// </summary>
        ///
        /// <param name="settings">User settings.</param>
        /// <param name="context">Synchronization context.</param>
        ///
        /* ----------------------------------------------------------------- */
        public MainViewModel(SettingFolder settings, SynchronizationContext context) :
            base(new Facade(settings), new Aggregator(), context)
        {
            Locale.Set(settings.Value.Language);

            General    = new SettingViewModel(settings, Aggregator, context);
            Metadata   = new MetadataViewModel(settings.Value.Metadata, Aggregator, context);
            Encryption = new EncryptionViewModel(settings.Value.Encryption, Aggregator, context);

            Facade.Settings.PropertyChanged += Observe;
        }
Esempio n. 7
0
        /* ----------------------------------------------------------------- */
        ///
        /// Normalize
        ///
        /// <summary>
        /// Normalizes the specified settings.
        /// </summary>
        ///
        /// <param name="src">Setting to be normalized.</param>
        ///
        /// <remarks>
        /// 1.0.0RC12 より Resolution を ComboBox のインデックスに対応
        /// する値から直接の値に変更しました。これに伴い、インデックスを
        /// 指していると予想される値を初期値にリセットしています。
        /// </remarks>
        ///
        /* ----------------------------------------------------------------- */
        public static void Normalize(this SettingFolder src)
        {
            var value = src.Value;

            value.Format            = GetFormat(value);
            value.Resolution        = GetResolution(value);
            value.Orientation       = GetOrientation(value);
            value.Metadata.Creator  = GetCreator(value);
            value.Metadata.Producer = GetCreator(value);
            value.Encryption.Deny();
            value.Encryption.Permission.Accessibility = PermissionValue.Allow;
        }
Esempio n. 8
0
        /* ----------------------------------------------------------------- */
        ///
        /// CreateDocumentConverter
        ///
        /// <summary>
        /// Initializes a new instance of the DocumentConverter class with
        /// the specified settings.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private static DocumentConverter CreateDocumentConverter(SettingFolder 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.SameAsSource;
            dest.Downsampling = src.Value.Downsampling;
            dest.EmbedFonts   = src.Value.EmbedFonts;

            return(dest);
        }
Esempio n. 9
0
        /* ----------------------------------------------------------------- */
        ///
        /// 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(SettingFolder 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.Temp        = src.Value.Temp;
            dest.Log         = src.IO.Combine(src.Value.Temp, src.Uid.ToString("D"), "console.log");
            dest.Resolution  = src.Value.Resolution;
            dest.Orientation = src.Value.Orientation;
            dest.Resources.Add(src.IO.Combine(dir, "lib"));

            return(dest);
        }
Esempio n. 10
0
        /* ----------------------------------------------------------------- */
        ///
        /// CreateForUserProgram
        ///
        /// <summary>
        /// Creates a message to show an OpenFileDialog dialog for
        /// selecting the user program.
        /// </summary>
        ///
        /// <param name="src">User settings.</param>
        ///
        /// <returns>OpenFileMessage object.</returns>
        ///
        /* ----------------------------------------------------------------- */
        public static OpenFileMessage CreateForUserProgram(this SettingFolder src)
        {
            var path = src.Value.UserProgram;
            var dest = new OpenFileMessage
            {
                Text        = Properties.Resources.TitleSelectUserProgram,
                Value       = GetFileNames(path, src.IO),
                Multiselect = false,
                Filter      = ViewResources.UserProgramFilters.GetFilter(),
            };

            if (src.Value.ExplicitDirectory)
            {
                dest.InitialDirectory = GetDirectoryName(path, src.IO);
            }
            return(dest);
        }
Esempio n. 11
0
        /* ----------------------------------------------------------------- */
        ///
        /// CreateForDestination
        ///
        /// <summary>
        /// Creates a message to show an OpenFileDialog dialog for
        /// selecting the destination path.
        /// </summary>
        ///
        /// <param name="src">User settings.</param>
        ///
        /// <returns>SaveFileMessage object.</returns>
        ///
        /* ----------------------------------------------------------------- */
        public static SaveFileMessage CreateForDestination(this SettingFolder src)
        {
            var path = src.Value.Destination;
            var dest = new SaveFileMessage
            {
                Text            = Properties.Resources.TitleSelectDestination,
                Value           = GetFileName(path, src.IO),
                OverwritePrompt = false,
                Filter          = ViewResources.DestinationFilters.GetFilter(),
                FilterIndex     = ViewResources.DestinationFilters.GetFilterIndex(path, src.IO),
            };

            if (src.Value.ExplicitDirectory)
            {
                dest.InitialDirectory = GetDirectoryName(path, src.IO);
            }
            return(dest);
        }
Esempio n. 12
0
        /* ----------------------------------------------------------------- */
        ///
        /// CreateForSource
        ///
        /// <summary>
        /// Creates a message to show an OpenFileDialog dialog for
        /// selecting the source path.
        /// </summary>
        ///
        /// <param name="src">User settings.</param>
        ///
        /// <returns>OpenFileMessage object.</returns>
        ///
        /* ----------------------------------------------------------------- */
        public static OpenFileMessage CreateForSource(this SettingFolder src)
        {
            var io   = src.IO;
            var path = src.Value.Source;
            var dest = new OpenFileMessage
            {
                Title       = Properties.Resources.TitleSelectSource,
                Value       = GetFileNames(path, io),
                Multiselect = false,
                Filter      = ViewResources.SourceFilters.GetFilter(),
                FilterIndex = ViewResources.SourceFilters.GetFilterIndex(path, io),
            };

            if (src.Value.ExplicitDirectory)
            {
                dest.InitialDirectory = GetDirectoryName(path, io);
            }
            return(dest);
        }
Esempio n. 13
0
 /* ----------------------------------------------------------------- */
 ///
 /// Execute
 ///
 /// <summary>
 /// Executes the conversion directly.
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 private static void Execute(SettingFolder settings)
 {
     using (var src = new Facade(settings)) src.Invoke();
 }
Esempio n. 14
0
 /* ----------------------------------------------------------------- */
 ///
 /// GetTitle
 ///
 /// <summary>
 /// Gets the title of main window.
 /// </summary>
 ///
 /// <param name="src">Setting to be normalized.</param>
 ///
 /// <returns>Title string.</returns>
 ///
 /* ----------------------------------------------------------------- */
 public static string GetTitle(this SettingFolder src) =>
 src.DocumentName.Source.HasValue() ?
 $"{src.DocumentName.Source} - {src.Assembly.GetTitle()} {src.Version.ToString(true)}" :
 $"{src.Assembly.GetTitle()} {src.Version.ToString(true)}";
Esempio n. 15
0
 /* ----------------------------------------------------------------- */
 ///
 /// MainViewModel
 ///
 /// <summary>
 /// Initializes a new instance of the MainViewModel class with the
 /// specified arguments.
 /// </summary>
 ///
 /// <param name="settings">User settings.</param>
 ///
 /* ----------------------------------------------------------------- */
 public MainViewModel(SettingFolder settings) :
     this(settings, SynchronizationContext.Current)
 {
 }
Esempio n. 16
0
 /* ----------------------------------------------------------------- */
 ///
 /// Facade
 ///
 /// <summary>
 /// Initializes a new instance of the specified settings.
 /// </summary>
 ///
 /// <param name="settings">User settings.</param>
 ///
 /* ----------------------------------------------------------------- */
 public Facade(SettingFolder settings)
 {
     Settings = settings;
 }
Esempio n. 17
0
 /* ----------------------------------------------------------------- */
 ///
 /// DigestChecker
 ///
 /// <summary>
 /// Initializes a new instance of the DigestChecker class with the
 /// specified settings.
 /// </summary>
 ///
 /// <param name="src">User settings.</param>
 ///
 /* ----------------------------------------------------------------- */
 public DigestChecker(SettingFolder src)
 {
     Settings = src;
 }
Esempio n. 18
0
 /* ----------------------------------------------------------------- */
 ///
 /// CreatePdfConverter
 ///
 /// <summary>
 /// Initializes a new instance of the PdfConverter class with the
 /// specified settings.
 /// </summary>
 ///
 /* ----------------------------------------------------------------- */
 private static PdfConverter CreatePdfConverter(SettingFolder src) =>
 new PdfConverter(src.IO)
 {
     Version     = src.Value.Metadata.Version,
     Compression = src.Value.ImageFilter ? Encoding.Jpeg : Encoding.Flate,
 };
Esempio n. 19
0
 /* ----------------------------------------------------------------- */
 ///
 /// FileDecorator
 ///
 /// <summary>
 /// Initializes a new instance of the FileDecorator class with the
 /// specified settings.
 /// </summary>
 ///
 /// <param name="src">User settings.</param>
 ///
 /* ----------------------------------------------------------------- */
 public FileDecorator(SettingFolder src)
 {
     Settings = src;
 }