Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            if (AppManager.CurrentApplication.Error == null)
            {
                ViewModel.ShowMenu();
            }
            else
            {
                UIAlertView alert = new UIAlertView();

                alert.Title = "Error";

                alert.AddButton("OK");

                alert.Message = AppManager.CurrentApplication.Error.Message;

                alert.Clicked += (object s, UIButtonEventArgs ev) => {
                    Process.GetCurrentProcess().Kill();
                    NSThread.Exit();
                };

                alert.Show();
            }
        }
        private NSData ApiCallAsync(NSUrlRequest request, ref NSUrlResponse response, ref NSError error)
        {
            var _result = (NSData)null;

            var _done = false;

            {
                var _response = (NSUrlResponse)null;
                var _error    = (NSError)null;

                var _task = NSUrlSession.SharedSession.CreateDataTask(request, (d, r, e) =>
                {
                    _response = r;
                    _error    = e;
                    _result   = d;

                    _done = true;
                });

                _task.Resume();

                while (_done == false)
                {
                    NSThread.SleepFor(0);
                }

                response = _response;
                error    = _error;
            }

            return(_result);
        }
Exemple #3
0
        public void ProcessJobWithCompletion(EDQueue.EDQueue queue, NSDictionary job, System.Action <int> block)
        {
            NSThread.SleepFor(1);

            try
            {
                var jobStatus = ((NSString)job.ObjectForKey(new NSString("task")))?.ToString();

                switch (jobStatus)
                {
                case "success":
                    block?.Invoke((int)EDQueueResult.Success);
                    break;

                case "fail":
                    block?.Invoke((int)EDQueueResult.Fail);
                    break;

                default:
                    block?.Invoke((int)EDQueueResult.Critical);
                    break;
                }
            } catch {
                block?.Invoke((int)EDQueueResult.Critical);
            }
        }
Exemple #4
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)

        {
            string dbPath = FileAccessHelper.GetLocalFilePath("miemss.db");

            global::Xamarin.Forms.Forms.Init();
            Firebase.Core.App.Configure();
            //Messaging.messaging().delegate = this;

            Syncfusion.SfPdfViewer.XForms.iOS.SfPdfDocumentViewRenderer.Init();
            Syncfusion.SfRangeSlider.XForms.iOS.SfRangeSliderRenderer.Init();

            NSThread.SleepFor(1);

            LoadApplication(new App(dbPath, new SQLitePlatformIOS()));


            if (UIDevice.CurrentDevice.CheckSystemVersion(8, 0))
            {
                var pushSettings = UIUserNotificationSettings.GetSettingsForTypes(
                    UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound,
                    new NSSet());

                UIApplication.SharedApplication.RegisterUserNotificationSettings(pushSettings);
                UIApplication.SharedApplication.RegisterForRemoteNotifications();
            }
            else
            {
                UIRemoteNotificationType notificationTypes = UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound;
                UIApplication.SharedApplication.RegisterForRemoteNotificationTypes(notificationTypes);
            }

            return(base.FinishedLaunching(app, options));
        }
        public void InitWithDataTest()
        {
            var obj    = new InitWithDataObject();
            var thread = new NSThread(obj, new Selector("start:"), null);

            thread.Start();
            Assert.IsTrue(obj.StartedEvent.WaitOne(TimeSpan.FromSeconds(5)), "thread start");
            GC.Collect();
        }
Exemple #6
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            // Override point for customization after application launch.
            // If not required for your application you can safely delete this method

            NSThread.SleepFor(2);

            return(true);
        }
Exemple #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            for (int i = 0; i < 30; i++)
            {
                list.Add(getItem());
            }



            chart          = new FlexChart();
            chart.BindingX = "Name";
            chart.Series.Add(new ChartSeries()
            {
                SeriesName = "Trucks", Binding = "Trucks,Trucks"
            });
            chart.Series.Add(new ChartSeries()
            {
                SeriesName = "Ships", Binding = "Ships,Ships"
            });
            chart.Series.Add(new ChartSeries()
            {
                SeriesName = "Planes", Binding = "Planes,Planes"
            });
            chart.ItemsSource = list;
            chart.Palette     = Palette.Coral;
            chart.ToolTip     = null;
            chart.ChartType   = ChartType.Line;
            this.Add(chart);

            InvokeInBackground(() =>
            {
                bool flag = true;
                while (flag)
                {
                    NSThread.SleepFor(.15);
                    InvokeOnMainThread(() =>
                    {
                        if (list.Count > 30)
                        {
                            list.RemoveAt(0);
                        }
                        list.Add(getItem());
                        chart.ItemsSource = list.ToArray();

                        if (!IsViewLoaded)
                        {
                            flag = false;
                        }
                    });
                }
            });
        }
