jaywingod
专注,厚积薄发,淡泊明志。
posts - 16,  comments - 4,  trackbacks - 0
[From http://bytes.com/forum/thread238429.html]
Here is the situation , in short:
one solution
two projects, the first one (A) calls the second (B) as a .dll .
Both are projects for PocketPC (Smart device applications).
When i set a Breakpoint in the code of B it looks OK but when i Debug
Question Mark appears with the infamous

note: The Breakpoint will not currently be hit. No Symbols have bee
loaded for this document.

The B.pdb has a timestamp different from B.dll and THIS is th
problem.
You have to DELETE B.pdb NOT ONLY from the Debug/bin directory becaus
THERE IS ANOTHER COPY of this B.pdb in the

obj directory and you CAN'T touch this copy so easily. So here is th
complete walkthrough:

1) For your project set "Generate DEBUG information" to FALSE
2) DELETE ALL the occurences of B.pdb under /bin and /obj
3) Set "Generate DEBUG information" back to TRUE
4) BUILD


Between 2 and 3 I also built once but i think this is not necessary.

Now my pdb and dll have the same timestamp and all is workin
perfectly
posted @ 2008-07-03 09:58 JerryGao 阅读(114) | 评论 (0)编辑

    首先,我的标题想告诉大家,我这篇文章讨论的是类设计的原则,但是他仅仅是我个人经验的总结。我并非一个优秀的程序员和设计师,经验也不多,只是有学习的冲动,乐于去思考总结,因此,我这篇文章可能给你的不是一个原则,而是起到抛砖引玉的作用,希望能有人来讨论,共同进步!   
    两个月的时间,4个人的团队,完成了一个小的项目(代码行数有3-4万行,听起来挺吓人的,BLL的代码有1万行左右,其他的是界面和实体的代码)。期间确实挺辛苦,从需求到设计再到代码,放下这个拿起那个,尽显“个人全能”的本色,呵呵。不过这个机会也是非常难得的,可以让我更快的对软件工程有一个更加深入的理解,每一天都会有一些进步,或代码,或设计,或管理。
    今天主要想讨论一下类设计(BLL层):
   
在这个项目之前,一直不明白的一个地方是:以下三种做法的异同,以及如何选择:
    看一下简单的例子:一个用户对象,我们如何创建对象,对其赋值,并调用其保存的方法。
第一种方法:
    User user = new User();
    user.Name = "jerry";
    user.Password = "jerrygod";
    //User.update();
    user.save();
   
第二种方法:
    User user = new User("jerry","jerrygod");
    user.save();
第三种方法:
    User user = new User();
    user.save("jerry","jerrygod");

    由于最开始并不明白以上方法的区别和一般的设计原则,因此,在作时序图和从时序图到dummy类设计的过程中,迭代了几次,浪费了不少时间,最后我采用的是方法二和方法三。因为在很多时候,我们关心的不是一个对象的某个属性(至少在我这个项目种是这样),我关系的是一个这个对象的整体。当然,我选二、三种做法,只是个人的一个感觉和开发时的便捷。并没有理论的支撑。
    前段时间在读《Effective C#》,在其中找到了一些理论基础和支持。(具体参见Item 33 ,34)
    利用构造器链,限制类的可见性,创建大粒度的Web API
    

       我们先看这种做法:
       //在服务器上创建Customer
       Customer c = new Server.Customer();
       //一次往返通信设置Name
       c.Name = "jerry";
        //一次通信设置password
       c.Password = "jerrygod";
       //…………………………设置其他属性
       假如我有一个构造函数:
       public Customer(string name,string password,……)
        {
                //在这里给属性赋值
         }
          这样,只需要一次通信,就可以完成操作,这样,我们可以利用构造器链,降低重复代码, 另外,在多线程的时候,也尽可能的减少了错误的发生。
    看如下例子,修改Customer信息
    Customer c = GetCustomer("jerry");
    c.Name = "Terry";//这个时候,名为Jerry的Customer已面目全非,当另外一个线程使用它时,将出现意想不到的错误。
    c.Update();
如果我们这么做,将尽可能的避免这种错误:
    Customer c = GetCustomer("jerry");
    c.updateName("Terry");
    ====================================================
    以上仅仅是个人不成熟的观点,还希望能有人来指点讨论。最后提到的关于多线程的问题,因为自己并没有真正做过,只是记得在哪里看到过,但是找了好久没找到,所举的例子貌似并没有说明问题,还请高人指点!

