Exemplo n.º 1
0
 public void Load(BorderPattern b)
 {
     this.BackArrowSize  = b.BackArrowSize;
     this.BackArrowType  = b.BackArrowType;
     this.Color          = b.Color;
     this.DashCap        = b.DashCap;
     this.DashCapVisible = b.DashCapVisible;
     this.DashStyle      = b.DashStyle;
     this.FrontArrowSize = b.FrontArrowSize;
     this.FrontArrowType = b.FrontArrowType;
     this.Width          = b.Width;
 }
Exemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Set the header icon. (Thanks to a post by Eddie Velasquez.)
        /// </summary>
        /// <param name="columnIndex">Index of the column.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <param name="size">The size.</param>
        /// ------------------------------------------------------------------------------------
        public void ShowHeaderIcon(int columnIndex, SortOrder sortOrder, ArrowSize size)
        {
            CheckDisposed();

            if (columnIndex < 0 || columnIndex >= Columns.Count)
            {
                return;
            }

            if (sortOrder == SortOrder.None)
            {
                m_columnIconIndexes.Remove(columnIndex);
            }
            else
            {
                // There are 3 potential sizes: Large, Medium, and Small with 2 sort orders, Ascending and Descending
                // The images are stored in that order, so the following works
                m_columnIconIndexes[columnIndex] = (int)size + (3 * ((int)sortOrder - 1));
            }
        }
Exemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create up/down icon (Adapted from a post by Eddie Velasquez.)
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="size">The size.</param>
        /// <returns></returns>
        /// ------------------------------------------------------------------------------------
        Bitmap GetArrowBitmap(ArrowType type, ArrowSize size)
        {
            int offset;

            switch (size)
            {
            case ArrowSize.Large:
                offset = 0;
                break;

            case ArrowSize.Medium:
                offset = 2;
                break;

            case ArrowSize.Small:
                offset = 3;
                break;

            default:
                offset = 0;
                break;
            }

            Bitmap bmp = new Bitmap(kHalfArrowSize * 2, kHalfArrowSize * 2);

            using (Graphics gfx = Graphics.FromImage(bmp))
            {
                Brush brush = new SolidBrush(Color.FromArgb(215, 230, 255));
                Pen   pen   = new Pen(Color.FromArgb(49, 106, 197));

                gfx.FillRectangle(new SolidBrush(Color.FromKnownColor(KnownColor.ControlLight)), 0, 0, kHalfArrowSize * 2, kHalfArrowSize * 2);

                Point[] points = null;
                if (type == ArrowType.Ascending)
                {
//					Point left = new Point(kHalfArrowSize, 0);
//					Point right = new Point(kHalfArrowSize, 0);
//					for (int i = 0; i < kHalfArrowSize; i++)
//					{
//						left.X -= 1;
//						right.X += 1;
//						gfx.DrawLine(pen, left, right);
//						left.Y += 1;
//						right.Y += 1;
//						gfx.DrawLine(pen, left, right);
//						left.Y += 1;
//						right.Y += 1;
//					}
                    points = new Point[] { new Point(kHalfArrowSize, offset), new Point(kHalfArrowSize * 2 - 1 - offset, kHalfArrowSize * 2 - 1 - offset),
                                           new Point(offset, kHalfArrowSize * 2 - 1 - offset) };
                    gfx.FillPolygon(brush, points);
                    gfx.DrawPolygon(pen, points);
                }
                else if (type == ArrowType.Descending)
                {
                    points = new Point[] { new Point(offset, offset), new Point(kHalfArrowSize * 2 - 1 - offset, offset), new Point(kHalfArrowSize, kHalfArrowSize * 2 - 1 - offset) };
                    gfx.FillPolygon(brush, points);
                    gfx.DrawPolygon(pen, points);
                }
            }

            return(bmp);
        }