Exemple #8
0
        static void TerminateApplication()
        {
            Console.WriteLine("Closing the running application to re-launch...");

            Console.WriteLine("Trying Exit Option 1...");
            Exit(0);
            Console.WriteLine("Option 1 failed. Trying Exit Option 2...");
            NSThread.Exit();
            Console.WriteLine("Option 2 failed. Trying Exit Option 3...");
            TerminateWithSuccess();
            Console.WriteLine("Option 3 failed. Trying Exit Option 4...");
            throw new Xamarin.iOS.HotRestart.KillApplicationException();
        }
Exemple #9
0
            public static void InitializeCocoaThreadingLocks()
            {
                var helper = new ThreadHelper();
                var thread = new NSThread(helper, Selector.FromHandle(Selector.GetHandle(InitThreadingName)), new NSObject());

                thread.Start();
                helper._event.WaitOne();
                helper._event.Dispose();
                if (!NSThread.IsMultiThreaded)
                {
                    throw new Exception("Unable to initialize Cocoa threading");
                }
            }
Exemple #10
0
        partial void CancelOperation(NSObject sender)
        {
            CancellationTokenSource.Cancel();

            //
            // Wait a few moments for the task to complete.
            //
            if (!RenameTask.IsCompleted)
            {
                for (int i = 0; i < 20 && !RenameTask.IsCompleted; i++)
                {
                    NSThread.SleepFor(0.1);
                }
            }

            DismissController(this);
        }
Exemple #11
0
        public void reportScore(long score, string category, MTGKTapperViewController controller)
        {
            GKScore scoreReporter = new GKScore(category);

            scoreReporter.Value = score;
            scoreReporter.ReportScore(new Action <NSError> ((error) => {
                if (error == null)
                {
                    new UIAlertView("Score reported", "Score Reported successfully", null, "OK", null).Show();
                }
                else
                {
                    new UIAlertView("Score Reported Failed", "Score Reported Failed", null, "OK", null).Show();
                }
                NSThread.SleepFor(1);
                controller.updateHighScore();
            }));
        }
        public void ReportScore(long score, string category, MTGKTapperViewController controller)
        {
            var scoreReporter = new GKScore(category)
            {
                Value = score
            };

            scoreReporter.ReportScore(error => {
                if (error == null)
                {
                    ShowAlert("Score reported", "Score Reported successfully");
                }
                else
                {
                    ShowAlert("Score Reported Failed", "Score Reported Failed");
                }
                NSThread.SleepFor(1);
                controller.UpdateHighScore();
            });
        }
Exemple #13
0
        /// <summary>
        /// Reports the error continue operation.
        /// </summary>
        /// <param name="error">The error.</param>
        /// <param name="continueOperation">if set to <c>true</c> [continue operation].</param>
        public virtual void ReportError(Exception error, bool continueOperation)
        {
            if (continueOperation)
            {
                return;
            }
#if PORTING
            string response = error.UserInfo.ObjectForKey(kUPErrorUserInfoResponse);
            if (!string.IsNullOrEmpty(response))
            {
                var organizerModelController = new UPOrganizerModelController(response);
                if (NSThread.CurrentThread().IsMainThread())
                {
                    this.ModelControllerDelegate.TransitionToContentModelController(organizerModelController);
                }
                else
                {
                    this.ModelControllerDelegate.PerformSelectorOnMainThreadWithObjectWaitUntilDone(@selector(transitionToContentModelController:), organizerModelController, false);
                }
            }
#endif
        }
        public override void DidUpdateFocus(UIFocusUpdateContext context, UIFocusAnimationCoordinator coordinator)
        {
            var nextFocusedView = context.NextFocusedView;

            if (!nextFocusedView.IsDescendantOfView(TableView))
            {
                return;
            }

            NSIndexPath indexPath = ((UITableViewFocusUpdateContext)context).NextFocusedIndexPath;

            if (indexPath == null)
            {
                return;
            }

            // Cancel any previously queued segues.
            delayedSeguesOperationQueue.CancelAllOperations();

            // Create an `NSBlockOperation` to perform the detail segue after a delay.
            var performSegueOperation = new NSBlockOperation();
            var segueIdentifier       = SegueIdentifierMap[indexPath.Section][indexPath.Row];

            performSegueOperation.AddExecutionBlock(() => {
                NSThread.SleepFor(performSegueDelay);
                if (performSegueOperation.IsCancelled && segueIdentifier == lastPerformedSegueIdentifier)
                {
                    return;
                }

                NSOperationQueue.MainQueue.AddOperation(() => {
                    PerformSegue(segueIdentifier, nextFocusedView);
                    lastPerformedSegueIdentifier = segueIdentifier;
                    TableView.SelectRow(indexPath, true, UITableViewScrollPosition.None);
                });
            });

            delayedSeguesOperationQueue.AddOperation(performSegueOperation);
        }
