Ejemplo n.º 1
0
 //Download events from the server
 private void syncButton_Click(object sender, System.Windows.RoutedEventArgs e)
 {
     string address = "sslab01.cs.purdue.edu";
     const int BACKUP_PORT = 7272;
     SocketClient client = new SocketClient();
     string tempy;
     tempy = client.Connect(address, BACKUP_PORT);
     tempy = client.Send("GetInfo|larry|pass");
     tempy = client.Receive();
     client.Close();
     remList.Recreate(tempy);
     //recreate the reminders and write to file
     Reminder rem;
     LinkedList<Node>.Enumerator looper = remList.loopHelp();
     while (looper.MoveNext())
     {
         rem = new Reminder(looper.Current.getTitle());
         rem.BeginTime = DateTime.Parse(looper.Current.getStart());
         rem.Content = looper.Current.getDescription();
         ScheduledActionService.Add(rem);
         //need to add buttons to main screen
         HyperlinkButton eventButton = new HyperlinkButton();
         eventButton.Height = 72;
         eventButton.Width = 427;
         eventButton.Margin = new Thickness(5);
         eventButton.Background = new SolidColorBrush(Colors.Red);
         eventButton.Foreground = new SolidColorBrush(Colors.Black);
         string buttonContent1 = looper.Current.getTitle();
         eventButton.Name = buttonContent1;
         string buttonContent2 = looper.Current.getStart();
         string buttonContentFinal = buttonContent1 + " " + buttonContent2;
         eventButton.Content = buttonContentFinal;
         listPanel.Children.Add(eventButton);
         //Add action handler to display information about event when clicked
         eventButton.Click += new RoutedEventHandler(eventButtonGeneralClick);
         //Add action handler to remove the event
         eventButton.Hold += new EventHandler<System.Windows.Input.GestureEventArgs>(eventButtonGeneralHold);
     }
     string bString = remList.returnAll();
     StreamWriter writer = new StreamWriter(new IsolatedStorageFileStream(eFile, FileMode.Truncate, eventFile));
     writer.Write(bString);
     writer.Close();
 }
Ejemplo n.º 2
0
 //Uploads event to the server
 private void uploadButton_Click(object sender, RoutedEventArgs e)
 {
     string address = "sslab01.cs.purdue.edu";
     const int BACKUP_PORT = 7272;
     SocketClient client = new SocketClient();
     client.Connect(address, BACKUP_PORT);
     client.Send("UpdateInfo|larry|pass|");
     client.Send(remList.returnAll());
     client.Close();
     //delete local content after pushing to server
     LinkedList<Node>.Enumerator looper = remList.loopHelp();
     while (looper.MoveNext())
     {
         if (ScheduledActionService.Find(looper.Current.getTitle()) != null)
         {
             ScheduledActionService.Remove(looper.Current.getTitle());
             //need to remove buttons from main screen
             string buttonName = looper.Current.getTitle();
             HyperlinkButton buttonRep = new HyperlinkButton();
             IEnumerator<UIElement> enumTemp = listPanel.Children.GetEnumerator();
             while (enumTemp.MoveNext())
             {
                 if (((HyperlinkButton)enumTemp.Current).Name.ToString() == buttonName)
                 {
                     buttonRep = ((HyperlinkButton)enumTemp.Current);
                 }
             }
             listPanel.Children.Remove(buttonRep);
         }
     }
     remList.Recreate("");
     string bString = "";
     StreamWriter writer = new StreamWriter(new IsolatedStorageFileStream(eFile, FileMode.Truncate, eventFile));
     writer.Write(bString);
     writer.Close();
 }
Ejemplo n.º 3
0
        // Constructor
        public MainPage()
        {
            InitializeComponent();
            //connect to the server and create a user
            string address = "sslab01.cs.purdue.edu";
            const int BACKUP_PORT = 7272;
            SocketClient client = new SocketClient();
            client.Connect(address, BACKUP_PORT);
            client.Send("CreateNewUser|larry|pass|");
            client.Close();

            Application.Current.Host.Settings.EnableFrameRateCounter = false;
            if (!listFile.FileExists(sFile))//Create a file for storing list names if it doesn't exist
            {
                IsolatedStorageFileStream dataFile = listFile.CreateFile(sFile);
                dataFile.Close();
            }
            if (!eventFile.FileExists(eFile))//Create a file for storing event details if it doesn't exist
            {
                IsolatedStorageFileStream temp = eventFile.CreateFile(eFile);
                temp.Close();
            }
            //Read listNames from the file
            StreamReader reader = new StreamReader(new IsolatedStorageFileStream(sFile, FileMode.Open, listFile));
            string rawData = reader.ReadToEnd();
            reader.Close();

            string[] sep = new string[] { "\r\n" };//Seperate by new line
            string[] arrData = rawData.Split(sep, StringSplitOptions.RemoveEmptyEntries);

            foreach (var d in arrData)
            {
                loadListButton(d);//Add the lists to the main screen
            }
            //Read the events in here, add buttons to the display
            reader = new StreamReader(new IsolatedStorageFileStream(eFile, FileMode.Open, eventFile));
            string data = reader.ReadToEnd();
            reader.Close();
            remList = new EList();
            remList.Recreate(data);
            loadEvents();
        }