Пример #1
0
        public void SetUp()
        {
            List <Note> notes = new List <Note>
            {
                new Note {
                    Name = "TestNote1", Description = "TestDescription1"
                },
                new Note {
                    Name = "TestNote2", Description = "TestDescription2"
                }
            };

            var stubDataProvider = new Mock <IDataProvider>();

            stubDataProvider.SetupAllProperties();
            stubDataProvider.Setup(dp => dp.Notes).Returns(notes);
            stubDataProvider.Setup(dp => dp.GetCollection <Note>()).Returns(notes);

            mockNotificationCenter = new Mock <INotificationCenter>();
            mockNotificationCenter.Setup(nc => nc.PostNotification(It.IsAny <NotificationName>(), It.IsAny <NotificationArgs>()))
            .Callback <NotificationName, NotificationArgs>((nName, nArgs) => notificationArgs = nArgs);
            notificationCenter = mockNotificationCenter.Object;

            notesVM = new NotesViewModel(stubDataProvider.Object, notificationCenter);
        }
Пример #2
0
 public CommandManager(IEnumerable<ISecurityRole> availableRoles, IEnumerable<IInputCommand> commands, INotificationCenter notificationCenter)
 {
     this.serverRoles = availableRoles ?? Enumerable.Empty<ISecurityRole>();
     this.commandCollection = commands;
     this.notificationCenter = notificationCenter;
     this.currentlyExecutingCommands = new Stack<IInputCommand>();
 }
Пример #3
0
 public FoilControl(INotificationCenter notificationCenter)
 {
     _notificationCenter = notificationCenter;
     ShowLabel           = true;
     InitializeComponent();
     rootGrid.DataContext = this;
 }
Пример #4
0
 public void Init()
 {
     _notificationCenter = Substitute.For <INotificationCenter>();
     _calc             = Substitute.For <IPositionCalc>();
     _display          = Substitute.For <IDisplay>();
     _displayFormatter = new DisplayFormatter(_display, _calc, _notificationCenter, _testWidth, _testHeight);
 }