posted @ 2008-01-26 16:32 JerryGao 阅读(40) | 评论 (0)编辑
    最近在做一个WinForm的项目,发现一些问题,还是与WebForm有较大的不同。由于我对UI的东西不是很熟,所以在一些简单的问题上,遇到不少的麻烦,其中一个就是控件的Focus()方法和TabIndex属性。
    首先我们来看一下$对TabIndex的解释。
    针对WebForm的解释:

C#
public virtual short TabIndex { get; set; }

属性值

Web 服务器控件的选项卡索引。默认值为 0,表示未设置此属性。
异常类型 条件

ArgumentOutOfRangeException

指定的选项卡索引不在 -32768 和 32767 之间。

使用 TabIndex 属性指定或确定 Web 窗体页上 Web 服务器控件的选项卡索引。当按 Tab 键时,Web 服务器控件接收焦点的顺序由每个控件的 TabIndex 属性确定。当最初加载页时,按 Tab 键时接收焦点的第一项是地址栏。然后,Web 窗体页上控件的 Tab 键顺序根据每个控件的 TabIndex 属性值,从最小的非零正值开始按升序排列。如果多个控件共享同一选项卡索引,则这些控件将按它们在 Web 窗体页上的声明顺序接收焦点。最后,具有零选项卡索引的控件的 Tab 键顺序按它们的声明顺序排列。

Note注意

只有具有非零选项卡索引的控件才呈现 tabindex 属性。

通过将 TabIndex 属性设置为负值,可以从 Tab 键顺序中移除 Web 服务器控件。

    当时一个负责UI的同事告诉我,TabIndex从1开始,设置为0,将无效,并发了这篇文章给我看。但是由于我在试验的过程中发现,设置为0的控件首先获得焦点,所以就抱着怀疑的态度看完了这篇文章,再仔细一看,才发现在这个是WebControl的接受,于是我接着搜,发现下面的介绍:

Tab 键索引较低的控件将先于 Tab 键索引较高的控件接收焦点。

    没有对0作特殊的说明。
   
    通过观察,我个人得出以下结论:

    在WinForm中,TabIndex
与“层”有关,假如有两个panel,panel1(里面有txtName,txtPassword)和Panel2(txtAddress,txtunit),那么,TabIndex的顺序是这样的。
首先在最外层(panel)选取index最小的控件,然后把光标定位到该panel中tabindex最小的控件上。这貌似在MSDN上没有提到。
        =============================================
    Focus()方法的用法。
    最开始,我在Form_Load()方法中设置this.txtName.Focus(),但是显示出来的结果不如人所愿,查MSDN,并没有什么发现,于是试了好多中组合(与TabIndex),以为是父子控件的问题,通过试验发现,在Form_Load中这样写,可以实现设置焦点的功能:
this.txtName.Focus();
this.txtName.tabIndex = 0;
以为自己有了一个伟大的发现,但是,经过几次的试验,发现有时行,有时不行……难道有什么魔咒?
经过几番的试验,得出一个结论。(其实不知道正确与否)

关于Focus():
    “研究发现”,该方法并没有魔咒,也不是$的Bug,主要与他的使用位置有关。在http://www.cnblogs.com/michaellee/archive/2008/01/25/1053366.html中,提到,控件的Focus()与enable和visible有关,在Form_Load中,该控件的visible属性不一定为true,所以,这个时候设置focus()不能成功。因此,要实现Focus(),可以这样:
1、像刚才那篇文章的作者提到的,在Form_Load中这样写:
this.Show();
this.txtName.Focus();
但是我觉得这样的做法不是特别好,因为我们知道,在Form_Load事件之后,还有很多事件发生,我觉得在这些事件中设置焦点更好。
在Activated方法中实现:
this.txtName.Focus();
======================================================
    以上的一些观点和方法,只代表个人目前的浅薄认识,不保证正确,记在这里,供个人日后思考,也为感兴趣的朋友提供一个思考问题的方面,仅此而已。
======================================================

