예제 #1
0
        public MainPage()
        {
            bool opened = true;

            this.InitializeComponent();

            // TEMP: delete settings - for debugging only
            //localSettings.DeleteContainer("startup");

            // Try to read composite value "startup" from settings to either load or create data
            try
            {
                startupSettings = localSettings.CreateContainer("startup", ApplicationDataCreateDisposition.Existing);
            }
            catch (Exception e)
            {
                // Startup settings have never been created! Create a new Schedule data structure
                System.Diagnostics.Debug.WriteLine("Creating ApplicationData in localSettings for new schedule");

                opened          = false;
                startupSettings = localSettings.CreateContainer("startup", ApplicationDataCreateDisposition.Always);

                // Create new scjedule object
                nextEventID = 1; // TODO: read from global configuration file (permanent storage)
                uint calID = (uint)rng.Next(int.MinValue, int.MaxValue);
                schedule          = new SmartSchedule(startupSettings, calID, "Default", new SolidColorBrush(Color.FromArgb(0xFF, 0x10, 0xEE, 0xEE)));
                scheduleStorageID = schedule.StorageID();

                // Store these values into the startup settings
                //   startupSettings = new ApplicationDataCompositeValue();
                startupSettings.Values["nextEventID"]       = nextEventID; // Events always start at 1
                startupSettings.Values["scheduleStorageID"] = scheduleStorageID;
                scheduleData = startupSettings.CreateContainer(scheduleStorageID, ApplicationDataCreateDisposition.Always);
                //startupSettings.Values[scheduleStorageID] = scheduleData;
                //localSettings.Values["startup"] = startupSettings;
            }
            if (opened)
            {
                // Startup settings already exist! Load previous values into usable data structure
                System.Diagnostics.Debug.WriteLine("Loading schedule data from application storage");
                nextEventID       = (uint)startupSettings.Values["nextEventID"];
                scheduleStorageID = (string)startupSettings.Values["scheduleStorageID"];
                scheduleData      = startupSettings.CreateContainer(scheduleStorageID, ApplicationDataCreateDisposition.Existing);

                schedule = new SmartSchedule(startupSettings, scheduleStorageID);
            }

            // Initialize XAML components
            CB_TypePicker.ItemsSource     = schedule.taskTypeList;
            CB_RequiredPicker.ItemsSource = schedule.ynList;
            CB_RepeatPicker.ItemsSource   = schedule.repeatTypeList;
            CB_DurHoursPicker.ItemsSource = SmartTask.hours;
            CB_DurMinsPicker.ItemsSource  = SmartTask.mins;
            LV_Schedule.ItemsSource       = schedule.GetTastsAt(selectedDate.Date);
            selectedDate = DateTime.Now;
        }
예제 #2
0
 public SmartTask(uint newID, SmartSchedule cal)
 {
     // Creating a new SmartTask object given its fields
     this.ID       = newID;
     this.calendar = null;
 }