Exemplo n.º 1
0
        void RefreshMessagesInBackground()
        {
            var messages = new MessageRef[0];

            using (var repo = new Repo()) {
                if (QuerySources != null && QuerySources.Length > 0)
                {
                    var ms = new List <MessageRef> ();
                    foreach (var src in QuerySources)
                    {
                        SourceType = src.GetType();
                        ms.AddRange(repo.GetRecentMessages(src));
                    }
                    ms.Sort((a, b) => b.PublishTime.CompareTo(a.PublishTime));
                    messages = ms.ToArray();
                    if (App.Inst.IsSimulator)
                    {
                        Thread.Sleep(TimeSpan.FromSeconds(new Random().NextDouble() * 2));
                    }
                }
            }

            App.RunUI(delegate {
                var ms      = TheMessages;
                TheMessages = messages;

                var changed = ms == null || (ms.Length != messages.Length);

                if (_scanner != null)
                {
                    _scanner.StopScanning();

                    UIView.BeginAnimations("RetFadeIn");
                    _scanner.Alpha = 0;
                    UIView.CommitAnimations();

                    NSTimer.CreateScheduledTimer(TimeSpan.FromMilliseconds(30), delegate { Sounds.PlayDataFound(); });
                    NSTimer.CreateScheduledTimer(TimeSpan.FromMilliseconds(250), delegate {
                        if (_scanner != null)
                        {
                            _scanner.RemoveFromSuperview();
                            _scanner = null;
                        }
                    });
                }

                RefreshMessagesUI(changed);
            });
        }
Exemplo n.º 2
0
        void Initialize()
        {
            table        = new SourceTypeMessages.MessageTable(this);
            TheMessages  = new MessageRef[0];
            SourceType   = typeof(News);
            Info         = new UIInfo();
            QuerySources = new Source[0];

            Info.MainTop = new LcarsDef();
            Info.MainTop.ComponentType = LcarsComponentType.SystemFunction;
            Info.MainTop.Caption       = "ADD";
            Info.MainTop.Command       = delegate { App.Inst.ShowAddSource(SourceType); };
            Info.MiscBtn = new LcarsDef {
                ComponentType = LcarsComponentType.DisplayFunction, NeedsDoubleTap = true, Caption = "REMOVE", Command = delegate { OnRemoveSource(); }
            };
        }
Exemplo n.º 3
0
 public Message Resolve(MessageRef mref)
 {
     return(Table <Message>().Where(m => m.Id == mref.Id).FirstOrDefault());
 }
Exemplo n.º 4
0
 void SelectMessage(MessageRef m)
 {
     App.Inst.ShowMessage(m, TheMessages);
 }
Exemplo n.º 5
0
 void SelectMessage(NSIndexPath p, MessageRef m)
 {
     Sounds.PlayBeep();
     SelectMessage(m);
 }
Exemplo n.º 6
0
        public void ShowMessage(MessageRef m, MessageRef[] messages)
        {
            MessageReader reader = null;

            //
            // Remove the SubView if it is not a reader
            //
            if (MVC.SubView != null)
            {
                reader = MVC.SubView as MessageReader;
                if (reader == null)
                {
                    PopInfo(reader);
                    MVC.SubView.View.RemoveFromSuperview();
                    MVC.SubView = null;
                }
            }

            //
            // Now add the reader
            //
            if (reader == null)
            {
                reader            = new MessageReader();
                reader.View.Frame = new RectangleF(MVC.MainView.View.Frame.Left, 1024, 600, 520);
                PushInfo(reader);
                MVC.View.AddSubview(reader.View);
                reader.View.Alpha = 0;
                UIView.BeginAnimations("SV");
                reader.View.Frame       = new RectangleF(MVC.MainView.View.Frame.Left, 1024 - 520, 600, 520);
                reader.View.Alpha       = 1;
                MVC.MainView.View.Frame = new RectangleF(MVC.MainView.View.Frame.Left, MVC.MainView.View.Frame.Top, MVC.MainView.View.Frame.Width, 720 - 520);
                UIView.CommitAnimations();
            }
            reader.MessageRef = m;

            //
            // Save the UI State
            //
            _uiState.ActiveScreen      = "Message";
            _uiState.ActiveScreenValue = m.Id.ToString();
            SaveUIState();

            //
            // Mark the message as being read
            //
            if (!m.IsRead)
            {
                m.IsRead = true;
                var message = Repo.Foreground.Resolve(m);
                if (message != null)
                {
                    message.IsRead = true;
                    Repo.Foreground.Update(message);
                }
            }

            //
            // Update scrolly
            //
            var ms = MVC.MainView as SourceTypeMessages;

            if (ms != null)
            {
                ms.SetActiveItem(messages.IndexOf(mm => mm.Id == m.Id));
            }

            MVC.SubView = reader;
            MVC.Layout(true);
        }