Translate C# into vb.net - map-processbar

Translate C# into vb.net - map-processbar

jan_tappenbeck
Collaborator Collaborator
580 Views
1 Reply
Message 1 of 2

Translate C# into vb.net - map-processbar

jan_tappenbeck
Collaborator
Collaborator

hi!

 

i get follwing C#-Code for show map-processbar:

 

Autodesk.Map.IM.Forms.Desktop.StatusForm<Object> statusForm = new Autodesk.Map.IM.Forms.Desktop.StatusForm<Object>(
        delegate (Autodesk.Map.IM.Data.Util.IStatusDisplay status, Object[] parameters)
    {
        try
        {
            //start process

            //values for processbar
            status.Minimum = 0;
            status.Maximum = 100;
 
            //set status-text
            status.Status = "Verarbeitung beginnt...";
 
            //stop graphic update
            using (this.Document.Map.InitiateDrawBurst()) ' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
            {
 
                //process to work
                for (int i = 0; i < 100; i++)
                {
                    //validate if cancel
                    if (status.CancelRequested)
                    {
                        //info for user
                        System.Windows.Forms.MessageBox.Show("process stopped!");
                        //cancel
                        return;
                    }
 
                    //sleep-for time to work
                    System.Threading.Thread.Sleep(100);
 
                    //update status
                    status.PerformStep();
                }
            } // update grafi
 
            //user-info
            System.Windows.Forms.MessageBox.Show("process finished.");
        }
        catch (Exception ex)
        {
            //catch error
            System.Windows.Forms.MessageBox.Show("error: " + ex + " " + ex.StackTrace);
        }
    });
    //type of status
    statusForm.Type = Autodesk.Map.IM.Forms.Desktop.ProgressBarType.ProgressBarWithText;
    //bei unbekannter Größe
    //statusForm.Type = Autodesk.Map.IM.Forms.Desktop.ProgressBarType.ContinuousProgressBar;
 
    //Abbrechen-Knopf anzeigen und aktivieren
    statusForm.CancelButtonVisible = true;
    statusForm.CancelButtonEnabled = true;
 
    //Verarbeitung starten
    statusForm.ShowDialog();
}

 my problem is to translate the first lines!


could someone help me ???

 

regards Jan

0 Likes
581 Views
1 Reply
Reply (1)
Message 2 of 2

_gile
Consultant
Consultant

Hi,

 

I'm not very cumfortable with VB and the VB syntax for lambda expressions, but it should be something like this :

 

Dim statusForm As New Autodesk.Map.IM.Forms.Desktop.StatusForm(Of Object)( _
    Sub(status As Autodesk.Map.IM.Data.Util.IStatusDisplay, parameters As Object()) 
        Try
            'start process

            'values for processbar
            status.Minimum = 0
            status.Maximum = 100

            'set status-text
            status.Status = "Verarbeitung beginnt..."

            'stop graphic update
            Using Me.Document.Map.InitiateDrawBurst()

                'process to work
                For i As Integer = 0 To 99
                    'validate if cancel
                    If status.CancelRequested Then
                        'info for user
                        System.Windows.Forms.MessageBox.Show("process stopped!")
                        'cancel
                        Return
                    End If

                    'sleep-for time to work
                    System.Threading.Thread.Sleep(100)

                    'update status
                    status.PerformStep()
                Next
            End Using
            ' update grafi
            'user-info
            System.Windows.Forms.MessageBox.Show("process finished.")
        Catch ex As Exception
            'catch error
            System.Windows.Forms.MessageBox.Show("error: " + ex + " " + ex.StackTrace)
        End Try
    End sub)


Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub