Пример #1
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();

            // Code to localize the ApplicationBar
            BuildLocalizedApplicationBar();

            // Set the data context of the listbox control to the sample data
            DataContext = App.ViewModel;
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

            if ((Application.Current as App).gbHaveLoadedSavedDate)
                datePicker.Value = (Application.Current as App).gdtSelectedDate;

            string strDisplayResults = "";
            FormatResultsClass frc = new FormatResultsClass();
            if (true == (Application.Current as App).gbSaveDate)
            {
                chkUseSelectedDate.IsChecked = true;
                
                chkShowOnLiveTile.Visibility = Visibility.Visible;
                if (true == (Application.Current as App).gbShowOnTile)
                {
                    chkShowOnLiveTile.IsChecked = true;
                    frc.FormatDaysSinceResults((Application.Current as App).gdtSelectedDate, DateTime.Now, out strDisplayResults);
                    textBlock1.Text = strDisplayResults;
                    SetDynamicTile();
                    StartPeriodicAgent();  //called to refresh the agent on each startup so it doesn't expire (agents expire every 14 days).
                }
                else
                {
                    frc.FormatDaysSinceResults((Application.Current as App).gdtSelectedDate, DateTime.Now, out strDisplayResults);
                    textBlock1.Text = strDisplayResults;
                    SetApplicationTile("");
                }
            }
            else
            {
                frc.FormatDaysSinceResults(DateTime.Now, DateTime.Now, out strDisplayResults);
                textBlock1.Text = strDisplayResults;
                SetApplicationTile(""); // Set up default flip tile (blank)
            }
        }
Пример #2
0
        // Called for 'DaysSince', when DatePicker is selected.
        void SelectedDateValueChanged(object sender, DateTimeValueChangedEventArgs e)
        {
            if (null == textBlock1)
                return;
            /*
            if (date is changed) && (chkbox is not already selected)
	            do nothing

             * if (date is unchanged and (chkbox is already selected)
	            // do nothing

            if (date is unchanged and (chkbox gets selected)
	            // save date  */

            // get today's date. This is the 'To' date.
            DateTime dtToday = DateTime.Now;

            // get 'from' date
            DateTime dtFromDate = new DateTime();
            dtFromDate = (DateTime)e.NewDateTime;

            string strDisplayResults = "";
            
            FormatResultsClass frc = new FormatResultsClass();
            frc.FormatDaysSinceResults(dtFromDate, dtToday, out strDisplayResults);
            
            textBlock1.Text = strDisplayResults;
            
            (Application.Current as App).gdtSelectedDate = dtFromDate;
            
            // if (date is changed) && (chkbox is already selected)
	        // assume user wants this to be new default selected date
            if ((bool)chkUseSelectedDate.IsChecked)
            {
                SaveSelectedDate();
            }

            // if (date is changed) && (chkbox is already selected)
            // assume user wants this to show on live tile
            if ((bool)chkShowOnLiveTile.IsChecked)
            {
                ShowOnLiveTile();
            }
        } // void SelectedDateValueChanged(object sender, DateTimeValueChangedEventArgs e)