コード例 #1
0
 public Authenticator(ITinyMessengerHub hub)
 {
     _hub = hub;
     _hub.Subscribe <ClientConnectedEvent>(msg => AddConnection(msg.ConnectionId, msg.IpAddress));
     _hub.Subscribe <ClientDisconnectedEvent>(msg => RemoveConnection(msg.ConnectionId));
     _hub.Subscribe <ConnectionReadyEvent>(msg => UpdateConnection(msg.Client));
 }
コード例 #2
0
ファイル: CameraController.cs プロジェクト: AlexMeuer/Rubik
        public CameraController(UnityEngine.Camera camera, ITinyMessengerHub messengerHub, ILogger logger, IStore store)
        {
            this.camera       = camera;
            this.messengerHub = messengerHub;
            this.logger       = PrefixedLogger.ForType <CameraController>(logger);

            var transform = camera.transform;

            cameraPivot = transform.parent;

            defaultPosition = transform.position;
            defaultRotation = transform.rotation.eulerAngles;

            context = new StateContext(this.logger, store);

            context.TransitionTo(
                new WaitingForDragState(context,
                                        messengerHub,
                                        this.logger,
                                        camera));

            context.Disable();

            spinSubscriptionToken = messengerHub.Subscribe <SpinCamera360Message>(OnSpinRequested);

            enableDisableSubscriptionToken = messengerHub.Subscribe <EnableCameraControlMessage>(EnableControl);

            resetPositionSubscriptionToken = messengerHub.Subscribe <ResetCameraMessage>(Reset);

            orbitSubscriptionToken = messengerHub.Subscribe <CameraOrbitRequestMessage>(Orbit);
        }
コード例 #3
0
 public Authenticator(ITinyMessengerHub hub)
 {
     _hub = hub ?? throw new ArgumentNullException(nameof(hub));
     _hub.Subscribe <ClientConnectedEvent>(msg => AddConnection(msg.ConnectionId, msg.IpAddress));
     _hub.Subscribe <ClientDisconnectedEvent>(msg => RemoveConnection(msg.ConnectionId));
     _hub.Subscribe <ConnectionReadyEvent>(msg => UpdateConnection(msg.Client));
 }
コード例 #4
0
ファイル: Config.cs プロジェクト: jmg999/LBCService
 public Config(ILogger logger, ITinyMessengerHub hub)
 {
     _logger      = logger;
     _hub         = hub;
     _subToReload = _hub.Subscribe <ConfigReloadRequestMessage>(_ => Load());
     _subToSave   = _hub.Subscribe <ConfigSaveRequestMessage>(message => Save(message.Data));
 }
コード例 #5
0
        public ApplicationViewModel()
        {
            _messageHub = TinyIoCContainer.Current.Resolve<ITinyMessengerHub> ();

            _messageHub.Subscribe<ApplicationStartingMessage> ((a) => StartApplication());
            _messageHub.Subscribe<DoneEditingUsername> ((a) => EvaluateSuccess());
            _messageHub.Subscribe<ApplicationFinishingMessage> ((a) => TerminateApplication());
        }
コード例 #6
0
 public ClientManager(ITinyMessengerHub hub, ClientRepository repository, LogRepository logRepository)
 {
     _hub           = hub ?? throw new ArgumentNullException(nameof(hub));
     _repository    = repository;
     _logRepository = logRepository;
     _hub.Subscribe <ConnectionReadyEvent>(msg => OnClientConnected(msg.Client));
     _hub.Subscribe <ConnectionRemovedEvent>(msg => OnClientDisconnected(msg.Client));
 }
コード例 #7
0
 public ClientManager(ITinyMessengerHub hub, ClientRepository repository, LogRepository logRepository)
 {
     _hub           = hub;
     _repository    = repository;
     _logRepository = logRepository;
     _hub.Subscribe <ConnectionReadyEvent>(msg => OnClientConnected(msg.Client));
     _hub.Subscribe <ConnectionRemovedEvent>(msg => OnClientDisconnected(msg.Client));
 }
コード例 #8
0
 public IdleTimerControl(ITinyMessengerHub hub, /*KeyboardHook keyboardHook, MouseHook mouseHook,*/ LastInputHook inputHook)
 {
     _hub = hub;
     //_keyboardHook = keyboardHook;
     //_mouseHook = mouseHook;
     _inputHook     = inputHook;
     _subToStatus   = _hub.Subscribe <OnStatusReceivedMessage>(OnSendStatus);
     _subToActivity = _hub.Subscribe <UserActiveMessage>(_ => RestartTimer());
 }
コード例 #9
0
        /// <inheritdoc/>
        public ITinyMessageSubscriptionToken Subscribe <TMessage>(
            Action <TMessage> deliveryAction) where TMessage : class, ITinyMessage
        {
            if (deliveryAction is null)
            {
                throw new ArgumentNullException(nameof(deliveryAction));
            }

            return(_messageHub.Subscribe(deliveryAction));
        }
コード例 #10
0
 public LyricCoverModel(ITinyMessengerHub hub)
 {
     _hub = hub ?? throw new ArgumentNullException(nameof(hub));
     _hub.Subscribe <CoverAvailable>(msg => Task.Factory.StartNew(
                                         () => SetCover(msg.Cover),
                                         _cts.Token,
                                         TaskCreationOptions.PreferFairness,
                                         _scheduler));
     _hub.Subscribe <LyricsAvailable>(msg => Lyrics = msg.Lyrics);
 }
コード例 #11
0
        protected override void ServiceStart()
        {
            _logger.Start();
            _subToStatus = _hub.Subscribe <OnStatusReceivedMessage>(OnStatusReceived);
            _subToConfig = _hub.Subscribe <OnConfigLoadedMessage>(OnConfigLoaded);
            _subToStop   = _hub.Subscribe <StopServiceRequestMessage>(_ => Stop());

            _hub.Publish(new ConfigReloadRequestMessage(this));
            _hub.Publish(new OnStartupMessage(this));
            _logger.Info("LenovoBacklightControl service started.", 50902);
        }
