示例#1
0
        // GET /Extensions
        // Displays the open extension added to the signed-in user
        public async Task <IActionResult> Index()
        {
            await EnsureScopes(_userScopes);

            try
            {
                // GET /me/extensions/com.contoso.roamingSettings
                var extension = await _graphClient.Me
                                .Extensions[RoamingSettings.ExtensionName]
                                .Request()
                                .GetAsync();

                var roamingSettings = RoamingSettings.FromOpenExtension(extension);

                var model = new RoamingSettingsDisplayModel(roamingSettings);

                return(View(model));
            }
            catch (ServiceException ex)
            {
                InvokeAuthIfNeeded(ex);

                if (ex.IsMatch(GraphConstants.ResourceNotFound))
                {
                    return(View(new RoamingSettingsDisplayModel(null)));
                }

                return(RedirectToAction("Error", "Home")
                       .WithError("Error getting open extension on user",
                                  ex.Error.Message));
            }
        }
示例#2
0
    public void TestRoamingSettings()
    {
        RoamingSettings.SetValueForKey("roaming_key1", "roaming value 1");

        RoamingSettings.SetValueForKeyInContainer("roaming_container1", "roaming_key2", "roaming value 2");

        var getValue1 = RoamingSettings.GetValueForKey("roaming_key1");

        if (getValue1.ToString() == "roaming value 1")
        {
            Debug.Log("roaming value 1 successfully retrieved");
        }
        else
        {
            Debug.Log("FAILED: roaming value 1 retrieval");
        }

        var getvalue2 = RoamingSettings.GetValueForKeyInContainer("roaming_container1", "roaming_key2");

        if (getvalue2.ToString() == "roaming value 2")
        {
            Debug.Log("roaming value 2 successfully retrieved");
        }
        else
        {
            Debug.Log("FAILED: roaming value 2 retrieval");
        }

        RoamingSettings.SetValueForKeyInContainer("roaming_container2", "roaming_key3", "roaming value 3");

        foreach (var containerName in RoamingSettings.AllContainerNames)
        {
            Debug.Log("Found container: " + containerName);
        }

        RoamingSettings.SetValueForKey("roaming_key_fordelete1", "roaming value for delete 1");
        RoamingSettings.DeleteValueForKey("roaming_key_fordelete1");


        RoamingSettings.SetValueForKeyInContainer("toDeleteContainer", "roaming_key_fordelete1", "roaming value for delete 1");
        RoamingSettings.DeleteValueForKeyInContainer("toDeleteContainer", "roaming_key_fordelete1");

        RoamingSettings.DeleteContainer("roaming_container2");
        Debug.Log("deleting container container2");

        RoamingSettings.ClearAllApplicationData((response) =>
        {
            Debug.Log("All application data cleared");
        });

        text.text = "Roaming settings tested";
        Debug.Log("SUCCESS: All roaming settings functions exercised");
    }
示例#3
0
        public void Dispose()
        {
            SecureSettings.Dispose();

            RoamingSettings.Dispose();
            AppUserSettings.Dispose();
            AppSettings.Dispose();
            FileSettings.Dispose();

            EnvVarsSettings.Dispose();
            RegistrySettings.Dispose();
            AppConfigSettings.Dispose();
            AppSwitchSettings.Dispose();
            CliSettings.Dispose();
        }
示例#4
0
        private void UpdateColorBox(object sender, EventArgs e)
        {
            RoamingSettings r = Settings.Roaming;

            var drpCurrentScheme = (DropDown)sender;

            GbxBackgroundColors.Content = null;

            if (drpCurrentScheme.SelectedIndex == -1)
            {
                return;
            }

            Dictionary <string, Color> scheme = NewColorSchemes[drpCurrentScheme.SelectedKey];

            var tblColors = new TableLayout(2, scheme.Count)
            {
                Spacing = MasterSpacing
            };

            for (int i = 0; i < scheme.Count; i++)
            {
                KeyValuePair <string, Color> color = scheme.ElementAt(i);

                var label = new Label {
                    Text = color.Key
                };
                var picker = new ColorPicker {
                    Value = color.Value, AllowAlpha = false
                };

                // True data binding isn't necessary here, since the color
                // collection won't change behind the scenes while the
                // preferences dialog is open. It's also impossible, since
                // said collection is currently not an ObservableCollection.
                picker.ValueChanged += (source, args) =>
                {
                    scheme[color.Key] = picker.Value;
                };

                tblColors.Add(label, 0, i);
                tblColors.Add(picker, 1, i);
            }

            GbxBackgroundColors.Content = tblColors;
        }
