예제 #1
0
        public int Compare(object x, object y)
        {
            SmartListItem item1 = (SmartListItem)x;
            string        item2 = (string)y;

            return(String.Compare(item1.Text, (string)y, true));
        }
예제 #2
0
        // This methos will shorten a long string to the desired width and add "..."
        private string ShortString(SmartListItem item, DrawItemEventArgs e, int desWidth)
        {
            SizeF size   = e.Graphics.MeasureString(item.Text, e.Font);
            SizeF p_size = e.Graphics.MeasureString("...", e.Font);

            string tempString = item.Text;

            if (size.Width > desWidth)
            {
                //get the new width
                int nWidth = desWidth - (int)p_size.Width;
                //get the desired string
                char[] textChars = item.Text.ToCharArray();
                tempString  = "";
                tempString += textChars[0].ToString();
                int nPos = 0;

                for (int i = 1; i < textChars.Length; i++)
                {
                    SizeF tempSize = e.Graphics.MeasureString(tempString, e.Font);
                    if (tempSize.Width >= nWidth)
                    {
                        nPos = tempString.Length;
                        break;
                    }
                    else
                    {
                        tempString += textChars[i].ToString();
                    }
                }
                tempString += "...";
            }

            return(tempString);
        }
예제 #3
0
            /// <summary>
            /// Determines whether the specified item is located within the collection.
            /// </summary>
            /// <param name="value">An object representing the item to locate in the collection.</param>
            /// <returns>true if the item is located within the collection; otherwise, false .</returns>
            public bool Contains(SmartListItem value)
            {
                // Use base class to process actual collection operation
                //return base.List.Contains(value as object);

                return(List.Contains(value));
                //return parent.arrList.Contains(value as object);
            }
예제 #4
0
 /// <summary>
 /// Gets or sets the item.
 /// </summary>
 public SmartListItem this[int index]
 {
     // Use base class to process actual collection operation
     get
     {
         SmartListItem item = (SmartListItem)List[index];
         //SmartListItem item = parent.arrList[index] as SmartListItem;
         return(item);
     }
     set
     {
         List[index] = (SmartListItem)value;
     }
 }
예제 #5
0
            /// <summary>
            /// Adds an item to the list of items for a SmartList .
            /// </summary>
            /// <param name="value">SmartListItem to add</param>
            /// <returns>Newly created SmartListItem</returns>
            public SmartListItem Add(SmartListItem value)
            {
                // Use base class to process actual collection operation
                //				if (value.Font == null)
                if (parent != null)
                {
                    value.Font = parent.Font;
                    //				if (value.ForeColor == Color.Empty)
                    value.ForeColor = parent.ForeColor;
                    //
                    value.Parent = parent;
                }

                int Return = 0;
                int NewIndex;

                if (_IsSorted)
                {
                    int Index = IndexOf(value);
                    NewIndex = Index >= 0 ? Index : -Index - 1;
                    if (NewIndex >= Count)
                    {
                        List.Add(value);
                    }
                    else
                    {
                        List.Insert(NewIndex, value);
                    }
                }
                else
                {
                    NewIndex = List.Add(value);
                }

                Return = NewIndex;

                //parent.arrList.Add(value);
                //				int i = List.Add(value as SmartListItem);
                if (parent != null)
                {
                    parent.Refresh();
                }

                //return i;
                return(value);
            }
예제 #6
0
        protected override void DestroyInstance(object instance)
        {
            IDesignerHost host;

            if (instance as IComponent != null)
            {
                host = (IDesignerHost)this.GetService(typeof(IDesignerHost));
                if (host != null)
                {
                    SmartListItem item = (SmartListItem)instance;
                    host.Container.Remove(item);
                }
                //(IComponent) instance.Dispose();
            }

            base.DestroyInstance(instance);
        }
예제 #7
0
            /// <summary>
            /// Adds an item to the list of items for a SmartList .
            /// </summary>
            /// <param name="value">string for text property</param>
            /// <returns>Newly created SmartListItem</returns>
            public SmartListItem Add(string value)
            {
                // Use base class to process actual collection operation
                SmartListItem item = new SmartListItem(value);

                if (parent != null)
                {
                    item.Font = parent.Font;
                    //				if (value.ForeColor == Color.Empty)
                    item.ForeColor = parent.ForeColor;
                    //
                    item.Parent = parent;
                }

                int NewIndex;

                if (_IsSorted)
                {
                    int Index = IndexOf(item);
                    NewIndex = Index >= 0 ? Index : -Index - 1;
                    if (NewIndex >= Count)
                    {
                        List.Add(item);
                    }
                    else
                    {
                        List.Insert(NewIndex, item);
                    }
                }
                else
                {
                    NewIndex = List.Add(item);
                }

                if (parent != null)
                {
                    parent.Refresh();
                }

                return(item);
            }