コード例 #12
0
        public void Start()
        {
            _coverSubscription  = _hub.Subscribe <CoverDataReadyEvent>(msg => BroadcastCover(msg.Cover));
            _lyricsSubscription = _hub.Subscribe <LyricsDataReadyEvent>(msg => BroadcastLyrics(msg.Lyrics));
            _hub.Subscribe <TrackChangedEvent>(_ => { BroadcastTrackInfo(); });
            _hub.Subscribe <ArtworkReadyEvent>(_ => { _hub.Publish(new CoverAvailable(_apiAdapter.GetCover())); });
            _hub.Subscribe <LyricsReadyEvent>(_ => { _hub.Publish(new LyricsAvailable(_apiAdapter.GetLyrics())); });

            _positionUpdateTimer          = new Timer(20000);
            _positionUpdateTimer.Elapsed += PositionUpdateTimerOnElapsed;
            _positionUpdateTimer.Enabled  = true;
        }
コード例 #13
0
        protected virtual void Initialize()
        {
            var container = TinyIoCContainer.Current;
            _hub = container.Resolve<ITinyMessengerHub>();

            _hub.Subscribe<EmptyUrlMessage>(m =>
            {
                SelectedIndex = 2;
                MessageBox.Show("Please enter a URL for your uTorrent server.", "No URL Found");
            });

            _hub.Subscribe<AddTorrentMessage>(_ => SelectedIndex = 0);
        }
コード例 #14
0
        public void Start()
        {
            _volumeSubscriptionToken      = _hub.Subscribe <VolumeLevelChangedEvent>(_ => { SendVolume(); });
            _muteSubscriptionToken        = _hub.Subscribe <VolumeMuteChangedEvent>(_ => { SendMuteState(); });
            _playStateSubscriptionToken   = _hub.Subscribe <PlayStateChangedEvent>(_ => { SendPlayState(); });
            _playingListSubscriptionToken = _hub.Subscribe <NowPlayingListChangedEvent>(_ => { });

            _timer = new Timer {
                Interval = 1000
            };
            _timer.Elapsed += HandleTimerElapsed;
            _timer.Enabled  = true;
        }
コード例 #15
0
        public CommandHandler(ITinyMessengerHub messengerHub, ILogger logger, ICommandExecutor executor)
        {
            this.logger       = PrefixedLogger.ForType <CommandHandler>(logger);
            this.messengerHub = messengerHub;
            this.executor     = executor;

            commandHistory = new Stack <IUndoableCommand>();
            undoHistory    = new Stack <IUndoableCommand>();

            enqueueSubscriptionToken = messengerHub.Subscribe <EnqueueCommandMessage>(HandleEnqueueMessage);
            undoSubscriptionToken    = messengerHub.Subscribe <UndoCommandMessage>(m => UndoLast());
            redoSubscriptionToken    = messengerHub.Subscribe <RedoCommandMessage>(m => RedoLast());
        }
コード例 #16
0
        protected virtual void Initialize()
        {
            var container = TinyIoCContainer.Current;

            _hub = container.Resolve <ITinyMessengerHub>();

            _hub.Subscribe <EmptyUrlMessage>(m =>
            {
                SelectedIndex = 2;
                MessageBox.Show("Please enter a URL for your uTorrent server.", "No URL Found");
            });

            _hub.Subscribe <AddTorrentMessage>(_ => SelectedIndex = 0);
        }
コード例 #17
0
ファイル: CameraController.cs プロジェクト: AlexMeuer/Rubik
        private void DisableControl(DisableCameraControlMessage message)
        {
            if (context.IsDisabled)
            {
                return;
            }

            context.Disable();

            enableDisableSubscriptionToken.Dispose();

            enableDisableSubscriptionToken = messengerHub.Subscribe <EnableCameraControlMessage>(EnableControl);

            logger.Info("Disabled camera control");
        }
コード例 #18
0
        public MerblaBaseView(ITinyMessengerHub messageHub, IRepository repo)
        {
            _messageHub = messageHub;
            _repo       = repo;

            _messageHub.Subscribe <PeopleMessage>((m) => {
                var label  = new UILabel(new RectangleF(20, 20, 100, 100));
                label.Text = "People message received @ " + DateTime.Now;

                label.Text += ": " + m.Content
                              .Select(p => p.Surname)
                              .Aggregate((text, item) =>
                                         text + " Surname: " + item);

                AddSubview(label);
            });

            var button = new UIButton(new RectangleF(10, 10, 100, 100));

            button.SetTitle("Make Service Call", UIControlState.Normal);
            button.TouchDown += delegate(object sender, EventArgs e) {
                _repo.GetPeople();
            };

            AddSubview(button);
        }
コード例 #19
0
        public MerblaBaseView(ITinyMessengerHub messageHub, IRepository repo)
        {
            _messageHub = messageHub;
            _repo= repo;

            _messageHub.Subscribe<PeopleMessage>((m) =>{

                var label = new UILabel(new RectangleF(20,20,100,100));
                label.Text = "People message received @ " + DateTime.Now;

                label.Text += ": " + m.Content
                    .Select(p=> p.Surname)
                        .Aggregate((text, item) =>
                            text + " Surname: " + item);

                AddSubview(label);
            });

            var button = new UIButton(new RectangleF(10,10, 100,100));

            button.SetTitle( "Make Service Call", UIControlState.Normal);
            button.TouchDown += delegate(object sender, EventArgs e) {
                _repo.GetPeople();
            };

            AddSubview(button);
        }
コード例 #20
0
ファイル: LockReceiver.cs プロジェクト: pascalfr/MPfm
 public LockReceiver()
 {            
     _messageHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>();
     _messageHub.Subscribe<ActivateLockScreenMessage>(message => {
         _activateLockScreen = message.ActivateLockScreen;
     });
 }
コード例 #21
0
        public ArrivalsTableViewController(ArrivalsDataSource dataSource, ITinyMessengerHub messenger)
        {
            _dataSource = dataSource;

            _messenger = messenger;
            _messenger.Subscribe<AirportSelectedMessage>(msg => NavigationItem.Title = string.Format("Arrivals at {0}", msg.Content.Code));
        }
コード例 #22
0
        public ArrivalsTableViewController(ArrivalsDataSource dataSource, ITinyMessengerHub messenger)
        {
            _dataSource = dataSource;

            _messenger = messenger;
            _messenger.Subscribe <AirportSelectedMessage>(msg => NavigationItem.Title = string.Format("Arrivals at {0}", msg.Content.Code));
        }
コード例 #23
0
ファイル: NamedPipeClient.cs プロジェクト: jmg999/LBCService
        public NamedPipeClient(ILogger logger, ITinyMessengerHub hub, string pipeName)
        {
            _logger   = logger;
            _pipeName = pipeName;

            _subToSend = hub.Subscribe <SendStatusRequestMessage>(OnSendStatusMessage);
        }
