Пример #1
0
        public static void updateSoundLevel(int offset)
        {
            sound_level += offset;
            if (sound_level > 100)
            {
                sound_level = 100;
            }
            else if (sound_level < 0)
            {
                sound_level = 0;
            }

            try
            {
                if (c_set_sound_level == 0)
                {
                    c_set_sound_level = CibylCallTable.getAddressByName("roadmap_main_set_sound_level");
                }

                UIWorker.addUIEvent(c_set_sound_level, sound_level, 0, 0, 0, false);
            }
            catch (Exception e)
            {
                UIWorker.addUIEventLog("Error in SoundMgr setVolume" + e);
                Logger.log("Exception: " + e.ToString());
            }
        }
Пример #2
0
        /// <summary>
        /// Update waze with new GPS coordinates
        /// </summary>
        /// <param name="position"></param>
        private void UpdatePosition(GeoPosition <GeoCoordinate> position)
        {
            try
            {
                UIWorker.addUIEvent(c_pos1,
                                    (int)(position.Location.Latitude * 1000000),
                                    (int)(position.Location.Longitude * 1000000),
                                    0,
                                    0, false);


                DateTime Now = DateTime.Now.ToUniversalTime();
                long     currentTimeMillis = (Now - baseTime).Ticks / 10000;

                UIWorker.addUIEvent(c_pos2,
                                    'A',
                                                                        //(int)(position.Timestamp.Ticks / 1000),
                                                                        //(int)DateTime.Now.Ticks / 10000 / 1000,
                                    (int)currentTimeMillis / 1000,
                                    (int)(position.Location.Speed * 2), // Convert to ~knots
                                    (int)position.Location.Course, false);

                if (meOnMapMenuItem != null)
                {
                    //meOnMapMenuItem.CallCallback();
                }
            }
            catch (Exception ex)
            {
                Logger.log("Exception in do_async_connect_cb: " + ex.ToString());
            }
        }
Пример #3
0
    static void TimerCallback(object ctx)
    {
        TimerCtx _ctx = (TimerCtx)ctx;

        try
        {
            if (c_on_invokeLater == 0)
            {
                c_on_invokeLater = CibylCallTable.getAddressByName("rim_on_scheduledTask");
            }
        }
        catch (Exception ex)
        {
            System.Diagnostics.Debug.WriteLine("Exception in run (rim_on_scheduledTask): " + ex.ToString());
            Logger.log(ex.ToString());

            throw; //todomt
            //Environment.Exit(0);
        }

        if (c_on_invokeLater != 0)
        {
            UIWorker.addUIEvent(c_on_invokeLater, _ctx.index, 0, 0, 0, _ctx.interval < 100 ? true : false);
        }
    }
Пример #4
0
    public void CallCallback()
    {
        int c_on_menuItem = CibylCallTable.getAddressByName("rim_on_menuItem");

        if (c_on_menuItem != 0)
        {
            UIWorker.addUIEvent(c_on_menuItem, wrapper_callback, callback, 0, 0, true);
        }
    }
Пример #5
0
 void gps_StatusChanged(object sender, GeoPositionStatusChangedEventArgs e)
 {
     gpsStatus = e.Status;
     if (gpsStatus == GeoPositionStatus.Disabled || gpsStatus == GeoPositionStatus.NoData)
     {
         try
         {
             UIWorker.addUIEvent(c_pos2, 'V', 0, 0, 0, false);
         }
         catch (Exception ex)
         {
             Logger.log("Exception in do_async_connect_cb: " + ex.ToString());
         }
     }
 }
