Beispiel #1
0
 private void SetupNetworkInfoTab( )
 {
     AddDataPageToTabControl("Network Info", tcMain, new DataPageControl <DprNetworkInfo>(this)
     {
         QueryDataCb = DprNetworkInfo.Generate, SetupColumnsCb = delegate(DataGridView dgv) {
             DgvHelpers.GenerateAllColumns(dgv, typeof(DprNetworkInfo), new List <string> {
                 @"DefaultIpGateway", @"DnsDomainSuffixSearchOrder", @"DnsServerSearchOrder", @"IpAddress", @"ConnectionStatus"
             });
             MoveStatusColumnsFirst(dgv);
             DgvHelpers.ConvertToMultilineColumn(DgvHelpers.GetColumn(dgv, @"DefaultIpGateways"));
             DgvHelpers.ConvertToMultilineColumn(DgvHelpers.GetColumn(dgv, @"DnsDomainSuffixSearchOrders"));
             DgvHelpers.ConvertToMultilineColumn(DgvHelpers.GetColumn(dgv, @"DnsServerSearchOrders"));
             DgvHelpers.ConvertToMultilineColumn(DgvHelpers.GetColumn(dgv, @"IpAddresses"));
             DgvHelpers.ConvertToMultilineColumn(DgvHelpers.GetColumn(dgv, @"WinsServers"));
             DgvHelpers.MoveColumnToIndex(DgvHelpers.GetColumn(dgv, @"Description"), 2);
             DgvHelpers.SetColumnHeader(DgvHelpers.GetColumn(dgv, @"ConnectionStatusString"), @"Connection Status");
             DgvHelpers.SetVisible(DgvHelpers.GetColumn(dgv, @"InterfaceIndex"), false);
             DgvHelpers.SetVisible(DgvHelpers.GetColumn(dgv, @"SettingId"), false);
             foreach (var actionName in DprNetworkInfo.SetupActions( ).Keys)
             {
                 DgvHelpers.AddButtonColumn(dgv, actionName);
             }
         }
     });
 }
 private static bool ValidateAndSelect(ref DataGridView dgv, DataGridViewCellMouseEventArgs e)
 {
     if (null == e || 0 > e.RowIndex || 0 > e.ColumnIndex || dgv.RowCount <= e.RowIndex || dgv.ColumnCount <= e.ColumnIndex)
     {
         return(false);
     }
     DgvHelpers.SelectCell(ref dgv, e.RowIndex, e.ColumnIndex);
     return(true);
 }
        private ContextMenu MakeCopyLookupMenus(DataGridView dataGridView, int rowIndex, int columnIndex)
        {
            var menu = new ContextMenu( );

            if (!String.IsNullOrEmpty(DgvHelpers.GetCellString(dataGridView, rowIndex, columnIndex).Trim( )))
            {
                menu.MenuItems.Add(new MenuItem(string.Format(@"Copy {0}", DgvHelpers.GetColumnName(dataGridView, columnIndex)), delegate { Clipboard.SetText(dataGridView.Rows[rowIndex].Cells[columnIndex].Value.ToString( )); }));
            }

            if (!GenerateLookupMenu)
            {
                return(menu);
            }

            var lookupMenu = new MenuItem(@"Lookup");

            var clickedColumnName = dataGridView.Columns[columnIndex].Name;

            foreach (DataGridViewColumn column in dataGridView.Columns)
            {
                if (MagicValues.FieldsToNotLoopup.Contains(column.Name))
                {
                    continue;
                }
                if (!DgvHelpers.CanSearch(column))
                {
                    continue;
                }
                if (!column.Visible)
                {
                    continue;
                }
                var curCellValue = DgvHelpers.GetCellString(dataGridView, rowIndex, column.Index);
                var menuName     = column.HeaderText;
                Helpers.AssertNotNull(menuName, @"All columns must have a header defined");
                if (0 == string.Compare(clickedColumnName, column.Name, StringComparison.InvariantCulture))
                {
                    menuName = "*" + menuName;
                }
                lookupMenu.MenuItems.Add(new MenuItem(menuName, delegate { SearchWeb(curCellValue); }));
            }
            if (0 < lookupMenu.MenuItems.Count)
            {
                menu.MenuItems.Add(lookupMenu);
            }
            return(menu);
        }
