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);
        }
Esempio n. 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>();
 }
Esempio n. 3
0
 public FoilControl(INotificationCenter notificationCenter)
 {
     _notificationCenter = notificationCenter;
     ShowLabel           = true;
     InitializeComponent();
     rootGrid.DataContext = this;
 }
Esempio n. 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);
 }
Esempio n. 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());
        }
Esempio n. 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);
        }
Esempio n. 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>();
 }
Esempio n. 8
0
 public SignUpViewModel(IAccountStorage accountStorage, INotificationCenter notificationCenter,
     ICurrentUser currentUser)
 {
     _accountStorage = accountStorage;
     _notificationCenter = notificationCenter;
     _currentUser = currentUser;
 }
Esempio n. 9
0
 public void Init()
 {
     _display            = Substitute.For <IDisplay>();
     _formatter          = Substitute.For <IDisplayFormatter>();
     _notificationCenter = new NotificationCenter(_display);
     _notificationCenter.SetFormatter(_formatter);
 }
Esempio n. 10
0
 protected CollectionViewModel(IDataProvider dataProvider, INotificationCenter notificationCenter)
 {
     _dataProvider       = dataProvider;
     _notificationCenter = notificationCenter;
     PopulateData();
     InitCommands();
 }
Esempio n. 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;
 }
Esempio n. 13
0
        public SetImage(INotificationCenter notificationCenter)
        {
            _notificationCenter = notificationCenter;

            InitializeComponent();
            rootGrid.DataContext = this;
        }
Esempio n. 14
0
 public static INotificationCenter GetInstance()
 {
     if (singleton == null)
     {
         singleton = new NotificationCenter();
     }
     return(singleton);
 }
Esempio n. 15
0
 public ShellViewModel(
     INotificationCenter notificationCenter)
 {
     notificationCenter.NotificationFired += (sender, e) =>
     {
         StatusBarMessage = e.Message;
     };
 }
 void DestroyNotificationCenter()
 {
     if (_notificationCenter != null)
     {
         _notificationCenter.Destroy();
         _notificationCenter = null;
     }
 }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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);
        }
Esempio n. 21
0
        public ReportsViewModel(IReportStorage reportStorage, INotificationCenter notificationCenter)
        {
            _reportStorage = reportStorage;

            Title = "Mina rapporter";

            notificationCenter.Subscribe<User>(this, NotificationKeys.CurrentUserChanged, u =>
            {
                Device.BeginInvokeOnMainThread(RefreshReports);
            });
        }
Esempio n. 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;
 }
Esempio n. 23
0
        public ReportsViewModel(IReportStorage reportStorage, INotificationCenter notificationCenter)
        {
            _reportStorage = reportStorage;

            Title = "Mina rapporter";

            notificationCenter.Subscribe <User>(this, NotificationKeys.CurrentUserChanged, u =>
            {
                Device.BeginInvokeOnMainThread(RefreshReports);
            });
        }
Esempio n. 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);
        }
Esempio n. 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);
            });
        }
Esempio n. 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 : "";
        }
Esempio n. 28
0
        public SightingsViewModel(ISightingStorage sightingStorage, INotificationCenter notificationCenter)
        {
            _sightingStorage = sightingStorage;

            Title      = "Observationer";
            DaysFilter = "";


            notificationCenter.Subscribe <User>(this, NotificationKeys.CurrentUserChanged, u =>
            {
                Device.BeginInvokeOnMainThread(RefreshSightings);
            });
        }
Esempio n. 29
0
        public SightingsViewModel(ISightingStorage sightingStorage, INotificationCenter notificationCenter)
        {
            _sightingStorage = sightingStorage;

            Title = "Observationer";
            DaysFilter = "";


            notificationCenter.Subscribe<User>(this, NotificationKeys.CurrentUserChanged, u =>
            {
                Device.BeginInvokeOnMainThread(RefreshSightings);
            });
        }
Esempio n. 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,
         };
     }
 }
Esempio n. 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);
            });
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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;
        }
Esempio n. 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();
            });
        }
Esempio n. 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);
        }
        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;
 }
Esempio n. 39
0
 public CharacterNameProcessor(INotificationCenter notificationCenter, CommandProcess nextProcessor)
     : base(nextProcessor)
 {
     this.notificationManager = notificationCenter;
 }
Esempio n. 40
0
 public CharacterNameProcessor(INotificationCenter notificationCenter)
 {
     this.notificationManager = notificationCenter;
 }
Esempio n. 41
0
 void Awake() {
     handlers = new Dictionary<string, EventHandler>();
     center = NotificationCenter.GenInstance();
 }
Esempio n. 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;
 }
Esempio n. 43
0
 public CharacterNameRequestor(INotificationCenter notificationManager)
     : base()
 {
     this.notificationCenter = notificationManager;
 }
Esempio n. 44
0
 public AccountStorage(INotificationCenter notificationCenter, ICurrentUser currentUser, IDeviceInfo deviceInfo)
 {
     _notificationCenter = notificationCenter;
     _currentUser = currentUser;
     _deviceInfo = deviceInfo;
 }