Exemple #15
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            for (int i = 0; i < 8; i++)
            {
                list.Add(getItem());
            }
            chart.ItemsSource       = list;
            chart.Palette           = XuniPalettes.Coral;
            chart.Tooltip.IsVisible = false;
            chart.ChartType         = ChartType.Line; 

            chart.LoadAnimation.AnimationMode = AnimationMode.Point;

            chart.BindingX = "time";
            chart.Series.Add(new Series(chart, "Trucks, Trucks", "Trucks"));
            chart.Series.Add(new Series(chart, "Ships, Ships", "Ships"));
            chart.Series.Add(new Series(chart, "Planes, Planes", "Planes"));

            chart.IsAnimated = true;

            InvokeInBackground(() => {
                bool flag = true;
                while (flag)
                {
                    NSThread.SleepFor(1);
                    InvokeOnMainThread(() =>
                    {
                        chart.CollectionView.RemoveAt(0);
                        chart.CollectionView.Add(getItem());
                        if (!IsViewLoaded)
                        {
                            flag = false;
                        }
                    });
                }
            });
        }
        public static bool Activate(int pid, int wait = 5000)
        {
            NSRunningApplication app = null;

            for (; wait > 0; wait -= 100)
            {
                if (app == null)
                {
                    app = NSRunningApplication.GetRunningApplication(pid);
                }

                if (app != null && app.FinishedLaunching)
                {
                    if (app.Activate(NSApplicationActivationOptions.ActivateIgnoringOtherWindows))
                    {
                        return(true);
                    }
                }

                NSThread.SleepFor(0.1);
            }
            return(false);
        }
Exemple #17
0
        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            NSThread.SleepFor(1);

            _window = new UIWindow(UIScreen.MainScreen.Bounds);

            MapServices.ProvideAPIKey(Constant.GOOGLE_PLACE_APIKEY);
            UIApplication.SharedApplication.SetStatusBarStyle(UIStatusBarStyle.LightContent, true);

            UINavigationBar.Appearance.BarTintColor        = new UIColor((nfloat)(60.0 / 255.0), (nfloat)(90.0 / 255.0), (nfloat)(126.0 / 255.0), (nfloat)1.0);
            UINavigationBar.Appearance.TitleTextAttributes = new UIStringAttributes()
            {
                ForegroundColor = UIColor.White
            };

            #region Facebook login

            Profile.EnableUpdatesOnAccessTokenChange(true);
            Settings.AppID       = Constant.FacebookAppId;
            Settings.DisplayName = Constant.DisplayName;

//			NSError configureError;
//			Context.SharedInstance.Configure (out configureError);
//			if (configureError != null) {
//				Console.WriteLine ("Error configuring the Google context: {0}", configureError);
//			}
//
//			Invite.ApplicationDidFinishLaunching ();
//
//			return true;

            // This method verifies if you have been logged into the app before, and keep you logged in after you reopen or kill your app.
            return(ApplicationDelegate.SharedInstance.FinishedLaunching(application, launchOptions));

            #endregion
        }
        public async void checkHighest(int sc, string level)
        {
            string catString = "com.commtech.inapppurchTest.StageScores";              //com.commtech.inapppurchTest.

            GKLocalPlayer xx = GKLocalPlayer.LocalPlayer;

            GKLeaderboard Leaderboard = new GKLeaderboard(new [] { xx.PlayerID })
            {
                Identifier = catString
            };

            var ss = Leaderboard.LocalPlayerScore;
            //var scores = await Leaderboard.LoadScoresAsync ();
            var oldScore = 0;            //ss.Value;
            //var oldScore = current.Value;

//			if (ss.Value != null) {
//
//				oldScore = (int)ss.Value;
//			}
//			var Category = Convert.ToInt64(  level.Substring (1, 1));
//
//			Console.WriteLine ("XXXXXXXXXXXXXXXXXXMXMXMXMXMMXMXMXXXXXXMXMXMXXXXXXXX");
//

//			if (oldScore == null) {
            var newScore = new GKScore(catString)
            {
                Value = sc
            };

            newScore.ReportScore(new Action <NSError> ((error) => {
                if (error == null)
                {
                    Console.WriteLine("YYYYYYYYYYYYYYYYYYYYYYYYYYBBBYYYBYBYBYBYYyy");

                    //new UIAlertView ("Score reported", "Score Reported successfully", null, "OK", null).Show ();
                }
                else
                {
                    Console.WriteLine("XXXXXXXXXXXXXXXXXXMXMXMXMXMMXMXMXXXXXXMXMXMXXXXXXXX");

                    //new UIAlertView ("Score Reported Failed", "Score Reported Failed", null, "OK", null).Show ();
                }
                NSThread.SleepFor(1);
                //controller.updateHighScore ();
            }));

//
//			Console.WriteLine ("score::"  + newScore.Value);
//				await GKScore.ReportScoresAsync(new [] {  newScore });
////
//			}
//			else if (sc > oldScore) {
//			//	gcm.reportScore (sc, car);
//				var newScore = new GKScore (catString) {
//					Value = sc
//
//				};
//
//				//await GKScore.ReportScoresAsync(new [] {  newScore });
//
//			}


            //GameCenterManager1 gcm = new GameCenterManager1 ();
        }
 public void DoSomeWorkThatTakesLong()
 {
     // we don't have anything to do. Simulate a long-running task by calling sleep.
     // That is okay here because we are in a demo and not running on the main thread.
     NSThread.SleepFor(2.0);
 }