Exemplo n.º 4
0
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         if (Visible != null)
         {
             hashCode = hashCode * 59 + Visible.GetHashCode();
         }
         if (X != null)
         {
             hashCode = hashCode * 59 + X.GetHashCode();
         }
         if (Y != null)
         {
             hashCode = hashCode * 59 + Y.GetHashCode();
         }
         if (Z != null)
         {
             hashCode = hashCode * 59 + Z.GetHashCode();
         }
         if (Ax != null)
         {
             hashCode = hashCode * 59 + Ax.GetHashCode();
         }
         if (Ay != null)
         {
             hashCode = hashCode * 59 + Ay.GetHashCode();
         }
         if (XAnchor != null)
         {
             hashCode = hashCode * 59 + XAnchor.GetHashCode();
         }
         if (XShift != null)
         {
             hashCode = hashCode * 59 + XShift.GetHashCode();
         }
         if (YAnchor != null)
         {
             hashCode = hashCode * 59 + YAnchor.GetHashCode();
         }
         if (YShift != null)
         {
             hashCode = hashCode * 59 + YShift.GetHashCode();
         }
         if (Text != null)
         {
             hashCode = hashCode * 59 + Text.GetHashCode();
         }
         if (TextAngle != null)
         {
             hashCode = hashCode * 59 + TextAngle.GetHashCode();
         }
         if (Font != null)
         {
             hashCode = hashCode * 59 + Font.GetHashCode();
         }
         if (Width != null)
         {
             hashCode = hashCode * 59 + Width.GetHashCode();
         }
         if (Height != null)
         {
             hashCode = hashCode * 59 + Height.GetHashCode();
         }
         if (Opacity != null)
         {
             hashCode = hashCode * 59 + Opacity.GetHashCode();
         }
         if (Align != null)
         {
             hashCode = hashCode * 59 + Align.GetHashCode();
         }
         if (VAlign != null)
         {
             hashCode = hashCode * 59 + VAlign.GetHashCode();
         }
         if (BgColor != null)
         {
             hashCode = hashCode * 59 + BgColor.GetHashCode();
         }
         if (BorderColor != null)
         {
             hashCode = hashCode * 59 + BorderColor.GetHashCode();
         }
         if (BorderPad != null)
         {
             hashCode = hashCode * 59 + BorderPad.GetHashCode();
         }
         if (BorderWidth != null)
         {
             hashCode = hashCode * 59 + BorderWidth.GetHashCode();
         }
         if (ShowArrow != null)
         {
             hashCode = hashCode * 59 + ShowArrow.GetHashCode();
         }
         if (ArrowColor != null)
         {
             hashCode = hashCode * 59 + ArrowColor.GetHashCode();
         }
         if (Arrowhead != null)
         {
             hashCode = hashCode * 59 + Arrowhead.GetHashCode();
         }
         if (StartArrowhead != null)
         {
             hashCode = hashCode * 59 + StartArrowhead.GetHashCode();
         }
         if (ArrowSide != null)
         {
             hashCode = hashCode * 59 + ArrowSide.GetHashCode();
         }
         if (ArrowSize != null)
         {
             hashCode = hashCode * 59 + ArrowSize.GetHashCode();
         }
         if (StartArrowSize != null)
         {
             hashCode = hashCode * 59 + StartArrowSize.GetHashCode();
         }
         if (ArrowWidth != null)
         {
             hashCode = hashCode * 59 + ArrowWidth.GetHashCode();
         }
         if (Standoff != null)
         {
             hashCode = hashCode * 59 + Standoff.GetHashCode();
         }
         if (StartStandoff != null)
         {
             hashCode = hashCode * 59 + StartStandoff.GetHashCode();
         }
         if (HoverText != null)
         {
             hashCode = hashCode * 59 + HoverText.GetHashCode();
         }
         if (HoverLabel != null)
         {
             hashCode = hashCode * 59 + HoverLabel.GetHashCode();
         }
         if (CaptureEvents != null)
         {
             hashCode = hashCode * 59 + CaptureEvents.GetHashCode();
         }
         if (Name != null)
         {
             hashCode = hashCode * 59 + Name.GetHashCode();
         }
         if (TemplateItemName != null)
         {
             hashCode = hashCode * 59 + TemplateItemName.GetHashCode();
         }
         return(hashCode);
     }
 }
