Пример #1
0
        public MainPage()
        {
            this.InitializeComponent();
            //add settings to title bar:
            Window.Current.SizeChanged += Current_SizeChanged_UpdateTitleBar;
            CustomizeTitleBar();
            customTitleBar.Visibility = Visibility.Collapsed;

            //get name of device:
            var deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();

            Settings.Name = deviceInfo.FriendlyName.ToString();

            //find server IP:
            ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;

            Windows.Storage.ApplicationDataCompositeValue composite = (ApplicationDataCompositeValue)roamingSettings.Values["IPConfigs"];

            if (composite != null)
            {
                Settings.ServerIP = composite["ServerIP"] as string;
            }

            //stream event subscriber:
            Settings.SourceChanged += Stream;

            //Worker to check for new source:
            UpdateLoop();
        }
Пример #2
0
        /// <summary>
        /// 复合设置
        /// </summary>
        /// <param name="composite"></param>
        public static void SetCompositeValue(Windows.Storage.ApplicationDataCompositeValue composite)
        {
            composite["intVal"] = 1;
            composite["strVal"] = "string";

            localSettings.Values["exampleCompositeSetting"] = composite;
        }
Пример #3
0
        private async Task <String> InputTextDialogAsync(string title = "Set Controller IP: ")
        {
            TextBox inputTextBox = new TextBox();

            inputTextBox.AcceptsReturn = false;
            inputTextBox.Height        = 32;
            ContentDialog dialog = new ContentDialog();

            dialog.Content = inputTextBox;
            dialog.Title   = title + Settings.ServerIP;
            dialog.IsSecondaryButtonEnabled = true;
            dialog.PrimaryButtonText        = "Ok";
            dialog.SecondaryButtonText      = "Cancel";
            if (await dialog.ShowAsync() == ContentDialogResult.Primary)
            {
                if (inputTextBox.Text == "")
                {
                    return("");
                }
                Settings.ServerIP = inputTextBox.Text;
                ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
                Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue();
                composite["ServerIP"] = inputTextBox.Text;
                roamingSettings.Values["IPConfigs"] = composite;
                return(inputTextBox.Text);
            }
            else
            {
                return("");
            }
        }
Пример #4
0
 private void MenuFlyoutItem_Click(object sender, RoutedEventArgs e)
 {
     if (loca == MainPage.localSettings.Values["startLocation"].ToString())
     {
         MainPage.localSettings.Values["startLocation"] = "auto_ip";
         Forecast.location = "auto_ip";
     }
     else
     {
         Windows.Storage.ApplicationDataCompositeValue weatherlist = MainPage.localSettings.Values["favlocation"] as ApplicationDataCompositeValue;
         Windows.Storage.ApplicationDataCompositeValue Weather_new = new Windows.Storage.ApplicationDataCompositeValue();
         int j = 0;
         for (int i = 0; i < weatherlist.Count; i++)
         {
             if (weatherlist[i.ToString()].ToString() != loca)
             {
                 Weather_new[j.ToString()] = weatherlist[i.ToString()];
                 j++;
             }
             else
             {
                 continue;
             }
         }
         MainPage.localSettings.Values["favlocation"] = Weather_new;
     }
     MainPage.Current.ContentFrame.CacheSize = 0;
     MainPage.Current.ContentFrame.Navigate(typeof(Fav), null, new EntranceNavigationTransitionInfo());
 }