Exemple #20
0
    /*
     *       Tells Appirater that the app was brought to the foreground on multitasking
     *       devices. You should call this method from the application delegate's
     *       applicationWillEnterForeground: method.
     *
     *       If the app has been used enough to be rated (and enough significant events),
     *       you can suppress the rating alert
     *       by passing NO for canPromptForRating. The rating alert will simply be postponed
     *       until it is called again with YES for canPromptForRating. The rating alert
     *       can also be triggered by appLaunched: and userDidSignificantEvent:
     *       (as long as you pass YES for canPromptForRating in those methods).
     */
    public void AppEnteredForeground(bool canPromptForRating)
    {
        NSThread t = new NSThread(this, new Selector(SELECTOR_INCREMENT_AND_RATE), NSNumber.FromBoolean(canPromptForRating));

        t.Start();
    }
Exemple #21
0
    /*
     *       Tells Appirater that the user performed a significant event. A significant
     *       event is whatever you want it to be. If you're app is used to make VoIP
     *       calls, then you might want to call this method whenever the user places
     *       a call. If it's a game, you might want to call this whenever the user
     *       beats a level boss.
     *
     *       If the user has performed enough significant events and used the app enough,
     *       you can suppress the rating alert by passing NO for canPromptForRating. The
     *       rating alert will simply be postponed until it is called again with YES for
     *       canPromptForRating. The rating alert can also be triggered by appLaunched:
     *       and appEnteredForeground: (as long as you pass YES for canPromptForRating
     *       in those methods).
     */
    public void UserDidSignificantEvent(bool canPromptForRating)
    {
        NSThread t = new NSThread(this, new Selector(SELECTOR_INCREMENT_EVENT_AND_RATE), NSNumber.FromBoolean(canPromptForRating));

        t.Start();
    }
Exemple #22
0
 // [Verify (PlatformInvoke)]
 static extern void WXPerformBlockOnThread(Action block, NSThread thread);
Exemple #23
0
 public void CloseApp()
 {
     NSThread.Exit();
 }