Пример #6
0
    /*
     *
     * Called when moving returning from background to foreground.
     *
     * Pressing end key sends to background. To avoid wasting battery when user is unaware,
     *
     * after SECONDS_IN_BACKGROUND_B4_DLG seconds, a confirm dialog willl pop up, telling the
     *
     * user that waze is in background, and advise him to exit. If he doesn't answer - ( since he isn't
     *
     * looking at phone), exit anyway.
     *
     */
    /*todomt
     * public void deactivate(){
     * UIWorker.addUIEventLog("INFO : User went to background");
     * locale_before_background = Locale.getDefaultInput();
     * FreemapMainScreen.revertToInitialLocale();
     * if ( isCharging(DeviceInfo.getBatteryStatus()) == 1 ){
     * Logger.log("Charging, so not adding the background check");
     * return; // if charging, no need to
     * }
     * Application app = Application.getApplication();
     * idTimerBackgroundDialog = app.invokeLater (
     *  new Thread()
     *  {
     *   public void run()
     *   {
     *    if(c_ticker_sound == 0){
     *     try {
     *      c_ticker_sound = CibylCallTable.getAddressByName("roadmap_sound_play_background_sound");
     *     } catch (Exception e) {
     *      UIWorker.addUIEventLog("Exception trying to get Cybil address for c_ticker_sound");
     *      FreemapApp.safe_exit();
     *     }
     *    }
     *    UIWorker.addUIEvent(c_ticker_sound, 0, 0, 0, 0, true);
     *    UiApplication.getApplication().requestForeground();
     *    UIWorker.addUIEventLog("INFO: Waited 10 minutes, asking user if he wants to keep waze open. ");
     *    if(idTimerBackgroundDialog!=0)
     *     UiApplication.getUiApplication().cancelInvokeLater(idTimerBackgroundDialog );
     * //todomt      stayInBackgroundDialog = new Dialog("Waze is still running in the background. To avoid excess battery consumption it will shut down in 30 seconds.",
     *      new string[]{"Exit waze", "Stay in background"},
     *      new int[]{Dialog.YES, Dialog.NO},
     *      Dialog.YES,
     *      new Bitmap(0,0));
     * //todomt      stayInBackgroundDialog.setDialogClosedListener(new DialogClosedListener(){
     *     public void dialogClosed(Dialog d,int dialogReturnValue){
     *      if (dialogReturnValue == Dialog.NO){
     *       UiApplication.getApplication().requestBackground();
     *      }
     *
     *      if (dialogReturnValue == Dialog.YES){
     *       UIWorker.addUIEventLog("INFO : User accepted advice to not run in background. Exit.");
     *       safe_exit();
     *      }
     *     }
     *    });
     *
     * //todomt      stayInBackgroundDialog.show();
     *    resInvokeLaterappBGExit = UiApplication.getUiApplication().invokeLater (
     *      new Runnable()
     *      {
     *       // will be called some time after user hasn't picked his choice in the dialog. exit!
     *       public void run()
     *       {
     *        if(resInvokeLaterappBGExit !=0){
     *         UiApplication.getUiApplication().cancelInvokeLater(resInvokeLaterappBGExit );
     *         resInvokeLaterappBGExit = 0;
     *        }
     */
    //todomt uncomment

    /*          if(stayInBackgroundDialog.isDisplayed()){
     *         UIWorker.addUIEventLog("INFO : Dialog confirm dialog open after waiting for answer, exitting");
     *         safe_exit();
     *        }*/
    /*todomt       }
     *    }, SECONDS_BACKGROUND_DIALOG*1000, false);
     *
     *  if(resInvokeLaterappBGExit == -1)
     *   UIWorker.addUIEventLog("NO MORE TIMERS - resInvokeLaterappBGExit = -1 ");
     * }
     *
     * }, SECONDS_IN_BACKGROUND_B4_DLG*1000, false); // ask user if he wants to exit app.
     *
     * if(idTimerBackgroundDialog == -1)
     * UIWorker.addUIEventLog("NO MORE TIMERS - idTimerBackgroundDialog = -1");
     *
     * }
     */
    /*
     *
     * Exit safely through roadmap_main, so user won't get error messages next time he quits.
     *
     */
    public static void safe_exit()
    {
        try
        {
            if (c_roadmap_main_exit == 0)
            {
                c_roadmap_main_exit = CibylCallTable.getAddressByName("roadmap_main_exit");
            }
            if (c_roadmap_main_exit != 0)
            {
                int c_sp = (CRunTime.memory.Length * 4) - 8;
                UIWorker.addUIEvent(c_roadmap_main_exit, 0, 0, 0, 0, true);
            }
        }
        catch (Exception t)
        {
            UIWorker.addUIEventLog("FreeMapMainScreen Safe Exit exception" + t.ToString());
            //   t.printStackTrace();
            throw;     //todomt
            //Environment.Exit(0);
        }
    }