예제 #8
0
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destType)
        {
            if (destType == typeof(InstanceDescriptor))
            {
                SmartListItem item = (SmartListItem)value;

//			System.Reflection.ConstructorInfo ci =
//				typeof(SmartListItem).GetConstructor(
//				System.Type.EmptyTypes);
//
//			return new InstanceDescriptor(ci, null, false);

                if (item.ShouldSerializeFont())
                {
                    System.Reflection.ConstructorInfo ci = typeof(SmartListItem).GetConstructor(new Type[0]);
                    return(new InstanceDescriptor(ci, null, false));
                }
            }

            return(base.ConvertTo(context, culture, value, destType));
        }
예제 #9
0
        private void DrawTextSelected(Graphics g, SmartListItem item, string text, Brush textBrush, int selStart, int selLen, Rectangle rc, DrawItemState state)
        {
            SizeF textSize = g.MeasureString(text, item.Font);

            SizeF sizeStart = SizeF.Empty;
            Brush backBrush = null;
            Brush selBrush  = null;

            string selStr = text.Substring(0, selLen);

            string rightStr = text.Substring(selLen, text.Length - selLen);

            //if (selStart > 0)
            sizeStart = g.MeasureString(selStr, item.Font);


            Rectangle rcSel = new Rectangle(rc.X, rc.Y + 1, (int)sizeStart.Width, rc.Height);

            Rectangle rcRight = new Rectangle((int)(rc.X + sizeStart.Width), rc.Y + 1, (int)(textSize.Width - sizeStart.Width), rc.Height);

            if (state == DrawItemState.Selected)
            {
                backBrush = new SolidBrush(SystemColors.HighlightText);
                selBrush  = new SolidBrush(SystemColors.Highlight);
            }
            else
            {
                backBrush = new SolidBrush(SystemColors.Highlight);
                selBrush  = new SolidBrush(SystemColors.HighlightText);
            }

            g.FillRectangle(backBrush, rcSel);

            g.DrawString(selStr, item.Font, selBrush, rcSel);

            g.DrawString(rightStr, item.Font, textBrush, rcRight);

            backBrush.Dispose();
            selBrush.Dispose();
        }
예제 #10
0
            //			public new int Count
            //			{
            //				get
            //				{
            //					return parent.arrList.Count;
            //				}
            //
            //			}

            /// <summary>
            /// Returns the index within the collection of the specified item
            /// </summary>
            /// <param name="value">An object representing the item to locate in the collection.</param>
            /// <returns>The zero-based index where the item is located within the collection; otherwise, negative one (-1). </returns>
            public int IndexOf(SmartListItem value)
            {
                // Find the 0 based index of the requested entry
                int Result = -1;

                if (_IsSorted)
                {
                    //Result = ArrayList.BinarySearch(value, _Comparer);
                    Result = Array.BinarySearch(this.ToArray(), 0, List.Count, value, new ListComparer());
                    while (Result > 0 && List[Result - 1].Equals(value))
                    {
                        Result--;                                                                    // We want to point at the FIRST occurence
                    }
                }
                else
                {
                    Result = List.IndexOf(value);
                }

                return(Result);
                //return List.IndexOf(value);
            }
예제 #11
0
        private bool FilterItems(string value, ArrayList items)
        {
            bool res = false;

            for (int i = 0; i < items.Count; i++)
            {
                string item = (string)items[i];
                string val  = item.Substring(0, value.Length).ToLower();

                if (String.Compare(val, value, true) == 0)
                {
                    if (!bTempCleaned)
                    {
                        tempItems.Clear();
                        bTempCleaned = true;
                    }
                    SmartListItem SmartListItem = new SmartListItem(item);
                    tempItems.Add(SmartListItem);
                    res = true;
                }
            }

            return(res);
        }
