Esempio n. 1
0
 //Show details about event when clicked
 private void eventButtonGeneralClick(object sender, System.Windows.RoutedEventArgs e)
 {
     string tempy = ((HyperlinkButton)sender).Content.ToString();
     tempy = tempy.Substring(tempy.IndexOf(' ')+1);
     string[] tempy1 = remList.returnEventSeg(DateTime.Parse(tempy));
     Popup container = new Popup();
     AboutControl temp = new AboutControl();
     container.Child = temp;
     container.IsOpen = true;
     container.VerticalOffset = 100;
     String aboutInfo = "Title:" + tempy1[0] + "\nDescription:" + tempy1[1]+ "\nStarts:"+tempy1[2]+"\nEnds:"+tempy1[3];
     temp.infoBox.Text = aboutInfo;
     //Close the about page when the x button is clicked
     temp.closeButton.Click += (s, args) =>
         {
             container.IsOpen = false;
         };
 }
Esempio n. 2
0
        //Create a new event
        private void newEventButton_Click(object sender, RoutedEventArgs e)
        {
            //error check number
            int error = 0;
            //Get the details from a popup, add the event to the linked list, write the string to the file
            Popup container = new Popup();
            container.Height = 300;
            container.Width = 400;
            container.VerticalOffset = 100;
            WindowsPhoneControl5 temp = new WindowsPhoneControl5();
            container.Child = temp;
            container.IsOpen = true;

            temp.OKbtn.Click += (s, args) =>
                {

                    //Create a new node and add it to the LinkedList
                    String title = temp.titleTxt.Text;  //error code 1
                    if(title == null)
                    {
                        error = error * 10;
                        error = error + 1;
                    }
                    else
                    {
                        if(title.Length < 1)
                        {
                            error = error * 10;
                            error = error + 1;
                        }
                    }
                    String date = temp.dateTxt.Text;
                    String startTimeString = temp.startTimeTxt.Text;
                    String endTimeString = temp.endTimeTxt.Text;
                    DateTime eventDate = new DateTime();
                    try
                    {
                        eventDate = DateTime.ParseExact(date, "MM/dd/yyyy", null);  //error code 2
                    }
                    catch (Exception ex)
                    {
                        error = error * 10;
                        error = error + 2;
                    }
                    DateTime startTime = new DateTime();
                    try
                    {
                        startTime = DateTime.ParseExact(startTimeString, "HH:mm", null);  //error code 3
                    }
                    catch (Exception ex)
                    {
                        error = error * 10;
                        error = error + 3;
                    }
                    DateTime endTime = new DateTime();
                    try
                    {
                        endTime = DateTime.ParseExact(endTimeString, "HH:mm", null);  //error code 4
                    }
                    catch (Exception ex)
                    {
                        error = error * 10;
                        error = error + 4;
                    }
                    DateTime startTimeDate = new DateTime(eventDate.Year, eventDate.Month, eventDate.Day, startTime.Hour, startTime.Minute, 0);
                    DateTime endTimeDate = new DateTime(eventDate.Year, eventDate.Month, eventDate.Day, endTime.Hour, endTime.Minute, 0);
                    String extra = temp.extraTxt.Text;  //error code 5
                    String detail = temp.extraTxt.Text;  //error code 6
                    System.Console.Write("extra: " + extra);
                    System.Console.Write("detail: " + detail);

                    if(error != 0)
                    {
                    Popup fixError = new Popup();
                    AboutControl page = new AboutControl();
                    fixError.Height = 300;
                    fixError.Width = 400;
                    fixError.VerticalOffset = 100;
                    fixError.Child = page;
                    fixError.IsOpen = true;
                    string errorMessage = "";
                    int code;
                    while (error > 0)
                    {
                        code = error % 10;
                        error = error / 10;
                        switch (code)
                        {
                            case 1:
                                errorMessage = String.Concat("Please enter a title\n", errorMessage);
                                break;
                            case 2:
                                errorMessage = String.Concat("Invalid date\n", errorMessage);
                                break;
                            case 3:
                                errorMessage = String.Concat("Invalid start time\n", errorMessage);
                                break;
                            case 4:
                                errorMessage = String.Concat("Invalid end time\n", errorMessage);
                                break;
                            case 5:
                                errorMessage = String.Concat("Invalid info\n", errorMessage);
                                break;
                            case 6:
                                errorMessage = String.Concat("Invalid description\n", errorMessage);
                                break;
                            default:
                                errorMessage = String.Concat("Unkown error\n", errorMessage);
                                break;
                        }
                    }
                    page.infoBox.Text = errorMessage;
                    page.closeButton.Click += (s1, args1) =>
                        {
                            fixError.IsOpen = false;
                        };
                    container.IsOpen = false;
                    return;
                    }

                    //Add the event to the EList linked list
                    if (remList == null)
                    {
                        remList = new EList();
                    }
                    remList.addEvent((startTimeDate.ToString()), endTimeDate.ToString(), title, 0, extra, detail);

                    //Write backupString to a file for persistent storage
                    string backupString = remList.returnAll();
                    StreamWriter writer = new StreamWriter(new IsolatedStorageFileStream(eFile, FileMode.Truncate, eventFile));
                    writer.Write(backupString);
                    writer.Close();
                    //add button on main screen for event, display title and start time
                    HyperlinkButton eventButton = new HyperlinkButton();
                    eventButton.Name = title;
                    eventButton.Height = 72;
                    eventButton.Width = 427;
                    eventButton.Margin = new Thickness(5);
                    eventButton.Content = title + " " + startTimeDate.ToString();
                    eventButton.Background = new SolidColorBrush(Colors.Red);
                    eventButton.Foreground = new SolidColorBrush(Colors.Black);
                    listPanel.Children.Add(eventButton);
                    //Add action handler to display information about event when clicked
                    eventButton.Click+= new RoutedEventHandler(eventButtonGeneralClick);
                    eventButton.Hold += new EventHandler<System.Windows.Input.GestureEventArgs>(eventButtonGeneralHold);
                    //create a reminder for the event
                    Reminder rem = new Reminder(title);
                    rem.BeginTime = new DateTime(eventDate.Year, eventDate.Month, eventDate.Day, startTime.Hour, startTime.Minute, 0);
                    rem.Content = detail;
                    ScheduledActionService.Add(rem);
                    container.IsOpen = false;
                };
            temp.cancelBtn.Click += (s, args) =>
                {
                    container.IsOpen = false;
                };
        }
Esempio n. 3
0
 //Show the about page as a pop-up
 private void aboutButton_Click(object sender, RoutedEventArgs e)
 {
     Popup container = new Popup();
     AboutControl temp = new AboutControl();
     container.Child = temp;
     container.IsOpen = true;
     container.VerticalOffset = 100;
     String aboutInfo = "Authors : \r\n      Theo Reinke\r\n      Chris King\r\n      Larry Schneck\r\n      Jordan Hardwick\r\n\nDO NOT NAME EVENTS OR LISTS WITH DUPLICATE NAMES!!!";
     temp.infoBox.Text = aboutInfo;
     temp.infoBox.IsReadOnly = true;
     temp.Opacity = 10;
     //Close the about page when the x button is clicked
     temp.closeButton.Click += (s, args) =>
         {
             container.IsOpen = false;
         };
 }