Пример #5
0
 // Load the ComDetails object from the application's local settings as an ApplicationDataCompositeValue instance.
 // Iterate through the properties in the static class of current app settings, that are in a static class.
 // If a property is in the ComDetails keys, assign the value for that key as in ComDetail, to the static class property.
 public static void LoadConSettings()
 {
     Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
     if (localSettings.Values.Keys.Contains("ConDetail"))
     {
         Windows.Storage.ApplicationDataCompositeValue composite =
             (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["ConDetail"];
         if (composite != null)
         {
             //Ref: https://stackoverflow.com/questions/9404523/set-property-value-using-property-name
             Type type = typeof(Pages.IoTHubConnectionDetails);                                                                          // IoTHubConnectionDetails is static class with public static properties
             foreach (var property in type.GetProperties(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static)) //(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic))
             {
                 string propertyName = property.Name;
                 if (composite.Keys.Contains(propertyName))
                 {
                     //Want to implement Cons.propertyName = composite[propertyName];
                     var propertyInfo = type.GetProperty(propertyName); //, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
                     propertyInfo.SetValue(type, composite[propertyName], null);
                 }
             }
         }
     }
     else
     {
         //Pages.IoTHubConnectionDetails.
     }
 }
Пример #6
0
        private void App_BackRequested(object sender, Windows.UI.Core.BackRequestedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;

            if (rootFrame == null)
            {
                return;
            }

            // Navigate back if possible, and if the event has not
            // already been handled .
            // Navigate back if possible, and if the event has not
            // already been handled .
            if (rootFrame.CanGoBack && e.Handled == false)
            {
                Windows.Storage.ApplicationDataCompositeValue composite = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["nowReading"];
                composite["chapter"] = returnIndex;// this.MasterListView.SelectedIndex;
                composite["count"]   = this.MasterListView.Items.Count;
                composite["offset"]  = panoOn ? this.panoView.HorizontalOffset : this.columnView.HorizontalOffset;
                localSettings.Values["nowReading"] = composite;
                //BookChapters.Chapters.Clear();
                e.Handled = true;
                rootFrame.GoBack();
            }
        }
Пример #7
0
        private void LoadSettings()
        {
            ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;

            Windows.Storage.ApplicationDataCompositeValue composite = (ApplicationDataCompositeValue)roamingSettings.Values["ApplicationSettings"];

            if (composite != null)
            {
                string theme = composite["Theme"] as string;

                switch (theme)
                {
                case "Dark":
                    IsDarkSelected = true;
                    break;

                case "Light":
                    IsLigthSelected = true;
                    break;

                case "Default":
                    IsDefaultSelected = true;
                    break;

                default:
                    break;
                }
            }
            else
            {
                //IsDarkMode = true;
                SaveSettings();
            }
        }
Пример #8
0
 private void Fav_Click(object sender, RoutedEventArgs e)
 {
     Windows.Storage.ApplicationDataCompositeValue weatherlist = MainPage.localSettings.Values["favlocation"] as ApplicationDataCompositeValue;
     weatherlist[weatherlist.Count.ToString()]    = location;
     MainPage.localSettings.Values["favlocation"] = weatherlist;
     MainPage.Current.ContentFrame.CacheSize      = 0;
 }
Пример #9
0
        BackgroundTaskDeferral _deferral; // Note: defined at class scope so we can mark it complete inside the OnCancel() callback if we choose to support cancellation
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral = taskInstance.GetDeferral();
            //
            // TODO: Insert code to start one or more asynchronous methods using the
            //       await keyword, for example:
            //
            // await ExampleMethodAsync();
            //
            Debug.WriteLine("Back");
            //var file = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/test.txt", UriKind. Absolute));
            var         localFolder = ApplicationData.Current.LocalFolder;
            StorageFile file        = await localFolder.CreateFileAsync("test.text", CreationCollisionOption.OpenIfExists);

            await Windows.Storage.FileIO.WriteTextAsync(file, "Swift as a shadow");

            // Composite setting
            Windows.Storage.ApplicationDataContainer localSettings =
                Windows.Storage.ApplicationData.Current.LocalSettings;
            Windows.Storage.ApplicationDataCompositeValue composite =
                (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["exampleCompositeSetting"];

            if (composite == null)
            {
                // No data
            }
            else
            {
                // Access data in composite["intVal"] and composite["strVal"]
                Debug.WriteLine(composite["intVal"]);
            }

            _deferral.Complete();
        }
Пример #10
0
        // Create a new instance of ApplicationDataCompositeValue object as ComDetail
        // Iterate through the properties of a static class and store each name value pair in a ComDetail
        // Save that to the application's local settings, replacing the existing object if it exists.
        public static void SaveSettingsToAppData()
        {
            Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            if (localSettings.Values.Keys.Contains("ConDetail"))
            {
                localSettings.Values.Remove("ConDetail");
            }
            Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue();

            //Ref: https://stackoverflow.com/questions/12480279/iterate-through-properties-of-static-class-to-populate-list
            Type type = typeof(Pages.IoTHubConnectionDetails); // IoTHubConnectionDetails is static class with public static properties

            foreach (var property in type.GetProperties())     //(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic))
            {
                string propertyName = property.Name;
                var    val          = property.GetValue(null); // static classes cannot be instanced, so use null...

                System.Diagnostics.Debug.WriteLine(string.Format("{0} {1}", propertyName, val));
                composite[propertyName] = val;
            }
            localSettings.Values.Add("ConDetail", composite);

            if (localSettings.Values.Keys.Contains("AppSettingsValues"))
            {
                localSettings.Values.Remove("AppSettingsValues");
            }
        }
        public SettingPage()
        {
            this.InitializeComponent();
            playEnablerGUIDList = new Dictionary <string, string>();
            explicitGuidList    = new Dictionary <string, string>();

            playEnablerGUIDList.Add("None", "None");
            playEnablerGUIDList.Add("Unknown Output", "{786627d8-c2a6-44be-8f88-08ae255b01a7}");
            playEnablerGUIDList.Add("Unknown Output Constrained", "{b621d91f-edcc-4035-8d4b-dc71760d43e9}");

            explicitGuidList.Add("cbBestEffortCGMS_A", "{225CD36F-F132-49EF-BA8C-C91EA28E4369}");
            explicitGuidList.Add("cbCGMS_A", "{2098DE8D-7DDD-4BAB-96C6-32EBB6FABEA3}");
            explicitGuidList.Add("cbDigitalOnlyToken", "{760AE755-682A-41E0-B1B3-DCDF836A7306}");
            explicitGuidList.Add("cbAGCColorStrip", "{C3FD11C6-F8B7-4D20-B008-1DB17D61F2DA}");
            explicitGuidList.Add("cbMaxVGARes", "{D783A191-E083-4BAF-B2DA-E69F910B3772}");
            explicitGuidList.Add("cbMaxComonentRes", "{811C5110-46C8-4C6E-8163-C0482A15D47E}");
            explicitGuidList.Add("cbHCMSorHDCP", "{6D5CFA59-C250-4426-930E-FAC72C8FCFA6}");
            explicitGuidList.Add("cbHDCPType1", "{ABB2C6F1-E663-4625-A945-972D17B231E7}");
            explicitGuidList.Add("tbMaxResDecoderWidth", "{9645E831-E01D-4FFF-8342-0A720E3E028F}");

            localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            composite     = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["CustomRightsSettings"];

            if (composite == null)
            {
                composite = new Windows.Storage.ApplicationDataCompositeValue();
            }

            this.navigationHelper            = new NavigationHelper(this);
            this.navigationHelper.LoadState += navigationHelper_LoadState;
            this.navigationHelper.SaveState += navigationHelper_SaveState;

            // Disable the cbOptoutHWDRM if the itemPage has launched before
            cbOptoutHWDRM.IsEnabled = !SettingPage.DiableOptOutHWDRM;
        }
Пример #12
0
        public static async Task copysample()
        {
            Uri uri = new Uri("ms-appx:///Assets/ab.png");

            Windows.Storage.StorageFile file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);

            Windows.Storage.StorageFile copiedfile = await file.CopyAsync(Windows.Storage.ApplicationData.Current.LocalFolder, "ab.png");

            await Routines.extractFiles(copiedfile);

            uri  = new Uri("ms-appdata:///local/ab/OPS/images/cover.png");
            file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(uri);

            Windows.Storage.StorageFolder imageFolder = await Windows.Storage.ApplicationData.Current.LocalFolder.GetFolderAsync("thumbs");

            await file.CopyAsync(imageFolder, "book0.jpg");

            var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue();
            composite["uniqueid"] = "book0";
            composite["title"]    = "The Arabian Nights";
            composite["author"]   = "Andrew Lang";
            composite["image"]    = "thumbs\\book0.jpg";;
            composite["location"] = "ab";
            var samplebook = new Book(composite["uniqueid"].ToString(), composite["title"].ToString(), composite["author"].ToString(),
                                      composite["image"].ToString(), composite["location"].ToString());

            BookSource.AddBookAsync(samplebook);
            int count = (int)localSettings.Values["bookCount"];

            localSettings.Values["bookCount"] = ++count;
            localSettings.Containers["booksContainer"].Values["book0"] = composite;
        }
