void RestoreUIState() { try { var repo = Repo.Foreground; var newState = LoadUIState(repo); if (newState) { InitialData.Load(repo); } if (_uiState.ActiveScreen == "Message") { var id = int.Parse(_uiState.ActiveScreenValue); var mq = from m in repo.Table <Message> () where m.Id == id select m; var msg = mq.First(); var s = msg.GetSource(repo.GetActiveSources()); ShowSourceMessages(s); ShowMessage(msg.Reference, ((SourceTypeMessages)MVC.MainView).TheMessages); } else if (_uiState.ActiveScreen == "Source") { var parts = _uiState.ActiveScreenValue.Split('-'); var sourceTypeName = parts[0]; var id = int.Parse(parts[1]); var s = repo.GetActiveSource(sourceTypeName, id); ShowSourceMessages(s); } else if (_uiState.ActiveScreen == "SourceType") { string sourceTypeName = _uiState.ActiveScreenValue; var sourceType = SourceTypes.Get(sourceTypeName); if (sourceType != null) { ShowSourceTypeMessages(sourceType, false); } } else if (_uiState.ActiveScreen == "Home") { ShowHome(); } else { ShowHome(); } } catch (Exception) { _uiState.ActiveScreen = ""; _uiState.ActiveScreenValue = ""; ShowHome(); } }
void UpdateTitle() { var s = SourceTypes.GetTitle(SourceType); if (QuerySources.Length == 1) { s += ": " + QuerySources[0].GetDistinguisher().ToUpperInvariant(); } if (Info.ScreenTitle != s) { Info.ScreenTitle = s; App.Inst.RefreshInfo(); } }
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(); }
public override void ViewDidLoad() { try { TitleLabel.Font = Theme.HugeFont; sourceTypes = SourceTypes.All; var items = new List <LcarsDef> (); foreach (var sourceType in sourceTypes) { var t = sourceType; var def = new LcarsDef(); def.Caption = SourceTypes.GetTitle(t); def.Command = delegate { Choose(t); }; items.Add(def); } var y = TitleLabel.Frame.Bottom + App.Inst.LabelGap; _select = new SelectItem(items, new RectangleF(TitleLabel.Frame.Left, y, View.Frame.Width, View.Frame.Height - y)); View.AddSubview(_select); } catch (Exception error) { Log.Error(error); } }
public void SetSources(params Source[] sources) { QuerySources = sources; SourceType = QuerySources.Length > 0 ? QuerySources[0].GetType() : typeof(News); // // Buttons to get to related sources // var allSources = new Source[0]; if (QuerySources != null && QuerySources.Length > 0) { allSources = Repo.Foreground.GetActiveSources(SourceType).OrderBy(s => s.GetDistinguisher()).ToArray(); } var n = allSources.Length; var buttons = new LcarsDef[n]; for (int i = 0; i < n; i++) { var s = allSources[i]; var b = new LcarsDef(); b.Caption = s.GetShortDistinguisher().ToUpperInvariant(); b.ComponentType = PossibleTypes[s.Id % PossibleTypes.Length]; b.Command = delegate { App.Inst.ShowSourceMessages(s); }; buttons[i] = b; } Info.CommandButtons = buttons; Info.MainTop.Caption = "ADD " + SourceTypes.GetTitle(SourceType); if (sources.Length == 1) { Info.MiscBtn.ComponentType = LcarsComponentType.DisplayFunction; if (App.Inst.IsIPad) { Info.MiscBtn.Caption = "REMOVE " + sources[0].GetShortDistinguisher().TruncateWords(15).ToUpperInvariant(); } else { Info.MiscBtn.Caption = "REMOVE"; } Info.MiscBtn.IsCommandable = true; } else { Info.MiscBtn.ComponentType = LcarsComponentType.Static; Info.MiscBtn.Caption = ""; Info.MiscBtn.IsCommandable = false; } UpdateTitle(); if (!_showingData && QuerySources.Length > 1 && PlayAnimation) { _scanner = new ScanningView(new RectangleF(0, 20, View.Frame.Width, View.Frame.Height - 20)); _scanner.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; _scanner.Alpha = 0; _scanner.StartScanning(); View.AddSubview(_scanner); UIView.BeginAnimations("RetFadeIn"); _scanner.Alpha = 1; UIView.CommitAnimations(); _showingData = true; } RefreshMessages(); }