コード例 #24
0
        public NearestAirportService(IGeolocation locationService, ITinyMessengerHub messenger)
        {
            _locationService = locationService;
            _messenger       = messenger;

            _airportsService = new AirportNamesService();
            _messenger.Subscribe <FindNearestAirportMessage>(m => FindNearestAirport());
        }
コード例 #25
0
ファイル: TimelineViewModel.cs プロジェクト: trymnilsen/Aegir
 /// <summary>
 /// Instantiates a new timeline viewmodel
 /// </summary>
 public TimelineViewModel(ITinyMessengerHub messenger, KeyframeEngine engine)
 {
     NotifyPropertyUpdateRate = 50;
     TimelineStart            = 0;
     TimelineEnd = 100;
     Messenger   = messenger;
     //Set up engine
     Engine = engine;
     Engine.CurrentTimeChanged += Engine_CurrentTimeChanged;
     //SetTimeLine(Engine.Keyframes);
     //MessengerInstance.Register<SelectedNodeChanged>(this, ActiveNodeChanged);
     //MessengerInstance.Register<ActiveTimelineChanged>(this, TimelineChanged);
     Messenger.Subscribe <SelectedEntityChanged>(ActiveEntityChanged);
     Messenger.Subscribe <InvalidateEntity>(OnInvalidateEntitiesMessage);
     AddKeyframeCommand = new RelayCommand(CaptureKeyframes, CanCaptureKeyframes);
     Keyframes          = new ObservableCollection <KeyframeViewModel>();
     playPauseCommand   = new RelayCommand(TogglePlayPauseState);
 }
コード例 #26
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            _subscriptionToken = _messengerHub.Subscribe <VoteCastedMessage>((message) =>
            {
                _hubContext.Clients.Group(message.PollId.ToString()).NotifyVoteCasted(message.PollId.ToString(), message.AnswerId.ToString());
            });

            return(Task.CompletedTask);
        }
コード例 #27
0
ファイル: PythonComponent.cs プロジェクト: Crobol/Bot
        public PythonComponent(ITinyMessengerHub hub)
            : base(hub)
        {
            PythonEngine.Initialize();

            LoadScripts("Scripts");

            hub.Subscribe<InvokeCommandMessage>(OnBotCommandMessage);
        }
コード例 #28
0
 public Settings(ITinyMessengerHub hub)
 {
     hub.Subscribe<ApplicationMessage>(m =>
     {
         if (m.Content == ApplicationMessageType.Backgrounded || m.Content == ApplicationMessageType.Foregrounded)
         {
             Synchronize();
         }
     });
 }
コード例 #29
0
ファイル: IrcComponent.cs プロジェクト: Crobol/Bot
        public IrcComponent(ITinyMessengerHub hub, IConfig config)
            : base(hub)
        {
            if (hub == null)
                throw new ArgumentNullException("hub");
            log.Info("Initializing IRC component...");
            this.config = config;

            hub.Subscribe<IrcSendMessage>(OnSendIrcMessage);
        }
コード例 #30
0
 public Settings(ITinyMessengerHub hub)
 {
     hub.Subscribe <ApplicationMessage>(m =>
     {
         if (m.Content == ApplicationMessageType.Backgrounded || m.Content == ApplicationMessageType.Foregrounded)
         {
             Synchronize();
         }
     });
 }
コード例 #31
0
ファイル: BaseActivity.cs プロジェクト: pascalfr/MPfm
 private void InitializeBase()
 {
     Console.WriteLine("BaseActivity - InitializeBase - Subcribing to ApplicationCloseMessage; activity of type {0}", this.GetType().FullName);
     _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>();
     _tokens.Add(_messengerHub.Subscribe<ApplicationCloseMessage>(message =>
     {
         Console.WriteLine("BaseActivity - InitializeBase - Received ApplicationCloseMessage; closing activity of type {0}", this.GetType().FullName);
         Finish();
     }));
 }
コード例 #32
0
        public void Subscribe <T>(object receiver, Action <T> action) where T : class, ITinyMessage
        {
            if (!_subscriptions.ContainsKey(receiver))
            {
                _subscriptions[receiver] = new List <TinyMessageSubscriptionToken>();
            }
            var token = _messengerHub.Subscribe(action);

            _subscriptions[receiver].Add(token);
        }
コード例 #33
0
ファイル: SocketServer.cs プロジェクト: kelsos/plugin
        public SocketServer(
            ProtocolHandler handler,
            ITinyMessengerHub hub,
            Authenticator auth,
            PersistenceManager settings)
        {
            _handler  = handler;
            _hub      = hub ?? throw new ArgumentNullException(nameof(hub));
            _auth     = auth;
            _settings = settings;
            _availableWorkerSockets = new ConcurrentDictionary <string, Socket>();
            TaskScheduler scheduler = new LimitedTaskScheduler(2);

            _factory = new TaskFactory(scheduler);

            _hub.Subscribe <RestartSocketEvent>(eEvent => RestartSocket());
            _hub.Subscribe <ForceClientDisconnect>(eEvent => DisconnectSocket(eEvent.ConnectionId));
            _hub.Subscribe <BroadcastEventAvailable>(eEvent => Broadcast(eEvent.BroadcastEvent));
            _hub.Subscribe <PluginResponseAvailableEvent>(eEvent => Send(eEvent.Message, eEvent.ConnectionId));
        }
コード例 #34
0
ファイル: ClojureComponent.cs プロジェクト: Crobol/Bot
        public ClojureComponent(ITinyMessengerHub hub)
            : base(hub)
        {
            if (hub == null)
                throw new ArgumentNullException("hub");

            log.Info("Initializing Clojure component...");

            LoadScripts("Scripts");

            hub.Subscribe<InvokeCommandMessage>(OnBotCommandMessage);
        }
コード例 #35
0
        public SnapperDemoForm()
        {
            InitializeComponent();
            messengerHub = container.Resolve<ITinyMessengerHub>();

            // Refresh all of the plugins.
            RefreshPlugins();

            // Subscribe to the NewPluginDetected message defining what to do when a new plugin appears.
            messengerHub.Subscribe<NewPluginDetected>((s) => { RefreshPlugins(); },
                new ControlInvokeTinyMessageProxy(this)); // ensure that this message is invoked on the UI thread.
        }
コード例 #36
0
 protected virtual void Initialize()
 {
     var container = TinyIoCContainer.Current;
     _hub = container.Resolve<ITinyMessengerHub>();
     _hub.Subscribe<SearchMessage>(OnSearch);
     _busyIndicator = container.Resolve<BusyIndicator>();
     _providers = container.ResolveAll<ISearchProvider>().ToArray();
     foreach (ISearchProvider item in _providers)
     {
         item.SearchCompleted += OnSearchCompleted;
     }
 }
