Private Sub MenuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuExit.Click Application.Exit() End Sub Private Sub CopyImageFromCurrentItem() Dim ItemIndex As Integer Dim Img As SftPictureObject ItemIndex = AxSftTree1.Items.Current If ItemIndex < 0 Then Exit Sub ' don't use images that are too large in the other areas Img = AxSftTree1.get_Cell(ItemIndex, 0).Image If Img.ActualHeight <= 20 And Img.ActualWidth <= 20 Then AxSftTree1.RowColumnHeader.Image = Img AxSftTree1.get_Header(1).Image = Img Else AxSftTree1.RowColumnHeader.Image.Clear() AxSftTree1.get_Header(1).Image.Clear() End If End Sub Private Sub ToggleImage(ByVal Img As SftPictureObject) Select Case Img.Appearance Case SftPictureImageConstants.sftImageCheckboxNo Img.Appearance = SftPictureImageConstants.sftImageCheckboxYes Case SftPictureImageConstants.sftImageCheckboxYes Img.Appearance = SftPictureImageConstants.sftImageCheckboxNo Case SftPictureImageConstants.sftImageCheckboxUnknown Img.Appearance = SftPictureImageConstants.sftImageCheckboxNo Case SftPictureImageConstants.sftImageCheckboxNoDisabled Img.Appearance = SftPictureImageConstants.sftImageCheckboxYesDisabled Case SftPictureImageConstants.sftImageCheckboxYesDisabled Img.Appearance = SftPictureImageConstants.sftImageCheckboxNoDisabled Case SftPictureImageConstants.sftImageCheckboxUnknownDisabled Img.Appearance = SftPictureImageConstants.sftImageCheckboxNoDisabled Case SftPictureImageConstants.sftImageRadioButtonNo Img.Appearance = SftPictureImageConstants.sftImageRadioButtonYes Case SftPictureImageConstants.sftImageRadioButtonYes Img.Appearance = SftPictureImageConstants.sftImageRadioButtonNo Case SftPictureImageConstants.sftImageRadioButtonNoDisabled Img.Appearance = SftPictureImageConstants.sftImageRadioButtonYesDisabled Case SftPictureImageConstants.sftImageRadioButtonYesDisabled Img.Appearance = SftPictureImageConstants.sftImageRadioButtonNoDisabled Case SftPictureImageConstants.sftImageUp Img.Appearance = SftPictureImageConstants.sftImageDown Case SftPictureImageConstants.sftImageUpDisabled Img.Appearance = SftPictureImageConstants.sftImageDownDisabled Case SftPictureImageConstants.sftImageDown Img.Appearance = SftPictureImageConstants.sftImageUp Case SftPictureImageConstants.sftImageDownDisabled Img.Appearance = SftPictureImageConstants.sftImageUpDisabled Case SftPictureImageConstants.sftImageSortAsc Img.Appearance = SftPictureImageConstants.sftImageSortDesc Case SftPictureImageConstants.sftImageSortAscDisabled Img.Appearance = SftPictureImageConstants.sftImageSortDescDisabled Case SftPictureImageConstants.sftImageSortDesc Img.Appearance = SftPictureImageConstants.sftImageSortAsc Case SftPictureImageConstants.sftImageSortDescDisabled Img.Appearance = SftPictureImageConstants.sftImageSortAscDisabled End Select End Sub Private Sub PropagateImage(ByVal ItemIndex As Integer, ByVal Img As SftPictureObject) ' don't use images that are too large in the other areas If Img.ActualHeight <= 20 And Img.ActualWidth < 20 Then AxSftTree1.get_Item(ItemIndex).Image = Img AxSftTree1.get_Item(ItemIndex).LabelImage = Img AxSftTree1.get_Item(ItemIndex).RowHeader.Image = Img End If End Sub Private Sub UpdatePictures(ByVal ItemIndex As Integer, ByVal IPic As stdole.IPictureDisp, ByVal Align As SftTreeHAlignConstants) Dim C As SftTreeCell C = AxSftTree1.get_Cell(ItemIndex, 0) C.Image.Picture = IPic C.ImageHAlign = Align PropagateImage(ItemIndex, C.Image) End Sub Private Sub UpdateImages(ByVal ItemIndex As Integer, ByVal Img As Image, ByVal Align As SftTreeHAlignConstants) Dim C As SftTreeCell C = AxSftTree1.get_Cell(ItemIndex, 0) C.Image.NETImageObject = Img C.ImageHAlign = Align PropagateImage(ItemIndex, C.Image) End Sub Private Sub UpdateImageList(ByVal ItemIndex As Integer, ByVal ImageListControl As ImageList, ByVal i As Integer, ByVal Align As SftTreeHAlignConstants) Dim C As SftTreeCell C = AxSftTree1.get_Cell(ItemIndex, 0) C.Image.SetImageListH(ImageListControl.Handle.ToInt32(), i) C.ImageHAlign = Align PropagateImage(ItemIndex, C.Image) End Sub Private Sub UpdateColor(ByVal ItemIndex As Integer, ByVal Clr As System.Drawing.Color, ByVal Align As SftTreeHAlignConstants) Dim C As SftTreeCell C = AxSftTree1.get_Cell(ItemIndex, 0) C.Image.SetColorSample(Convert.ToUInt32(ColorTranslator.ToOle(Clr) And &HFFFFFFFF&), _ Convert.ToUInt32(ColorTranslator.ToOle(Color.Black) And &HFFFFFFFF&)) C.Image.Width = 12 C.Image.Height = 12 C.ImageHAlign = Align PropagateImage(ItemIndex, C.Image) End Sub Private Sub AddColor(ByVal Text As String, ByVal Clr As Color) Dim i As Integer i = AxSftTree1.Items.Add(Text) AxSftTree1.get_Item(i).Level = 2 UpdateColor(i, Clr, SftTreeHAlignConstants.halignSftTreeRight) End Sub Private Sub UpdateBuiltinImage(ByVal ItemIndex As Integer, ByVal Style As SftPictureImageConstants, ByVal wPix As Integer, ByVal hPix As Integer, ByVal Align As SftTreeHAlignConstants) Dim C As SftTreeCell C = AxSftTree1.get_Cell(ItemIndex, 0) C.Image.Appearance = Style C.Image.Width = wPix C.Image.Height = hPix C.ImageHAlign = Align PropagateImage(ItemIndex, C.Image) End Sub Private Sub AddBuiltinImage(ByVal Text As String, ByVal Style As SftPictureImageConstants, ByVal wPix As Integer, ByVal hPix As Integer) Dim i As Integer i = AxSftTree1.Items.Add(Text) AxSftTree1.get_Item(i).Level = 2 UpdateBuiltinImage(i, Style, wPix, hPix, SftTreeHAlignConstants.halignSftTreeRight) End Sub Private Sub ShowSortDirection(ByVal Ascending As Boolean) If (Ascending) Then AxSftTree1.get_Header(0).Image.Appearance = SftPictureImageConstants.sftImageSortAsc Else AxSftTree1.get_Header(0).Image.Appearance = SftPictureImageConstants.sftImageSortDesc End If m_SortDirection = Ascending End Sub Private Sub SetSortDirection(ByVal NewDirection As Boolean) ShowSortDirection(NewDirection) If NewDirection Then AxSftTree1.Items.SortDependents(-1, 0, SftTreeSortTypeConstants.sortSftTreeAscending) Else AxSftTree1.Items.SortDependents(-1, 0, SftTreeSortTypeConstants.sortSftTreeDescending) End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load AxSftTree1.Dock = DockStyle.Fill Dim ItemIndex As Integer ItemIndex = AxSftTree1.Items.Add("Progress Bars") AxSftTree1.get_Cell(ItemIndex, 1).Text = "SftTree/OCX supports progress bars as cell background (partial or full size)." Dim I As Integer I = AxSftTree1.Items.Add("Progress Bar - Full Size") AxSftTree1.get_Item(I).Level = 1 AxSftTree1.get_Cell(I, 0).ProgressMax = 100 ' maximum value 0-100 AxSftTree1.get_Cell(I, 0).ProgressValue = 33 ' current value I = AxSftTree1.Items.Add("Progress Bar - Partial") AxSftTree1.get_Item(I).Level = 1 AxSftTree1.get_Cell(I, 0).ProgressColorOrientation = SftTreeOrientationDefaultConstants.horizontalDefaultOrientationSftTree AxSftTree1.get_Cell(I, 0).ProgressStyle = SftTreeProgressStyleDefaultConstants.smallDefaultProgressStyleSftTree AxSftTree1.get_Cell(I, 0).ProgressMax = 200 ' maximum value 0-200 AxSftTree1.get_Cell(I, 0).ProgressValue = 33 ' current value I = AxSftTree1.Items.Add("Progress Bar - with gradient fill") AxSftTree1.get_Item(I).Level = 1 AxSftTree1.get_Cell(I, 0).ProgressColorOrientation = SftTreeOrientationDefaultConstants.horizontalDefaultOrientationSftTree AxSftTree1.get_Cell(I, 0).ProgressStyle = SftTreeProgressStyleDefaultConstants.smallDefaultProgressStyleSftTree AxSftTree1.get_Cell(I, 0).ProgressColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.FromArgb(128, 128, 0)) And &HFFFFFFFF&) AxSftTree1.get_Cell(I, 0).ProgressColorEnd = Convert.ToUInt32(ColorTranslator.ToOle(Color.FromArgb(255, 255, 0)) And &HFFFFFFFF&) AxSftTree1.get_Cell(I, 0).ProgressMax = 50 ' maximum value 0-50 AxSftTree1.get_Cell(I, 0).ProgressValue = 40 ' current value I = AxSftTree1.Items.Add("Progress Bar - customizable colors") AxSftTree1.get_Item(I).Level = 1 AxSftTree1.get_Cell(I, 0).ProgressColorOrientation = SftTreeOrientationDefaultConstants.verticalDefaultOrientationSftTree AxSftTree1.get_Cell(I, 0).ProgressStyle = SftTreeProgressStyleDefaultConstants.smallDefaultProgressStyleSftTree AxSftTree1.get_Cell(I, 0).ProgressColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.FromArgb(128, 128, 0)) And &HFFFFFFFF&) AxSftTree1.get_Cell(I, 0).ProgressColorEnd = Convert.ToUInt32(ColorTranslator.ToOle(Color.FromArgb(255, 255, 0)) And &HFFFFFFFF&) AxSftTree1.get_Cell(I, 0).ProgressMax = 150 ' maximum value 0-150 AxSftTree1.get_Cell(I, 0).ProgressValue = 40 ' current value AxSftTree1.get_Cell(I, 0).BackColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.FromKnownColor(KnownColor.Window)) And &HFFFFFFFF&) AxSftTree1.get_Cell(I, 0).BackColorEnd = Convert.ToUInt32(ColorTranslator.ToOle(Color.FromArgb(255, 0, 0)) And &HFFFFFFFF&) AxSftTree1.get_Cell(I, 0).BackColorOrientation = SftTreeOrientationDefaultConstants.horizontalDefaultOrientationSftTree ItemIndex = AxSftTree1.Items.Add("Supported Picture Types") AxSftTree1.get_Cell(ItemIndex, 1).Text = "SftTree/OCX supports numerous image types, such as GDI+, bitmaps, icons, ImageLists and also offers numerous built-in images.." ' add GDI+ samples ItemIndex = AxSftTree1.Items.Add("GDI+ Images") AxSftTree1.get_Item(ItemIndex).Level = 1 AxSftTree1.get_Cell(ItemIndex, 1).Text = "All GDI+ images are supported, like GIF, JPEG, Exif, PNG, TIFF and device-independent bitmaps (up to 64bpp) with semi-transparent and translucent areas." I = AxSftTree1.Items.Add("PNG Sample with alpha-channel for translucent edges") AxSftTree1.get_Item(I).Level = 2 UpdateImages(I, PicturePNG1.Image, SftTreeHAlignConstants.halignSftTreeRight) I = AxSftTree1.Items.Add("Another PNG Sample with alpha-channel for translucent edges") AxSftTree1.get_Item(I).Level = 2 UpdateImages(I, PicturePNG2.Image, SftTreeHAlignConstants.halignSftTreeRight) ' add bitmap samples ItemIndex = AxSftTree1.Items.Add("Bitmaps") AxSftTree1.get_Item(ItemIndex).Level = 1 AxSftTree1.get_Cell(ItemIndex, 1).Text = "Bitmaps can be of varying sizes and also support Bitmap Transparency, which allows the background to show through the image (in areas selected by the bitmap designer)." I = AxSftTree1.Items.Add("Large Bitmap") AxSftTree1.get_Item(I).Level = 2 UpdateImages(I, PictureLogo.Image, SftTreeHAlignConstants.halignSftTreeRight) I = AxSftTree1.Items.Add("Various bitmap sizes") AxSftTree1.get_Item(I).Level = 2 UpdateImages(I, PictureSmallBitmap.Image, SftTreeHAlignConstants.halignSftTreeRight) ' add icon samples ItemIndex = AxSftTree1.Items.Add("Icons") AxSftTree1.get_Item(ItemIndex).Level = 1 AxSftTree1.get_Cell(ItemIndex, 1).Text = "The supported icons can be stardard size icons (32x32) or any other size supported by the operating system." I = AxSftTree1.Items.Add("Standard Icon (32x32)") AxSftTree1.get_Item(I).Level = 2 UpdateImages(I, PictureIcon.Image, SftTreeHAlignConstants.halignSftTreeRight) I = AxSftTree1.Items.Add("Any other size") AxSftTree1.get_Item(I).Level = 2 UpdateImages(I, PictureIconSmall.Image, SftTreeHAlignConstants.halignSftTreeRight) ' add imagelist samples ItemIndex = AxSftTree1.Items.Add("ImageLists") AxSftTree1.get_Item(ItemIndex).Level = 1 AxSftTree1.get_Cell(ItemIndex, 1).Text = "Complete ImageList support simplifies bitmap handling and can avoid the limited resource availability on earlier Windows versions." Dim C As Integer For C = 0 To imageList1.Images.Count - 1 I = AxSftTree1.Items.Add("Image " & C) AxSftTree1.get_Item(I).Level = 2 UpdateImageList(I, imageList1, C, SftTreeHAlignConstants.halignSftTreeRight) Next ' add color samples ItemIndex = AxSftTree1.Items.Add("Color Samples") AxSftTree1.get_Item(ItemIndex).Level = 1 AxSftTree1.get_Cell(ItemIndex, 1).Text = "Using the built-in color sample image, simple color selection can easily be implemented. Color samples can display all colors available." AddColor("Black", System.Drawing.Color.Black) AddColor("Blue", System.Drawing.Color.Blue) AddColor("Cyan", System.Drawing.Color.Cyan) AddColor("Green", System.Drawing.Color.Lime) AddColor("Magenta", System.Drawing.Color.Magenta) AddColor("Red", System.Drawing.Color.Red) AddColor("White", System.Drawing.Color.White) AddColor("Yellow", System.Drawing.Color.Yellow) AddColor("3DDKSHADOW - Dark shadow for 3D elements", System.Drawing.SystemColors.ControlDarkDark) AddColor("3DFACE - Face color for 3D elements", System.Drawing.SystemColors.Control) AddColor("3DHILIGHT - Edges facing the light source", System.Drawing.SystemColors.ControlLightLight) AddColor("3DLIGHT - Edges facing the light source", System.Drawing.SystemColors.ControlLight) AddColor("3DSHADOW - Edges facing away from the light source", System.Drawing.SystemColors.ControlDark) AddColor("INFOBK - Background color for tooltip controls", System.Drawing.SystemColors.Info) AddColor("INFOTEXT - Text color for tooltip controls", System.Drawing.SystemColors.InfoText) AddColor("MENUTEXT - Text in menus", System.Drawing.SystemColors.MenuText) AddColor("ACTIVEBORDER - Active window border", System.Drawing.SystemColors.ActiveBorder) AddColor("ACTIVECAPTION - Active window caption", System.Drawing.SystemColors.ActiveCaption) AddColor("APPWORKSPACE - Background color MDI applications", System.Drawing.SystemColors.AppWorkspace) AddColor("BACKGROUND - Desktop", System.Drawing.SystemColors.Desktop) AddColor("BTNFACE - Face shading on push buttons", System.Drawing.SystemColors.Control) AddColor("BTNHILIGHT - Highlight color for buttons", System.Drawing.SystemColors.ControlLightLight) AddColor("BTNSHADOW - Edge shading on push buttons", System.Drawing.SystemColors.ControlDark) AddColor("BTNTEXT - Text on push buttons", System.Drawing.SystemColors.ControlText) AddColor("CAPTIONTEXT - Text in caption", System.Drawing.SystemColors.ActiveCaptionText) AddColor("GRAYTEXT - Grayed (disabled) text", System.Drawing.SystemColors.GrayText) AddColor("HIGHLIGHT - Selected Item(s)", System.Drawing.SystemColors.Highlight) AddColor("HIGHLIGHTTEXT - Text of selected item(s)", System.Drawing.SystemColors.HighlightText) AddColor("INACTIVEBORDER - Inactive window border", System.Drawing.SystemColors.InactiveBorder) AddColor("INACTIVECAPTION - Inactive window caption", System.Drawing.SystemColors.InactiveCaption) AddColor("INACTIVECAPTIONTEXT - Inactive caption text color", System.Drawing.SystemColors.InactiveCaptionText) AddColor("MENU - Menu background", System.Drawing.SystemColors.Menu) AddColor("SCROLLBAR - Scroll bar gray area", System.Drawing.SystemColors.ScrollBar) AddColor("WINDOW - Window background", System.Drawing.SystemColors.Window) AddColor("WINDOWFRAME - Window frame", System.Drawing.SystemColors.WindowFrame) AddColor("WINDOWTEXT - Text in windows", System.Drawing.SystemColors.WindowText) ' add predefined image samples ItemIndex = AxSftTree1.Items.Add("Predefined (Built-in) Pictures") AxSftTree1.get_Cell(ItemIndex, 1).Text = "Predefined images are available for commonly used items, such as check boxes, radio buttons, sort direction indicators and more..." ItemIndex = AxSftTree1.Items.Add("Check Boxes - Honors Windows Themes") AxSftTree1.get_Item(ItemIndex).Level = 1 AddBuiltinImage("Enabled, Selected Check Box", SftPictureImageConstants.sftImageCheckboxYes, 14, 14) AddBuiltinImage("Disabled, Selected Check Box", SftPictureImageConstants.sftImageCheckboxYesDisabled, 14, 14) AddBuiltinImage("Enabled Check Box", SftPictureImageConstants.sftImageCheckboxNo, 14, 14) AddBuiltinImage("Disabled Check Box", SftPictureImageConstants.sftImageCheckboxNoDisabled, 14, 14) AddBuiltinImage("Enabled, Unknown Check Box", SftPictureImageConstants.sftImageCheckboxUnknown, 14, 14) AddBuiltinImage("Disabled, Unknown Check Box", SftPictureImageConstants.sftImageCheckboxUnknownDisabled, 14, 14) ItemIndex = AxSftTree1.Items.Add("Radio Buttons - Honors Windows Themes") AxSftTree1.get_Item(ItemIndex).Level = 1 AddBuiltinImage("Enabled, Selected Radio Button", SftPictureImageConstants.sftImageRadioButtonYes, 14, 14) AddBuiltinImage("Disabled, Selected Radio Button", SftPictureImageConstants.sftImageRadioButtonYesDisabled, 14, 14) AddBuiltinImage("Enabled Radio Button", SftPictureImageConstants.sftImageRadioButtonNo, 14, 14) AddBuiltinImage("Disabled Radio Button", SftPictureImageConstants.sftImageRadioButtonNoDisabled, 14, 14) ItemIndex = AxSftTree1.Items.Add("Up/Down Buttons - Honors Windows Themes") AxSftTree1.get_Item(ItemIndex).Level = 1 AddBuiltinImage("Enabled Up Button", SftPictureImageConstants.sftImageUp, 14, 14) AddBuiltinImage("Disabled Up Button", SftPictureImageConstants.sftImageUpDisabled, 14, 14) AddBuiltinImage("Enabled Down Button", SftPictureImageConstants.sftImageDown, 14, 14) AddBuiltinImage("Disabled Down Button", SftPictureImageConstants.sftImageDownDisabled, 14, 14) ItemIndex = AxSftTree1.Items.Add("Sort Direction Indicator") AxSftTree1.get_Item(ItemIndex).Level = 1 AddBuiltinImage("Enabled Ascending Indicator", SftPictureImageConstants.sftImageSortAsc, 8, 8) AddBuiltinImage("Disabled Ascending Indicator", SftPictureImageConstants.sftImageSortAscDisabled, 8, 8) AddBuiltinImage("Enabled Descending Indicator", SftPictureImageConstants.sftImageSortDesc, 8, 8) AddBuiltinImage("Disabled Descending Indicator", SftPictureImageConstants.sftImageSortDescDisabled, 8, 8) AxSftTree1.RowHeaders.MakeOptimal() ' make the row headers optimal AxSftTree1.get_Column(0).MakeOptimal() ' make the first column optimal AxSftTree1.Items.RecalcHorizontalExtent() ' update horizontal scroll bar AxSftTree1.get_Item(0).Selected = True AxSftTree1.Items.Current = 0 CopyImageFromCurrentItem() End Sub Private Sub AxSftTree1_ItemClick(ByVal sender As Object, ByVal e As AxSftTreeLib70._DSftTreeEvents_ItemClickEvent) Handles AxSftTree1.ItemClick Dim AreaType As SftTreeAreaTypeConstants AreaType = e.areaType If AreaType = SftTreeAreaTypeConstants.constSftTreeExpandAll Then AxSftTree1.get_Item(e.itemIndex).Expand(True, True) ElseIf AreaType = SftTreeAreaTypeConstants.constSftTreeColumn And e.colIndex = 0 Then SetSortDirection(Not m_SortDirection) ElseIf AreaType = SftTreeAreaTypeConstants.constSftTreeCellGraphic Then ToggleImage(AxSftTree1.get_Cell(e.itemIndex, e.colIndex).Image) ElseIf AreaType = SftTreeAreaTypeConstants.constSftTreeItem Then ToggleImage(AxSftTree1.get_Item(e.itemIndex).Image) ElseIf AreaType = SftTreeAreaTypeConstants.constSftTreeLabel Then ToggleImage(AxSftTree1.get_Item(e.itemIndex).LabelImage) End If End Sub Private Sub AxSftTree1_ItemDblClick(ByVal sender As Object, ByVal e As AxSftTreeLib70._DSftTreeEvents_ItemDblClickEvent) Handles AxSftTree1.ItemDblClick Dim AreaType As SftTreeAreaTypeConstants AreaType = e.areaType If AreaType = SftTreeAreaTypeConstants.constSftTreeColumnRes Then AxSftTree1.get_Column(e.colIndex).MakeOptimal() ' Make column width optimal AxSftTree1.Items.RecalcHorizontalExtent() ' Update horizontal scroll bar ElseIf AreaType = SftTreeAreaTypeConstants.constSftTreeColumn And e.colIndex = 0 Then SetSortDirection(Not m_SortDirection) ElseIf AreaType = SftTreeAreaTypeConstants.constSftTreeCellGraphic Then ToggleImage(AxSftTree1.get_Cell(e.itemIndex, e.colIndex).Image) End If End Sub Private Sub AxSftTree1_SelectionChange(ByVal sender As Object, ByVal e As System.EventArgs) Handles AxSftTree1.SelectionChange CopyImageFromCurrentItem() End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick ' update all cells that have a progress bar by incrementing the progress value Dim Items As Integer = AxSftTree1.Items.Count Dim Cols As Integer = AxSftTree1.ColumnsObj.Count For Item As Integer = 0 To Items - 1 Dim CellObj As ISftTreeCell CellObj = AxSftTree1.get_Cell(Item, 0) If CellObj.ProgressMax > 0 Then CellObj.ProgressValue = (CellObj.ProgressValue + 4) Mod CellObj.ProgressMax End If Next End Sub End Class