Пример #7
0
 public static void addCallback(int addr, int p1, int p2, int p3, int p4)
 {
     UIWorker.addUIEvent(addr, p1, p2, p3, p4, false);
 }
Пример #8
0
    private static void messageBoxBuilder(string titleText, int titleSize,
                                          string msgText, int textSize, string buttonText,
                                          int callback, int numberOfSeconds, int isModal)
    {
        // if numberOfSeconds is non zero we should auto close, but MessageBox is always Modal and does not support closing from code.
        // we will need to implement a non modal message box calss for this scenario.

        MessageBoxResult res = MessageBoxResult.None;

        mre.Reset();
        System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
        {
            if (numberOfSeconds > 0)
            {
                Syscalls.rtlDialog.Show(titleText, msgText);

                // Auto hide on timeout.
                Thread threadAutoHide = new Thread(new ThreadStart(
                                                       delegate()
                {
                    Thread.Sleep(numberOfSeconds * 1000);

                    System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        Syscalls.rtlDialog.Hide();
                        res = Syscalls.rtlDialog.Result;
                    });

                    // If we were asked to display an error, try to handle it gracefully by trying to navigate again.
                    if (titleText.Contains("אופס") || titleText.Contains("Oops"))
                    {
                        //TODO: Try to navigate to latest destination again.
                    }
                }));

                threadAutoHide.Start();
            }
            else
            {
                // Show dialog
                Syscalls.rtlDialog.Show(titleText, msgText);


                //res = MessageBox.Show(msgText, titleText, MessageBoxButton.OK);
            }
        });

        if (numberOfSeconds == 0)
        {
            // Wait for use to press OK
            while (Syscalls.rtlDialog.Result == MessageBoxResult.None)
            {
                Thread.Sleep(100);
            }

            // Get result
            res = Syscalls.rtlDialog.Result;
        }

        System.Windows.Deployment.Current.Dispatcher.BeginInvoke(() =>
        {
            if (res == MessageBoxResult.OK || res == MessageBoxResult.Yes)
            {
                Logger.log("Messagebox: " + msgText);
                if (callback != 0)
                {
                    UIWorker.addUIEvent(callback, 0, 0, 0, 0, true);
                }
            }

            mre.Set();
        }

                                                                 );
        mre.WaitOne();

        /* todomt
         *
         * UiApplication.getUiApplication().invokeLater(new Runnable()
         * {
         *
         *
         * public void run()
         * {
         * Font font;
         * PopupScreen screen = new PopupScreen(new VerticalFieldManager(Manager.VERTICAL_SCROLL),Field.FOCUSABLE);
         * if(titleText.length() > 0 ){
         * // Add the title
         * RichTextField title = new RichTextField(" "+titleText+ " ",RichTextField.TEXT_ALIGN_HCENTER|Field.FIELD_HCENTER|Field.NON_FOCUSABLE)
         *  {
         *     protected void paint(Graphics g)
         *     {
         *     g.setColor(Colors.WHITE);
         *     invalidate();
         *     super.paint(g);
         *     }
         *  };
         *  font = Font.getDefault().derive(Font.PLAIN,titleSize,Ui.UNITS_pt);
         *  title.setFont(font);
         *  screen.add(title);
         *
         *  // Add separator between title and text
         *  screen.add(new SeparatorField());
         * }
         *
         * // Add the message text
         * RichTextField text = new RichTextField(" "+msgText+" ",RichTextField.TEXT_ALIGN_HCENTER|Field.FIELD_HCENTER|Field.NON_FOCUSABLE)
         * {
         *    protected void paint(Graphics g)
         *    {
         *    g.setColor(Colors.WHITE);
         *    invalidate();
         *    super.paint(g);
         *    }
         * };
         * font = Font.getDefault().derive(Font.PLAIN,textSize,Ui.UNITS_pt);
         * text.setFont(font);
         * screen.add(text);
         *
         * if(numberOfSeconds>0)
         *       screen.add(new PopupScreenButton(screen, buttonText,callback,numberOfSeconds,0,0));
         * else
         *       screen.add(new PopupScreenButton(screen, buttonText,callback,0,0));
         *
         * pushScreen(isModal==1, screen);
         *
         * }
         * });*/
    }