posted @ 2008-01-26 15:26 JerryGao 阅读(229) | 评论 (0)编辑
Table _searchTable;
   //定义被查找的表
   Column _searchColumn;
   //定义被查找的列,必须是被索引的
   FindResult _result;
   //定义查询结果
   Find find = null;
   //定义查找对象,并实例化为null
   _searchTable = Session.Current.Catalog.OpenTable(@"C:\Program Files\MapInfo\MapXtreme\6.0\Samples\Data\worldcap.TAB");
   //打开被查找的表
   Columns columns = _searchTable.TableInfo.Columns;
   //定义出表的列
   _searchColumn = columns["Capital"];
   //注意此处的Capital是要区分大小写的。指定查找的列
   find = new Find(_searchTable,_searchColumn);
   //实例化查找对象
   find.UseCloseMatches = true;
   //指定如果找不到完全匹配是否返回 "N" 个接近的匹配。
   find.CloseMatchesMax = 6;
   //即上面的 "N"
   FindResult _findResult = find.Search(textBox2.Text.ToString());
   //给出所要查找的目标,返回查找的结果
   MapInfo.Geometry.DPoint dpoint;
   dpoint.x = (double)_findResult.FoundPoint.X;
   dpoint.y = (double)_findResult.FoundPoint.Y;
   mapControl1.Map.Center = dpoint;
   find.Dispose();
   //释放find对象
posted @ 2007-12-11 09:34 JerryGao 阅读(114) | 评论 (0)编辑
//用来改变某一个图元的位置 ,使用offestxy函数          
Catalog cat = MapInfo.Engine.Session.Current.Catalog;
            Table tbl = cat.GetTable("地铁站");
            if (tbl != null)
            {
                //更新点的位置
                tbl.BeginAccess(MapInfo.Data.TableAccessMode.Write);
                foreach (Feature fcar in tbl)
                {
                    fcar.Geometry.GetGeometryEditor().OffsetByXY(0.5, 0, MapInfo.Geometry.DistanceUnit.Degree, MapInfo.Geometry.DistanceType.Spherical);
                    fcar.Geometry.EditingComplete();
                    fcar.Update();
                }
                tbl.EndAccess();
            }
posted @ 2007-12-10 16:49 JerryGao 阅读(77) | 评论 (0)编辑
//SearchInfo si = MapInfo.Data.SearchInfoFactory.SearchWhere("Country like '%" + txtName.Text + "%'");
IResultSetFeatureCollection ifs = MapInfo.Engine.Session.Current.Catalog.Search("world",si);

if (ifs.Count <=0)
{
return;
}

//缩放到选择图元范围
MapMain.Map.SetView(ifs.Envelope);
MapMain.Map.Scale = MapMain.Map.Scale * 2;

//高亮显示
MapInfo.Engine.Session.Current.Selections.DefaultSelection.Clear();
MapInfo.Engine.Session.Current.Selections.DefaultSelection.Add(ifs);

//输出查询信息
ListBox1.Items.Clear();
ListBox1.Items.Add("图层: " + ifs.BaseTable.Alias.ToString());
foreach (Feature feature in ifs)
{
//显示每个选择图元的属性数据
foreach (Column column in feature.Columns)
{
   ListBox1.Items.Add("   " + column.ToString() + " = " + feature[column.ToString()].ToString());
}
ListBox1.Items.Add("____________________________");
}
posted @ 2007-12-07 18:47 JerryGao 阅读(125) | 评论 (1)编辑

MapInfo.Data.Feature myfc=MapInfo.Engine.Session.Current.Catalog.SearchForFeature(tabname,MapInfo.Data.SearchInfoFactory.SearchWhere("Highway='I 10'"));
MapInfo.Geometry.MultiCurve c=(MapInfo.Geometry.MultiCurve)myfc.Geometry ;


foreach(MapInfo.Geometry.Curve c1 in c)
{
  MapInfo.Geometry.DPoint []d=c1.SamplePoints();
  for (int i=0;i<c.MultiCurveEditor[0].ControlPointCount;i++)
  {
   MessageBox.Show(this,d.x.ToString()+","++d.y.ToString());
  }

}

}

