Beispiel #1
0
        private async void Button_OnClick(object sender, RoutedEventArgs e)
        {
            if (CurrentWork?.Result == ResultCodes.Success)
            {
                MainTransitioner.SelectedIndex = 3;
                Content.SelectedIndex          = 2;
                return;
            }

            var NextButton = (Button)sender;

            if (MainViewModel.Instance.Encoder == null)
            {
                MainTransitioner.SelectedIndex = 1;
                PeerDiscovery.DiscoverPeersAsync(PeerDiscovery.DiscoveryMethod.UDPBroadcast);
                return;
            }

            if (workFetched)
            {
                return;
            }
            workFetched = true;
            ButtonProgressAssist.SetIsIndicatorVisible(NextButton, true);
            ButtonProgressAssist.SetIsIndeterminate(NextButton, true);
            var work = await Client.GetNextWork();

            CurrentWork         = work;
            Student.DataContext = work.Student;
            ButtonProgressAssist.SetIsIndicatorVisible(NextButton, false);
            ButtonProgressAssist.SetIsIndeterminate(NextButton, false);
            //_encoderMagic.IsGenieOut = false;
            var errorMessage = "";

            switch (work.Result)
            {
            case ResultCodes.Success:
                WorkDataGrid.ItemsSource = work.ClassSchedules;
                //_workMagic.IsGenieOut = true;
                MainTransitioner.SelectedIndex = 3;
                Content.SelectedIndex          = 2;
                LoginLamp.Visibility           = Visibility.Collapsed;
                StudentId.Text   = work.StudentId;
                StudentName.Text = work.StudentName;
                break;

            case ResultCodes.NotFound:
                //MessageBox.Show("No more pending items.");
                errorMessage = "No more requests";
                break;

            case ResultCodes.Offline:
                errorMessage = "Can not find server";
                break;

            case ResultCodes.Timeout:
                errorMessage = "Request timeout";
                break;

            case ResultCodes.Error:
                errorMessage = "Request timeout";
                break;
            }


            await ShowMessage(errorMessage);


            workFetched = false;
        }
Beispiel #2
0
        public static async Task ShowDialog(GetWorkResult work)
        {
            var view = new WorkView();

            view.ShowDialog();
        }