コード例 #37
0
        protected virtual void Initialize()
        {
            var container = TinyIoCContainer.Current;

            _hub = container.Resolve <ITinyMessengerHub>();
            _hub.Subscribe <CommentsMessage>(m =>
            {
                _details = m.Details;
                _commentsController.TableView.ReloadData();
                _commentsController.TableView.SetContentOffset(PointF.Empty, false);
                _navigationController.PushViewController(_commentsController, true);
            });
        }
コード例 #38
0
        protected virtual void Initialize()
        {
            var container = TinyIoCContainer.Current;

            _server = container.Resolve <Server>();
            _hub    = container.Resolve <ITinyMessengerHub>();

            _hub.Subscribe <TorrentDetailsMessage>(m =>
            {
                _torrent = m.Torrent;
                _torrentDetailsController.TableView.ReloadData();
                _torrentDetailsController.TableView.SetContentOffset(PointF.Empty, false);
                _navigationController.PushViewController(_torrentDetailsController, true);
            });
            _hub.Subscribe <TorrentChangedMessage>(m => Execute.BeginInvoke(() =>
            {
                if (_torrent != null && _torrent.ID == m.Torrent.ID)
                {
                    if (m.Removed)
                    {
                        _navigationController.PopViewControllerAnimated(true);
                    }
                    else
                    {
                        _torrent = m.Torrent;
                        _torrentDetailsController.TableView.ReloadData();
                    }
                }
            }));


            for (int i = 0; i < _cells.Length; i++)
            {
                _cells[i] = new UITableViewCell(UITableViewCellStyle.Value1, string.Empty)
                {
                    SelectionStyle = UITableViewCellSelectionStyle.None,
                };
            }
        }
