Esempio n. 1
0
        public void StartClient()
        {
            if (_lt != null)
            {
                return;
            }

            MainViewModel.Clear();

            string user     = "";
            string password = "";

            ApplicationDataContainer settings = Windows.Storage.ApplicationData.Current.LocalSettings;

            if (settings.Containers.ContainsKey("Settings"))
            {
                if (settings.Containers["Settings"].Values.ContainsKey("user"))
                {
                    user = settings.Containers["Settings"].Values["user"].ToString();
                }

                if (settings.Containers["Settings"].Values.ContainsKey("password"))
                {
                    password = settings.Containers["Settings"].Values["password"].ToString();
                }

                if (settings.Containers["Settings"].Values.ContainsKey("estimateData"))
                {
                    MainViewModel.IsDataEstimationEnabled = (bool)settings.Containers["Settings"].Values["estimateData"];
                }
            }

            if (user != "" && password != "")
            {
                MainViewModel.ProgressIsIndeterminate = true;
                MainViewModel.ProgressIsVisible       = true;

                _lt = new LiveTiming(user, password, false);
                _lt.CarMessageHandler     += _lt_CarMessageHandler;
                _lt.ControlMessageHandler += _lt_ControlMessageHandler;
                _lt.SystemMessageHandler  += _lt_SystemMessageHandler;
                _lt.StartThread();
            }
            else
            {
                if (OnSettingsPageRequest != null)
                {
                    OnSettingsPageRequest.Invoke();
                }
                else
                {
                    NeedSettingsPage = true;
                }
            }
        }
Esempio n. 2
0
        private void StartClient(bool showSettingsIfNeeded = true)
        {
            if (_lt != null)
            {
                return;              //prevent from starting twice
            }
            MainViewModel.Clear();

            string user = "", passwd = "";

            if (IsolatedStorageSettings.ApplicationSettings.Contains("username"))
            {
                user = (string)IsolatedStorageSettings.ApplicationSettings["username"];
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains("password"))
            {
                passwd = (string)IsolatedStorageSettings.ApplicationSettings["password"];
            }

            if (IsolatedStorageSettings.ApplicationSettings.Contains("estimateData"))
            {
                MainViewModel.IsDataEstimationEnabled = (bool)IsolatedStorageSettings.ApplicationSettings["estimateData"];
            }

            if (user != "" && passwd != "")
            {
                MainViewModel.ProgressIsIndeterminate = true;
                MainViewModel.ProgressText            = "Connecting";
                MainViewModel.ProgressIsVisible       = true;

                _lt = new LiveTiming(user, passwd, false);
                _lt.SystemMessageHandler  += new LiveTimingMessageHandlerDelegate(_lt_SystemMessageHandler);
                _lt.CarMessageHandler     += new LiveTimingMessageHandlerDelegate(_lt_CarMessageHandler);
                _lt.ControlMessageHandler += _lt_ControlMessageHandler;
                _lt.StartThread();
            }
            else
            {
                //navigate to settings page cos there is no user and/or password set
                if (OnSettingsPageRequest != null)
                {
                    OnSettingsPageRequest.Invoke();
                }
                else
                {
                    NeedSettingsPage = true;
                }
            }
        }