public MainViewModel(IEventAggregator eventAggregator, IImageCacheRepository imageCacheRepository)
        {
            this.EventAggregator      = eventAggregator;
            this.ImageCacheRepository = imageCacheRepository;

            _ = this.LoadResolutions();
            _ = this.LoadIpAddresses();
            _ = this.LoadLabelUnits();

            this.StartCommand        = new DelegateCommand(() => _ = this.StartAsync(), () => !this.IsBusy && !this.IsRunning && this.Port > 0 && this.LabelWidth > 0 && this.LabelHeight > 0);
            this.StopCommand         = new DelegateCommand(() => _ = this.StopAsync(), () => !this.IsBusy && this.IsRunning);
            this.TestLabelCommand    = new DelegateCommand(() => _ = this.TestLabelAsync(), () => !this.IsBusy && this.IsRunning);
            this.ClearLabelsCommand  = new DelegateCommand(() => _ = this.ClearLabelsAsync(), () => !this.IsBusy && this.Labels.Count > 0);
            this.BrowseCommand       = new DelegateCommand(() => _ = this.BrowseCommandAsync(), () => !this.IsBusy);
            this.DeleteLabelCommand  = new DelegateCommand(() => _ = this.DeleteLabelAsync(), () => !this.IsBusy & this.SelectedLabel != null);
            this.LabelPreviewCommand = new DelegateCommand(() => _ = this.LabelPreviewAsync(), () => !this.IsBusy & this.SelectedLabel != null);

            //
            // Subscribe to the running state changed event to update the running
            // status of the UI.
            //
            _ = this.EventAggregator.GetEvent <RunningStateChangedEvent>().Subscribe((a) =>
            {
                this.IsRunning = a.IsRunning;

                if (a.IsError)
                {
                    this.StatusText = a.ErrorMessage;
                }
            }, ThreadOption.UIThread);

            //
            // Subscribe to the label created event to add all new labels
            // to the UI.
            //
            _ = this.EventAggregator.GetEvent <LabelCreatedEvent>().Subscribe((a) =>
            {
                //
                // Add the new label to the collection.
                //
                this.Labels.Add(a.Label);

                //
                // Make the new label the currently selected label.
                //
                this.SelectedLabel = a.Label;
            }, ThreadOption.UIThread);

            //
            // Subscribe to the timer event.
            //
            _ = this.EventAggregator.GetEvent <TimerEvent>().Subscribe((a) =>
            {
                foreach (var label in this.Labels)
                {
                    label.Refresh();
                }
            }, ThreadOption.UIThread);
        }
Exemple #2
0
 public LoadCacheServiceHost(IOptions <ImageSearchConfig> imageSearchConfig,
                             IImageCacheRepository imageCacheRepository,
                             ILogger <LoadCacheServiceHost> logger)
 {
     ImageSearchConfig    = imageSearchConfig.Value;
     ImageCacheRepository = imageCacheRepository;
     Logger = logger;
 }
Exemple #3
0
 public TcpListenerClientHandler(IEventAggregator eventAggregator, ILabelService labelService, IImageCacheRepository imageCacheRepository)
 {
     this.EventAggregator      = eventAggregator;
     this.LabelService         = labelService;
     this.ImageCacheRepository = imageCacheRepository;
 }
 public ImageSearchEngine(IImageCacheRepository imageCacheRepository)
 {
     ImageCacheRepository = imageCacheRepository;
 }