Example #1
0
 /* ----------------------------------------------------------------- */
 ///
 /// SettingViewModel
 ///
 /// <summary>
 /// Initializes a new instance of the SettingViewModel
 /// with the specified arguments.
 /// </summary>
 ///
 /// <param name="src">User settings.</param>
 /// <param name="context">Synchronization context.</param>
 ///
 /* ----------------------------------------------------------------- */
 public SettingViewModel(SettingFolder src, SynchronizationContext context) :
     base(() => Properties.Resources.TitleSetting, new Aggregator(), context)
 {
     _model     = src;
     OK.Command = new DelegateCommand(() =>
     {
         Send <UpdateSourcesMessage>();
         Send <CloseMessage>();
     });
 }
Example #2
0
 /* ----------------------------------------------------------------- */
 ///
 /// MainFacade
 ///
 /// <summary>
 /// Initializes a new instance of the MainFacade class with the
 /// specified arguments.
 /// </summary>
 ///
 /// <param name="folder">Folder of user settings.</param>
 /// <param name="context">Synchronization context.</param>
 ///
 /* ----------------------------------------------------------------- */
 public MainFacade(SettingFolder folder, SynchronizationContext context)
 {
     Folder = Setup(folder);
     Cache  = new RendererCache(Folder.IO, () => Value.Query);
     Backup = new Backup(Folder.IO);
     Value  = new MainBindable(
         new ImageCollection(e => Cache?.GetOrAdd(e), new ContextInvoker(context, true)),
         Folder,
         new ContextInvoker(context, false)
         );
 }
Example #3
0
        /* ----------------------------------------------------------------- */
        ///
        /// MainBindable
        ///
        /// <summary>
        /// Initializes a new instance of the MainBindable class
        /// with the specified arguments.
        /// </summary>
        ///
        /// <param name="images">Image collection.</param>
        /// <param name="settings">User settings.</param>
        /// <param name="invoker">Invoker object.</param>
        ///
        /* ----------------------------------------------------------------- */
        public MainBindable(ImageCollection images, SettingFolder settings, Invoker invoker) : base(invoker)
        {
            _settings = settings;

            var index = images.Preferences.ItemSizeOptions.LastIndex(e => e <= ItemSize);

            images.Preferences.ItemSizeIndex = Math.Max(index, 0);
            images.Preferences.FrameOnly     = Settings.FrameOnly;
            images.Preferences.TextHeight    = 25;

            Images  = images;
            History = new History(invoker);
        }
Example #4
0
        /* ----------------------------------------------------------------- */
        ///
        /// MainViewModel
        ///
        /// <summary>
        /// Initializes a new instance of the MainViewModel class
        /// with the specified settings.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public MainViewModel(SettingFolder src, SynchronizationContext context) :
            base(new Aggregator(), context)
        {
            var recent   = Environment.SpecialFolder.Recent.GetName();
            var mon      = new DirectoryMonitor(recent, "*.pdf.lnk", src.IO, GetDispatcher(false));
            var password = new Query <string>(e => Send(new PasswordViewModel(e, src.IO, context)));

            Model  = new MainFacade(src, password, context);
            Ribbon = new RibbonViewModel(Model.Bindable, Aggregator, context);
            Recent = new RecentViewModel(mon, Aggregator, context);

            SetCommands();
            Track(() => Model.Setup(App.Arguments));
        }
Example #5
0
        /* ----------------------------------------------------------------- */
        ///
        /// MainViewModel
        ///
        /// <summary>
        /// Initializes a new instance of the MainViewModel class
        /// with the specified settings.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        public MainViewModel(SettingFolder src, SynchronizationContext context) : base(
                new MainFacade(src, context),
                new Aggregator(),
                context
                )
        {
            var recent = Environment.SpecialFolder.Recent.GetName();
            var mon    = new DirectoryMonitor(recent, "*.pdf.lnk", src.IO, GetInvoker(false));

            Ribbon      = new RibbonViewModel(Facade, Aggregator, context);
            Recent      = new RecentViewModel(mon, Aggregator, context);
            Value.Query = new Query <string>(e => Send(new PasswordViewModel(e, context)));
            Recent.Open = GetOpenLinkCommand();
        }
Example #6
0
        /* ----------------------------------------------------------------- */
        ///
        /// Setup
        ///
        /// <summary>
        /// Initializes the specified settings.
        /// </summary>
        ///
        /* ----------------------------------------------------------------- */
        private SettingFolder Setup(SettingFolder src)
        {
            src.Load();
            src.PropertyChanged += (s, e) => {
                switch (e.PropertyName)
                {
                case nameof(SettingValue.ItemSize):
                    this.Zoom();
                    break;

                case nameof(SettingValue.FrameOnly):
                    Value.Images.Preferences.FrameOnly = src.Value.FrameOnly;
                    break;
                }
            };
            return(src);
        }
Example #7
0
 /* ----------------------------------------------------------------- */
 ///
 /// MainBindable
 ///
 /// <summary>
 /// Initializes a new instance of the MainBindable class
 /// with the specified arguments.
 /// </summary>
 ///
 /// <param name="images">Image collection.</param>
 /// <param name="settings">User settings.</param>
 /// <param name="query">Password query.</param>
 /// <param name="dispatcher">Dispatcher object.</param>
 ///
 /* ----------------------------------------------------------------- */
 public MainBindable(ImageCollection images, SettingFolder settings,
                     IQuery <string> query, IDispatcher dispatcher)
 {
     _settings = settings;
     Images    = images;
     Query     = query;
     History   = new History(dispatcher);
     Source    = new BindableValue <Information>(dispatcher);
     Message   = new BindableValue <string>(string.Empty, dispatcher);
     Busy      = new BindableValue <bool>(() => _busy, dispatcher);
     Modified  = new BindableValue <bool>(() => History.Undoable, dispatcher);
     Count     = new BindableValue <int>(() => Images.Count, dispatcher);
     ItemSize  = new BindableValue <int>(
         () => Settings.ItemSize,
         e => Settings.ItemSize = e,
         dispatcher
         );
 }
Example #8
0
        /* ----------------------------------------------------------------- */
        ///
        /// MainFacade
        ///
        /// <summary>
        /// Initializes a new instance of the MainFacade class with the
        /// specified arguments.
        /// </summary>
        ///
        /// <param name="src">User settings.</param>
        /// <param name="query">Password query.</param>
        /// <param name="context">Synchronization context.</param>
        ///
        /* ----------------------------------------------------------------- */
        public MainFacade(SettingFolder src, IQuery <string> query, SynchronizationContext context)
        {
            var images = new ImageCollection(e => _core?.GetOrAdd(e), new Dispatcher(context, true));
            var post   = new Dispatcher(context, false);

            _core    = new DocumentCollection(query, src.IO);
            Backup   = new Backup(src.IO);
            Bindable = new MainBindable(images, src, query, post);

            Settings = src;
            Settings.Load();
            Settings.PropertyChanged += (s, e) => Update(e.PropertyName);

            var sizes = Bindable.Images.Preferences.ItemSizeOptions;
            var index = sizes.LastIndexOf(e => e <= Bindable.ItemSize.Value);

            Bindable.Images.Preferences.ItemSizeIndex = Math.Max(index, 0);
            Bindable.Images.Preferences.FrameOnly     = src.Value.FrameOnly;
            Bindable.Images.Preferences.TextHeight    = 25;
        }