Exemplo n.º 1
0
        public override void ViewDidLoad()
        {
            try {
                TitleLabel.Font = Theme.HugeFont;
                TitleLabel.Text = "EMAIL";

                _info = Repo.Foreground.Table <ShareInfo> ().FirstOrDefault();
                if (_info == null)
                {
                    _info = new ShareInfo {
                        From = UIDevice.CurrentDevice.Name, To = ""
                    };
                    Repo.Foreground.Insert(_info);
                }

                var y = TitleLabel.Frame.Bottom + App.Inst.LabelGap;
                _form = new Form(_info, new RectangleF(TitleLabel.Frame.Left, y, View.Frame.Width, View.Frame.Height - y));
                _form.ConfirmButtonText = "SHARE";
                _form.ShowCancelButton  = true;

                _form.OnCancel += delegate {
                    try {
                        App.Inst.PopDialog();
                    } catch (Exception error) {
                        Log.Error(error);
                    }
                };
                _form.OnOK += delegate {
                    try {
                        Repo.Foreground.Update(_info);

                        var sh = new ShareMessage {
                            From = _info.From, To = _info.To, Comment = "", MessageId = Message.Id, Status = ShareMessageStatus.Unsent
                        };
                        Repo.Foreground.Insert(sh);

                        ShareUpdater.SetSharesChanged();

                        App.Inst.PopDialog();
                    } catch (Exception error) {
                        Log.Error(error);
                    }
                };

                View.AddSubview(_form);
            } catch (Exception error) {
                Log.Error(error);
            }
        }
Exemplo n.º 2
0
        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);
        }