예제 #12
0
			/// <summary>
			/// Determines whether the specified item is located within the collection.  
			/// </summary>
			/// <param name="value">An object representing the item to locate in the collection.</param>
			/// <returns>true if the item is located within the collection; otherwise, false .</returns>
			public bool Contains(SmartListItem value)
			{
				// Use base class to process actual collection operation
				//return base.List.Contains(value as object);

				return List.Contains(value);
				//return parent.arrList.Contains(value as object);
			}
예제 #13
0
			/// <summary>
			/// Inserts an item into the list box at the specified index.  
			/// </summary>
			/// <param name="index">The zero-based index location where the item is inserted.</param>
			/// <param name="value">An object representing the item to insert.</param>
			public void Insert(int index, SmartListItem value)
			{
				// Use base class to process actual collection operation
				List.Insert(index, value as object);
				parent.RefreshItems();
			}
예제 #14
0
			//			public void AddRange(SmartListItem[] values)
			//			{
			//				// Use existing method to add each array entry
			//				foreach(SmartListItem page in values)
			//					Add(page);
			//
			//				parent.RefreshItems();
			//			}

			/// <summary>
			/// Removes the specified object from the collection.
			/// </summary>
			/// <param name="value">SmartListItem to remove</param>
			public void Remove(SmartListItem value)
			{
				List.Remove(value);
				parent.RefreshItems();
			}
예제 #15
0
			/// <summary>
			/// Adds an item to the list of items for a SmartList . 
			/// </summary>
			/// <param name="value">string for text property</param>
			/// <returns>Newly created SmartListItem</returns>
			public SmartListItem Add(string value)
			{
				// Use base class to process actual collection operation
				SmartListItem item = new SmartListItem(value);
				if (parent != null)
				{
					item.Font = parent.Font;
					//				if (value.ForeColor == Color.Empty)
					item.ForeColor = parent.ForeColor;
					//
					item.Parent = parent;
				}

				int NewIndex;

				if (_IsSorted)
				{
					int Index = IndexOf(item);
					NewIndex = Index>=0 ? Index : -Index-1;
					if (NewIndex>=Count) 
						List.Add(item);
					else 
						List.Insert(NewIndex, item);
				}
				else
					NewIndex = List.Add(item);
				   
				if (parent!=null)
					parent.RefreshItems();

				return item;
			}
예제 #16
0
			/// <summary>
			/// Adds an item to the list of items for a SmartList . 
			/// </summary>
			/// <param name="value">SmartListItem to add</param>
			/// <returns>Newly created SmartListItem</returns>
			public SmartListItem Add(SmartListItem value)
			{
				// Use base class to process actual collection operation
				//				if (value.Font == null)
				if (parent != null)
				{
					value.Font = parent.Font;
					//				if (value.ForeColor == Color.Empty)
					value.ForeColor = parent.ForeColor;
					//
					value.Parent = parent;
				}

				int Return  = 0;
				int NewIndex;

				if (_IsSorted)
				{
					int Index = IndexOf(value);
					NewIndex = Index>=0 ? Index : -Index-1;
					if (NewIndex >= Count) 
						List.Add(value);
					else 
						List.Insert(NewIndex, value);
				}
				else
					NewIndex = List.Add(value);
				   
				Return = NewIndex;

				//parent.arrList.Add(value);
				//				int i = List.Add(value as SmartListItem);
				if (parent != null)
					parent.RefreshItems();

				//return i;
				return value;
			}
예제 #17
0
		private bool FilterItems(string value, ArrayList items)
		{
			bool res = false;
			
			for(int i=0;i<items.Count;i++)
			{
				string item = (string)items[i];
				string val = item.Substring(0, value.Length).ToLower();
				
				if (String.Compare(val, value, true) == 0)
				{
					if (!bTempCleaned)
					{
						tempItems.Clear();
						bTempCleaned = true;
					}
					SmartListItem SmartListItem = new SmartListItem(item);
					tempItems.Add(SmartListItem);
					res = true;
				}
			}

			return res;
		}
예제 #18
0
 internal SmartListItem AddItem(SmartListItem item)
 {
     itemList.Add(item);
     this.Invalidate();
     return(item);
 }