Пример #5
0
        public CollectionViewModel(
            INotificationCenter notification,
            IUserDatabase userDatabase,
            ICardDatabase cardDatabase,
            IApplicationSettings applicationSettings)
        {
            _notification        = notification;
            _userDatabase        = userDatabase;
            _cardDatabase        = cardDatabase;
            _applicationSettings = applicationSettings;
            Collections          = _userDatabase
                                   .GetAllCollections()
                                   .Select(c => new SingleCollectionViewModell(notification, _userDatabase, _cardDatabase, c));

            ISingleCollectionViewModel loadedCollection = null;

            Task.Factory.StartNew(() =>
            {
                var currentCollectionName = _applicationSettings.GetCurrentCollection();
                var found        = Collections.FirstOrDefault(c => c.CollectionName == currentCollectionName);
                loadedCollection = LoadCollection(found);
            }).ContinueWith((task) =>
            {
                SelectedCollection = loadedCollection;
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Пример #6
0
        public static void ClearImageData(INotificationCenter notificationCenter)
        {
            var watch = Stopwatch.StartNew();

            notificationCenter.FireNotification(LogLevel.Debug, "Resetting image paths");
            foreach (var item in PriceCache.Values.ToList())
            {
                item.ImagePath = "";
            }

            notificationCenter.FireNotification(LogLevel.Debug, "Flush image cache");
            Write();

            foreach (var file in Directory.EnumerateFiles(PathHelper.CardImageCacheFolder, "*.*", SearchOption.AllDirectories))
            {
                try
                {
                    notificationCenter.FireNotification(LogLevel.Debug, "Deleting file " + file);
                    File.Delete(file);
                }
                catch (Exception error)
                {
                    notificationCenter.FireNotification(LogLevel.Error, "Error deleting file '" + file + "':" + error.Message);
                }
            }

            watch.Stop();
            notificationCenter.FireNotification(LogLevel.Debug, "Clear image data took " + watch.Elapsed);
        }
Пример #7
0
 public CommandManager(IEnumerable <ISecurityRole> availableRoles, IEnumerable <IInputCommand> commands, INotificationCenter notificationCenter)
 {
     this.serverRoles                = availableRoles ?? Enumerable.Empty <ISecurityRole>();
     this.commandCollection          = commands;
     this.notificationCenter         = notificationCenter;
     this.currentlyExecutingCommands = new Stack <IInputCommand>();
 }
Пример #8
0
 public SignUpViewModel(IAccountStorage accountStorage, INotificationCenter notificationCenter,
     ICurrentUser currentUser)
 {
     _accountStorage = accountStorage;
     _notificationCenter = notificationCenter;
     _currentUser = currentUser;
 }
Пример #9
0
 public void Init()
 {
     _display            = Substitute.For <IDisplay>();
     _formatter          = Substitute.For <IDisplayFormatter>();
     _notificationCenter = new NotificationCenter(_display);
     _notificationCenter.SetFormatter(_formatter);
 }
Пример #10
0
 protected CollectionViewModel(IDataProvider dataProvider, INotificationCenter notificationCenter)
 {
     _dataProvider       = dataProvider;
     _notificationCenter = notificationCenter;
     PopulateData();
     InitCommands();
 }
Пример #11
0
 public SignUpViewModel(IAccountStorage accountStorage, INotificationCenter notificationCenter,
                        ICurrentUser currentUser)
 {
     _accountStorage     = accountStorage;
     _notificationCenter = notificationCenter;
     _currentUser        = currentUser;
 }
 public BinderStatisticsViewModel(
     INotificationCenter notificationCenter,
     MagicBinderViewModel binderViewModel)
 {
     _notificationCenter = notificationCenter;
     _binderViewModel    = binderViewModel;
 }
Пример #13
0
        public SetImage(INotificationCenter notificationCenter)
        {
            _notificationCenter = notificationCenter;

            InitializeComponent();
            rootGrid.DataContext = this;
        }
Пример #14
0
 public static INotificationCenter GetInstance()
 {
     if (singleton == null)
     {
         singleton = new NotificationCenter();
     }
     return(singleton);
 }
Пример #15
0
 public ShellViewModel(
     INotificationCenter notificationCenter)
 {
     notificationCenter.NotificationFired += (sender, e) =>
     {
         StatusBarMessage = e.Message;
     };
 }
 void DestroyNotificationCenter()
 {
     if (_notificationCenter != null)
     {
         _notificationCenter.Destroy();
         _notificationCenter = null;
     }
 }
Пример #17
0
        public PlayerLoginCommand(INotificationCenter notificationManager)
        {
            this.passwordProcessor = new CharacterPasswordProcessor();
            this.nameProcessor     = new CharacterNameProcessor(notificationManager, this.passwordProcessor);
            this.nameRequestor     = new CharacterNameRequestor(notificationManager, this.nameProcessor);

            this.currentProcessor    = this.nameRequestor;
            this.notificationManager = notificationManager;
        }
Пример #18
0
        public PlayerLoginCommand(INotificationCenter notificationManager)
        {
            this.passwordProcessor = new CharacterPasswordProcessor();
            this.nameProcessor = new CharacterNameProcessor(notificationManager, this.passwordProcessor);
            this.nameRequestor = new CharacterNameRequestor(notificationManager, this.nameProcessor);

            this.currentProcessor = this.nameRequestor;
            this.notificationManager = notificationManager;
        }
Пример #19
0
        public PostsViewHolder(View itemView, INotificationCenter notification, IRepositoryPost repository, IRepositoryQc repositoryQc,
                               PostOtherThemeStrings otherThemeStrings) : base(itemView)
        {
            _repository   = repository;
            _repositoryQc = repositoryQc;
            _notification = notification;

            _otherThemeStrings = otherThemeStrings;

            _itemView = itemView;
        }
Пример #20
0
        public DisplayFormatter(IDisplay display, IPositionCalc calc, INotificationCenter notificationCenter, int width = 150, int height = 50)
        {
            _calc = calc;
            _notificationCenter = notificationCenter;

            Width    = width;
            Height   = height;
            _display = display;

            _display.BuildFrame(width, height);
        }
Пример #21
0
        public ReportsViewModel(IReportStorage reportStorage, INotificationCenter notificationCenter)
        {
            _reportStorage = reportStorage;

            Title = "Mina rapporter";

            notificationCenter.Subscribe<User>(this, NotificationKeys.CurrentUserChanged, u =>
            {
                Device.BeginInvokeOnMainThread(RefreshReports);
            });
        }
Пример #22
0
 public ServerService(ILogger <ServerService> logger, ApplicationDbContext context, IApplicationManager application,
                      IConsoleService console, IDownloadService download, IFileWriterService fileWriter, INotificationCenter notificationCenter)
 {
     _logger             = logger;
     _context            = context;
     _application        = application;
     _console            = console;
     _download           = download;
     _fileWriter         = fileWriter;
     _notificationCenter = notificationCenter;
 }
Пример #23
0
        public ReportsViewModel(IReportStorage reportStorage, INotificationCenter notificationCenter)
        {
            _reportStorage = reportStorage;

            Title = "Mina rapporter";

            notificationCenter.Subscribe <User>(this, NotificationKeys.CurrentUserChanged, u =>
            {
                Device.BeginInvokeOnMainThread(RefreshReports);
            });
        }
Пример #24
0
        public MagicBinderCardViewModel(
            IMagicCardDefinition definition,
            MagicBinderCard card)
        {
            _notificationCenter = NotificationCenter.Instance;
            _definition         = definition;
            _card  = card;
            _price = StaticPriceDatabase.FindPrice(_definition, false, false, "", false);
            _price.PriceChanged += OnPricePriceChanged;

            UpdatePrice();
        }
        public DataViewModel(ITasksViewModel tasksViewModel, INotesViewModel notesViewModel, IEventsViewModel eventsViewModel, INotificationCenter notificationCenter)
        {
            TasksViewModel  = tasksViewModel;
            NotesViewModel  = notesViewModel;
            EventsViewModel = eventsViewModel;

            SetControlVisibility = new RelayCommand(ControlVisibility);

            this.notificationCenter = notificationCenter;
            notificationCenter.AddMessageHandler(ShowModal, NotificationName.SHOW_ITEM_EDIT_MODAL);
            notificationCenter.AddMessageHandler(CloseModal, NotificationName.CLOSE_ITEM_EDIT_MODAL);
        }
Пример #26
0
        public RulesViewModel(IRuleStorage ruleStorage, INotificationCenter notificationCenter)
        {
            _ruleStorage = ruleStorage;

            Title = "Regler";

            Device.BeginInvokeOnMainThread(RefreshRules);

            notificationCenter.Subscribe<User>(this, NotificationKeys.CurrentUserChanged, u =>
            {
                Device.BeginInvokeOnMainThread(RefreshRules);
            });
        }
Пример #27
0
        public SingleCollectionViewModell(
            INotificationCenter notification,
            IUserDatabase userDatabase,
            ICardDatabase cardDatabase,
            MagicCollection databaseCollection)
        {
            _userDatabase       = userDatabase;
            _notification       = notification;
            _cardDatabase       = cardDatabase;
            _databaseCollection = databaseCollection;

            CollectionName = _databaseCollection != null ? _databaseCollection.Name : "";
        }
Пример #28
0
        public SightingsViewModel(ISightingStorage sightingStorage, INotificationCenter notificationCenter)
        {
            _sightingStorage = sightingStorage;

            Title      = "Observationer";
            DaysFilter = "";


            notificationCenter.Subscribe <User>(this, NotificationKeys.CurrentUserChanged, u =>
            {
                Device.BeginInvokeOnMainThread(RefreshSightings);
            });
        }
Пример #29
0
        public SightingsViewModel(ISightingStorage sightingStorage, INotificationCenter notificationCenter)
        {
            _sightingStorage = sightingStorage;

            Title = "Observationer";
            DaysFilter = "";


            notificationCenter.Subscribe<User>(this, NotificationKeys.CurrentUserChanged, u =>
            {
                Device.BeginInvokeOnMainThread(RefreshSightings);
            });
        }
Пример #30
0
 public MagicBinderViewModel(string name, INotificationCenter notificationCenter)
 {
     _notificationCenter = notificationCenter;
     _cards       = new ObservableCollection <MagicBinderCardViewModel>();
     _sortedCards = new Dictionary <string, MagicBinderCardViewModel>();
     if (!string.IsNullOrEmpty(name))
     {
         _magicCollection = new MagicBinder
         {
             Name = name,
         };
     }
 }
Пример #31
0
        public RulesViewModel(IRuleStorage ruleStorage, INotificationCenter notificationCenter)
        {
            _ruleStorage = ruleStorage;

            Title = "Regler";

            Device.BeginInvokeOnMainThread(RefreshRules);

            notificationCenter.Subscribe <User>(this, NotificationKeys.CurrentUserChanged, u =>
            {
                Device.BeginInvokeOnMainThread(RefreshRules);
            });
        }
Пример #32
0
        public CardImage(INotificationCenter notificationCenter)
        {
            _notificationCenter = notificationCenter;

            InitializeComponent();
            rootGrid.DataContext = this;

            _emptyImage = new BitmapImage();
            _emptyImage.BeginInit();
            _emptyImage.StreamSource = GetType().Assembly.GetEmbeddedResourceStream("Empty.png");
            _emptyImage.EndInit();
            _emptyImage.Freeze();
            imageControl.Source = _emptyImage;
        }
Пример #33
0
        /// <summary>
        /// Instances a new PlayerConnectionState.
        /// </summary>
        /// <param name="player">An instance of a Player type that will be performing network communication</param>
        /// <param name="currentSocket">The Socket used to communicate with the client.</param>
        /// <param name="bufferSize">The storage size of the data buffer</param>
        public PlayerConnectionState(IPlayer player, Socket currentSocket, int bufferSize)
        {
            this.Player = player;
            this.notificationManager       = player.NotificationCenter;
            this.systemMessageSubscription = this.notificationManager.Subscribe <InformationMessage>(
                callback: (msg, sub) => this.SendMessage(msg.Content),
                condition: msg => !string.IsNullOrEmpty(msg.Content) && msg.Target == this.Player);
            this.Player.Deleted += this.PlayerDeleted;

            this.CurrentSocket = currentSocket;
            this.bufferSize    = bufferSize;
            this.Buffer        = new byte[bufferSize];

            this.outgoingMessageQueue.CollectionChanged += MessageAddedToOutboundQueue;
        }
Пример #34
0
        /// <summary>
        /// Instances a new PlayerConnectionState.
        /// </summary>
        /// <param name="player">An instance of a Player type that will be performing network communication</param>
        /// <param name="currentSocket">The Socket used to communicate with the client.</param>
        /// <param name="bufferSize">The storage size of the data buffer</param>
        public PlayerConnectionState(IPlayer player, Socket currentSocket, int bufferSize)
        {
            this.Player = player;
            this.notificationManager = player.NotificationCenter;
            this.systemMessageSubscription = this.notificationManager.Subscribe<InformationMessage>(
                callback: (msg, sub) => this.SendMessage(msg.Content),
                condition: msg => !string.IsNullOrEmpty(msg.Content) && msg.Target == this.Player);
            this.Player.Deleted += this.PlayerDeleted;

            this.CurrentSocket = currentSocket;
            this.bufferSize = bufferSize;
            this.Buffer = new byte[bufferSize];

            this.outgoingMessageQueue.CollectionChanged += MessageAddedToOutboundQueue;
        }
Пример #35
0
        public MainViewModel(INotificationCenter notificationCenter)
        {
            _logger.Log(LogLevel.Info, "============================= NEW APP START ============================= ");
            _notificationCenter      = notificationCenter;
            CardLookup               = new CardLookup();
            CardLookup.SearchWanted += (sender, e) =>
            {
                if (CardLookup.SearchAsYouType)
                {
                    LookupCards();
                }
            };

            DatabaseSummary = string.Format(
                CultureInfo.CurrentUICulture,
                "{0} cards from {1} sets",
                StaticMagicData.CardDefinitions.Count(),
                StaticMagicData.SetDefinitions.Count());

            notificationCenter.NotificationFired += (sender, e) =>
            {
                _logger.Log(e.LogLevel, e.Message);

                if (e.LogLevel >= _maxLevel)
                {
                    StatusBarText = e.Message;
                }
            };

            // Load the settings
            var provider = new SettingsProvider(new LocalAppDataStorage("AppSettings"));

            _settings = provider.GetSettings <SettingsData>();
            _maxLevel = LogLevel.FromString(_settings.LogLevel);

            _currentDataSource = new StaticMagicDataDataSource();

            if (!string.IsNullOrEmpty(_settings.LoadedBinder))
            {
                LoadBinder(new DirectoryInfo(PathHelper.UserDataFolder).MakeAbsolutePath(_settings.LoadedBinder));
            }

            Task.Factory.StartNew(() =>
            {
                LookupSource = LookupSource.ActiveBinder;
                // LookupCards();
            });
        }
Пример #36
0
        public InteractorPost(string postId, IOnePostController onePostsController, INotificationCenter notificationCenter, IRepositoryPost repository, IRepositoryQc repositoryQc)
        {
            _postId = postId;

            _repository = repository;

            _onePostController = onePostsController;
            _onePostController.OnRecieveModel += ControllerOnMessage;

            InteractorPostBody   = new InteractorPostBody(_postId, notificationCenter, repository);
            InteractorPostChart  = new InteractorPostChart(notificationCenter, repository);
            InteractorPostHeader = new InteractorPostHeader(_postId, new PostHeaderController(ConnectionController.GetInstance(), WebMsgParser.ParseResponseDeletePost, notificationCenter, repositoryQc,
                                                                                              repository.GetPostById(_postId).Quote), repository);
            InteractorPostSocial = new InteractorPostSocial(_postId, new PostSocialController(ConnectionController.GetInstance(), WebMsgParser.ParseResponsePostLike), notificationCenter, repository);
            //InteractorPostStatistics = new InteractorPostStatistics(notificationCenter, repository);
            InteractorTrade = new InteractorTrade(notificationCenter, repository);
        }
Пример #37
0
        private static void WorkaroundTimeout(INotificationCenter notificationCenter, string additionalLogText)
        {
            ////lock (_timeoutSync)
            ////{
            ////    _timeoutHelper += 1;
            ////    if (_timeoutHelper > 50)
            ////    {
            ////        _timeoutHelper = 0;

            ////        notificationCenter.FireNotification(
            ////            LogLevel.Debug,
            ////            "Waiting to get around MKM timeout " + additionalLogText);

            ////        // Warte kurz zwischen den Requests, damit wir nicht von
            ////        // MKM einen Timeout bekommen
            ////        Thread.Sleep(5 * 1000);
            ////    }
            ////}
        }
 public static INotificationCenter GetInstance()
 {
     if (singleton == null)
         singleton = new NotificationCenter();
     return singleton;
 }
Пример #39
0
 public CharacterNameProcessor(INotificationCenter notificationCenter, CommandProcess nextProcessor)
     : base(nextProcessor)
 {
     this.notificationManager = notificationCenter;
 }
Пример #40
0
 public CharacterNameProcessor(INotificationCenter notificationCenter)
 {
     this.notificationManager = notificationCenter;
 }
Пример #41
0
 void Awake() {
     handlers = new Dictionary<string, EventHandler>();
     center = NotificationCenter.GenInstance();
 }
Пример #42
0
 /// <summary>
 /// Set our notification interface so we can post messages
 /// </summary>
 /// <param name="notificationInterface"></param>
 public void SetNotificationInterface(INotificationCenter notificationInterface)
 {
     this.notificationInterface = notificationInterface;
 }
Пример #43
0
 public CharacterNameRequestor(INotificationCenter notificationManager)
     : base()
 {
     this.notificationCenter = notificationManager;
 }
Пример #44
0
 public AccountStorage(INotificationCenter notificationCenter, ICurrentUser currentUser, IDeviceInfo deviceInfo)
 {
     _notificationCenter = notificationCenter;
     _currentUser = currentUser;
     _deviceInfo = deviceInfo;
 }