Пример #13
0
        private void Register(object sender, RoutedEventArgs e)
        {
            Windows.Storage.ApplicationDataCompositeValue composite =
                new Windows.Storage.ApplicationDataCompositeValue();
            composite["intVal"] = 1;
            composite["strVal"] = "string";
            localSettings.Values["exampleCompositeSetting"] = composite;

            var taskRegistered  = false;
            var exampleTaskName = "ExampleBackgroundTask";

            foreach (var task in BackgroundTaskRegistration.AllTasks)
            {
                if (task.Value.Name == exampleTaskName)
                {
                    taskRegistered = true;
                    break;
                }
            }
            if (!taskRegistered)
            {
                var builder = new BackgroundTaskBuilder();

                builder.Name           = exampleTaskName;
                builder.TaskEntryPoint = "MyBackgroundTask.MyTask";
                builder.SetTrigger(new SystemTrigger(SystemTriggerType.TimeZoneChange, false));
                BackgroundTaskRegistration task = builder.Register();
                task.Completed += new BackgroundTaskCompletedEventHandler(OnCompleted);
                task.Progress  += new BackgroundTaskProgressEventHandler(Onprogress);
            }
        }
Пример #14
0
        public static void MysqlDatabase()
        {
            string connection;

            // connection = "server=DS218P;database=room;user=room;password=talky-polka-pause6-3selector-countable-Freebie9;port=3307";
            Windows.Storage.ApplicationDataCompositeValue composite = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["mysqlSettings"];
            if (composite == null)
            {
                SqliteDatabase();
            }
            else
            {
                connection = "server=" + composite["server"].ToString() + ";"
                             + "database=" + composite["database"].ToString() + ";"
                             + "user="******"user"].ToString() + ";"
                             + "password="******"password"].ToString() + ";"
                             + "port=" + composite["port"].ToString() + ";"

                ;

                DbContextOptionsBuilder <Room5Context> dbOptions = new DbContextOptionsBuilder <Room5Context>().UseMySql(connection,
                                                                                                                         mysqlOptions => { });

                Repository = new SQLRoom5Repository(dbOptions);
            }
        }
