See the top rated post in this thread. Click here

Results 1 to 1 of 1

Thread: Slide Shows of Images and Drawing Images

  1. #1
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,106
    Login to Give a bone
    1

    Default Slide Shows of Images and Drawing Images

    Well after playing with the splash screen program, I liked the fact you could display image files in a dialog, which LISP cannot do without using slides.

    I also thought it might be nice to create a Slide Show, using a timer and a listbox.

    So here it is on you tube.

    http://www.youtube.com/watch?v=NVS59...ature=youtu.be

    If you like what you see you could download the attachments.

    Here is the LISP file that calls the new .net function

    Code:
    (defun C:Slides ()
     (slideshow "c:\\slideshow\\testbitmap.dwg" "photo1.jpg" "photo2.jpg" "photo3.jpg" "photo4.jpg" "photo5.jpg")
    )
    
    (defun C:Slides2 ()
     (slideshow (list "c:\\slideshow\\testbitmap.dwg" "photo1.jpg" "photo2.jpg" "photo3.jpg" "photo4.jpg" "photo5.jpg"))
    )
    This is the dialog appearance:

    SlideShowDialog.jpg

    Panel1(Image), Button1(OK), Button2(Cancel), Button3(SlideShowOnOff), Listbox1(ImageFiles)

    This is the Form1 Code

    Code:
    Imports Autodesk.AutoCAD.DatabaseServices
    
    Public Class Form1
        ''' <summary>
        ''' OK Button
        ''' </summary>
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            SlideShowClass1.objTimer.Stop()
            SlideShowClass1.strImageFullName = ListBox1.SelectedItem.ToString
            Close()
        End Sub
    
        ''' <summary>
        ''' Cancel Button
        ''' </summary>
    
        Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
            SlideShowClass1.objTimer.Stop()
            Close()
        End Sub
    
        ''' <summary>
        ''' Turn Slide Show On and Off Button
        ''' </summary>
    
        Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
            If SlideShowClass1.blnSlideShowOn = True Then
                SlideShowClass1.blnSlideShowOn = False
                Button3.Text = "Turn Slide Show On"
            Else
                SlideShowClass1.blnSlideShowOn = True
                Button3.Text = "Turn Slide Show Off"
            End If
        End Sub
    
        ''' <summary>
        ''' List Box Selection Callback changes image of Panel1 to image file or drawing thumbnail
        ''' </summary>
    
        Private Sub ListBox1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ListBox1.SelectedIndexChanged
            Try
                SlideShowClass1.strImageFullName = Me.ListBox1.SelectedItem.ToString
                If System.IO.Path.GetExtension(SlideShowClass1.strImageFullName).ToUpper = ".DWG" Then
                    Dim objDatabase As New Database
                    objDatabase.ReadDwgFile(SlideShowClass1.strImageFullName, _
                                            FileOpenMode.OpenForReadAndAllShare, False, Nothing)
                    Me.Panel1.BackgroundImage = objDatabase.ThumbnailBitmap
                Else
                    Me.Panel1.BackgroundImage = System.Drawing.Image.FromFile(SlideShowClass1.strImageFullName)
                End If
                Me.BringToFront()
            Catch ex As Exception
            End Try
        End Sub
    
    End Class
    and this is the class code

    Code:
    Imports Autodesk.AutoCAD.ApplicationServices
    Imports Autodesk.AutoCAD.DatabaseServices
    Imports Autodesk.AutoCAD.EditorInput
    Imports Autodesk.AutoCAD.Runtime
    
    Imports System.Windows.Forms
    
    Imports objACADApplication = Autodesk.AutoCAD.ApplicationServices.Application
    Public Class SlideShowClass1
        Private tpvNil As New TypedValue(LispDataType.Nil, -1)
    
        Public Shared objForm As New Form1
        Public Shared objTimer As System.Windows.Forms.Timer
        Public Shared blnSlideShowOn As Boolean = True
        Public Shared strImageFullName As String
    
        ''' <summary>
        ''' LISP Function to show slide show of images (or drawing thumbnail images)
        ''' </summary>
    
        <LispFunction("SlideShow")> _
        Public Function SlideShow(ByVal rbfArguments As ResultBuffer)
            Try
    
                Dim arrArguments As TypedValue() = rbfArguments.AsArray
                If arrArguments.Length > 0 Then
    
                    Dim strImageFullName, strImageName As String
                    ' Dim tpvItem As TypedValue()
    
                    blnSlideShowOn = True
    
                    If Not objForm Is Nothing Then objForm = New Form1
    
                    With objForm.ListBox1
                        If .Items.Count > 0 Then .Items.Clear()
                        For intCount = 0 To arrArguments.Length - 1
                            If arrArguments(intCount).TypeCode = 5005 Then
                                strImageName = arrArguments(intCount).Value.ToString
                                strImageFullName = HostApplicationServices.Current.FindFile(strImageName, _
                                                   objACADApplication.DocumentManager.MdiActiveDocument.Database, _
                                                   FindFileHint.Default)
                                If strImageFullName IsNot Nothing Then .Items().Add(strImageFullName)
                            End If
                        Next
                        strImageFullName = ""
                        If .Items.Count = 0 Then Return tpvNil
                        .SelectedIndex = 0
                        TimerInitialize(2000.0) '<- Milliseconds
                        If objForm.ShowDialog() = DialogResult.Cancel Then
                            Return tpvNil
                        End If
    
                    End With
                End If
     
                Return New TypedValue(LispDataType.Text, strImageFullName)
            Catch ex As System.Exception
            End Try
            Return tpvNil
        End Function
    
        ''' <summary>
        ''' Function to initialize the forms timer
        ''' </summary>
    
        Private Function TimerInitialize(ByVal dblMilliseconds As Double)
            Try
                If objTimer Is Nothing Then
                    objTimer = New System.Windows.Forms.Timer
                    AddHandler objTimer.Tick, AddressOf TickHandler
                End If
                objTimer.Interval = CType(dblMilliseconds, Integer)
                objTimer.Enabled = True
                objTimer.Start()
    
                Return True
            Catch ex As Exception
            End Try
            Return False
        End Function
    
        ''' <summary>
        ''' Timer Callback Function to switch image
        ''' </summary>
    
        Private Sub TickHandler(ByVal sender As Object, ByVal e As System.EventArgs)
            ImageChange(objForm.ListBox1)
        End Sub
    
        Public Delegate Sub ListBoxDelegate(ByVal objListBox As ListBox)
    
        ''' <summary>
        ''' Function to Change Image in Listbox to next image
        ''' </summary>
    
        Public Sub ImageChange(ByVal objListBox As ListBox)
            objForm.BringToFront()
            If objListBox.InvokeRequired Then
                objListBox.Invoke(New ListBoxDelegate(AddressOf ImageChange), objListBox)
            Else
                If blnSlideShowOn Then
                    With objForm
                        If .ListBox1.Items.Count > 0 Then
                            If .ListBox1.SelectedIndex < .ListBox1.Items.Count - 1 Then
                                .ListBox1.SelectedIndex += 1
                            Else
                                .ListBox1.SelectedIndex = 0
                            End If
                        End If
                    End With
                End If
            End If
        End Sub
    
    End Class
    I should mention that I coded this in Visual Studio 2013 and used AutoCAD 2014 for the code package
    Attached Files Attached Files
    Last edited by peter; 2014-01-25 at 05:34 PM.
    AutomateCAD

Similar Threads

  1. Slide Images, Wide Polylines, and DCL Image Tiles
    By jasontyde in forum AutoCAD Customization
    Replies: 3
    Last Post: 2014-08-13, 04:17 PM
  2. 2012: Ghost Images and Lines On-Screen and in Exported Images
    By cwride in forum Revit - Plotting/Printing/Exporting
    Replies: 0
    Last Post: 2012-08-15, 08:49 PM
  3. Slide Library images not showing
    By Grumple in forum AutoCAD General
    Replies: 12
    Last Post: 2010-04-21, 03:14 PM
  4. Slide Images
    By david.brissenden in forum AutoCAD Customization
    Replies: 1
    Last Post: 2008-08-23, 12:14 PM
  5. Replies: 14
    Last Post: 2008-03-01, 03:18 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •