Exemple #1
0
        private void treeViewAzureSub_MouseClick(object sender, MouseEventArgs e)
        {
            TreeViewHitTestInfo hitTest = treeViewAzureSub.HitTest(e.Location);

            if (hitTest.Location == TreeViewHitTestLocations.PlusMinus && hitTest.Node.IsExpanded)
            {
                // user clicked on the '+' button

                Cursor = Cursors.WaitCursor;

                Subscription selectedSubscription = subscriptions.Where(s => s.DisplayName == hitTest.Node.Text).FirstOrDefault();

                // Getting Media Services accounts...
                AzureMediaServicesClient mediaServicesClient = new AzureMediaServicesClient(environment.ArmEndpoint, credentials)
                {
                    SubscriptionId = selectedSubscription.SubscriptionId
                };
                IPage <SubscriptionMediaService> mediaServicesAccounts = mediaServicesClient.Mediaservices.ListBySubscription();

                // let's save the data
                allAMSAccountsPerSub[mediaServicesClient.SubscriptionId] = mediaServicesAccounts;

                treeViewAzureSub.BeginUpdate();
                hitTest.Node.Nodes.Clear();
                foreach (SubscriptionMediaService mediaAcct in mediaServicesAccounts)
                {
                    TreeNode node = new TreeNode(mediaAcct.Name)
                    {
                        Tag = mediaAcct.Id
                    };
                    hitTest.Node.Nodes.Add(node);
                }
                treeViewAzureSub.EndUpdate();
                Cursor             = Cursors.Arrow;
                buttonNext.Enabled = false;
            }
            else if (hitTest.Location == TreeViewHitTestLocations.Label && hitTest.Node.Level == 1)
            {
                IPage <SubscriptionMediaService> accounts = allAMSAccountsPerSub[(string)hitTest.Node.Parent.Tag];
                SubscriptionMediaService         account  = accounts.Where(a => a.Id == (string)hitTest.Node.Tag).FirstOrDefault();

                // let's display account info
                DisplayInfoAccount(account);
                selectedAccount    = account;
                buttonNext.Enabled = true;
            }
            else
            {
                buttonNext.Enabled = false;
            }
        }
Exemple #2
0
        private void DisplayInfoAccount(SubscriptionMediaService account)
        {
            DGAcct.Rows.Clear();
            DGAcct.ColumnCount = 2;
            DGAcct.ColumnCount = 2;
            DGAcct.Columns[0].DefaultCellStyle.BackColor = Color.Gainsboro;

            // acount info
            DGAcct.Columns[0].DefaultCellStyle.BackColor = Color.Gainsboro;
            DGAcct.Rows.Add("Name", account.Name);
            DGAcct.Rows.Add("Location", account.Location);
            DGAcct.Rows.Add("Id", account.Id);
            DGAcct.Rows.Add("MediaServiceId", account.MediaServiceId);
        }
        private void treeViewAzureSub_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (e.Node.Level == 1)
            {
                List <SubscriptionMediaService> accounts = allAMSAccountsPerSub[(string)e.Node.Parent.Tag];
                SubscriptionMediaService        account  = accounts.Where(a => a.Id == (string)e.Node.Tag).FirstOrDefault();

                // let's display account info
                DisplayInfoAccount(account);
                selectedAccount    = account;
                buttonNext.Enabled = true;
            }
            else
            {
                ClearDisplayInfoAccount();
                buttonNext.Enabled = false;
            }
        }
        /// <summary>
        /// Display the AMS account info on the right.
        /// </summary>
        /// <param name="account"></param>
        private void DisplayInfoAccount(SubscriptionMediaService account)
        {
            DGAcct.Rows.Clear();
            DGAcct.ColumnCount = 2;
            DGAcct.ColumnCount = 2;
            DGAcct.Columns[0].DefaultCellStyle.BackColor = Color.Gainsboro;

            // acount info
            DGAcct.Columns[0].DefaultCellStyle.BackColor = Color.Gainsboro;
            DGAcct.Rows.Add("AMS Account Name", account.Name);
            DGAcct.Rows.Add("Location", account.Location);
            DGAcct.Rows.Add("Resource Group", GetResourceGroupNameFromId(account.Id));
            DGAcct.Rows.Add("MediaServiceId", account.MediaServiceId);

            int i = 1;

            foreach (var stor in account.StorageAccounts)
            {
                string add = stor.Type == StorageAccountType.Primary ? " (primary)" : string.Empty;
                DGAcct.Rows.Add($"Storage account #{i}" + add, GetStorageNameFromId(stor.Id));
                i++;
            }
        }