惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
Jina AI
Jina AI
宝玉的分享
宝玉的分享
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
人人都是产品经理
人人都是产品经理
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
博客园 - 【当耐特】
小众软件
小众软件
博客园 - Franky
S
SegmentFault 最新的问题
WordPress大学
WordPress大学
雷峰网
雷峰网
The Cloudflare Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
Last Week in AI
Last Week in AI
博客园_首页
月光博客
月光博客
IT之家
IT之家
阮一峰的网络日志
阮一峰的网络日志
Webroot Blog
Webroot Blog
Stack Overflow Blog
Stack Overflow Blog
腾讯CDC
云风的 BLOG
云风的 BLOG
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
W
WeLiveSecurity
Recent Commits to openclaw:main
Recent Commits to openclaw:main
D
Docker
The Last Watchdog
The Last Watchdog
有赞技术团队
有赞技术团队
Hacker News - Newest:
Hacker News - Newest: "LLM"
D
DataBreaches.Net
S
Security @ Cisco Blogs
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
TaoSecurity Blog
TaoSecurity Blog
S
Security Affairs
Y
Y Combinator Blog
O
OpenAI News
罗磊的独立博客
MongoDB | Blog
MongoDB | Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Forbes - Security
Forbes - Security
P
Palo Alto Networks Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
K
Kaspersky official blog
Cloudbric
Cloudbric

博客园 - 阮

Database access assembly build program. - 阮 Remoting: Server encountered an internal error. - 阮 昨天忽然发现被加到training团队中了,遂来发一篇。 利用Brush修改图片,并写入Response一例(网上BBS中贴可变文字图片的例子)。 Avalon 与 3D。 关于QQ的临时消息 Google Search for dot net nuke. 初识 Avalon 通过程序控制Windows传真发送。 VRML Merry Chirstmas. What's wrong? 构建安全的 ASP.NET 应用程序。(转) 检测Win Form Datagrid点击cell值的代码,from msdn。 Google search for DNN 终于写完了。 DataGrid不能绑定Field? 试了试Dot Net Nuke还真爽。 取得天气的WEB地址,weather.com 终于,从System.Windows.Forms.Control继承了一下。
继续昨天的问题。
· 2004-12-15 · via 博客园 - 阮

昨天的问题,DataGrid的TableStyle的确是一个很复杂的结构,而clone的实现应该是基于prototype模式的,昨天回家的路上感觉还是有点不爽,使用prototype解决这个问题,不是不可以,但是不是很好,应验了Richard的一句话,"There is no right or wrong, but good or bad."(不是原话,意思而已)也正因为Richard说过"Just make it good enough",我还是想改它,参考了一下Builder模式,写了一个不伦不类的Builder,见笑了。

先说下我对prototype的疑虑:
1、MS并没有将TableStyle做成可以clone的,可见这个东西不适合clone;
2、TableStyle太复杂,clone起来自然也简单不了,基本解决不了问题在clone里,还是乱七八糟。

唉,不知道怎么,坐在电脑前永远也想不了问题,习惯性的在键盘上狂敲而已。

下面看看我的不伦不类的Builder吧,赫赫,见笑了

Copyright (c) runmin Copyright

Using directives

namespace Runmin.Sample
{
    
/// <summary>
    
/// Returns an instance of System.Windows.Forms.DataGridTableStyle class.
    
/// </summary>

    public interface ITableStyleBuilder
    
{
        
/// <summary>
        
/// The builder method.
        
/// </summary>
        
/// <returns>TableStyle instance</returns>

        DataGridTableStyle BuildStyle(string theMappingName);
    }


    
public class DefaultTableStyleBuilder : ITableStyleBuilder
    
{
        
private DisplayStyle displayStyle;
        
public DisplayStyle DisplayStyle
        
{
            
get
            
{
                
return this.displayStyle;
            }

            
set
            
{
                
this.displayStyle = value;
            }

        }



        
private DataGridColumnStyle gridColumnStyle;
        
public DataGridColumnStyle GridColumnStyle
        
{
            
get
            
{
                
return this.gridColumnStyle;
            }

            
set
            
{
                
this.gridColumnStyle = value;
            }

        }



        
public virtual DataGridTableStyle BuildStyle(string theMappingName)
        
{
            DataGridTableStyle theTableStyle 
= new DataGridTableStyle();

            theTableStyle.MappingName 
= theMappingName;

            theTableStyle.ForeColor 
= 
                theTableStyle.HeaderForeColor 
= 
                theTableStyle.SelectionForeColor 
= 
                
this.displayStyle.ForeColor;

            theTableStyle.BackColor            
= this.displayStyle.BackColor;
            theTableStyle.HeaderBackColor      
= this.displayStyle.HeaderBackColor;
            theTableStyle.GridLineColor        
= this.displayStyle.GridLineColor;
            theTableStyle.SelectionBackColor   
= this.displayStyle.SelectionBackColor;

            
return theTableStyle;
        }


    }


    
public struct DisplayStyle
    
{
        
private System.Drawing.Color backColor;
        
public System.Drawing.Color BackColor
        
{
            
get
            
{
                
return backColor;
            }


            
set
            
{
                backColor 
= value;
            }

        }


        
private System.Drawing.Color foreColor;
        
public System.Drawing.Color ForeColor
        
{
            
get
            
{
                
return foreColor;
            }


            
set
            
{
                foreColor 
= value;
            }

        }


        
private System.Drawing.Color gridLineColor;
        
public System.Drawing.Color GridLineColor
        
{
            
get
            
{
                
return gridLineColor;
            }


            
set
            
{
                gridLineColor 
= value;
            }

        }


        
private System.Drawing.Color headerBackColor;
        
public System.Drawing.Color HeaderBackColor
        
{
            
get
            
{
                
return headerBackColor;
            }


            
set
            
{
                headerBackColor 
= value;
            }

        }


        
private System.Drawing.Color selectionBackColor;
        
public System.Drawing.Color SelectionBackColor
        
{
            
get
            
{
                
return selectionBackColor;
            }


            
set
            
{
                selectionBackColor 
= value;
            }

        }


        
private System.Drawing.Color alternatingBackColor;
        
public System.Drawing.Color AlternatingBackColor
        
{
            
get
            
{
                
return alternatingBackColor;
            }


            
set
            
{
                alternatingBackColor 
= value;
            }

        }

    }

}