Ejemplo n.º 1
0
        private async void SaveContactList()
        {
            try
            {
                StorageFolder appData = await ApplicationData.Current.RoamingFolder.CreateFolderAsync("MetroSoul", CreationCollisionOption.OpenIfExists);

                StorageFolder folder = await appData.CreateFolderAsync(this.UserLogin, CreationCollisionOption.OpenIfExists);

                try
                {
                    StorageFile file = await folder.CreateFileAsync("contactlist.xml", CreationCollisionOption.ReplaceExisting);

                    try
                    {
                        using (Stream str = await file.OpenStreamForWriteAsync())
                        {
                            XmlSerializer      xs  = new XmlSerializer(typeof(List <ContactInfo>));
                            List <ContactInfo> Lst = new List <ContactInfo>(this.ContactList);
                            xs.Serialize(str, Lst);
                        }
                    }
                    catch
                    {
                        NetsoulNotificationSystem.DisplayNotification("Contact list can not be saved", NetsoulNotificationType.Error);
                    }
                }
                catch
                {
                }
            }
            catch
            {
            }
        }
Ejemplo n.º 2
0
        private async Task SaveParameters()
        {
            StorageFolder sf = null;

            try
            {
                sf = await ApplicationData.Current.RoamingFolder.GetFolderAsync("MetroSoul");
            }
            catch
            {
                sf = this.CreateMetroSoulDirectory().Result;
            }
            if (sf != null)
            {
                StorageFile file = await sf.CreateFileAsync("remember.xml", CreationCollisionOption.ReplaceExisting);

                using (Stream fileStream = await file.OpenStreamForWriteAsync())
                {
                    XmlSerializer xs = new XmlSerializer(typeof(ConnectionInfo));
                    xs.Serialize(fileStream, this.Connection);
                }
            }
            else
            {
                NetsoulNotificationSystem.DisplayNotification("Saving connection data failed", NetsoulNotificationType.Error);
            }
        }
Ejemplo n.º 3
0
        private async Task <StorageFolder> CreateMetroSoulDirectory()
        {
            StorageFolder sf = null;

            try
            {
                sf = await ApplicationData.Current.RoamingFolder.CreateFolderAsync("MetroSoul", CreationCollisionOption.FailIfExists);
            }
            catch
            {
                NetsoulNotificationSystem.DisplayNotification("Creation of MetroSoul directory failed", NetsoulNotificationType.Error);
            }
            return(sf);
        }
Ejemplo n.º 4
0
        async void OpenFile()
        {
            try
            {
                StorageFolder appData = await ApplicationData.Current.RoamingFolder.CreateFolderAsync("MetroSoul", CreationCollisionOption.OpenIfExists);

                StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(appData.Path);

                try
                {
                    StorageFile file = await folder.GetFileAsync("remember.xml");

                    try
                    {
                        using (Stream Str = await file.OpenStreamForReadAsync())
                        {
                            XmlSerializer xs = new XmlSerializer(typeof(ConnectionInfo));
                            this.Connection           = (ConnectionInfo)xs.Deserialize(Str);
                            this.tbServer.Text        = this.Connection.Server;
                            this.tbPort.Text          = this.Connection.Port;
                            this.tbLogin.Text         = this.Connection.Login;
                            this.tbPassword.Password  = this.Connection.Password;
                            this.tbLocation.Text      = this.Connection.Location;
                            this.cbServer.IsChecked   = this.Connection.RemServer;
                            this.cbPort.IsChecked     = this.Connection.RemPort;
                            this.cbLogin.IsChecked    = this.Connection.RemLogin;
                            this.cbPassword.IsChecked = this.Connection.RemPassword;
                            this.cbLocation.IsChecked = this.Connection.RemLocation;
                            this.TextBox_KeyDown_1(null, null);
                        }
                    }
                    catch
                    {
                        NetsoulNotificationSystem.DisplayNotification("Impossible to load your connection data", NetsoulNotificationType.Error);
                    }
                }
                catch
                {
                }
            }
            catch
            {
                NetsoulNotificationSystem.DisplayNotification("Impossible to create and/or open MetroSoul folder", NetsoulNotificationType.Error);
            }
        }
Ejemplo n.º 5
0
        private async Task LoadContactList(string Login)
        {
            try
            {
                StorageFolder appData = await ApplicationData.Current.RoamingFolder.GetFolderAsync("MetroSoul");

                StorageFolder folder = await appData.GetFolderAsync(Login);

                try
                {
                    StorageFile file = await folder.GetFileAsync("contactlist.xml");

                    try
                    {
                        using (Stream str = await file.OpenStreamForReadAsync())
                        {
                            List <ContactInfo> Lst = new List <ContactInfo>();
                            XmlSerializer      xs  = new XmlSerializer(typeof(List <ContactInfo>));
                            Lst = (List <ContactInfo>)xs.Deserialize(str);
                            foreach (ContactInfo c in Lst)
                            {
                                this.ContactList.Add(new ContactInfo(c.Login));
                            }
                        }
                    }
                    catch
                    {
                        NetsoulNotificationSystem.DisplayNotification("Saved contact list can not be loaded", NetsoulNotificationType.Error);
                    }
                }
                catch
                {
                    NetsoulNotificationSystem.DisplayNotification("No saved list", NetsoulNotificationType.Error);
                }
            }
            catch
            {
            }
        }