posted @ 2007-12-07 18:46 JerryGao 阅读(123) | 评论 (0)编辑
如果想要将一个选中的图元强调显示,用红色醒目的文字显示的话,我的思路如下:
            1、不可能直接改原先的图元,所以必须要在一个新的图层上进行操作
            2、新的图层因为不同的人用,会放置不同的东西,用固定图层不合适,得用动态生成的图层
        碰到很多问题,如下:
            1、原来的图层,默认设置了autolabel,所以可以直接显示,但是mapxtreme2004并不支持对图层的autolabel的设置。要想在程序中自动标注,必须得依赖labellayer。
            2、用固定的设置好autolabel的图层不行,那么能否动态的将一个设置好autolabel属性的固定层复制成一个动态图层呢?我没有找到图层的clone方法。
            3、试验过程中,试过复制图层,在旁边动态创建一个标注文字的方式。但文字随放大缩小变化,很不好快。
        最终解决方法:
            1、创建一个ShowLayer,同时也创建一个LabelLayer,关联,并设置好显示效果。
            2、强调显示时,用Feature.Clone复制图元。但是必须注意,要保证ShowLayer的列与被复制的图元的列一致才行。   
            3、如果强调点的位置偏移,可以重新调整坐标系。
        创建ShowLayer的代码:
  public ShowLayerSys(Map MainMap)
  {
   map=MainMap;
   
   _tempTable=MapInfo.Engine.Session.Current.Catalog.GetTable("ShowLayer");
   if(_tempTable==null)
   {   
    TableInfo ti= TableInfoFactory.CreateTemp("ShowLayer"); // create tableinfo with just obj and style cols
    ti.Columns.Add(new Column("ID",MapInfo.Data.MIDbType.String,50,0));
    ti.Columns.Add(new Column("f_name",MapInfo.Data.MIDbType.String,50,0));
    _tempTable = MapInfo.Engine.Session.Current.Catalog.CreateTable(ti);
   }
   map.Layers.Insert(0, new FeatureLayer(_tempTable));

   //设置标注层
   LabelLayer layer = new LabelLayer();
   MainMap.Layers.Add(layer);
   LabelSource source = new LabelSource(MapInfo.Engine.Session.Current.Catalog.GetTable("ShowLayer"));
   source.DefaultLabelProperties.Caption = "f_name";
   source.DefaultLabelProperties.Style.Font.ForeColor=System.Drawing.Color.Blue;   //字体颜色
   //source.DefaultLabelProperties.Style.Font.BackColor =System.Drawing.Color.PowderBlue ;   //字体背景
   source.DefaultLabelProperties.Style.Font.TextEffect=MapInfo.Styles.TextEffect.Box;  //边缘效果
   source.DefaultLabelProperties.Style.Font.FontWeight =MapInfo.Styles.FontWeight.Bold ; //粗体
   source.DefaultLabelProperties.Layout.Alignment=MapInfo.Text.Alignment.CenterRight;  //相对位置
   source.DefaultLabelProperties.Layout.Offset=2;

   layer.Sources.Append(source);
  }
        强调显示的代码:
   MapInfo.Styles.SimpleVectorPointStyle  sty=new SimpleVectorPointStyle();
   
   sty.Color=System.Drawing.Color.Blue  ;
   Feature f=(Feature)ftr.Clone();
   f.Style=sty;
   _tempTable.InsertFeature(f);
posted @ 2007-12-07 15:48 JerryGao 阅读(178) | 评论 (0)编辑
     摘要: 1 设置图层可选状态/**////<summary>///改变层的可选择状态///</summary>///<paramname="selectableStatus"></param>///<returns></returns>publicboolLayerSelectableStatusUpdate(stringtableA... 阅读全文
posted @ 2007-12-07 15:44 JerryGao 阅读(286) | 评论 (0)编辑
以前在mapx里面一个show就可以搞定的问题,现在在这里需要几行代码才能实现,代码如下:
    LabelLayer layer = new LabelLayer();
    MapControl1.Map.Layers.Add(layer);
    LabelSource source = new LabelSource(MapInfo.Engine.Session.Current.Catalog.GetTable("地名"));
    source.DefaultLabelProperties.Caption = "f_name";        //标注用到的那个字段名称
    layer.Sources.Append(source);

===========拉框选择区域实现快速导航=====================
首先在拉框选择时,获得鼠标的位置,并保存,步骤略去。
然后,保存zoom,
接着,创建一个矩形区域:
            MapInfo.Geometry.DRect rect = new MapInfo.Geometry.DRect(RectPoint[0,0], RectPoint[0,1], RectPoint[1,0], RectPoint[1, 1]);
            MapInfo.Geometry.CoordSys cs = this.mapControl1.Map.GetDisplayCoordSys();
调用setview()即可。
            this.mapControl1.Map.SetView(rect, cs);
            this.mapControl1.Map.Zoom = tempZoom;

posted @ 2007-12-07 14:12 JerryGao 阅读(163) | 评论 (0)编辑

<2008年10月>
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

与我联系

搜索

 

常用链接

留言簿(1)

我参加的小组

我参与的团队

随笔分类

随笔档案

文章分类

相册

最新评论

阅读排行榜

评论排行榜