Пример #15
0
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            Book currentBook = App.splitBook;

            globalCurrentBookFolder = currentBook.Location;
            await this.getBookContent(currentBook);

            Windows.Storage.ApplicationDataCompositeValue composite = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["nowReading"];
            if (composite["uniqueid"].ToString() == currentBook.UniqueId)
            {
            }
            else
            {
                composite["uniqueid"] = currentBook.UniqueId;
                composite["location"] = currentBook.Location;
                composite["title"]    = currentBook.Title;
                composite["author"]   = currentBook.Author;
                composite["image"]    = "thumbs/" + currentBook.UniqueId + ".jpg";
                composite["chapter"]  = 0;
                composite["offset"]   = 0;
                localSettings.Values["nowReading"] = composite;
            }
            if (e.PageState == null)
            {
                //this.MasterListView.SelectedItem = null;
                // When this is a new page, select the first item automatically unless logical page
                // navigation is being used (see the logical page navigation #region below.)
                if (!this.UsingLogicalPageNavigation() && this.MasterListView.Items.Count > 0)
                {
                    this.MasterListView.IsEnabled     = true;
                    this.MasterListView.SelectedIndex = Convert.ToInt32(composite["chapter"].ToString());
                    this.currChapter.Text             = composite["chapter"].ToString();
                    offset = Convert.ToDouble(composite["offset"].ToString());
                    if (localSettings.Values.ContainsKey("readmode"))
                    {
                        if (localSettings.Values["readmode"].ToString() == "pano")
                        {
                            panoOn = true;
                            this.panoView.ChangeView(offset, null, null);
                        }
                        else
                        {
                            panoOn = false;
                            this.columnView.ChangeView(offset, null, null);
                        }
                    }
                }
            }
            else
            {
                // Restore the previously saved state associated with this page
                if (e.PageState.ContainsKey("SelectedItem") && this.MasterListView.Items.Count > 0)
                {
                    //this.MasterListView.SelectedIndex = Convert.ToInt32(e.PageState["SelectedIndex"]);
                }
            }
            this.pbar.IsActive = false;
            //this.updatenotifier.Text = "";
        }
