[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 950
  • Last Modified:

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.Serialization;
//using System.Collections;

namespace xBase
{
      /// <summary>
      /// Description of UserControl1.      
      /// </summary>
            
      public class Desktop : System.Windows.Forms.UserControl
      {
            private System.ComponentModel.IContainer components;
            private System.Windows.Forms.ImageList 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.Count-1 >= fIconList[a].Index) && (IconImageList.Images.Count>0))
                                             {
                                                   Image IconBitmap = IconImageList.Images[fIconList[a].Index];
                                                   Bitmap bmIcon = (Bitmap)IconBitmap;
                                                   bmIcon.MakeTransparent(bmIcon.GetPixel(1,1));
                                                   g.DrawImage(bmIcon,fIconList[a].XPosition,fIconList[a].YPosition,IconBitmap.Width,IconBitmap.Height);
                                             }
                                       }
                                       catch
                                       {}
                                 }
                     }
                }
            }
            
            public ImageList IconImages
            {
                  set      {IconImageList = value; Invalidate();}
                  get {return IconImageList;}
      
            }
            public Bitmap BackGroundBitmap
            {
                  set {BkGroundBitmap = value; Invalidate();}
                  get {return BkGroundBitmap;}
            }
            
            [
            DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
            EditorAttribute("System.ComponentModel.Design.CollectionEditor", "System.Drawing.Design.UITypeEditor")
            ]
            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.CollectionBase
            {
                  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.Container();
                  this.IconImageList = new System.Windows.Forms.ImageList(this.components);
                  //
                  // IconImageList
                  //
                  this.IconImageList.ImageSize = new System.Drawing.Size(16, 16);
                  this.IconImageList.TransparentColor = System.Drawing.Color.Transparent;
                  //
                  // Desktop
                  //
                  this.Name = "Desktop";
                  this.Size = new System.Drawing.Size(292, 266);
            }
            #endregion
      }
}
0
wwwbetyar
Asked:
wwwbetyar
  • 2
  • 2
1 Solution
 
tomvergoteCommented:
maybe there's a bug in sharpdevelop's designer?

Are you using their latest version?
0
 
wwwbetyarAuthor Commented:
yes I use the lastest version so I"m not sure that is the bug.
0
 
tomvergoteCommented:
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.
0
 
wwwbetyarAuthor Commented:
I tryed it in visual studio !
It works fine , so I will write  to the sharpdevelop forums....
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now