/// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            try
            {
                random = new Random();
                _sync = new object();
                _client = SimpleIoc.Default.GetInstance<IClient>();
                _settingsRepository = SimpleIoc.Default.GetInstance<ISettingsRepository>();

                apiExt = _client.GetAPIExtension(null);

                CallCommand = new RelayCommand<string>(CallPressed,
                                                       phoneNumber => !string.IsNullOrEmpty(UsedPhoneNumber) && !string.IsNullOrEmpty(phoneNumber));

                _internalPhoneBookItems = new List<PhoneBookItem>();
                PhoneBookItems = CollectionViewSource.GetDefaultView(_internalPhoneBookItems);

                _client.PhoneBookChanged += OnPhoneBookChanged;
                _client.SessionCreated += ClientOnSessionCreated;
                _client.ErrorOccurred += ClientOnErrorOccurred;
                _client.GetPhoneBook();
            }
            catch (Exception ex)
            {

            }
        }
Exemple #2
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            try
            {
                random              = new Random();
                _sync               = new object();
                _client             = SimpleIoc.Default.GetInstance <IClient>();
                _settingsRepository = SimpleIoc.Default.GetInstance <ISettingsRepository>();

                apiExt = _client.GetAPIExtension(null);

                CallCommand = new RelayCommand <string>(CallPressed,
                                                        phoneNumber => !string.IsNullOrEmpty(UsedPhoneNumber) && !string.IsNullOrEmpty(phoneNumber));

                _internalPhoneBookItems = new List <PhoneBookItem>();
                PhoneBookItems          = CollectionViewSource.GetDefaultView(_internalPhoneBookItems);

                _client.PhoneBookChanged += OnPhoneBookChanged;
                _client.SessionCreated   += ClientOnSessionCreated;
                _client.ErrorOccurred    += ClientOnErrorOccurred;
                _client.GetPhoneBook();
            }
            catch (Exception ex)
            {
            }
        }
        public LoginViewModel()
        {
            _client = SimpleIoc.Default.GetInstance<IClient>();
            settingsRepository = SimpleIoc.Default.GetInstance<ISettingsRepository>();

            UserInfo = settingsRepository.GetUserInfo();

            if (!string.IsNullOrEmpty(UserInfo.Username))
                RememberMe = true;

            Login = new RelayCommand(() =>
                                         {
                                             canceled = false;
                                             LoginToServer();
                                         }, () => UserInfo.IsValid);

            _client.LoginCompleted += LoginCompleted;
            rand = new Random();

            InitReconnectionTimer();
        }
        public LoginViewModel()
        {
            _client            = SimpleIoc.Default.GetInstance <IClient>();
            settingsRepository = SimpleIoc.Default.GetInstance <ISettingsRepository>();

            UserInfo = settingsRepository.GetUserInfo();

            if (!string.IsNullOrEmpty(UserInfo.Username))
            {
                RememberMe = true;
            }


            Login = new RelayCommand(() =>
            {
                canceled = false;
                LoginToServer();
            }, () => UserInfo.IsValid);

            _client.LoginCompleted += LoginCompleted;
            rand = new Random();

            InitReconnectionTimer();
        }