void Subscribe(Dictionary <string, string> subs) { var sourceType = typeof(Blog); using (var repo = new Repo()) { var sources = repo.GetActiveSources(sourceType); var existingSources = new Dictionary <string, Blog>(); foreach (Blog s in sources) { existingSources.Add(s.Url, s); } foreach (var s in subs) { var url = s.Value; if (!existingSources.ContainsKey(url)) { var source = new Blog(); source.Url = url; repo.Insert(source); Console.WriteLine("GU: Subscribed to " + url); } } } SourceUpdater.SetSourcesChanged(); App.RunUI(delegate { App.Inst.RefreshInfo(); }); }
public override void ViewDidLoad() { try { AddLabel.Font = Theme.HugeFont; Source = (Source)Activator.CreateInstance(SourceType); AddLabel.Text = "ADD " + SourceTypes.GetTitle(SourceType); var y = AddLabel.Frame.Bottom + App.Inst.LabelGap; _form = new Form(Source, new RectangleF(AddLabel.Frame.Left, y, View.Frame.Width, View.Frame.Height - y)); _form.OnOK += delegate { try { Repo.Foreground.AddOrActivateSource(Source); SourceUpdater.SetSourcesChanged(); App.Inst.ShowSourceMessages(Source); } catch (Exception error) { Log.Error(error); } }; View.AddSubview(_form); } catch (Exception error) { Log.Error(error); } }
public bool FinishedLaunching(UIWindow window, UIApplication app, NSDictionary options) { IsSimulator = UIDevice.CurrentDevice.Model.IndexOf("Simulator") >= 0; Inst = this; NSError err; AVAudioSession.SharedInstance().SetCategory(AVAudioSession.CategoryAmbient, out err); Sounds.PlayStartUp(); Theme.Init(); Repo.CreateForeground(); MVC = new MainViewController(); MVC.View.BackgroundColor = UIColor.Black; MVC.View.Frame = new RectangleF(0, 0, 768, 1024 - 20); MVC.BuildUI(); window.AddSubview(MVC.View); NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillShowNotification, MVC.OnShowKeyboard); NSNotificationCenter.DefaultCenter.AddObserver(UIKeyboard.WillHideNotification, MVC.OnHideKeyboard); MVC.Layout(false); RestoreUIState(); RefreshInfo(); _netStartTimer = NSTimer.CreateScheduledTimer(TimeSpan.FromSeconds(5), delegate { try { CheckNetwork(); // Console.WriteLine ("MAIN REFRESH INFO"); SourceUpdater.SourceWasUpdated += delegate { RefreshInfo(); }; SourceUpdater.Start(); ShareUpdater.Start(); } catch (Exception error) { Log.Error(error); } }); window.MakeKeyAndVisible(); return(true); }
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); }