/* ----------------------------------------------------------------- */ /// /// 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) ); }
/* ----------------------------------------------------------------- */ /// /// RibbonViewModel /// /// <summary> /// Initializes a new instance of the RibbonViewModel /// class with the specified arguments. /// </summary> /// /// <param name="src">Bindable data.</param> /// <param name="aggregator">Message aggregator.</param> /// <param name="context">Synchronization context.</param> /// /* ----------------------------------------------------------------- */ public RibbonViewModel(MainBindable src, Aggregator aggregator, SynchronizationContext context ) : base(aggregator, context) { if (src != null) { src.Source.PropertyChanged += WhenPropertyChanged; src.Busy.PropertyChanged += WhenPropertyChanged; } _model = src; }
/* ----------------------------------------------------------------- */ /// /// 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; }
/* ----------------------------------------------------------------- */ /// /// RibbonViewModel /// /// <summary> /// Initializes a new instance of the RibbonViewModel /// class with the specified arguments. /// </summary> /// /// <param name="src">Bindable data.</param> /// <param name="messenger">Messenger object.</param> /// /* ----------------------------------------------------------------- */ public RibbonViewModel(MainBindable src, IMessenger messenger) : base(messenger) { Insert = new RibbonElement( () => Properties.Resources.MenuInsert, () => Properties.Resources.TooltipInsert, () => !src.Busy.Value && src.IsOpen(), nameof(Insert) ); Remove = new RibbonElement( () => Properties.Resources.MenuRemove, () => Properties.Resources.TooltipRemove, () => !src.Busy.Value && src.IsOpen(), nameof(Remove) ); FrameOnly = this.Create( () => src.Settings.FrameOnly, e => src.Settings.FrameOnly = e, () => Properties.Resources.MenuFrameOnly ); }