Пример #16
0
        void App_Suspending(Object sender, Windows.ApplicationModel.SuspendingEventArgs e)
        {
            // TODO: This is the time to save app data in case the process is terminated

            Windows.Storage.ApplicationDataContainer localSettings =
                Windows.Storage.ApplicationData.Current.LocalSettings;
            Windows.Storage.ApplicationDataCompositeValue TypeSUP =
                new Windows.Storage.ApplicationDataCompositeValue();
            TypeSUP.Clear();
            TypeSUP["nb"] = SUPCategory.Count;
            for (int i = 0; i < SUPCategory.Count; i++)
            {
                string I    = i.ToString();
                string name = I + "NAME";
                string id   = I + "ID";
                string demi = I + "DEMI";
                string hour = I + "HOUR";
                string supp = I + "SUPP";

                TypeSUP[name] = SUPCategory[i].Name.ToString();
                TypeSUP[id]   = SUPCategory[i].ID.ToString();
                TypeSUP[demi] = SUPCategory[i].Demi.ToString();
                TypeSUP[hour] = SUPCategory[i].Hour.ToString();
                TypeSUP[supp] = SUPCategory[i].Supp.ToString();
            }
            localSettings.Values["TypeOfSUP"] = TypeSUP;

            Windows.Storage.ApplicationDataCompositeValue SUPStock =
                new Windows.Storage.ApplicationDataCompositeValue();
            SUPStock.Clear();
            SUPStock["nb"] = StockSUP.Count;
            for (int i = 0; i < StockSUP.Count; i++)
            {
                string I    = i.ToString();
                string type = I + "TYPE";
                string id   = I + "ID";

                SUPStock[id]   = StockSUP[i].getID();
                SUPStock[type] = StockSUP[i].strType;
            }
            localSettings.Values["StockSUP"] = SUPStock;

            Windows.Storage.ApplicationDataCompositeValue SUPAway =
                new Windows.Storage.ApplicationDataCompositeValue();
            SUPAway.Clear();
            SUPAway["nb"] = AwaySUP.Count;
            for (int i = 0; i < AwaySUP.Count; i++)
            {
                string I    = i.ToString();
                string type = I + "TYPE";
                string id   = I + "ID";
                string time = I + "TIME";

                SUPAway[id]   = AwaySUP[i].getID();
                SUPAway[type] = AwaySUP[i].strType;
                SUPAway[time] = AwaySUP[i].getDeparture();
            }
            localSettings.Values["AwaySUP"] = SUPAway;
        }
