示例#1
0
        public void RefreshInfo(UIInfo info)
        {
            TitleLabel.Text = info.ScreenTitle.ToUpperInvariant();
            PrimaryComp.Def = info.TopLeft;

            HomeBtn.Def = info.TopMisc;

            //
            // Did the buttons actually change?
            //
            var oldNumButtons = Defs == null ? 0 : Defs.Length;
            var numButtons    = info.CommandButtons != null ? info.CommandButtons.Length : 0;
            var sameButtons   = numButtons == oldNumButtons;

            if (sameButtons)
            {
                for (var i = 0; i < numButtons && sameButtons; i++)
                {
                    var a = Defs[i];
                    var b = info.CommandButtons[i];
                    sameButtons = a.Caption == b.Caption;
                }
            }

            Defs = info.CommandButtons;
            if (!sameButtons)
            {
                if (_buttons != null)
                {
                    _buttons.RemoveFromSuperview();
                    _buttons = null;
                }

                if (numButtons > 0)
                {
                    var w = 600;
                    var h = 160;
                    _buttons = new SelectItem(info.CommandButtons, new RectangleF(View.Frame.Width - w, TitleLabel.Frame.Bottom + 10, w, h), 100, 10, 0, ItemOrder.RightToLeft);
                    _buttons.BackgroundColor = UIColor.Clear;
                    View.AddSubview(_buttons);
                    DoLayout();
                }
            }

//			var leftButton = View.Frame.Width;
//			if (numButtons > 0) {
//				var b = buttons[numButtons - 1];
//				leftButton = b.Frame.Left;
//			}
//
//			MsgTable.Frame = new System.Drawing.RectangleF(MsgTable.Frame.Left,
//			                                               MsgTable.Frame.Top,
//			                                               leftButton - 20 - MsgTable.Frame.Left,
//			                                               MsgTable.Frame.Height);
//			MsgTable.Hidden = MsgTable.Frame.Width < 100;
        }
示例#2
0
        void Up(UIInfo other, Func <UIInfo, LcarsDef> g, Action <LcarsDef> s)
        {
            var mine = g(this);

            if (mine == null)
            {
                s(g(other));
            }
            else
            {
                mine.UpdateWith(g(other));
            }
        }
示例#3
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(); }
            };
        }
示例#4
0
        public void RefreshInfo(UIInfo info)
        {
            Comp7.Def        = info.BottomLeft;
            RelativeComp.Def = info.MainRel;
            Comp1.Def        = info.MainTop;
            Comp2.Def        = info.MainFill;
            MiscComp.Def     = info.MiscBtn;
            Comp6.Def        = info.MainSec;
            Comp6.Hidden     = true;

            var activeTypes = Repo.Foreground.GetActiveSourceTypes();

            foreach (var c in sourceComps)
            {
                c.RemoveFromSuperview();
            }
            sourceComps.Clear();
            if (activeTypes.Length != 0)
            {
                sourceComps = new List <LcarsComp> ();
                foreach (var t in activeTypes)
                {
                    var tt = t;
                    var c  = new LcarsComp();

                    var cap = SourceTypes.GetTitle(t);

                    if (!App.Inst.IsIPad && cap.Length > 8)
                    {
                        var parts = cap.Split(' ');
                        for (var j = 0; j < parts.Length; j++)
                        {
                            parts[j] = parts[j].TruncateChars(3);
                        }

                        cap = string.Join(" ", parts);
                    }

                    c.Def.Caption       = cap;
                    c.Def.ComponentType = LcarsComponentType.NavigationFunction;
                    c.Def.Command       = delegate { App.Inst.ShowSourceTypeMessages(tt, true); };
                    View.AddSubview(c);
                    sourceComps.Add(c);
                }
            }
            DoLayout();
        }
示例#5
0
        public void UpdateWith(UIInfo other)
        {
            ScreenTitle = other.ScreenTitle;

            Up(other, i => i.BottomLeft, d => { this.BottomLeft = d; });
            Up(other, i => i.MainRel, d => { this.MainRel = d; });
            Up(other, i => i.MainTop, d => { this.MainTop = d; });
            Up(other, i => i.MainFill, d => { this.MainFill = d; });
            Up(other, i => i.TopLeft, d => { this.TopLeft = d; });
            Up(other, i => i.TopMisc, d => { this.TopMisc = d; });
            Up(other, i => i.MiscBtn, d => { this.MiscBtn = d; });
            Up(other, i => i.MainSec, d => { this.MainSec = d; });

            if (other.CommandButtons != null)
            {
                CommandButtons = other.CommandButtons;
            }
        }
示例#6
0
 public void RefreshInfo(UIInfo info)
 {
     RefreshMessagesUI(false);
 }
