示例#1
0
        public SavedConnections[] LoadSaved()
        {
            try
            {
                SavedConnections[] sc = new SavedConnections[0];

                IsolatedStorageFile       myIsolatedStorage = IsolatedStorageFile.GetUserStoreForApplication();
                IsolatedStorageFileStream fileStream        = myIsolatedStorage.OpenFile("saved.txt", FileMode.Open, FileAccess.Read);
                using (StreamReader reader = new StreamReader(fileStream))
                {    //Visualize the text data in a TextBlock text
                    int i = 0;
                    while (!reader.EndOfStream)
                    {
                        Array.Resize(ref sc, sc.Length + 1);
                        sc[i].Name        = reader.ReadLine();
                        sc[i].Address     = reader.ReadLine();
                        sc[i].ViewOnly    = reader.ReadLine();
                        sc[i].Username    = reader.ReadLine();
                        sc[i].Password    = reader.ReadLine();
                        sc[i].RefreshTime = Convert.ToInt16(reader.ReadLine());
                        i++;
                    }
                    reader.Close();
                }

                return(sc);
            }
            catch
            {
                return(null);
            }
        }
示例#2
0
        private void save_Click(object sender, RoutedEventArgs e)
        {
            SavedConnections[] scb;
            if (connectionData.SavedConnections == null)
            {
                scb = new SavedConnections[1];
            }
            else
            {
                scb = connectionData.SavedConnections;
                Array.Resize(ref scb, scb.Length + 1);
            }
            SavedConnections sc = new SavedConnections();

            sc.Name     = nameInput.Text;
            sc.Address  = addressInput.Text;
            sc.Password = passwordInput.Password;
            sc.Username = usernameInput.Text;
            if (viewCheck.IsChecked == true)
            {
                sc.ViewOnly = "yes";
            }
            else
            {
                sc.ViewOnly = "no";
            }
            scb[scb.Length - 1]             = sc;
            connectionData.SavedConnections = scb;

            new WriteServer().WriteXML();

            NavigationService.GoBack();
        }