예제 #1
0
 private void LaterButton_Pressed(object sender, EventArgs args)
 {
     if (timeRange != SelectedTimeRange.Later)
     {
         ListViewJournal.ItemsSource     = journalLogController.GetLaterJournals(journalLogs);
         ThisWeekButton.BackgroundColor  = Color.FromHex("#82b8e0");
         ThisMonthButton.BackgroundColor = Color.FromHex("#82b8e0");
         LaterButton.BackgroundColor     = Color.FromHex("#2f89cc");
         timeRange = SelectedTimeRange.Later;
     }
 }
예제 #2
0
        protected async override void OnAppearing()
        {
            try
            {
                journalLogs = await journalLogController.GetAllJournalLogsAsync(_patientId);

                ListViewJournal.ItemsSource = journalLogController.GetThisWeekJournals(journalLogs);
                timeRange = SelectedTimeRange.ThisWeek;
                ThisWeekButton.BackgroundColor  = Color.FromHex("#2f89cc");
                ThisMonthButton.BackgroundColor = Color.FromHex("#82b8e0");
                LaterButton.BackgroundColor     = Color.FromHex("#82b8e0");
            }
            catch (ApiException ex)
            {
                await DisplayAlert(AppResources.ErrorTitle, LogicHelper.ErrorMessage(ex.ErrorCode), AppResources.DialogOk);
            }
            catch (ConnectionException)
            {
                await DisplayAlert(AppResources.ErrorTitle, AppResources.ConnectionException, AppResources.DialogOk);
            }
        }
예제 #3
0
        public WeatherViewModel(WeatherFile weatherFile, Window parentWindow)
            : base(weatherFile, parentWindow)
        {
            _weatherFile = weatherFile;

            NewTimeRangeCmd = new RelayCommand(arg =>
            {
                _weatherFile.WeatherSet.Add(new WeatherTimeRange(WeatherFile));
                SelectedTimeRange = _weatherFile.WeatherSet.Last();
            }
                                               );

            DelTimeRangeCmd = new RelayCommand(arg =>
            {
                _weatherFile.WeatherSet.Remove(SelectedTimeRange);
            },
                                               arg =>
            {
                return(SelectedTimeRange != null);
            }
                                               );

            AddVariableCmd = new RelayCommand(arg =>
            {
                if (SelectedTimeRange != null)
                {
                    SelectedTimeRange.Variables.Add(new L3dVariable(WeatherFile, "Variable", string.Empty));
                    SelectedVariable = SelectedTimeRange.Variables.Last();
                }
            },
                                              arg =>
            {
                return(SelectedTimeRange != null);
            }
                                              );

            RemoveVariableCmd = new RelayCommand(arg =>
            {
                if (SelectedTimeRange != null && SelectedVariable != null)
                {
                    SelectedTimeRange.Variables.Remove(SelectedVariable);
                    SelectedVariable = null;
                }
            },
                                                 arg =>
            {
                return(SelectedTimeRange != null && SelectedVariable != null);
            }
                                                 );

            CopyTimeRange = new RelayCommand(arg =>
            {
                try
                {
                    if (SelectedTimeRange != null)
                    {
                        Clipboard.SetText(SelectedTimeRange.ConvertToXml().ToString(), TextDataFormat.UnicodeText);
                    }
                }
                catch (Exception)
                {
                    SystemSounds.Exclamation.Play();
                }
            },
                                             arg =>
            {
                return(SelectedTimeRange != null);
            }
                                             );

            CutTimeRange = new RelayCommand(arg =>
            {
                try
                {
                    if (SelectedTimeRange != null)
                    {
                        Clipboard.SetText(SelectedTimeRange.ConvertToXml().ToString(), TextDataFormat.UnicodeText);
                        _weatherFile.WeatherSet.Remove(SelectedTimeRange);
                    }
                }
                catch (Exception)
                {
                    SystemSounds.Exclamation.Play();
                }
            },
                                            arg =>
            {
                return(SelectedTimeRange != null);
            }
                                            );

            PasteTimeRange = new RelayCommand(arg =>
            {
                var w = WeatherTimeRange.ReadFromXml(Clipboard.GetText(), WeatherFile);
                if (w != null)
                {
                    _weatherFile.WeatherSet.Add(w);
                    SelectedTimeRange = w;
                }
            },
                                              arg =>
            {
                try
                {
                    return(Clipboard.ContainsText() && WeatherTimeRange.ReadFromXml(Clipboard.GetText(), WeatherFile) != null);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
                                              );

            SortTimeRangesCmd = new RelayCommand(arg =>
            {
                string sortCol = (string)arg;
                _timerangesView.SortDescriptions.Clear();

                if (_timerangesSortAsc)
                {
                    _timerangesView.SortDescriptions.Add(new SortDescription(sortCol, ListSortDirection.Ascending));
                }
                else
                {
                    _timerangesView.SortDescriptions.Add(new SortDescription(sortCol, ListSortDirection.Descending));
                }
                _timerangesSortAsc = !_timerangesSortAsc;
            }
                                                 );

            _weatherCtrl             = new WeatherCtrl();
            _weatherCtrl.WeatherFile = _weatherFile;

            _timerangesView        = new CollectionViewSource();
            _timerangesView.Source = _weatherFile.WeatherSet;

            SelectedTimeRange = _weatherFile.WeatherSet.FirstOrDefault();
        }