示例#7
0
        public override void ViewDidLoad()
        {
            try {
                Info = new UIInfo();

                TextBox.MultipleTouchEnabled = true;

                CompWidth = CloseBtn.Frame.Width;
                if (!App.Inst.IsIPad)
                {
                    CompWidth *= 0.75f;
                }

                wdel                         = new MessageReader.WDel(this);
                TextBox.Delegate             = wdel;
                TextBox.MultipleTouchEnabled = true;

                OriginalBtn.Def.Caption          = "ORIGINAL";
                OriginalBtn.Def.ComponentType    = LcarsComponentType.NavigationFunction;
                OriginalBtn.Def.PlayCommandSound = delegate {
                    if (Message != null && !string.IsNullOrEmpty(Message.Url))
                    {
                        Sounds.PlayDataRetrieval();
                    }
                    else
                    {
                        Sounds.PlayNotAllowed();
                    }
                };
                OriginalBtn.Def.Command = delegate { ToggleOriginal(); };

                ShareBtn.Def.ComponentType = LcarsComponentType.PrimaryFunction;
                ShareBtn.Def.Caption       = "SHARE";
                ShareBtn.Def.Command       = delegate {
                    if (Message == null)
                    {
                        return;
                    }
                    var s = new ShareView();
                    s.Message = Message;
                    App.Inst.ShowDialog(s);
                };

                Filler                   = new LcarsComp();
                Filler.Frame             = new RectangleF(ShareBtn.Frame.Left, ShareBtn.Frame.Bottom, ShareBtn.Frame.Width, 0);
                Filler.Def.ComponentType = LcarsComponentType.Static;
                Filler.Hidden            = true;
                View.AddSubview(Filler);

                TextBox.Layer.CornerRadius = 10;


                CloseBtn.Def.Caption       = "CLOSE";
                CloseBtn.Def.ComponentType = LcarsComponentType.DisplayFunction;
                CloseBtn.Def.Command       = delegate { App.Inst.CloseSubView(true); };

                RelativeComp.Def.ComponentType = LcarsComponentType.SystemFunction;
                RelativeComp.Width             = CloseBtn.Width;
                RelativeComp.Shape             = LcarsShape.TopRight;
                RelativeComp.Height            = Theme.HorizontalBarHeight;
                RelativeComp.Def.Command       = delegate {
                    var full = App.Inst.ToggleSubViewFullScreen(true);
                    RelativeComp.Def.Caption = full ? "MIN" : "MAX";
                    DoLayout(full);
                    RelativeComp.SetNeedsDisplay();
                };
                RelativeComp.Def.Caption = "MAX";

                TopBtn.Def.ComponentType = LcarsComponentType.MiscFunction;
                TopBtn.Def.Caption       = "PREV";
                TopBtn.Def.Command       = delegate { App.Inst.GotoNextMessage(Message, -1); };

                BottomBtn.Def.ComponentType = LcarsComponentType.MiscFunction;
                BottomBtn.Def.Caption       = "NEXT";
                BottomBtn.Def.Command       = delegate { App.Inst.GotoNextMessage(Message, 1); };

                Theme.MakeBlack(TextBox);
                TextBox.Hidden = true;
                SetHtml("", "");

                DoLayout();
            } catch (Exception error) {
                Log.Error(error);
            }
        }
示例#8
0
        public UIInfo GetDefaultUI()
        {
            var i = new UIInfo();

            i.ScreenTitle = UIInfo.DefaultScreenTitle;

            i.MainFill = new LcarsDef();
            i.MainFill.ComponentType = LcarsComponentType.Static;

            i.MiscBtn = new LcarsDef {
                ComponentType = LcarsComponentType.Static
            };

            i.MainTop = new LcarsDef {
                ComponentType = LcarsComponentType.Static
            };

            i.TopLeft = new LcarsDef {
                ComponentType = LcarsComponentType.MiscFunction, Caption = "REFRESH", Command = delegate {
                    SourceRef r = null;
                    if (MVC.SubView is MessageReader)
                    {
                        var m = ((MessageReader)MVC.SubView).MessageRef;
                        if (m != null)
                        {
                            r = m.GetSourceReference();
                        }
                    }
                    else if (MVC.MainView is SourceTypeMessages)
                    {
                        var ms = (SourceTypeMessages)MVC.MainView;
                        var s  = ms.QuerySources.FirstOrDefault();
                        if (s != null)
                        {
                            r = s.Reference;
                        }
                    }
                    SourceUpdater.ForceRefresh(r);
                }
            };

            i.TopMisc = new LcarsDef {
                ComponentType = LcarsComponentType.SystemFunction, Caption = Sounds.IsMuted ? "UNMUTE" : "MUTE", Command = delegate {
                    Sounds.ToggleMute();
                    var a = AudioPlayerController.Inst;
                    if (Sounds.IsMuted && a != null && a.IsPlaying)
                    {
                        ResumeAudioOnNextUnmute = true;
                        a.Pause();
                    }
                    else if (!Sounds.IsMuted && ResumeAudioOnNextUnmute && a != null)
                    {
                        a.Play();
                        ResumeAudioOnNextUnmute = false;
                    }

                    RefreshInfo();
                }
            };

            i.MainSec = new LcarsDef {
                ComponentType = LcarsComponentType.MiscFunction, Caption = "SETTINGS", Command = delegate {
                    var c = new UserSettings();
                    ShowMain(c);
                }
            };

            i.MainRel = new LcarsDef {
                ComponentType = LcarsComponentType.DisplayFunction
            };
            if (!IsIPad)
            {
                i.MainRel.Command = delegate { MVC.ToggleMainFullScreen(true); };
            }

            i.BottomLeft = new LcarsDef {
                ComponentType = LcarsComponentType.SystemFunction, Caption = App.Inst.IsIPad ? "ADD SOURCE" : "ADD", Command = delegate {
                    var c = new ChooseSource();
                    ShowMain(c);
                }
            };

            return(i);
        }