예제 #19
0
            //			public void AddRange(SmartListItem[] values)
            //			{
            //				// Use existing method to add each array entry
            //				foreach(SmartListItem page in values)
            //					Add(page);
            //
            //				parent.RefreshItems();
            //			}

            /// <summary>
            /// Removes the specified object from the collection.
            /// </summary>
            /// <param name="value">SmartListItem to remove</param>
            public void Remove(SmartListItem value)
            {
                List.Remove(value);
                parent.Refresh();
            }
예제 #20
0
			//			public new int Count
			//			{
			//				get
			//				{
			//					return parent.arrList.Count;
			//				}
			//
			//			}

			/// <summary>
			/// Returns the index within the collection of the specified item
			/// </summary>
			/// <param name="value">An object representing the item to locate in the collection.</param>
			/// <returns>The zero-based index where the item is located within the collection; otherwise, negative one (-1). </returns>
			public int IndexOf(SmartListItem value)
			{
				// Find the 0 based index of the requested entry
				int Result = -1;
				if ( _IsSorted )
				{
					//Result = ArrayList.BinarySearch(value, _Comparer);
					Result = Array.BinarySearch(this.ToArray(), 0, List.Count, value, new ListComparer());
					while ( Result>0 && List[Result-1].Equals(value) ) Result--; // We want to point at the FIRST occurence
				}
				else Result = List.IndexOf(value);
				
				return Result;
				//return List.IndexOf(value);
			}
예제 #21
0
		internal SmartListItem AddItem(SmartListItem item)
		{
			itemList.Add(item);
			this.Invalidate();
			return item;
		}
예제 #22
0
		private void DrawTextSelected(Graphics g, SmartListItem item, string text, Brush textBrush, int selStart, int selLen, Rectangle rc, DrawItemState state)
		{
			SizeF textSize = g.MeasureString(text, item.Font);
		
			SizeF sizeStart = SizeF.Empty;
			Brush backBrush = null;
			Brush selBrush = null;

			string selStr = text.Substring(0, selLen);

			string rightStr = text.Substring(selLen, text.Length - selLen);

			//if (selStart > 0)
			sizeStart = g.MeasureString(selStr, item.Font);
		
			
			Rectangle rcSel = new Rectangle(rc.X, rc.Y + 1, (int)sizeStart.Width, rc.Height);

			Rectangle rcRight = new Rectangle((int)(rc.X+sizeStart.Width), rc.Y + 1, (int)(textSize.Width - sizeStart.Width), rc.Height);

			if (state == DrawItemState.Selected)
			{
				backBrush = new SolidBrush(SystemColors.HighlightText);
				selBrush = new SolidBrush(SystemColors.Highlight);
			}
			else
			{
				backBrush = new SolidBrush(SystemColors.Highlight);
				selBrush = new SolidBrush(SystemColors.HighlightText);
			}

			g.FillRectangle(backBrush, rcSel);
 
			g.DrawString(selStr, item.Font, selBrush, rcSel);

			g.DrawString(rightStr, item.Font, textBrush, rcRight);

			backBrush.Dispose();
			selBrush.Dispose();

		}
예제 #23
0
		// This methos will shorten a long string to the desired width and add "..."
		private string ShortString(SmartListItem item, DrawItemEventArgs e, int desWidth)
		{
			SizeF size = e.Graphics.MeasureString(item.Text, e.Font);
			SizeF p_size = e.Graphics.MeasureString("...", e.Font);

			string tempString = item.Text;

			if (size.Width > desWidth)
			{
				//get the new width
				int nWidth = desWidth - (int)p_size.Width;
				//get the desired string
				char[] textChars = item.Text.ToCharArray();
				tempString = "";
				tempString += textChars[0].ToString();
				int nPos = 0;

				for(int i=1;i<textChars.Length;i++)
				{
					SizeF tempSize = e.Graphics.MeasureString(tempString, e.Font);
					if (tempSize.Width >= nWidth)
					{
						nPos = tempString.Length;
						break;
					}
					else
					{
						tempString += textChars[i].ToString();

					}
				}
				tempString += "...";
			}

			return tempString;
		}
예제 #24
0
 /// <summary>
 /// Inserts an item into the list box at the specified index.
 /// </summary>
 /// <param name="index">The zero-based index location where the item is inserted.</param>
 /// <param name="value">An object representing the item to insert.</param>
 public void Insert(int index, SmartListItem value)
 {
     // Use base class to process actual collection operation
     List.Insert(index, value as object);
     parent.Refresh();
 }