金沙国际官网_金沙国际平台登录

因为这个金沙国际官网_金沙国际平台登录网站与很多的大型澳门赌场都有合作,金沙国际官网_金沙国际平台登录尽职尽责,高效执行,保持好奇心,不断学习,追求卓越,点击进入金沙国际官网_金沙国际平台登录马上体验吧,所以现在也正式地开始了营业。

您的位置:金沙国际官网 > 编程 > 双击获取当前行的控件,计算机名

双击获取当前行的控件,计算机名

发布时间:2019-11-03 23:19编辑:编程浏览(177)

    <DataGrid Margin="10" HorizontalAlignment="Left" VerticalAlignment="Top" AutoGenerateColumns="False" ItemsSource="{Binding }" Name="dg_cards"  MouseDoubleClick="dg_cards_MouseDoubleClick" >
    <DataGrid.Columns>
    <DataGridTextColumn Header="ID" Width="40" Binding="{Binding index}" IsReadOnly="True" />
    <DataGridTemplateColumn Header="启用" Width="50">
    <DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
    <CheckBox Name="cbStatus" MinWidth="{Binding ID}" Uid="{Binding Path=ID}" IsChecked="{Binding IsChecked}" Tag="{Binding ID}" />
    </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    <DataGridTextColumn Header="卡口" Width="80" IsReadOnly="True" Binding="{Binding cardname}" />
    <DataGridTemplateColumn Header="八端口卡" Width="80">
    <DataGridTemplateColumn.CellTemplate>
    <DataTemplate>
    <CheckBox Name="cbeight" IsChecked="{Binding IsEChecked}" />
    </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
    </DataGridTemplateColumn>
    
    <DataGridTextColumn Header="操作" Width="80" IsReadOnly="True" Binding="{Binding op}" />
    </DataGrid.Columns>
    </DataGrid>
    

    一.Django内置admin

    图片 1

     

         a.配置路由**

    首先引入服务 然后 调用

    后台代码:

    urlpatterns = [
            url(r'^admin/', admin.site.urls),
        ]
    

    本文转载自

     private void dg_cards_MouseDoubleClick(object sender, MouseButtonEventArgs e)
            {
                bool isEight = false;
                DataGrid dg = sender as DataGrid;
    
                //双击获取第三列的控件
                DataGridTemplateColumn templeColumn1 = dg.Columns[3] as DataGridTemplateColumn;
                FrameworkElement fwElement1 = dg_cards.Columns[3].GetCellContent(dg.CurrentItem);
                CheckBox cBox1 = templeColumn1.CellTemplate.FindName("cbeight", fwElement1) as CheckBox;
                if ((bool)cBox1.IsChecked) {
                    isEight = true;
                }
            }
    

        b.定制admin 在admin.py中只需要讲Mode中的某个类注册,即可在Admin中实现增删改查的功能,如:

     

      

    admin.site.register(models.UserInfo)
    
    但是,这种方式比较简单,如果想要进行更多的定制操作,需要利用ModelAdmin进行操作,如:
    
    方式一:
        class UserAdmin(admin.ModelAdmin):
            list_display = ('user', 'pwd',)
    
        admin.site.register(models.UserInfo, UserAdmin) # 第一个参数可以是列表
    
    方式二:
        @admin.register(models.UserInfo)                # 第一个参数可以是列表
        class UserAdmin(admin.ModelAdmin):
            list_display = ('user', 'pwd',)
    
      public class Computer
        {
            public static string CpuID; //1.cpu序列号
            public static string MacAddress; //2.mac序列号
            public static string DiskID; //3.硬盘id
            public static string IpAddress; //4.ip地址
            public static string LoginUserName; //5.登录用户名
            public static string ComputerName; //6.计算机名
            public static string SystemType; //7.系统类型
            public static string TotalPhysicalMemory; //8.内存量 单位:M
    
             static   Computer()
            {
                CpuID = GetCpuID();
                MacAddress = GetMacAddress();
                DiskID = GetDiskID();
                IpAddress = GetIPAddress();
                LoginUserName = GetUserName();
                SystemType = GetSystemType();
                TotalPhysicalMemory = GetTotalPhysicalMemory();
                ComputerName = GetComputerName();
            }
            //1.获取CPU序列号代码 
    
           static  string GetCpuID()
            {
                try
                {
                    string cpuInfo = "";//cpu序列号 
                    ManagementClass mc = new ManagementClass("Win32_Processor");
                    ManagementObjectCollection moc = mc.GetInstances();
                    foreach (ManagementObject mo in moc)
                    {
                        cpuInfo = mo.Properties["ProcessorId"].Value.ToString();
                    }
                    moc = null;
                    mc = null;
                    return cpuInfo;
                }
                catch
                {
                    return "unknow";
                }
                finally
                {
                }
    
            }
    
            //2.获取网卡硬件地址 
    
           static string GetMacAddress()
            {
                try
                {
                    string mac = "";
                    ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
                    ManagementObjectCollection moc = mc.GetInstances();
                    foreach (ManagementObject mo in moc)
                    {
                        if ((bool)mo["IPEnabled"] == true)
                        {
                            mac = mo["MacAddress"].ToString();
                            break;
                        }
                    }
                    moc = null;
                    mc = null;
                    return mac;
                }
                catch
                {
                    return "unknow";
                }
                finally
                {
                }
    
            }
    
            //3.获取硬盘ID 
           static string GetDiskID()
            {
                try
                {
                    String HDid = "";
                    ManagementClass mc = new ManagementClass("Win32_DiskDrive");
                    ManagementObjectCollection moc = mc.GetInstances();
                    foreach (ManagementObject mo in moc)
                    {
                        HDid = (string)mo.Properties["Model"].Value;
                    }
                    moc = null;
                    mc = null;
                    return HDid;
                }
                catch
                {
                    return "unknow";
                }
                finally
                {
                }
    
            }
    
            //4.获取IP地址 
    
           static string GetIPAddress()
            {
                try
                {
                    string st = "";
                    ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
                    ManagementObjectCollection moc = mc.GetInstances();
                    foreach (ManagementObject mo in moc)
                    {
                        if ((bool)mo["IPEnabled"] == true)
                        {
                            //st=mo["IpAddress"].ToString(); 
                            System.Array ar;
                            ar = (System.Array)(mo.Properties["IpAddress"].Value);
                            st = ar.GetValue(0).ToString();
                            break;
                        }
                    }
                    moc = null;
                    mc = null;
                    return st;
                }
                catch
                {
                    return "unknow";
                }
                finally
                {
                }
    
            }
    
            /// 5.操作系统的登录用户名 
           static string GetUserName()
            {
                try
                {
                    string un = "";
    
                    un = Environment.UserName;
                    return un;
                }
                catch
                {
                    return "unknow";
                }
                finally
                {
                }
    
            }
    
    
    
            //6.获取计算机名
           static string GetComputerName()
            {
                try
                {
                    return System.Environment.MachineName;
    
                }
                catch
                {
                    return "unknow";
                }
                finally
                {
                }
            }
    
    
    
            ///7 PC类型 
           static string GetSystemType()
            {
                try
                {
                    string st = "";
                    ManagementClass mc = new ManagementClass("Win32_ComputerSystem");
                    ManagementObjectCollection moc = mc.GetInstances();
                    foreach (ManagementObject mo in moc)
                    {
    
                        st = mo["SystemType"].ToString();
    
                    }
                    moc = null;
                    mc = null;
                    return st;
                }
                catch
                {
                    return "unknow";
                }
                finally
                {
                }
            }
    
    
    
            ///8.物理内存        
           static string GetTotalPhysicalMemory()
            {
                try
                {
    
                    string st = "";
                    ManagementClass mc = new ManagementClass("Win32_ComputerSystem");
                    ManagementObjectCollection moc = mc.GetInstances();
                    foreach (ManagementObject mo in moc)
                    {
    
                        st = mo["TotalPhysicalMemory"].ToString();
    
                    }
                    moc = null;
                    mc = null;
                    return st;
                }
                catch
                {
                    return "unknow";
                }
                finally
                {
                }
    
            }
    
    
        }
    

    3.ModelAdmin中提供了大量的可定制功能,如:

     

    1. list_display,列表时,定制显示的列。

    class UserAdmin(admin.ModelAdmin):
        list_display = ('user', 'pwd', 'xxxxx')
    
        def xxxxx(self, obj):
            return "xxxxx"
    

     

    2. list_display_links,列表时,定制列可以点击跳转。

     

    class UserAdmin(admin.ModelAdmin):
        list_display = ('user', 'pwd', 'xxxxx')
        list_display_links = ('pwd',) 
    

    3. list_filter,列表时,定制右侧快速筛选。

     

    class UserAdmin(admin.ModelAdmin):
         list_display = ('user', 'pwd')
        class Ugg(admin.SimpleListFilter):
            title = _('decade born')
            parameter_name = 'xxxxxx'
    list_filter = ('user',Ugg,)
    

     

    4. list_select_related,列表时,连表查询是否自动select_related

    5. 分页相关

     

    图片 2

    # 分页,每页显示条数
        list_per_page = 100
    
    # 分页,显示全部(真实数据<该值时,才会有显示全部)
        list_max_show_all = 200
    
    # 分页插件
        paginator = Paginator
    

    图片 3

     

    6. list_editable,列表时,可以编辑的列

     

    class UserAdmin(admin.ModelAdmin):
        list_display = ('user', 'pwd','ug',)
        list_editable = ('ug',)
    

     

    7. search_fields,列表时,模糊搜索的功能

    class UserAdmin(admin.ModelAdmin):
    
        search_fields = ('user', 'pwd'
    

    8. date_hierarchy,列表时,对Date和DateTime类型进行搜索

     

    本文由金沙国际官网发布于编程,转载请注明出处:双击获取当前行的控件,计算机名

    关键词:

上一篇:正则表达式,线程安全使用

下一篇:没有了