Exemplo n.º 5
0
        /// <inheritdoc />
        public bool Equals([AllowNull] Annotation other)
        {
            if (other == null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Visible == other.Visible ||
                     Visible != null &&
                     Visible.Equals(other.Visible)
                     ) &&
                 (
                     X == other.X ||
                     X != null &&
                     X.Equals(other.X)
                 ) &&
                 (
                     Y == other.Y ||
                     Y != null &&
                     Y.Equals(other.Y)
                 ) &&
                 (
                     Z == other.Z ||
                     Z != null &&
                     Z.Equals(other.Z)
                 ) &&
                 (
                     Ax == other.Ax ||
                     Ax != null &&
                     Ax.Equals(other.Ax)
                 ) &&
                 (
                     Ay == other.Ay ||
                     Ay != null &&
                     Ay.Equals(other.Ay)
                 ) &&
                 (
                     XAnchor == other.XAnchor ||
                     XAnchor != null &&
                     XAnchor.Equals(other.XAnchor)
                 ) &&
                 (
                     XShift == other.XShift ||
                     XShift != null &&
                     XShift.Equals(other.XShift)
                 ) &&
                 (
                     YAnchor == other.YAnchor ||
                     YAnchor != null &&
                     YAnchor.Equals(other.YAnchor)
                 ) &&
                 (
                     YShift == other.YShift ||
                     YShift != null &&
                     YShift.Equals(other.YShift)
                 ) &&
                 (
                     Text == other.Text ||
                     Text != null &&
                     Text.Equals(other.Text)
                 ) &&
                 (
                     TextAngle == other.TextAngle ||
                     TextAngle != null &&
                     TextAngle.Equals(other.TextAngle)
                 ) &&
                 (
                     Font == other.Font ||
                     Font != null &&
                     Font.Equals(other.Font)
                 ) &&
                 (
                     Width == other.Width ||
                     Width != null &&
                     Width.Equals(other.Width)
                 ) &&
                 (
                     Height == other.Height ||
                     Height != null &&
                     Height.Equals(other.Height)
                 ) &&
                 (
                     Opacity == other.Opacity ||
                     Opacity != null &&
                     Opacity.Equals(other.Opacity)
                 ) &&
                 (
                     Align == other.Align ||
                     Align != null &&
                     Align.Equals(other.Align)
                 ) &&
                 (
                     VAlign == other.VAlign ||
                     VAlign != null &&
                     VAlign.Equals(other.VAlign)
                 ) &&
                 (
                     BgColor == other.BgColor ||
                     BgColor != null &&
                     BgColor.Equals(other.BgColor)
                 ) &&
                 (
                     BorderColor == other.BorderColor ||
                     BorderColor != null &&
                     BorderColor.Equals(other.BorderColor)
                 ) &&
                 (
                     BorderPad == other.BorderPad ||
                     BorderPad != null &&
                     BorderPad.Equals(other.BorderPad)
                 ) &&
                 (
                     BorderWidth == other.BorderWidth ||
                     BorderWidth != null &&
                     BorderWidth.Equals(other.BorderWidth)
                 ) &&
                 (
                     ShowArrow == other.ShowArrow ||
                     ShowArrow != null &&
                     ShowArrow.Equals(other.ShowArrow)
                 ) &&
                 (
                     ArrowColor == other.ArrowColor ||
                     ArrowColor != null &&
                     ArrowColor.Equals(other.ArrowColor)
                 ) &&
                 (
                     Arrowhead == other.Arrowhead ||
                     Arrowhead != null &&
                     Arrowhead.Equals(other.Arrowhead)
                 ) &&
                 (
                     StartArrowhead == other.StartArrowhead ||
                     StartArrowhead != null &&
                     StartArrowhead.Equals(other.StartArrowhead)
                 ) &&
                 (
                     ArrowSide == other.ArrowSide ||
                     ArrowSide != null &&
                     ArrowSide.Equals(other.ArrowSide)
                 ) &&
                 (
                     ArrowSize == other.ArrowSize ||
                     ArrowSize != null &&
                     ArrowSize.Equals(other.ArrowSize)
                 ) &&
                 (
                     StartArrowSize == other.StartArrowSize ||
                     StartArrowSize != null &&
                     StartArrowSize.Equals(other.StartArrowSize)
                 ) &&
                 (
                     ArrowWidth == other.ArrowWidth ||
                     ArrowWidth != null &&
                     ArrowWidth.Equals(other.ArrowWidth)
                 ) &&
                 (
                     Standoff == other.Standoff ||
                     Standoff != null &&
                     Standoff.Equals(other.Standoff)
                 ) &&
                 (
                     StartStandoff == other.StartStandoff ||
                     StartStandoff != null &&
                     StartStandoff.Equals(other.StartStandoff)
                 ) &&
                 (
                     HoverText == other.HoverText ||
                     HoverText != null &&
                     HoverText.Equals(other.HoverText)
                 ) &&
                 (
                     HoverLabel == other.HoverLabel ||
                     HoverLabel != null &&
                     HoverLabel.Equals(other.HoverLabel)
                 ) &&
                 (
                     CaptureEvents == other.CaptureEvents ||
                     CaptureEvents != null &&
                     CaptureEvents.Equals(other.CaptureEvents)
                 ) &&
                 (
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                 ) &&
                 (
                     TemplateItemName == other.TemplateItemName ||
                     TemplateItemName != null &&
                     TemplateItemName.Equals(other.TemplateItemName)
                 ));
        }
