wwwbetyar
asked on
c# CollectionBase, I lost the design time collection after build....
Hi
I want to write a component is c# with collection.
It works fine, but if I create a nem collection item in desig time,I lost this value(s) when I go to the code view or build it.
I need a fast solution....
Here is the source code :
/*
* Created by SharpDevelop.
* User: xxxx
* Date: 2004.11.19.
* Time: 22:32
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using System.Runtime.Serializati on;
//using System.Collections;
namespace xBase
{
/// <summary>
/// Description of UserControl1.
/// </summary>
public class Desktop : System.Windows.Forms.UserC ontrol
{
private System.ComponentModel.ICon tainer components;
private System.Windows.Forms.Image List IconImageList;
private System.Drawing.Bitmap BkGroundBitmap = null;
private Desktop.MyIconsCollection fIconList = new MyIconsCollection();
public Desktop()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
protected override void OnResize(EventArgs e)
{
Invalidate();
}
protected override void OnPaint( PaintEventArgs pe )
{
Graphics g = pe.Graphics;
Rectangle rect = this.ClientRectangle;
if (BkGroundBitmap != null)
{
g.DrawImage(BkGroundBitmap , rect);
} else
{
g.Clear(this.BackColor);
}
if (fIconList != null)
{
if (fIconList.Count > 0)
{
for (int a=0;a<=fIconList.Count-1;a ++)
{
try
{
if ((IconImageList.Images.Cou nt-1 >= fIconList[a].Index) && (IconImageList.Images.Coun t>0))
{
Image IconBitmap = IconImageList.Images[fIcon List[a].In dex];
Bitmap bmIcon = (Bitmap)IconBitmap;
bmIcon.MakeTransparent(bmI con.GetPix el(1,1));
g.DrawImage(bmIcon,fIconLi st[a].XPos ition,fIco nList[a].Y Position,I conBitmap. Width,Icon Bitmap.Hei ght);
}
}
catch
{}
}
}
}
}
public ImageList IconImages
{
set {IconImageList = value; Invalidate();}
get {return IconImageList;}
}
public Bitmap BackGroundBitmap
{
set {BkGroundBitmap = value; Invalidate();}
get {return BkGroundBitmap;}
}
[
DesignerSerializationVisib ility(Desi gnerSerial izationVis ibility.Co ntent),
EditorAttribute("System.Co mponentMod el.Design. Collection Editor", "System.Drawing.Design.UIT ypeEditor" )
]
public Desktop.MyIconsCollection Iconlist
{
get
{
if (this.fIconList == null)
{
this.fIconList = new Desktop.MyIconsCollection( );
}
return this.fIconList;
}
}
///
/// Collection
///
public sealed class Icons : Component
{
private string IconCaption;
private int IconIndex;
private int IconXPosition;
private int IconYPosition;
public Icons()
{
}
//[Browsable(false)]
public string Caption
{
set { IconCaption = value;}
get { return IconCaption;}
}
public int XPosition
{
set { IconXPosition = value;}
get { return IconXPosition;}
}
public int YPosition
{
set { IconYPosition = value;}
get { return IconYPosition;}
}
public int Index
{
set { IconIndex = value;}
get { return IconIndex;}
}
}
[Serializable]
public sealed class MyIconsCollection : System.Collections.Collect ionBase
{
public int Add(Icons item)
{
return List.Add(item);
}
public void Insert(int index, Icons item)
{
List.Insert(index,item);
}
public void Remove(Icons item)
{
List.Remove(item);
}
public bool Contains(Icons item)
{
return List.Contains(item);
}
public int IndexOf(Icons item)
{
return List.IndexOf(item);
}
public void CopyTo(Icons[] array,int index)
{
List.CopyTo(array,index);
}
public Icons this[int index]
{
get {return(Icons)List[index]; }
set {List[index] = value;}
}
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Cont ainer();
this.IconImageList = new System.Windows.Forms.Image List(this. components );
//
// IconImageList
//
this.IconImageList.ImageSi ze = new System.Drawing.Size(16, 16);
this.IconImageList.Transpa rentColor = System.Drawing.Color.Trans parent;
//
// Desktop
//
this.Name = "Desktop";
this.Size = new System.Drawing.Size(292, 266);
}
#endregion
}
}
I want to write a component is c# with collection.
It works fine, but if I create a nem collection item in desig time,I lost this value(s) when I go to the code view or build it.
I need a fast solution....
Here is the source code :
/*
* Created by SharpDevelop.
* User: xxxx
* Date: 2004.11.19.
* Time: 22:32
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Drawing.Drawing2D;
using System.Runtime.Serializati
//using System.Collections;
namespace xBase
{
/// <summary>
/// Description of UserControl1.
/// </summary>
public class Desktop : System.Windows.Forms.UserC
{
private System.ComponentModel.ICon
private System.Windows.Forms.Image
private System.Drawing.Bitmap BkGroundBitmap = null;
private Desktop.MyIconsCollection fIconList = new MyIconsCollection();
public Desktop()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
protected override void OnResize(EventArgs e)
{
Invalidate();
}
protected override void OnPaint( PaintEventArgs pe )
{
Graphics g = pe.Graphics;
Rectangle rect = this.ClientRectangle;
if (BkGroundBitmap != null)
{
g.DrawImage(BkGroundBitmap
} else
{
g.Clear(this.BackColor);
}
if (fIconList != null)
{
if (fIconList.Count > 0)
{
for (int a=0;a<=fIconList.Count-1;a
{
try
{
if ((IconImageList.Images.Cou
{
Image IconBitmap = IconImageList.Images[fIcon
Bitmap bmIcon = (Bitmap)IconBitmap;
bmIcon.MakeTransparent(bmI
g.DrawImage(bmIcon,fIconLi
}
}
catch
{}
}
}
}
}
public ImageList IconImages
{
set {IconImageList = value; Invalidate();}
get {return IconImageList;}
}
public Bitmap BackGroundBitmap
{
set {BkGroundBitmap = value; Invalidate();}
get {return BkGroundBitmap;}
}
[
DesignerSerializationVisib
EditorAttribute("System.Co
]
public Desktop.MyIconsCollection Iconlist
{
get
{
if (this.fIconList == null)
{
this.fIconList = new Desktop.MyIconsCollection(
}
return this.fIconList;
}
}
///
/// Collection
///
public sealed class Icons : Component
{
private string IconCaption;
private int IconIndex;
private int IconXPosition;
private int IconYPosition;
public Icons()
{
}
//[Browsable(false)]
public string Caption
{
set { IconCaption = value;}
get { return IconCaption;}
}
public int XPosition
{
set { IconXPosition = value;}
get { return IconXPosition;}
}
public int YPosition
{
set { IconYPosition = value;}
get { return IconYPosition;}
}
public int Index
{
set { IconIndex = value;}
get { return IconIndex;}
}
}
[Serializable]
public sealed class MyIconsCollection : System.Collections.Collect
{
public int Add(Icons item)
{
return List.Add(item);
}
public void Insert(int index, Icons item)
{
List.Insert(index,item);
}
public void Remove(Icons item)
{
List.Remove(item);
}
public bool Contains(Icons item)
{
return List.Contains(item);
}
public int IndexOf(Icons item)
{
return List.IndexOf(item);
}
public void CopyTo(Icons[] array,int index)
{
List.CopyTo(array,index);
}
public Icons this[int index]
{
get {return(Icons)List[index];
set {List[index] = value;}
}
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Cont
this.IconImageList = new System.Windows.Forms.Image
//
// IconImageList
//
this.IconImageList.ImageSi
this.IconImageList.Transpa
//
// Desktop
//
this.Name = "Desktop";
this.Size = new System.Drawing.Size(292, 266);
}
#endregion
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think you should try posting this to the sharpdevelop forums or mailinglists as it seems clear that it's something with their designer.
You create a collection in design view and it isn't reflected in code.
You create a collection in design view and it isn't reflected in code.
ASKER
I tryed it in visual studio !
It works fine , so I will write to the sharpdevelop forums....
It works fine , so I will write to the sharpdevelop forums....
ASKER