コード例 #39
0
        public SettingsForm(ITinyMessengerHub hub, SysTray sysTray, IdleTimerControl idleTimer, DisplayHook displayHook, NamedPipeServer pipeServer)
        {
            _hub         = hub;
            _sysTray     = sysTray;
            _idleTimer   = idleTimer;
            _displayHook = displayHook;
            _pipeServer  = pipeServer;

            InitializeComponent();
            _ctx = SynchronizationContext.Current;
            try
            {
                var sc = new ServiceController("LenovoBacklightControl");
                if (sc.Status == ServiceControllerStatus.Running)
                {
                    //Do nothing, this is to allow the app to catch the exception if the service is not present
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Could not find service. Please install.", "Service Error!", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
                Close();
            }

            _hub.Subscribe <OnConfigLoadedMessage>(x => ExecuteOnUi(OnConfigLoaded, x));
            _hub.Subscribe <ServiceStateMessage>(x => ExecuteOnUi(CheckService, x));
            _hub.Subscribe <FormOpenRequestMessage>(x => ExecuteOnUi(ShowSettingsForm));
            _hub.Subscribe <DisplayStateMessage>(x =>
            {
                if (x.State == DisplayState.On)
                {
                    _hub.PublishAsync(new SendStatusRequestMessage(this, Status.EnableBacklight));
                }
            });
            _hub.Subscribe <OnStatusReceivedMessage>(x => ExecuteOnUi(OnStatus, x));
            _pipeServer.Start();
            _hub.PublishAsync(new SendStatusRequestMessage(this, Status.RequestBacklightState));
        }
コード例 #40
0
        protected virtual void Initialize()
        {
            var container = TinyIoCContainer.Current;

            _hub = container.Resolve <ITinyMessengerHub>();
            _hub.Subscribe <SearchMessage>(OnSearch);
            _busyIndicator = container.Resolve <BusyIndicator>();
            _providers     = container.ResolveAll <ISearchProvider>().ToArray();
            foreach (ISearchProvider item in _providers)
            {
                item.SearchCompleted += OnSearchCompleted;
            }
        }
コード例 #41
0
 public AndroidNavigationManager(ITinyMessengerHub messageHub)
 {
     _messageHub = messageHub;
     _messageHub.Subscribe<MobileNavigationManagerCommandMessage>((m) => {
         switch (m.CommandType)
         {
             case MobileNavigationManagerCommandMessageType.ShowPlayerView:
                 CreatePlayerView(MobileNavigationTabType.More);
                 break;
             case MobileNavigationManagerCommandMessageType.ShowEqualizerPresetsView:
                 var sourceView = (IBaseView) m.Sender;
                 CreateEqualizerPresetsView(sourceView);
                 break;
         }
     });
 }
コード例 #42
0
ファイル: ProcessorComponent.cs プロジェクト: Crobol/Bot
        public ProcessorComponent(ITinyMessengerHub hub, IConfig config)
            : base(hub)
        {
            log.Info("Initializing processor component...");

            hub.Subscribe<IrcMessage>(OnIrcMessage);

            using (var catalog = new DirectoryCatalog("Plugins"))
            {
                using (var container = new CompositionContainer(catalog))
                {
                    container.ComposeExportedValue<IConfig>("Config", config);
                    container.ComposeParts(this);
                }
            }
        }
コード例 #43
0
        protected virtual void Initialize()
        {
            var container = TinyIoCContainer.Current;

            _hub = container.Resolve <ITinyMessengerHub>();
            _hub.Subscribe <SearchDetailsMessage>(OnDetails);
            _busyIndicator = container.Resolve <BusyIndicator>();

            for (int i = 0; i < _cells.Length; i++)
            {
                _cells[i] = new UITableViewCell(UITableViewCellStyle.Value1, string.Empty)
                {
                    SelectionStyle = UITableViewCellSelectionStyle.None,
                };
            }
        }
コード例 #44
0
        public FlightsViewModel(IGetFlights flightsService,
                                IStoreObjects objectStore,
                                ITinyMessengerHub messenger,
                                IDispatchOnUIThread dispatcher)
        {
            Arrivals   = new ObservableCollection <Flight>();
            Departures = new ObservableCollection <Flight>();

            _objectStore    = objectStore;
            _flightsService = flightsService;
            _messenger      = messenger;
            _dispatcher     = dispatcher;

            _messenger.Subscribe <AirportSelectedMessage>(OnAirportSelected);

            LoadSelectedAirport();
        }
コード例 #45
0
        public FlightsViewModel(IGetFlights flightsService, 
                                IStoreObjects objectStore, 
                                ITinyMessengerHub messenger, 
                                IDispatchOnUIThread dispatcher)
        {
            Arrivals = new ObservableCollection<Flight>();
            Departures = new ObservableCollection<Flight>();

            _objectStore = objectStore;
            _flightsService = flightsService;
            _messenger = messenger;
            _dispatcher = dispatcher;

            _messenger.Subscribe<AirportSelectedMessage>(OnAirportSelected);

            LoadSelectedAirport();
        }
コード例 #46
0
ファイル: CommandComponent.cs プロジェクト: Crobol/Bot
        public CommandComponent(ITinyMessengerHub hub, IPersistentStore store)
            : base(hub)
        {
            if (hub == null)
                throw new ArgumentNullException("hub");

            log.Info("Initializing Command component...");

            this.store = store;

            hub.Subscribe<InvokeCommandMessage>(this.OnBotCommandMessage);

            Commands = new List<ICommand>();

            LoadCommands();

            RegisterCommands();
        }
コード例 #47
0
ファイル: CliComponent.cs プロジェクト: Crobol/Bot
        public CliComponent(ITinyMessengerHub hub)
            : base(hub)
        {
            hub.Subscribe<InvokeCommandMessage>(OnBotCommandMessage);

            log.Info("Registering Python scripts...");

            string[] files = Directory.GetFiles("Scripts", "*.py");
            foreach (string file in files)
            {
                try
                {
                    string name = string.Join("", Path.GetFileNameWithoutExtension(file));
                    scripts.Add(name.ToLower(), file);
                    log.Info("Found script \"" + name + "\"");
                }
                catch (Exception e)
                {
                    log.Error("Failed to load script file \"" + file + "\"", e);
                }
            }
        }
コード例 #48
0
ファイル: iOSNavigationManager.cs プロジェクト: pascalfr/MPfm
 public iOSNavigationManager(ITinyMessengerHub messageHub)
 {
     _messageHub = messageHub;
     _messageHub.Subscribe<MobileNavigationManagerCommandMessage>((m) => {
         using(var pool = new NSAutoreleasePool())
         {
             pool.InvokeOnMainThread(() => {
                 switch(m.CommandType)
                 {
                     case MobileNavigationManagerCommandMessageType.ShowPlayerView:
                         var navCtrl = (SessionsNavigationController)m.Sender;
                         CreatePlayerView(navCtrl.TabType);
                         break;
                     case MobileNavigationManagerCommandMessageType.ShowEqualizerPresetsView:
                         CreateEqualizerPresetsView(null);
                         break;
                     case MobileNavigationManagerCommandMessageType.ShowPlaylistView:
                         CreatePlaylistView(null);
                         break;
                 }
             });
         }
     });
 }
コード例 #49
0
ファイル: WidgetService.cs プロジェクト: pascalfr/MPfm
        private void Initialize()
        {
            Console.WriteLine("WidgetService - Initializing service...");
            int maxMemory = (int) (Runtime.GetRuntime().MaxMemory()/1024);
            int cacheSize = maxMemory/16;
            _bitmapCache = new BitmapCache(null, cacheSize, 200, 200);

            _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>();
            _playerService = Bootstrapper.GetContainer().Resolve<IPlayerService>();
            _messengerHub.Subscribe<PlayerPlaylistIndexChangedMessage>((message) => {
                Console.WriteLine("WidgetService - PlayerPlaylistIndexChangedMessage");
                if (message.Data.AudioFileStarted != null)
                {
                    _audioFile = message.Data.AudioFileStarted;
                    //UpdateNotificationView(message.Data.AudioFileStarted, null);
                    UpdateWidgetView();
                    GetAlbumArt(message.Data.AudioFileStarted);
                }
            });
            _messengerHub.Subscribe<PlayerStatusMessage>((message) => {
                Console.WriteLine("WidgetService - PlayerStatusMessage - Status=" + message.Status.ToString());
                _status = message.Status;
                UpdateWidgetView();
            });
        }
コード例 #50
0
 protected virtual void Initialize()
 {
     _hub = TinyIoCContainer.Current.Resolve<ITinyMessengerHub>();
     _hub.Subscribe<DonateMessage>(m => Donate());
 }
コード例 #51
0
ファイル: NotificationService.cs プロジェクト: pascalfr/MPfm
        private void Initialize()
        {
            Console.WriteLine("NotificationService - Initializing service...");
            int maxMemory = (int) (Runtime.GetRuntime().MaxMemory()/1024);
            int cacheSize = maxMemory/16;
            _bitmapCache = new BitmapCache(null, cacheSize, 200, 200);

            _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>();
            _playerService = Bootstrapper.GetContainer().Resolve<IPlayerService>();
            _messengerHub.Subscribe<PlayerPlaylistIndexChangedMessage>((message) => {
                Console.WriteLine("NotificationService - PlayerPlaylistIndexChangedMessage");
                if (message.Data.AudioFileStarted != null)
                {
                    _audioFile = message.Data.AudioFileStarted;
                    //UpdateNotificationView(message.Data.AudioFileStarted, null);
                    UpdateNotificationView();
                    GetAlbumArt(message.Data.AudioFileStarted);
                }
            });
            _messengerHub.Subscribe<PlayerStatusMessage>((message) => {
                Console.WriteLine("NotificationService - PlayerStatusMessage - Status=" + message.Status.ToString());
                _status = message.Status;
                UpdateNotificationView();
            });

            // Declare the service as foreground (i.e. the user is aware because of the audio)
            Console.WriteLine("NotificationService - Declaring service as foreground (API {0})...", (int) global::Android.OS.Build.VERSION.SdkInt);
            CreateNotificationView();
        }
コード例 #52
0
ファイル: MainActivity.cs プロジェクト: pascalfr/MPfm
        protected override void OnCreate(Bundle bundle)
        {
            Console.WriteLine("MainActivity - OnCreate");
            base.OnCreate(bundle);

            _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>();
            _messengerHub.Subscribe<MobileLibraryBrowserItemClickedMessage>(MobileLibraryBrowserItemClickedMessageReceived);

            RequestWindowFeature(WindowFeatures.ActionBar);
            SetContentView(Resource.Layout.Main);
            _actionBarSpinnerAdapter = ArrayAdapter.CreateFromResource(this, Resource.Array.action_list, Resource.Layout.actionbar_spinner_item);
            ActionBar.NavigationMode = ActionBarNavigationMode.List;
            ActionBar.Title = string.Empty;
            ActionBar.SetListNavigationCallbacks(_actionBarSpinnerAdapter, this);
            ActionBar.SetSelectedNavigationItem(1);

            _viewFlipper = FindViewById<ViewFlipper>(Resource.Id.main_viewflipper);
            _miniPlayer = FindViewById<LinearLayout>(Resource.Id.main_miniplayer);
            _miniPlaylist = FindViewById<LinearLayout>(Resource.Id.main_miniplaylist);
            _lblArtistName = FindViewById<TextView>(Resource.Id.main_miniplayer_lblArtistName);
            _lblAlbumTitle = FindViewById<TextView>(Resource.Id.main_miniplayer_lblAlbumTitle);
            _lblSongTitle = FindViewById<TextView>(Resource.Id.main_miniplayer_lblSongTitle);
            //_lblNextArtistName = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblNextArtistName);
            //_lblNextAlbumTitle = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblNextAlbumTitle);
            //_lblNextSongTitle = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblNextSongTitle);
            _lblPlaylistCount = FindViewById<TextView>(Resource.Id.main_miniplaylist_lblPlaylistCount);
            _btnPrevious = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnPrevious);
            _btnPlayPause = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnPlayPause);
            _btnNext = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnNext);
            _btnPlaylist = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnPlaylist);
            _btnShuffle = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnShuffle);
            _btnRepeat = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnRepeat);
            _btnLeft = FindViewById<ImageButton>(Resource.Id.main_miniplaylist_btnLeft);
            _cboPlaylist = FindViewById<Spinner>(Resource.Id.main_miniplaylist_cboPlaylist);
            _btnRight = FindViewById<ImageButton>(Resource.Id.main_miniplayer_btnRight);
            _imageAlbum = FindViewById<SquareImageView>(Resource.Id.main_miniplayer_imageAlbum);
            _miniPlayer.Click += (sender, args) => _messengerHub.PublishAsync<MobileNavigationManagerCommandMessage>(new MobileNavigationManagerCommandMessage(this, MobileNavigationManagerCommandMessageType.ShowPlayerView));
            _btnLeft.SetOnTouchListener(this);
            _btnRight.SetOnTouchListener(this);
            _btnPrevious.SetOnTouchListener(this);
            _btnPlayPause.SetOnTouchListener(this);
            _btnNext.SetOnTouchListener(this);
            _btnPlaylist.SetOnTouchListener(this);
            _btnShuffle.SetOnTouchListener(this);
            _btnRepeat.SetOnTouchListener(this);
            _btnPrevious.Click += (sender, args) => OnPlayerPrevious();
            _btnPlayPause.Click += (sender, args) => OnPlayerPlayPause();
            _btnNext.Click += (sender, args) => OnPlayerNext();
            _btnPlaylist.Click += (sender, args) => OnOpenPlaylist();
            _btnShuffle.Click += (sender, args) => OnPlayerShuffle();
            _btnRepeat.Click += (sender, args) => OnPlayerRepeat();
            _btnLeft.Click += BtnLeftOnClick;
            _btnRight.Click += BtnRightOnClick;

            // Set initial view flipper item
            int realIndex = _viewFlipper.IndexOfChild(_miniPlayer);
            _viewFlipper.DisplayedChild = realIndex;

            // Create bitmap cache
            Point size = new Point();
            WindowManager.DefaultDisplay.GetSize(size);
            int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024);
            int cacheSize = maxMemory / 16;
            BitmapCache = new BitmapCache(this, cacheSize, size.X / 6, size.X / 6);

            _playlistSpinnerAdapter = new ArrayAdapter<string>(this, Resource.Layout.playlist_spinner_item, new string[2] {"Hello", "World"});
            _cboPlaylist.Adapter = _playlistSpinnerAdapter;
            _cboPlaylist.ItemSelected += CboPlaylistOnItemSelected;

            Console.WriteLine("MainActivity - OnCreate - Binding presenters...");
            var navigationManager = (AndroidNavigationManager)Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
            navigationManager.MainActivity = this; // Watch out, this can lead to memory leaks!
            navigationManager.BindOptionsMenuView(this);
            navigationManager.BindPlayerStatusView(this);
            navigationManager.BindMobileMainView(this);
        }