示例#5
0
        public async Task <IActionResult> Create(string SelectedTheme,
                                                 string SelectedColor,
                                                 string SelectedLanguage)
        {
            await EnsureScopes(_userScopes);

            try
            {
                var roamingSettings = RoamingSettings.Create(SelectedTheme, SelectedColor, SelectedLanguage);

                var extension = roamingSettings.ToOpenExtension();

                //POST /me/extensions

                /*
                 * {
                 * "@odata.type": "microsoft.graph.openTypeExtension",
                 * "extensionName": "com.contoso.roamingSettings",
                 * "theme": "...",
                 * "color": "...",
                 * "language": "..."
                 * }
                 */
                await _graphClient.Me
                .Extensions
                .Request()
                .AddAsync(extension);

                return(RedirectToAction("Index")
                       .WithSuccess("Roaming settings created"));
            }
            catch (ServiceException ex)
            {
                InvokeAuthIfNeeded(ex);

                return(RedirectToAction("Index")
                       .WithError("Error creating extension",
                                  ex.Error.Message));
            }
        }
    void OnGUI()
    {
        beginColumn();

        if (GUILayout.Button("Set Roaming Setting Value"))
        {
            RoamingSettings.setValueForKey("intKey", 14);
            Debug.Log("value of intKey: " + RoamingSettings.valueForKey("intKey"));
        }


        if (GUILayout.Button("Update Badge"))
        {
            Tiles.updateBadge("attention");
        }


        if (GUILayout.Button("Show Share UI"))
        {
            // setup something to share. note that title and description are mandatory
            Sharing.title       = "Share This Cool Stuff!";
            Sharing.description = "This is a link to the prime[31] web site";

            // url and text and optional
            Sharing.url  = "http://prime31.com";
            Sharing.text = "Check this out!";

            Debug.Log("about to show share with actual api");
            Sharing.showShareUI();
        }


        if (GUILayout.Button("Show Settings Pane"))
        {
            SettingsPane.show();
        }


        if (GUILayout.Button("Show Toast (ToastText04)"))
        {
            var text = new string[] { "The Headline", "Some body text", "The second body text here" };
            Toasts.showToast(ToastTemplateType.ToastText04, text);
        }


        if (GUILayout.Button("Show Toast (ToastImageAndText03)"))
        {
            var text = new string[] { "The Headline", "Some body text" };
            Toasts.showToast(ToastTemplateType.ToastImageAndText03, text, "http://cchronicle.com/wp-content/uploads/2010/06/Stuff-Story-7102832.png");
        }


        if (GUILayout.Button("Show Toast with Events (ToastText04)"))
        {
            var text = new string[] { "The Headline", "Some body text", "The second body text here" };
            Toasts.showToast(ToastTemplateType.ToastText04, text, null, null,
                             reasonDismissed =>
            {
                Debug.Log("Toast dismissed: " + reasonDismissed);
            },
                             () =>
            {
                Debug.Log("Toast activated");
            },
                             reasonFailed =>
            {
                Debug.Log("Toast failed: " + reasonFailed.Message);
            });
        }


        if (GUILayout.Button("Schedule Toast for 30 seconds from now (ToastText03)"))
        {
            var text = new string[] { "The Headline Goes Here", "Then the body text goes here" };
            Toasts.scheduleToast(ToastTemplateType.ToastText03, text, DateTime.Now.AddSeconds(30));
        }


        if (GUILayout.Button("Create Push Channel"))
        {
            Toasts.createPushNotificationChannelForApplication((channel, error) =>
            {
                if (error != null)
                {
                    Debug.Log("error creating push channel: " + error);
                }
                else
                {
                    Debug.Log("push channel created successfully: " + channel);

#if NETFX_CORE
                    // NOTE THAT THIS WONT WORK WHEN IN A SCRIPT THAT IS IN THE PLUGINS FOLDER DUE TO A UNITY BUG!
                    // we use this native block to access the native channel and add an event listener
                    // for when a push is received
                    Debug.Log("adding push event listener");
                    var nativeChannel = (Windows.Networking.PushNotifications.PushNotificationChannel)channel.nativeChannel;
                    nativeChannel.PushNotificationReceived += (sender, args) =>
                    {
                        Debug.Log("push received: " + args.RawNotification.Content);
                    };
#endif
                }
            });
        }


        endColumn(true);

        if (GUILayout.Button("Register for Snap Changes"))
        {
            Snap.registerForSnapChanges((width, height) =>
            {
                Debug.Log("snap event fired. width: " + width + ", height: " + height);
            }, true);
        }


        if (GUILayout.Button("Get Tile Template Content"))
        {
            var content = Tiles.getTemplateContent(TileTemplateType.TileSquareText04);
            Debug.Log("tile template content: " + content);
        }


        if (GUILayout.Button("Update Live Tile (TileSquareText02)"))
        {
            var text = new string[] { "The Title", "Some smaller text for the sub title" };
            Tiles.updateTile(TileTemplateType.TileSquareText02, text);
        }


        if (GUILayout.Button("Update Live Tile (TileSquareImage) with Bundle Image"))
        {
            // image in the app bundle. Note that you must put an image named "tileText.png" in the Visual Studio
            // assets folder for this to work!
            var images = new string[] { "ms-appx:///assets/tileText.png" };
            Tiles.updateTile(TileTemplateType.TileSquareImage, null, images);
        }


        if (GUILayout.Button("Update Live Tile (TileSquareImage) with Remote Image"))
        {
            // remote images require the internetClient capability in the manifest
            var images = new string[] { "https://prime31.com/media/img/prime31logo.png" };
            Tiles.updateTile(TileTemplateType.TileSquareImage, null, images);
        }


        if (GUILayout.Button("Update Live Tile (TileSquareImage) with Local Image"))
        {
            Debug.Log("starting liveTileWithScreenshot");
            StartCoroutine(liveTileWithScreenshot());
        }


        endColumn();
    }