Exemplo n.º 6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Set the header icon. (Thanks to a post by Eddie Velasquez.)
        /// </summary>
        /// <param name="columnIndex">Index of the column.</param>
        /// <param name="sortOrder">The sort order.</param>
        /// <param name="size">The size.</param>
        /// ------------------------------------------------------------------------------------
        public void ShowHeaderIcon(int columnIndex, SortOrder sortOrder, ArrowSize size)
        {
            CheckDisposed();

            if (columnIndex < 0 || columnIndex >= this.Columns.Count)
            {
                return;
            }

            IntPtr hHeader = SendMessage(this.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

            ColumnHeader colHdr = this.Columns[columnIndex];

            // Setting these icons happens during view startup BEFORE we restore the saved settings,
            // so saving the current ones overwrites the saved ones. Anyway, modifying the icon
            // doesn't modif the width, so doing anything about column widths would be a waste.
            bool oldSuppress = SuppressColumnWidthChanges;

            SuppressColumnWidthChanges = true;
            // the following commented out code uses the default visual style sort arrows,
            // we are not using them so that we can use different size arrows
            //if (Application.RenderWithVisualStyles)
            //{
            //    IntPtr colPtr = new IntPtr(columnIndex);
            //    HDITEM hd = new HDITEM();
            //    hd.mask = HDI_FORMAT;
            //    SendMessage2(hHeader, HDM_GETITEM, colPtr, ref hd);
            //    if (sortOrder != SortOrder.None)
            //    {
            //        switch (sortOrder)
            //        {
            //            case SortOrder.Ascending:
            //                hd.fmt &= ~HDF_SORTDOWN;
            //                hd.fmt |= HDF_SORTUP;
            //                break;

            //            case SortOrder.Descending:
            //                hd.fmt &= ~HDF_SORTUP;
            //                hd.fmt |= HDF_SORTDOWN;
            //                break;
            //        }
            //    }
            //    else
            //    {
            //        hd.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
            //    }

            //    SendMessage2(hHeader, HDM_SETITEM, colPtr, ref hd);
            //}
            //else
            //{
            HDITEM hd = new HDITEM();

            hd.mask = HDI_IMAGE | HDI_FORMAT;

            HorizontalAlignment align = colHdr.TextAlign;

            if (align == HorizontalAlignment.Left)
            {
                hd.fmt = HDF_LEFT | HDF_STRING | HDF_BITMAP_ON_RIGHT;
            }

            else if (align == HorizontalAlignment.Center)
            {
                hd.fmt = HDF_CENTER | HDF_STRING | HDF_BITMAP_ON_RIGHT;
            }

            else                // HorizontalAlignment.Right
            {
                hd.fmt = HDF_RIGHT | HDF_STRING;
            }

            if (sortOrder != SortOrder.None)
            {
                hd.fmt |= HDF_IMAGE;
            }

            if (sortOrder == SortOrder.None)
            {
                hd.iImage = -1;
            }
            else
            {
                // There are 3 potential sizes: Large, Medium, and Small with 2 sort orders, Ascending and Descending
                // The images are stored in that order, so the following works
                hd.iImage = (int)size + (3 * ((int)sortOrder - 1));
            }

            SendMessage2(hHeader, HDM_SETITEM, new IntPtr(columnIndex), ref hd);
            //}
            SuppressColumnWidthChanges = oldSuppress;

            Update();
        }
Exemplo n.º 7
0
        public bool Equals([AllowNull] Annotation other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return((Visible == other.Visible && Visible != null && other.Visible != null && Visible.Equals(other.Visible)) &&
                   (Text == other.Text && Text != null && other.Text != null && Text.Equals(other.Text)) &&
                   (TextAngle == other.TextAngle && TextAngle != null && other.TextAngle != null && TextAngle.Equals(other.TextAngle)) &&
                   (Font == other.Font && Font != null && other.Font != null && Font.Equals(other.Font)) &&
                   (Width == other.Width && Width != null && other.Width != null && Width.Equals(other.Width)) &&
                   (Height == other.Height && Height != null && other.Height != null && Height.Equals(other.Height)) &&
                   (Opacity == other.Opacity && Opacity != null && other.Opacity != null && Opacity.Equals(other.Opacity)) &&
                   (Align == other.Align && Align != null && other.Align != null && Align.Equals(other.Align)) &&
                   (VAlign == other.VAlign && VAlign != null && other.VAlign != null && VAlign.Equals(other.VAlign)) &&
                   (BgColor == other.BgColor && BgColor != null && other.BgColor != null && BgColor.Equals(other.BgColor)) &&
                   (BorderColor == other.BorderColor && BorderColor != null && other.BorderColor != null && BorderColor.Equals(other.BorderColor)) &&
                   (BorderPad == other.BorderPad && BorderPad != null && other.BorderPad != null && BorderPad.Equals(other.BorderPad)) &&
                   (BorderWidth == other.BorderWidth && BorderWidth != null && other.BorderWidth != null && BorderWidth.Equals(other.BorderWidth)) &&
                   (ShowArrow == other.ShowArrow && ShowArrow != null && other.ShowArrow != null && ShowArrow.Equals(other.ShowArrow)) &&
                   (ArrowColor == other.ArrowColor && ArrowColor != null && other.ArrowColor != null && ArrowColor.Equals(other.ArrowColor)) &&
                   (Arrowhead == other.Arrowhead && Arrowhead != null && other.Arrowhead != null && Arrowhead.Equals(other.Arrowhead)) &&
                   (StartArrowhead == other.StartArrowhead && StartArrowhead != null && other.StartArrowhead != null && StartArrowhead.Equals(other.StartArrowhead)) &&
                   (ArrowSide == other.ArrowSide && ArrowSide != null && other.ArrowSide != null && ArrowSide.Equals(other.ArrowSide)) &&
                   (ArrowSize == other.ArrowSize && ArrowSize != null && other.ArrowSize != null && ArrowSize.Equals(other.ArrowSize)) &&
                   (StartArrowSize == other.StartArrowSize && StartArrowSize != null && other.StartArrowSize != null && StartArrowSize.Equals(other.StartArrowSize)) &&
                   (ArrowWidth == other.ArrowWidth && ArrowWidth != null && other.ArrowWidth != null && ArrowWidth.Equals(other.ArrowWidth)) &&
                   (Standoff == other.Standoff && Standoff != null && other.Standoff != null && Standoff.Equals(other.Standoff)) &&
                   (StartStandoff == other.StartStandoff && StartStandoff != null && other.StartStandoff != null && StartStandoff.Equals(other.StartStandoff)) &&
                   (Ax == other.Ax && Ax != null && other.Ax != null && Ax.Equals(other.Ax)) &&
                   (Ay == other.Ay && Ay != null && other.Ay != null && Ay.Equals(other.Ay)) &&
                   (AXref == other.AXref && AXref != null && other.AXref != null && AXref.Equals(other.AXref)) &&
                   (AyRef == other.AyRef && AyRef != null && other.AyRef != null && AyRef.Equals(other.AyRef)) &&
                   (XRef == other.XRef && XRef != null && other.XRef != null && XRef.Equals(other.XRef)) &&
                   (X == other.X && X != null && other.X != null && X.Equals(other.X)) &&
                   (XAnchor == other.XAnchor && XAnchor != null && other.XAnchor != null && XAnchor.Equals(other.XAnchor)) &&
                   (XShift == other.XShift && XShift != null && other.XShift != null && XShift.Equals(other.XShift)) &&
                   (YRef == other.YRef && YRef != null && other.YRef != null && YRef.Equals(other.YRef)) &&
                   (Y == other.Y && Y != null && other.Y != null && Y.Equals(other.Y)) &&
                   (YAnchor == other.YAnchor && YAnchor != null && other.YAnchor != null && YAnchor.Equals(other.YAnchor)) &&
                   (YShift == other.YShift && YShift != null && other.YShift != null && YShift.Equals(other.YShift)) &&
                   (ClickToShow == other.ClickToShow && ClickToShow != null && other.ClickToShow != null && ClickToShow.Equals(other.ClickToShow)) &&
                   (XClick == other.XClick && XClick != null && other.XClick != null && XClick.Equals(other.XClick)) &&
                   (YClick == other.YClick && YClick != null && other.YClick != null && YClick.Equals(other.YClick)) &&
                   (HoverText == other.HoverText && HoverText != null && other.HoverText != null && HoverText.Equals(other.HoverText)) &&
                   (HoverLabel == other.HoverLabel && HoverLabel != null && other.HoverLabel != null && HoverLabel.Equals(other.HoverLabel)) &&
                   (CaptureEvents == other.CaptureEvents && CaptureEvents != null && other.CaptureEvents != null && CaptureEvents.Equals(other.CaptureEvents)) &&
                   (Name == other.Name && Name != null && other.Name != null && Name.Equals(other.Name)) &&
                   (TemplateItemName == other.TemplateItemName && TemplateItemName != null && other.TemplateItemName != null && TemplateItemName.Equals(other.TemplateItemName)));
        }
Exemplo n.º 8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set the header icon. (Thanks to a post by Eddie Velasquez.)
		/// </summary>
		/// <param name="columnIndex">Index of the column.</param>
		/// <param name="sortOrder">The sort order.</param>
		/// <param name="size">The size.</param>
		/// ------------------------------------------------------------------------------------
		public void ShowHeaderIcon(int columnIndex, SortOrder sortOrder, ArrowSize size)
		{
			CheckDisposed();

			if (columnIndex < 0 || columnIndex >= this.Columns.Count)
				return;

			IntPtr hHeader = SendMessage(this.Handle, LVM_GETHEADER, IntPtr.Zero, IntPtr.Zero);

			ColumnHeader colHdr = this.Columns[columnIndex];

			// Setting these icons happens during view startup BEFORE we restore the saved settings,
			// so saving the current ones overwrites the saved ones. Anyway, modifying the icon
			// doesn't modif the width, so doing anything about column widths would be a waste.
			bool oldSuppress = SuppressColumnWidthChanges;
			SuppressColumnWidthChanges = true;
			// the following commented out code uses the default visual style sort arrows,
			// we are not using them so that we can use different size arrows
			//if (Application.RenderWithVisualStyles)
			//{
			//    IntPtr colPtr = new IntPtr(columnIndex);
			//    HDITEM hd = new HDITEM();
			//    hd.mask = HDI_FORMAT;
			//    SendMessage2(hHeader, HDM_GETITEM, colPtr, ref hd);
			//    if (sortOrder != SortOrder.None)
			//    {
			//        switch (sortOrder)
			//        {
			//            case SortOrder.Ascending:
			//                hd.fmt &= ~HDF_SORTDOWN;
			//                hd.fmt |= HDF_SORTUP;
			//                break;

			//            case SortOrder.Descending:
			//                hd.fmt &= ~HDF_SORTUP;
			//                hd.fmt |= HDF_SORTDOWN;
			//                break;
			//        }
			//    }
			//    else
			//    {
			//        hd.fmt &= ~HDF_SORTDOWN & ~HDF_SORTUP;
			//    }

			//    SendMessage2(hHeader, HDM_SETITEM, colPtr, ref hd);
			//}
			//else
			//{
			HDITEM hd = new HDITEM();
			hd.mask = HDI_IMAGE | HDI_FORMAT;

			HorizontalAlignment align = colHdr.TextAlign;

			if (align == HorizontalAlignment.Left)
				hd.fmt = HDF_LEFT | HDF_STRING | HDF_BITMAP_ON_RIGHT;

			else if (align == HorizontalAlignment.Center)
				hd.fmt = HDF_CENTER | HDF_STRING | HDF_BITMAP_ON_RIGHT;

			else	// HorizontalAlignment.Right
				hd.fmt = HDF_RIGHT | HDF_STRING;

			if (sortOrder != SortOrder.None)
			{
				hd.fmt |= HDF_IMAGE;
			}

			if (sortOrder == SortOrder.None)
				hd.iImage = -1;
			else
			{
				// There are 3 potential sizes: Large, Medium, and Small with 2 sort orders, Ascending and Descending
				// The images are stored in that order, so the following works
				hd.iImage = (int)size + (3 * ((int)sortOrder - 1));
			}

			SendMessage2(hHeader, HDM_SETITEM, new IntPtr(columnIndex), ref hd);
			//}
			SuppressColumnWidthChanges = oldSuppress;

			Update();
		}
Exemplo n.º 9
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create up/down icon (Adapted from a post by Eddie Velasquez.)
		/// </summary>
		/// <param name="type">The type.</param>
		/// <param name="size">The size.</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		Bitmap GetArrowBitmap(ArrowType type, ArrowSize size)
		{
			int offset;
			switch(size)
			{
				case ArrowSize.Large:
					offset = 0;
					break;
				case ArrowSize.Medium:
					offset = 2;
					break;
				case ArrowSize.Small:
					offset = 3;
					break;
				default:
					offset = 0;
					break;
			}

			Bitmap bmp = new Bitmap(kHalfArrowSize * 2, kHalfArrowSize * 2);
			using (Graphics gfx = Graphics.FromImage(bmp))
			{
				Brush brush = new SolidBrush(Color.FromArgb(215,230,255));
				Pen pen = new Pen(Color.FromArgb(49,106,197));

				gfx.FillRectangle(new SolidBrush(Color.FromKnownColor(KnownColor.ControlLight)), 0, 0, kHalfArrowSize * 2, kHalfArrowSize * 2);

				Point[] points = null;
				if(type == ArrowType.Ascending)
				{
//					Point left = new Point(kHalfArrowSize, 0);
//					Point right = new Point(kHalfArrowSize, 0);
//					for (int i = 0; i < kHalfArrowSize; i++)
//					{
//						left.X -= 1;
//						right.X += 1;
//						gfx.DrawLine(pen, left, right);
//						left.Y += 1;
//						right.Y += 1;
//						gfx.DrawLine(pen, left, right);
//						left.Y += 1;
//						right.Y += 1;
//					}
					points = new Point[] { new Point(kHalfArrowSize, offset), new Point(kHalfArrowSize * 2 - 1 - offset, kHalfArrowSize * 2 - 1 - offset),
						new Point(offset,kHalfArrowSize * 2 - 1 - offset)};
					gfx.FillPolygon(brush, points);
					gfx.DrawPolygon(pen, points);
				}
				else if(type == ArrowType.Descending)
				{
					points = new Point[] { new Point(offset,offset), new Point(kHalfArrowSize * 2 - 1 - offset, offset), new Point(kHalfArrowSize,kHalfArrowSize * 2 - 1 - offset)};
					gfx.FillPolygon(brush, points);
					gfx.DrawPolygon(pen, points);
				}
			}

			return bmp;
		}
Exemplo n.º 10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Set the header icon. (Thanks to a post by Eddie Velasquez.)
		/// </summary>
		/// <param name="columnIndex">Index of the column.</param>
		/// <param name="sortOrder">The sort order.</param>
		/// <param name="size">The size.</param>
		/// ------------------------------------------------------------------------------------
		public void ShowHeaderIcon(int columnIndex, SortOrder sortOrder, ArrowSize size)
		{
			CheckDisposed();

			if (columnIndex < 0 || columnIndex >= Columns.Count)
				return;

			if (sortOrder == SortOrder.None)
			{
				m_columnIconIndexes.Remove(columnIndex);
			}
			else
			{
				// There are 3 potential sizes: Large, Medium, and Small with 2 sort orders, Ascending and Descending
				// The images are stored in that order, so the following works
				m_columnIconIndexes[columnIndex] = (int)size + (3 * ((int)sortOrder - 1));
			}
		}