コード例 #53
0
 protected virtual void Initialize()
 {
     var container = TinyIoCContainer.Current;
     _hub = container.Resolve<ITinyMessengerHub>();
     _hub.Subscribe<FilesMessage>(m =>
     {
         _details = m.Details;
         _filesController.TableView.ReloadData();
         _filesController.TableView.SetContentOffset(PointF.Empty, false);
         _navigationController.PushViewController(_filesController, true);
     });
 }
コード例 #54
0
        protected virtual void Initialize()
        {
            var container = TinyIoCContainer.Current;
            _server = container.Resolve<Server>();
            _hub = container.Resolve<ITinyMessengerHub>();

            _hub.Subscribe<TorrentDetailsMessage>(m =>
            {
                _torrent = m.Torrent;
                _torrentDetailsController.TableView.ReloadData();
                _torrentDetailsController.TableView.SetContentOffset(PointF.Empty, false);
                _navigationController.PushViewController(_torrentDetailsController, true);
            });
            _hub.Subscribe<TorrentChangedMessage>(m => Execute.BeginInvoke(() =>
            {
                if (_torrent != null && _torrent.ID == m.Torrent.ID)
                {
                    if (m.Removed)
                    {
                        _navigationController.PopViewControllerAnimated(true);
                    }
                    else
                    {
                        _torrent = m.Torrent;
                        _torrentDetailsController.TableView.ReloadData();
                    }
                }
            }));

            for (int i = 0; i < _cells.Length; i++)
            {
                _cells[i] = new UITableViewCell(UITableViewCellStyle.Value1, string.Empty)
                {
                    SelectionStyle = UITableViewCellSelectionStyle.None,
                };
            }
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="SkinManagerBase"/> class.
        /// </summary>
        /// <param name="messageHub">
        /// The message hub.
        /// </param>
        /// <param name="resourceManager">
        /// The resource manager.
        /// </param>
        protected SkinManagerBase(ITinyMessengerHub messageHub, IResourceManager resourceManager)
        {
            this.resourceManager = resourceManager;

            messageHub.Subscribe<SkinUpdatedMessage>(m => this.SwitchSkin(m.Skin.ToString()));
        }
コード例 #56
0
        public SessionsNavigationController(MobileNavigationTabType tabType) : base(typeof(SessionsNavigationBar), typeof(UIToolbar))
        {
            TabType = tabType;
            WeakDelegate = this;

            // Create messenger hub to listen to player changes
            _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>();
            _messengerHub.Subscribe<PlayerPlaylistIndexChangedMessage>((message) => {
                //Console.WriteLine("NavCtrl (" + TabType.ToString() + ") - PlayerPlaylistIndexChangedMessage");
                UpdateNowPlayingView();
            });
            _messengerHub.Subscribe<PlayerStatusMessage>((message) => {
                //Console.WriteLine("NavCtrl (" + TabType.ToString() + ") - PlayerStatusMessage - Status=" + message.Status.ToString());
                if(message.Status == PlayerStatusType.Playing ||
                   message.Status == PlayerStatusType.Paused)
                    _isPlayerPlaying = true;
                else
                    _isPlayerPlaying = false;
                
                UpdateNowPlayingView();
            });

            // Create controls
            _lblTitle = new UILabel(new RectangleF(60, 4, UIScreen.MainScreen.Bounds.Width - 120, 20));
            _lblTitle.TextColor = UIColor.White;
            _lblTitle.BackgroundColor = UIColor.Clear;
            _lblTitle.Text = "";
            _lblTitle.TextAlignment = UITextAlignment.Center;
            _lblTitle.AdjustsFontSizeToFitWidth = true;
            _lblTitle.MinimumScaleFactor = 14f/16f; // min:14pt max:16pt
            _lblTitle.Font = UIFont.FromName("HelveticaNeue", 16);

            _imageViewIcon = new UIImageView();
            _imageViewIcon.Image = UIImage.FromBundle("Images/Nav/album");
            _imageViewIcon.BackgroundColor = UIColor.Clear;

            _btnBack = new SessionsFlatButton();
            _btnBack.Alpha = 0;
            _btnBack.Frame = new RectangleF(0, 0, 70, 44);
            _btnBack.OnButtonClick += () =>  {

                var viewController = (BaseViewController)VisibleViewController;
                if (viewController.ConfirmBackButton && !_confirmedViewPop)
                {
                    var alertView = new UIAlertView(viewController.ConfirmBackButtonTitle, viewController.ConfirmBackButtonMessage, null, "OK", new string[1] { "Cancel" });
                    alertView.Clicked += (object sender, UIButtonEventArgs e) => {
                        Console.WriteLine("AlertView button index: {0}", e.ButtonIndex);
                        switch(e.ButtonIndex)
                        {
                            case 0:
                                viewController.ConfirmedBackButton();
                                _confirmedViewPop = true;
								Console.WriteLine("NavCtrl - PopViewController A");
                                PopViewControllerAnimated(true);
                                break;
                            default:
                                break;
                        }
                    };
                    alertView.Show();
                    return;
                }

                _confirmedViewPop = false;
                if(ViewControllers.Length > 1)
				{
					Console.WriteLine("NavCtrl - PopViewController B");
                    PopViewControllerAnimated(true);
				}
            };

            _btnPlaylist = new SessionsFlatButton();
            _btnPlaylist.LabelAlignment = UIControlContentHorizontalAlignment.Right;
			_btnPlaylist.Frame = new RectangleF(UIScreen.MainScreen.Bounds.Width - 80, 0, 80, 44);
            _btnPlaylist.Alpha = 0;
            _btnPlaylist.Label.TextAlignment = UITextAlignment.Right;
			_btnPlaylist.Label.Text = "Playlist";
			_btnPlaylist.Label.Frame = new RectangleF(0, 0, 54, 44);
            _btnPlaylist.ImageChevron.Image = UIImage.FromBundle("Images/Tables/chevron_blue");
			_btnPlaylist.ImageChevron.Frame = new RectangleF(80 - 22, 0, 22, 44);
            _btnPlaylist.OnButtonClick += () => {
				_messengerHub.PublishAsync<MobileNavigationManagerCommandMessage>(new MobileNavigationManagerCommandMessage(this, MobileNavigationManagerCommandMessageType.ShowPlaylistView));
            };

            _btnNowPlaying = new SessionsFlatButton();
            _btnNowPlaying.LabelAlignment = UIControlContentHorizontalAlignment.Right;
            _btnNowPlaying.Frame = new RectangleF(UIScreen.MainScreen.Bounds.Width - 70, 0, 70, 44);
            _btnNowPlaying.Alpha = 0;
            _btnNowPlaying.Label.TextAlignment = UITextAlignment.Right;
            _btnNowPlaying.Label.Frame = new RectangleF(0, 0, 44, 44);
            _btnNowPlaying.ImageChevron.Image = UIImage.FromBundle("Images/Tables/chevron_blue");
            _btnNowPlaying.ImageChevron.Frame = new RectangleF(70 - 22, 0, 22, 44);
            _btnNowPlaying.Label.Text = "Player";
            _btnNowPlaying.OnButtonClick += () => {
                _messengerHub.PublishAsync<MobileNavigationManagerCommandMessage>(new MobileNavigationManagerCommandMessage(this, MobileNavigationManagerCommandMessageType.ShowPlayerView));
            };

            this.NavigationBar.AddSubview(_btnBack);
            this.NavigationBar.AddSubview(_btnPlaylist);
            this.NavigationBar.AddSubview(_btnNowPlaying);
            this.NavigationBar.AddSubview(_lblTitle);
            this.NavigationBar.AddSubview(_imageViewIcon);
        }
コード例 #57
0
        protected virtual void Initialize()
        {
            var container = TinyIoCContainer.Current;

            //Messenger
            _hub = container.Resolve<ITinyMessengerHub>();
            _hub.Subscribe<ApplicationMessage>(m =>
            {
                if (m.Content == ApplicationMessageType.Loaded || m.Content == ApplicationMessageType.Foregrounded)
                {
            //					if (!string.IsNullOrEmpty(_settings.Url) && ++_settings.NumberOfRuns == 3)
            //					{
            //						MessageBox.Ask("Would you consider donating a mere $.99?", "Enjoy the App?", yes =>
            //						{
            //							if (yes)
            //							{
            //								_hub.Publish(new DonateMessage(this));
            //							}
            //							else
            //							{
            //								Refresh();
            //							}
            //						});
            //					}
            //					else
                    {
                        Refresh();
                    }
                }
            });
            _hub.Subscribe<AddTorrentMessage>(m =>
            {
                try
                {
                    _server.AddUrl(m.Url.Url);
                }
                catch (Exception exc)
                {
                    Execute.BeginInvoke(() => MessageBox.Show(exc.Message, "Error"));
                }
            });
            _settings = container.Resolve<Settings>();

            //Server
            _server = container.Resolve<Server>();
            _server.TorrentsChanged += (sender, e) => Execute.BeginInvoke(() =>
            {
                if (_tableView != null)
                {
                    _tableView.ReloadData();
                }
            });
            _server.TorrentsError += (sender, e) => Execute.BeginInvoke(() =>
            {
                MessageBox.Show("Could not get list of torrents: " + Environment.NewLine +
                                e.Exception.Message + Environment.NewLine +
                                "Press refresh to try again.", "Error");
            });
            _server.TorrentChanged += (sender, e) => _hub.Publish(new TorrentChangedMessage(this, false, e.Torrent));
            _server.TorrentRemoved += (sender, e) => _hub.Publish(new TorrentChangedMessage(this, true, e.Torrent));
        }
コード例 #58
0
ファイル: PlayerActivity.cs プロジェクト: pascalfr/MPfm
        protected override void OnCreate(Bundle bundle)
        {
            Console.WriteLine("PlayerActivity - OnCreate");

            _messengerHub = Bootstrapper.GetContainer().Resolve<ITinyMessengerHub>(); 
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Player);
            ActionBar.SetDisplayHomeAsUpEnabled(true);
            ActionBar.SetHomeButtonEnabled(true);

            _navigationManager = Bootstrapper.GetContainer().Resolve<MobileNavigationManager>();
            _fragments = new List<Fragment>();
            _viewPager = FindViewById<ViewPager>(Resource.Id.player_pager);
            _viewPager.OffscreenPageLimit = 4;
            _viewPagerAdapter = new ViewPagerAdapter(FragmentManager, _fragments, _viewPager);
            _viewPagerAdapter.OnPageChanged += ViewPagerAdapterOnOnPageChanged;
            _viewPager.Adapter = _viewPagerAdapter;
            _viewPager.SetOnPageChangeListener(_viewPagerAdapter);

            _waveFormScrollView = FindViewById<WaveFormScrollView>(Resource.Id.player_waveFormScrollView);
            _imageViewAlbumArt = FindViewById<SquareImageView>(Resource.Id.player_imageViewAlbumArt);
            _lblPosition = FindViewById<TextView>(Resource.Id.player_lblPosition);
            _lblLength = FindViewById<TextView>(Resource.Id.player_lblLength);
            _btnPlayPause = FindViewById<ImageButton>(Resource.Id.player_btnPlayPause);
            _btnPrevious = FindViewById<ImageButton>(Resource.Id.player_btnPrevious);
            _btnNext = FindViewById<ImageButton>(Resource.Id.player_btnNext);
            _btnShuffle = FindViewById<ImageButton>(Resource.Id.player_btnShuffle);
            _btnRepeat = FindViewById<ImageButton>(Resource.Id.player_btnRepeat);
            _btnPlaylist = FindViewById<ImageButton>(Resource.Id.player_btnPlaylist);
            _seekBar = FindViewById<SeekBar>(Resource.Id.player_seekBar);
            _carrouselDot1 = FindViewById<Button>(Resource.Id.player_carrouselDot1);
            _carrouselDot2 = FindViewById<Button>(Resource.Id.player_carrouselDot2);
            _carrouselDot3 = FindViewById<Button>(Resource.Id.player_carrouselDot3);
            _carrouselDot4 = FindViewById<Button>(Resource.Id.player_carrouselDot4);
            _carrouselDot5 = FindViewById<Button>(Resource.Id.player_carrouselDot5);
            _btnPlayPause.Click += BtnPlayPauseOnClick;            
            _btnPrevious.Click += BtnPreviousOnClick;
            _btnNext.Click += BtnNextOnClick;
            _btnPlaylist.Click += BtnPlaylistOnClick;
            _btnRepeat.Click += BtnRepeatOnClick;
            _btnShuffle.Click += BtnShuffleOnClick;
            _btnPlayPause.SetOnTouchListener(this);
            _btnPrevious.SetOnTouchListener(this);
            _btnNext.SetOnTouchListener(this);
            _btnPlaylist.SetOnTouchListener(this);
            _btnRepeat.SetOnTouchListener(this);
            _btnShuffle.SetOnTouchListener(this);
            _seekBar.StartTrackingTouch += SeekBarOnStartTrackingTouch;
            _seekBar.StopTrackingTouch += SeekBarOnStopTrackingTouch;
            _seekBar.ProgressChanged += SeekBarOnProgressChanged;

            // Get screen size
            Point size = new Point();
            WindowManager.DefaultDisplay.GetSize(size);

            // Create bitmap cache
            int maxMemory = (int)(Runtime.GetRuntime().MaxMemory() / 1024);
            int cacheSize = maxMemory / 12;
            _bitmapCache = new BitmapCache(this, cacheSize, size.X, size.X); // The album art takes the whole screen width

            // Match height with width (cannot do that in xml)
            //_imageViewAlbumArt.LayoutParameters = new ViewGroup.LayoutParams(_imageViewAlbumArt.Width, _imageViewAlbumArt.Width);

            if (bundle != null)
            {
                string state = bundle.GetString("key", "value");
                Console.WriteLine("PlayerActivity - OnCreate - State is {0} - isInitialized: {1}", state, _isInitialized);
            }
            else
            {

                Console.WriteLine("PlayerActivity - OnCreate - State is null - isInitialized: {0}", _isInitialized);
            }

            // Don't try to check the bundle contents, if the activity wasn't destroyed, it will be null.
            //if (bundle != null)
            //    Console.WriteLine("PlayerActivity - OnCreate - Bundle isn't null - value: {0}", bundle.GetString("key", "null"));
            //else
            //    Console.WriteLine("PlayerActivity - OnCreate - Bundle is null!");

            // When Android stops an activity, it recalls OnCreate after, even though the activity is not destroyed (OnDestroy). It actually goes through creating a new object (the ctor is called).
            //((AndroidNavigationManager)_navigationManager).SetPlayerActivityInstance(this);
            _navigationManager.BindPlayerView(MobileNavigationTabType.Playlists, this);

            // Activate lock screen if not already activated
            _messengerHub.PublishAsync<ActivateLockScreenMessage>(new ActivateLockScreenMessage(this, true));

            _messengerHub.Subscribe<ApplicationCloseMessage>(message =>
            {
                Console.WriteLine("PlayerActivity - Received ApplicationCloseMessage; closing activity of type {0}", this.GetType().FullName);
            });

        }