예제 #1
0
        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(Defaults.APPLICATION_ID) || string.IsNullOrEmpty(Defaults.SECRET_KEY) ||
                string.IsNullOrEmpty(Defaults.VERSION))
            {
                NavigationService.Navigate(new Uri("/ErrorPage.xaml", UriKind.Relative));
                return;
            }

            Backendless.InitApp(Defaults.APPLICATION_ID, Defaults.SECRET_KEY, Defaults.VERSION);
            DataStore = Backendless.Persistence.Of <ToDoEntity>();

            EntitiesDataGrid.DataContext = _toDoList;
            _toDoList.CollectionChanged +=
                (senderObj, args) => Footer.Visibility = _toDoList.Count == 0 ? Visibility.Collapsed : Visibility.Visible;

            AsyncStartedEvent += () =>
            {
                ProgressBar.Visibility = Visibility.Visible;
                ContentPanel.Opacity   = 0.1;
            };
            AsyncFinishedEvent += () =>
            {
                ProgressBar.Visibility = Visibility.Collapsed;
                ContentPanel.Opacity   = 1;
            };

            AsyncStartedEvent.Invoke();
            DataStore.Find(new AsyncCallback <BackendlessCollection <ToDoEntity> >(response => Dispatcher.BeginInvoke(() =>
            {
                _toDoList.AddAll(response.GetCurrentPage());
                AsyncFinishedEvent.Invoke();
            }), fault => Dispatcher.BeginInvoke(() => AsyncFinishedEvent.Invoke())));
        }
예제 #2
0
        private void SearchPoints()
        {
            if (_backendlessGeoQuery.Radius < 1)
            {
                return;
            }

            AsyncStartedEvent.Invoke();
            _cityPointsList.Clear();
            Backendless.Geo.GetPoints(_backendlessGeoQuery,
                                      new AsyncCallback <BackendlessCollection <GeoPoint> >(
                                          response =>
                                          Dispatcher.BeginInvoke(() =>
            {
                _cityPointsList.SetAll(response.GetCurrentPage());
                AsyncFinishedEvent.Invoke();
            }),
                                          fault => Dispatcher.BeginInvoke(() =>
            {
                AsyncFinishedEvent.Invoke();
                MessageBox.Show(fault.Message);
            })));
        }
예제 #3
0
        private void NewToDoFIeld_KeyDown(object sender, KeyEventArgs e)
        {
            if (!e.Key.Equals(Key.Enter) || string.IsNullOrEmpty(NewToDoField.Text))
            {
                return;
            }

            AsyncStartedEvent.Invoke();
            DataStore.Save(new ToDoEntity {
                DeviceId = _deviceId, Text = NewToDoField.Text
            },
                           new AsyncCallback <ToDoEntity>(response => Dispatcher.BeginInvoke(() =>
            {
                _toDoList.Add(new ToDoEntityProxy(response));
                NewToDoField.Text = "What needs to be done?";
                AsyncFinishedEvent.Invoke();
                Focus();
            }), fault => Dispatcher.BeginInvoke(() =>
            {
                MessageBox.Show(fault.Message);
                AsyncFinishedEvent.Invoke();
            })));
        }