Пример #17
0
        /// <summary>
        /// 获取复合设置
        /// </summary>
        /// <param name="compositeKey"></param>
        /// <returns></returns>
        public static Windows.Storage.ApplicationDataCompositeValue GetCompositeValue(string compositeKey)
        {
            // Composite setting
            Windows.Storage.ApplicationDataCompositeValue composite =
                (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values[compositeKey];

            return(composite);
        }
Пример #18
0
 public DataViewModel()
 {
     myInstance    = this;
     localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
     localFolder   = Windows.Storage.ApplicationData.Current.LocalFolder;
     composite     = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["DataStoreViewModel"];
     LoadLocalSettings();
 }
Пример #19
0
        public async void LoadLocalSettings()
        {
            if (composite == null)
            {
                composite = new Windows.Storage.ApplicationDataCompositeValue();
            }
            else
            {
                try
                {
                    currentCurrencyCode  = (string)composite["currentCurrencyCode"];
                    currentDate          = (string)composite["currentDate"];
                    currentDateSelection = (int)composite["currentDateSelection"];
                    toRateHistoryDate    = (DateTimeOffset?)composite["toRateHistoryDate"];
                    fromRateHistoryDate  = (DateTimeOffset?)composite["fromRateHistoryDate"];
                } catch (Exception e)
                {
                    Debug.WriteLine(e.StackTrace);
                }
            }
            try
            {
                StorageFile datesFile = await localFolder.GetFileAsync("dates.txt");

                String datesString = await FileIO.ReadTextAsync(datesFile);

                Debug.WriteLine(datesString);
                dates = JsonConvert.DeserializeObject <List <YearRates> >(datesString);
            }
            catch (Exception)
            {
                Debug.WriteLine("No dates saved");
            }
            try
            {
                StorageFile ratesFile = await localFolder.GetFileAsync("rates.txt");

                String ratesString = await FileIO.ReadTextAsync(ratesFile);

                rates = JsonConvert.DeserializeObject <List <Rate> >(ratesString);
            }
            catch (Exception)
            {
                Debug.WriteLine("No rates saved");
            }
            try
            {
                StorageFile historyFile = await localFolder.GetFileAsync("history.txt");

                String historyOfCurrencyString = await FileIO.ReadTextAsync(historyFile);

                historyOfCurrency = JsonConvert.DeserializeObject <List <DayRate> >(historyOfCurrencyString);
            }
            catch (Exception)
            {
                Debug.WriteLine("No history saved");
            }
        }
Пример #20
0
        public void ClearSaveState()
        {
            // Save a setting locally on the device
            ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

            Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue();

            localSettings.Values["Backup"] = composite;
        }
Пример #21
0
 /// <summary>
 /// Inicjuje pojedynczy obiekt aplikacji. Jest to pierwszy wiersz napisanego kodu
 /// wykonywanego i jest logicznym odpowiednikiem metod main() lub WinMain().
 /// </summary>
 public App()
 {
     this.InitializeComponent();
     this.Suspending += OnSuspending;
     this.ViewModel   = new DataViewModel();
     localSettings    = Windows.Storage.ApplicationData.Current.LocalSettings;
     localFolder      = Windows.Storage.ApplicationData.Current.LocalFolder;
     composite        = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["DataStoreViewModel"];
 }
Пример #22
0
        public static async Task <string> SaveMyConnectionsToFile(string filename)
        {
            try
            {
                Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
                if (localSettings.Values.Keys.Contains("ConDetail"))
                {
                    Windows.Storage.ApplicationDataCompositeValue composite =
                        (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["ConDetail"];
                    if (composite != null)
                    {
                        string         cons       = JsonConvert.SerializeObject(composite);
                        FileSavePicker filePicker = new FileSavePicker();
                        filePicker.SuggestedStartLocation = PickerLocationId.Downloads;
                        filePicker.FileTypeChoices.Add("Connections", new List <string>()
                        {
                            ".con", ".json", ".txt"
                        });
                        // Default file name if the user does not type one in or select a file to replace
                        filePicker.SuggestedFileName = filename;

                        StorageFile file = await filePicker.PickSaveFileAsync();

                        if (file != null)
                        {
                            // Prevent updates to the remote version of the file until we finish making changes and call CompleteUpdatesAsync.
                            CachedFileManager.DeferUpdates(file);
                            // write to file
                            await FileIO.WriteTextAsync(file, cons);

                            // Let Windows know that we're finished changing the file so the other app can update the remote version of the file.
                            // Completing updates may require Windows to ask for user input.
                            FileUpdateStatus status = await CachedFileManager.CompleteUpdatesAsync(file);

                            if (status == FileUpdateStatus.Complete)
                            {
                                return("Save Connection File " + file.Name + " was saved.");
                            }
                            else
                            {
                                return("Save Connection File " + file.Name + " couldn't be saved.");
                            }
                        }
                        else
                        {
                            return("Save Connection Operation cancelled.");
                        }
                    }
                    return("Save Connection Operation  not completed.");
                }
                return("Save Connection Operation  not completed.");
            } catch (Exception ex)
            {
                return("Save Connection Operation failed: " + ex.Message);
            }
        }
        private void UpdateSettingsTheme()
        {
            Windows.Storage.ApplicationDataCompositeValue compositeTheme = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["themeSettings"];

            compositeTheme["foregroundRed"]   = scannerSettings.Theme.foregroundRed;
            compositeTheme["foregroundGreen"] = scannerSettings.Theme.foregroundGreen;
            compositeTheme["foregroundBlue"]  = scannerSettings.Theme.foregroundBlue;

            localSettings.Values["themeSettings"] = compositeTheme;
        }
        private void UpdateSettingsCommunications()
        {
            Windows.Storage.ApplicationDataCompositeValue compositeCommunication = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["communicationSettings"];

            compositeCommunication["deviceID"] = scannerSettings.Communication.deviceID;
            compositeCommunication["comPort"]  = scannerSettings.Communication.comPort;
            compositeCommunication["baudRate"] = scannerSettings.Communication.baudRate;

            localSettings.Values["communicationSettings"] = compositeCommunication;
        }
Пример #25
0
        private void AppBarButton_Tapped_1(object sender, TappedRoutedEventArgs e)
        {
            ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;

            Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue();
            composite["StartIP"]   = St.Text;
            composite["EndIP"]     = En.Text;
            composite["StartPort"] = Sp.Text;
            composite["EndPort"]   = Ep.Text;
            roamingSettings.Values["SettingFontInfo"] = composite;
        }
 public static void SaveChapters()
 {
     if (CustomTabViewItems.Count > SelectedIndex)
     {
         Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue();
         composite["bookNumber"]         = CustomTabViewItems[SelectedIndex].Chapter.BookNumber;
         composite["chapterNumber"]      = CustomTabViewItems[SelectedIndex].Chapter.ChapterNumber;
         composite["paragraph"]          = CustomTabViewItems[SelectedIndex].Chapter.Paragraph;
         LocalSettings.Values["chapter"] = composite;
     }
 }
Пример #27
0
        public PageIPScanner()
        {
            this.InitializeComponent();
            ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
            String localValue = localSettings.Values["langsetting"] as string;
            int    x          = 0;

            if (localSettings == null || localValue == String.Empty)
            {
                localValue = "Auto";
            }
            if (localValue == "Русский")
            {
                Windows.ApplicationModel.Resources.Core.ResourceContext.SetGlobalQualifierValue("Language", "ru-RU");
                x = 2;
            }
            if (localValue == "English")
            {
                Windows.ApplicationModel.Resources.Core.ResourceContext.SetGlobalQualifierValue("Language", "en-DE");
                x = 1;
            }
            if (localValue == "Deutsch")
            {
                Windows.ApplicationModel.Resources.Core.ResourceContext.SetGlobalQualifierValue("Language", "de-DE");
                x = 3;
            }
            if (localValue == "Japanese")
            {
                Windows.ApplicationModel.Resources.Core.ResourceContext.SetGlobalQualifierValue("Language", "ja-JP");
                x = 4;
            }
            if (localValue == "French")
            {
                Windows.ApplicationModel.Resources.Core.ResourceContext.SetGlobalQualifierValue("Language", "fr-FR");
                x = 5;
            }

            this.InitializeComponent();

            viewIP.NetInfo();
            myIP();

            ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;

            Windows.Storage.ApplicationDataCompositeValue composite = (ApplicationDataCompositeValue)roamingSettings.Values["SettingFontInfo"];
            if (composite != null)
            {
                St.Text = composite["StartIP"] as string;
                En.Text = composite["EndIP"] as string;
                Sp.Text = composite["StartPort"] as string;
                Ep.Text = composite["EndPort"] as string;
            }
            IpListView.ItemsSource = viewIP.ListIP;
        }
Пример #28
0
        private async void checkReviews()
        {
            if (showOt && (NowreviewBarrier == reviewBarrier))
            {
                var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
                Debug.WriteLine("Show");
                ContentDialog deleteFileDialog = new ContentDialog
                {
                    Title               = resourceLoader.GetString("ShowTitle"),
                    Content             = resourceLoader.GetString("ShowContent"),
                    PrimaryButtonText   = resourceLoader.GetString("ShowPrimaryText"),
                    SecondaryButtonText = resourceLoader.GetString("ShowSecondaryText"),
                    CloseButtonText     = resourceLoader.GetString("ShowCloseText")
                };

                ContentDialogResult result = await deleteFileDialog.ShowAsync();

                // Delete the file if the user clicked the primary button.
                /// Otherwise, do nothing.
                if (result == ContentDialogResult.Primary)
                {
                    bool result1 = await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-windows-store://review/?ProductId=9N0RCC49K629"));

                    if (result1)
                    {
                        ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
                        Windows.Storage.ApplicationDataCompositeValue composite = (ApplicationDataCompositeValue)roamingSettings.Values["RoamingFontInfo"];
                        composite["Reviewed"]      = "false";
                        composite["reviewBarrier"] = 0;
                        roamingSettings.Values["RoamingFontInfo"] = composite;
                        Debug.WriteLine("Yess false");
                    }
                }
                if (result == ContentDialogResult.Secondary)
                {
                    ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
                    Windows.Storage.ApplicationDataCompositeValue composite = (ApplicationDataCompositeValue)roamingSettings.Values["RoamingFontInfo"];
                    composite["Reviewed"]      = "true";
                    composite["reviewBarrier"] = 0;
                    roamingSettings.Values["RoamingFontInfo"] = composite;
                    Debug.WriteLine("Yess true");
                }
                else
                {
                    ApplicationDataContainer roamingSettings = Windows.Storage.ApplicationData.Current.RoamingSettings;
                    Windows.Storage.ApplicationDataCompositeValue composite = (ApplicationDataCompositeValue)roamingSettings.Values["RoamingFontInfo"];
                    composite["Reviewed"]      = "false";
                    composite["reviewBarrier"] = 0;
                    roamingSettings.Values["RoamingFontInfo"] = composite;
                    Debug.WriteLine("nooo false");
                }
            }
        }
Пример #29
0
        public Windows.Storage.ApplicationDataCompositeValue deleteCompositeValue()
        {
            ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;

            if (localSettings.Values.ContainsKey(m_DataCompositeIDName))
            {
                localSettings.Values.Remove(m_DataCompositeIDName);
                m_DataSourcecomposite = null;
            }

            return(m_DataSourcecomposite);
        }
        private void UpdateSettingsScanner()
        {
            Windows.Storage.ApplicationDataCompositeValue compositeScanner = (Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["scannerSettings"];

            compositeScanner["volume"]       = scannerSettings.Scanner.volume;
            compositeScanner["squelch"]      = scannerSettings.Scanner.squelch;
            compositeScanner["mute"]         = scannerSettings.Scanner.mute;
            compositeScanner["backlight"]    = scannerSettings.Scanner.backlight;
            compositeScanner["btscreenstay"] = scannerSettings.Scanner.btscreenstay;

            localSettings.Values["scannerSettings"] = compositeScanner;
        }
Пример #31
0
        private void OnSaveSetting(object sender, RoutedEventArgs e)
        {
            set.Add(new KeyValuePair<string, object>("mine", "blah"));

            // Create a simple setting
            container.Values["exampleSetting"] = txtSetting.Text;
            container.Values["HighPriority"] = txtSetting.Text;

            //create a CompositeSetting
            var atomic = new Windows.Storage.ApplicationDataCompositeValue();
            atomic["keya"] = "123";
            atomic["value1"] = "abc";
            atomic["value2"] = "def";
            atomic["value3"] = "ghi";

            DisplayText("Data saved: " + txtSetting.Text);
        }