示例#7
0
 protected StoreEndpoints()
 {
     roamingSettings = new RoamingSettings();
 }
示例#8
0
 public RoamingPlaylist()
 {
     roamingSettings = new RoamingSettings();
 }
示例#9
0
 public Settings(RoamingSettings roaming, SecureSettings secure, LocalSettings local)
 {
     Roaming = roaming;
     Secure  = secure;
     Local   = local;
 }
示例#10
0
 public Settings()
 {
     Roaming = new RoamingSettings();
     Secure  = new SecureSettings();
     Local   = new LocalSettings();
 }
示例#11
0
 public StoreBeamPlaylist(PimpSession session, PimpWebSocket webSocket, BeamPlayer player)
     : base(session, webSocket, player)
 {
     roaming = new RoamingSettings();
 }
示例#12
0
        private TabPage BuildColorsTab()
        {
            GbxBackgroundColors.Padding = MasterPadding;

            RoamingSettings r = Settings.Roaming;

            NewColorSchemes.Clear();
            foreach (KeyValuePair <string, Dictionary <string, Color> > scheme in r.ColorSchemes)
            {
                NewColorSchemes.Add(scheme.Key, scheme.Value);
            }
            NewCurrentColorScheme = r.CurrentColorScheme;

            var lblScheme = new Label {
                Text = "Color scheme"
            };

            var drpCurrentScheme = new DropDown();

            foreach (string key in NewColorSchemes.Keys)
            {
                drpCurrentScheme.Items.Add(key);
            }

            drpCurrentScheme.SelectedKeyChanged += (sender, e) =>
            {
                NewCurrentColorScheme = drpCurrentScheme.SelectedKey;
            };
            drpCurrentScheme.SelectedKeyChanged += UpdateColorBox;
            drpCurrentScheme.SelectedKey         = NewCurrentColorScheme;

            var btnAddScheme = new Button {
                Text = "Add"
            };

            btnAddScheme.Click += (sender, e) =>
            {
                var txtSchemeName = new TextBox {
                    PlaceholderText = "Name"
                };

                var dlgName = new Dialog
                {
                    Title     = "New color scheme",
                    Resizable = true,
                    Padding   = MasterPadding,
                    Content   = txtSchemeName
                };

                var btnOK = new Button {
                    Text = "OK", Enabled = false
                };
                var btnCancel = new Button {
                    Text = "Cancel"
                };

                txtSchemeName.TextChanged += (source, args) =>
                {
                    btnOK.Enabled = txtSchemeName.Text.Trim().Length > 0;
                };

                bool enteredName = false;

                btnOK.Click += (source, args) =>
                {
                    // The OK button can only be clicked if it's enabled, and as
                    // per the anonymous method attached to TextChanged above,
                    // that only happens if the TextBox has text in it.
                    enteredName = true;
                    dlgName.Close();
                };
                btnCancel.Click += (source, args) =>
                {
                    enteredName = false;
                    dlgName.Close();
                };

                dlgName.PositiveButtons.Add(btnOK);
                dlgName.NegativeButtons.Add(btnCancel);

                dlgName.ShowModal(this);

                if (enteredName)
                {
                    NewColorSchemes.Add(
                        txtSchemeName.Text.Trim(),
                        new Dictionary <string, Color>
                    {
                        { "3D Wireframe", Colors.Black },
                        { "3D Flat", Colors.Black },
                        { "3D Textured", Colors.Black }
                    });

                    drpCurrentScheme.Items.Clear();
                    foreach (string key in NewColorSchemes.Keys)
                    {
                        drpCurrentScheme.Items.Add(key);
                    }

                    drpCurrentScheme.SelectedIndex = drpCurrentScheme.Items.Count - 1;
                }
            };

            var btnCopyScheme = new Button {
                Text = "Copy"
            };

            btnCopyScheme.Click += (sender, e) =>
            {
                NewColorSchemes.Add(
                    $"{drpCurrentScheme.SelectedKey} - Copy",
                    new Dictionary <string, Color>(NewColorSchemes[NewCurrentColorScheme]));

                drpCurrentScheme.Items.Clear();
                foreach (string key in NewColorSchemes.Keys)
                {
                    drpCurrentScheme.Items.Add(key);
                }

                drpCurrentScheme.SelectedIndex = drpCurrentScheme.Items.Count - 1;
            };

            var btnRenameScheme = new Button {
                Text = "Rename"
            };

            btnRenameScheme.Click += (sender, e) =>
            {
                var txtNewName = new TextBox {
                    PlaceholderText = "New color scheme name"
                };

                var dlgName = new Dialog
                {
                    Title     = "New name",
                    Resizable = true,
                    Padding   = MasterPadding,
                    Content   = txtNewName
                };

                var btnOK = new Button {
                    Text = "OK", Enabled = false
                };
                var btnCancel = new Button {
                    Text = "Cancel"
                };

                txtNewName.TextChanged += (source, args) =>
                {
                    btnOK.Enabled = txtNewName.Text.Trim().Length > 0;
                };

                bool enteredName = false;

                btnOK.Click += (source, args) =>
                {
                    // The OK button can only be clicked if it's enabled, and as
                    // per the anonymous method attached to TextChanged above,
                    // that only happens if the TextBox has text in it.
                    enteredName = true;
                    dlgName.Close();
                };
                btnCancel.Click += (source, args) =>
                {
                    enteredName = false;
                    dlgName.Close();
                };

                dlgName.PositiveButtons.Add(btnOK);
                dlgName.NegativeButtons.Add(btnCancel);

                dlgName.ShowModal(this);

                if (enteredName)
                {
                    Dictionary <string, Color> scheme = NewColorSchemes[drpCurrentScheme.SelectedKey];

                    int index = 0;
                    for (int i = 0; i < NewColorSchemes.Count; i++)
                    {
                        if (NewColorSchemes.ElementAt(i).Key == drpCurrentScheme.SelectedKey)
                        {
                            index = i;
                            break;
                        }
                    }

                    NewColorSchemes.Remove(drpCurrentScheme.SelectedKey);
                    NewColorSchemes.Add(txtNewName.Text.Trim(), scheme);

                    drpCurrentScheme.Items.Clear();
                    foreach (string key in NewColorSchemes.Keys)
                    {
                        drpCurrentScheme.Items.Add(key);
                    }

                    drpCurrentScheme.SelectedIndex = drpCurrentScheme.Items.Count - 1;
                }
            };

            var btnRemoveScheme = new Button {
                Text = "Remove"
            };

            btnRemoveScheme.Click += (sender, e) =>
            {
                if (NewColorSchemes.Count == 0)
                {
                    return;
                }

                int newIndex = 0;
                for (int i = 0; i < NewColorSchemes.Count; i++)
                {
                    KeyValuePair <string, Dictionary <string, Color> > scheme = NewColorSchemes.ElementAt(i);

                    if (scheme.Key == drpCurrentScheme.SelectedKey)
                    {
                        newIndex = i - 1;
                        break;
                    }
                }

                NewColorSchemes.Remove(drpCurrentScheme.SelectedKey);

                if (NewColorSchemes.Count == 0)
                {
                    newIndex = -1;
                }
                else if (newIndex < 0)
                {
                    newIndex = 0;
                }

                drpCurrentScheme.Items.Clear();
                foreach (string key in NewColorSchemes.Keys)
                {
                    drpCurrentScheme.Items.Add(key);
                }

                drpCurrentScheme.SelectedIndex = newIndex;

                NewCurrentColorScheme = drpCurrentScheme.SelectedKey;

                UpdateColorBox(drpCurrentScheme, EventArgs.Empty);
            };

            var stkSchemes = new StackLayout
            {
                Orientation = Orientation.Horizontal,
                VerticalContentAlignment = VerticalAlignment.Center,
                Spacing = MasterPadding,
                Items   =
                {
                    lblScheme,
                    drpCurrentScheme,
                    btnAddScheme,
                    btnCopyScheme,
                    btnRenameScheme,
                    btnRemoveScheme
                }
            };

            var stkColors = new StackLayout
            {
                Orientation = Orientation.Vertical,
                Spacing     = MasterPadding,
                Items       =
                {
                    stkSchemes,
                    GbxBackgroundColors
                }
            };

            return(new TabPage {
                Padding = MasterPadding, Text = "Colors", Content = stkColors
            });
        }