Beispiel #4
0
 private void SetupCurrentUsersTab( )
 {
     AddDataPageToTabControl("Current Users", tcMain, new DataPageControl <DprCurrentUsers>(this)
     {
         GenerateLookupMenu = false,
         QueryDataCb        = DprCurrentUsers.Generate,
         SetupColumnsCb     = delegate(DataGridView dgv) {
             DgvHelpers.GenerateAllColumns(dgv, typeof(DprCurrentUsers));
             DgvHelpers.SetColumnHeader(DgvHelpers.GetColumn(dgv, @"ConnectionStatusString"), @"Connection Status");
             MoveStatusColumnsFirst(dgv);
             foreach (var actionName in DprCurrentUsers.SetupActions( ).Keys)
             {
                 DgvHelpers.AddButtonColumn(dgv, actionName);
             }
         }
     });
 }
Beispiel #5
0
 private void SetupComputerInfoTab( )
 {
     AddDataPageToTabControl("Computer Info", tcMain, new DataPageControl <DprComputerInfo>(this)
     {
         QueryDataCb    = DprComputerInfo.Generate,
         SetupColumnsCb = delegate(DataGridView dgv) {
             DgvHelpers.GenerateAllColumns(dgv, typeof(DprComputerInfo), new List <string> {
                 @"ConnectionStatus"
             });
             DgvHelpers.SetColumnHeader(DgvHelpers.GetColumn(dgv, @"ConnectionStatusString"), @"Connection Status");
             MoveStatusColumnsFirst(dgv);
             foreach (var actionName in DprComputerInfo.SetupActions( ).Keys)
             {
                 DgvHelpers.AddButtonColumn(dgv, actionName);
             }
         }
     });
 }
Beispiel #6
0
 private void SetupSoftwareTab( )
 {
     AddDataPageToTabControl(@"Software", tcMain, new DataPageControl <DprComputerSoftware>(this)
     {
         CompletionMessage = @"Computer Software Query Complete",
         QueryDataCb       = DprComputerSoftware.Generate,
         SetupColumnsCb    = delegate(DataGridView dgv) {
             DgvHelpers.GenerateAllColumns(dgv, typeof(DprComputerSoftware), new List <string> {
                 @"ConnectionStatus"
             });
             DgvHelpers.ConvertToLinkColumn(DgvHelpers.GetColumn(dgv, @"HelpLink"));
             DgvHelpers.ConvertToLinkColumn(DgvHelpers.GetColumn(dgv, @"UrlInfoAbout"));
             DgvHelpers.SetColumnHeader(DgvHelpers.GetColumn(dgv, @"Guid"), @"GUID");
             DgvHelpers.SetColumnHeader(DgvHelpers.GetColumn(dgv, @"Size"), @"Size(MB)");
             DgvHelpers.SetColumnHeader(DgvHelpers.GetColumn(dgv, @"ConnectionStatusString"), @"Connection Status");
             MoveStatusColumnsFirst(dgv);
             foreach (var actionName in DprComputerSoftware.SetupActions(  ).Keys)
             {
                 DgvHelpers.AddButtonColumn(dgv, actionName);
             }
         }
     });
 }
Beispiel #7
0
 private static void MoveStatusColumnsFirst(DataGridView dgv)
 {
     DgvHelpers.MoveColumnToIndex(DgvHelpers.GetColumn(dgv, @"ComputerName"), 0);
     DgvHelpers.MoveColumnToIndex(DgvHelpers.GetColumn(dgv, @"ConnectionStatusString"), 1);
 }