Exemple #24
0
        private void procBtn(int state = 1)
        {
            if (state == 4)
            {
                string[]    filetypes = { "rar" };
                NSOpenPanel dlg       = NSOpenPanel.OpenPanel;
                dlg.Title                   = "Selecione";
                dlg.CanChooseFiles          = true;
                dlg.CanChooseDirectories    = false;
                dlg.AllowedFileTypes        = filetypes;
                dlg.AllowsMultipleSelection = false;
                dlg.ResolvesAliases         = true;
                dlg.ReleasedWhenClosed      = true;
                dlg.BeginSheet(this, (i) => {
                    try
                    {
                        if (dlg.Url != null)
                        {
                            var urlString = dlg.Url.Path;
                            if (!string.IsNullOrEmpty(urlString))
                            {
                                //NSDate DateLoop = new NSDate ();
                                //DateLoop = DateLoop.AddSeconds (0.1);
                                //NSRunLoop.Current.RunUntil(DateLoop );

                                NSThread.Start(() => {
                                    clsRAR orar = new clsRAR();
                                    rarFile     = orar.OpenRAR(urlString, this, this.tbv_Arquivos);
                                    orar        = null;
                                });
                            }
                        }
                    }
                    finally
                    {
                        dlg.Dispose();
                        dlg = null;
                    }
                });
            }
            else
            {
                NSIndexSet nSelRows = this.tbv_Arquivos.SelectedRows;
                if (nSelRows.Count > 0)
                {
                    nuint[] nRows = nSelRows.ToArray();
                    if (nRows.Length > 0)
                    {
                        ViewArquivosDataSource datasource = (ViewArquivosDataSource)this.tbv_Arquivos.DataSource;
                        clsViewArquivos        cvarqs     = new clsViewArquivos();
                        string aState = string.Empty;
                        foreach (nint lRow in nRows)
                        {
                            switch (state)
                            {
                            case 1:
                                aState = "1";
                                break;

                            case 2:
                                aState = cvarqs.GetTagsArquivo(datasource, (int)lRow, 1);
                                break;

                            case 3:
                                NSOpenPanel dlg = NSOpenPanel.OpenPanel;
                                dlg.Title                   = "Salvar em";
                                dlg.CanChooseFiles          = false;
                                dlg.CanChooseDirectories    = true;
                                dlg.AllowsMultipleSelection = false;
                                dlg.ResolvesAliases         = true;
                                dlg.ReleasedWhenClosed      = true;
                                dlg.BeginSheet(this, (i) => {
                                    try {
                                        string urlString = dlg.Url.Path;
                                        if (!string.IsNullOrEmpty(urlString))
                                        {
                                            nSelRows = this.tbv_Arquivos.SelectedRows;
                                            NSThread.Start(() => {
                                                clsRAR exRAR = new clsRAR();
                                                exRAR.ExtractRAR(this, this.tbv_Arquivos, nSelRows, rarFile, urlString);
                                                exRAR = null;
                                            });
                                        }
                                    } finally {
                                        dlg.Dispose();
                                        dlg = null;
                                    }
                                    this.tbv_Arquivos.ReloadData();
                                });
                                break;

                            case 5:

                                break;
                            }
                            if (state != 3)
                            {
                                cvarqs.SetTagsArquivo(datasource, (int)lRow, aState);
                                cvarqs     = null;
                                datasource = null;
                                this.tbv_Arquivos.ReloadData();
                            }
                        }
                    }
                }
                else
                {
                    string mText = string.Empty;
                    string iText = string.Empty;
                    switch (state)
                    {
                    case 1:
                        mText = "Remover Arquivo(s)";
                        iText = "Selecione ao menos um aquivo para Remover !";
                        break;

                    case 2:
                        mText = "Desfazer Ação";
                        iText = "Selecione ao menos um arquivo para\r\n Desfazer a Ação !";
                        break;

                    case 3:
                        mText = "Extrair Arquivos";
                        iText = "Selecione ao menos um arquivo para Extrair !";
                        break;
                    }

                    NSAlert alert = new NSAlert()
                    {
                        AlertStyle      = NSAlertStyle.Warning,
                        InformativeText = iText,
                        MessageText     = mText,
                    };
                    alert.RunSheetModal(this);
                }
            }
        }
Exemple #25
0
    /*
         Tells Appirater that the app was brought to the foreground on multitasking
         devices. You should call this method from the application delegate's
         applicationWillEnterForeground: method.

         If the app has been used enough to be rated (and enough significant events),
         you can suppress the rating alert
         by passing NO for canPromptForRating. The rating alert will simply be postponed
         until it is called again with YES for canPromptForRating. The rating alert
         can also be triggered by appLaunched: and userDidSignificantEvent:
         (as long as you pass YES for canPromptForRating in those methods).
         */
    public void AppEnteredForeground(bool canPromptForRating)
    {
        NSThread t = new NSThread (this, new Selector (SELECTOR_INCREMENT_AND_RATE), NSNumber.FromBoolean (canPromptForRating));
        t.Start ();
    }
Exemple #26
0
    /*
         Tells Appirater that the user performed a significant event. A significant
         event is whatever you want it to be. If you're app is used to make VoIP
         calls, then you might want to call this method whenever the user places
         a call. If it's a game, you might want to call this whenever the user
         beats a level boss.

         If the user has performed enough significant events and used the app enough,
         you can suppress the rating alert by passing NO for canPromptForRating. The
         rating alert will simply be postponed until it is called again with YES for
         canPromptForRating. The rating alert can also be triggered by appLaunched:
         and appEnteredForeground: (as long as you pass YES for canPromptForRating
         in those methods).
         */
    public void UserDidSignificantEvent(bool canPromptForRating)
    {
        NSThread t = new NSThread (this, new Selector (SELECTOR_INCREMENT_EVENT_AND_RATE), NSNumber.FromBoolean (canPromptForRating));
        t.Start ();
    }