Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

New Post: Could you please give an example on ShapeEidtor.dll?

$
0
0
This code below gives an error

Unable to cast object of type 'DotSpatial.Plugins.ShapeEditor.ShapeEditorPlugin' to type 'DotSpatial.Controls.IMapFunction'.

System.InvalidCastException was unhandled
Message=Unable to cast object of type 'DotSpatial.Plugins.ShapeEditor.ShapeEditorPlugin' to type 'DotSpatial.Controls.IMapFunction'.
Source=SWING viewer
StackTrace:
   at SWINGviewer.Form1.ToolStripButtonShapeEditor_Click(Object sender, EventArgs e)
   at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
   at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
   at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
   at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
   at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ToolStrip.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at SWINGviewer.My.MyApplication.Main(String[] Args)
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
InnerException:
    Private WithEvents se As ShapeEditorPlugin
    Private Sub ToolStripButtonShapeEditor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ToolStripButtonShapeEditor.Click
        With myVenster
            .FunctionMode = FunctionMode.None
            'if was already added, remove and add again 
            For Each mapfunc As IMapFunction In .MapFunctions
                If TypeOf mapfunc Is ShapeEditorPlugin Then
                    .MapFunctions.Remove(mapfunc)
                    Exit For
                End If
            Next
            se = New ShapeEditorPlugin()
            .MapFunctions.Add(se)
            .Cursor = Cursors.Cross
            se.Activate()
        End With
    End Sub

Viewing all articles
Browse latest Browse all 3973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>