/// <summary> /// Constructor initializing all needed components. /// </summary> public WeatherSettings() { InitializeComponent(); // Connect to the database and instantiate data context. ComponentDB = new ViewModels.Component(ViewModels.Component.DBConnectionString); }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters Application.Current.Host.Settings.EnableFrameRateCounter = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } // Create the database if it does not exist. using (ViewModels.Component db = new ViewModels.Component(ViewModels.Component.DBConnectionString)) { if (db.DatabaseExists() == false) { //Create the database db.CreateDatabase(); } } }
/// <summary> /// Constructor initializing all needs components. /// </summary> public ToDoPage() { InitializeComponent(); // Connect to the database and instantiate data context. ComponentDB = new ViewModels.Component(ViewModels.Component.DBConnectionString); // Data context and observable collection are children of the main page. this.DataContext = this; }
/// <summary> /// /// </summary> public ShowSeizeDay() { InitializeComponent(); // Connect to the database and instantiate data context. ComponentDB = new ViewModels.Component(ViewModels.Component.DBConnectionString); // Data context and observable collection are children of the main page. this.DataContext = this; // Checking if date is not validate, remove from database ValidateDate(); }
/// <summary> /// This method save selected time to remainder and alarm. /// </summary> /// <param name="sender">object</param> /// <param name="e">EventArgs</param> private void SaveButton_Click(object sender, EventArgs e) { // Generate a unique name for the new notification. You can choose a // name that is meaningful for your app, or just use a GUID. String nameReminder = System.Guid.NewGuid().ToString(); String nameAlarm = System.Guid.NewGuid().ToString(); // Get the begin time for the notification by combining the DatePicker // value and the TimePicker value. DateTime time = (DateTime)timePicker.Value; // if time of the day already passed, set alarm for next day if ( time < DateTime.Now ) time = time.AddDays(1); // which page alarm should be navigated to after displaying Uri navigationUri = new Uri("/ShowSeizeDay.xaml", UriKind.Relative); Reminder reminder = new Reminder(nameReminder); reminder.Title = "“Determination is the wake-up call to the human will”"; reminder.BeginTime = time.AddSeconds(6); //beginTime; reminder.ExpirationTime = time.AddMinutes(2); //expirationTime; reminder.NavigationUri = navigationUri; // Register the reminder with the system. ScheduledActionService.Add(reminder); Alarm alarm = new Alarm(nameAlarm); if (alarmSound == null) { alarm.Sound = new Uri("/Ringtones/sensitivewalk.wma", UriKind.Relative); } else { alarm.Sound = new Uri(alarmSound, UriKind.Relative); } alarm.BeginTime = time; // beginTime; alarm.ExpirationTime = time.AddMinutes(2); // expirationTime; // Register the alarm with the system. ScheduledActionService.Add(alarm); // Get vaule from AddAlarm page // Create a new to-do item based on the string. TimeItem newTimeItem = new TimeItem { ItemAlarmName = nameAlarm, ItemReminderName = nameReminder, DateField = time.ToString() }; // Connect to the database and instantiate data context. Component ComponentDB = new Component(Component.DBConnectionString); // Add a alarm item to the local database. ComponentDB.TimeItems.InsertOnSubmit(newTimeItem); // Save changes to the database. ComponentDB.SubmitChanges(); // Navigate back to the main page. NavigationService.Navigate(new Uri("/mainPage.xaml", UriKind.Relative)); ; }