Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Background image (Read 4413 times)
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Background image
Jun 20th, 2012 at 9:18am
Print Post  
Hello. I have the some problem with setting background image.
I have the class based on ShapeNode. Contrctuctor is the following
Code
Select All
        public TPDESwitchNode():base()
        {
            HandlesStyle = HandlesStyle.Custom;
            SetBackgroundImg();
            Type = NodeType.Switch;
        }
        private void SetBackgroundImg()
        {
            BitmapImage bi = new BitmapImage();
            bi.BeginInit();
            bi.UriSource = new Uri("pack://application:,,,/Images/Nodes/switch.png");
            bi.EndInit();
            Image = bi;
        }
 


And when I drop this node on the diagram by mouse (in the NodeCreated remove the NodeAdapter and create the object of the TPDESwitchNode class) after NodeActivated I see the following exception:
A first chance exception of type 'System.NotSupportedException' occurred in PresentationCore.dll
If I comment SetBackgroundImg() all works nice. Can you help me?
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Background image
Reply #1 - Jun 20th, 2012 at 9:29am
Print Post  
What is the full call stack and is this exception unhandled? First-chance means it has been thrown, but some code might be handling it later.
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Background image
Reply #2 - Jun 20th, 2012 at 9:42am
Print Post  
It is not unhandled exception. It means that I don't catch it into DispatcherUnhandledException handler of the App, but in the same time my another code also doesn't this exception. It is oocurs after I call Diagram.SaveToString method. In my project I need to save copy of the diagram as compressed xml into Hashtable.
Call stack:

>      Technologist.exe!Technologist.Utils.SaveDiagram(MindFusion.Diagramming.Wpf.Diagr
am a_Diagram) Line 222      C#
     Technologist.exe!Technologist.App.UpdateDiagramIntoHashTable(MindFusion.Diagramm
ing.Wpf.Diagram a_Diagram, int a_nDiagramId) Line 395 + 0x8 bytes      C#
     Technologist.exe!Technologist.TPDEDiagram.OnDiagram_Drop(object sender, System.Windows.DragEventArgs e) Line 250 + 0x11 bytes      C#
     PresentationCore.dll!System.Windows.DragEventArgs.InvokeEventHandler(System.Dele
gate genericHandler, object genericTarget) + 0x31 bytes      
     PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegat
e handler, object target) + 0x36 bytes      
     PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) + 0x40 bytes      
     PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) + 0x1ae bytes      
     PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.Depe
ndencyObject sender, System.Windows.RoutedEventArgs args) + 0x79 bytes      
     PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEv
entArgs e) + 0x29 bytes      
     PresentationCore.dll!System.Windows.OleDropTarget.RaiseDragEvent(System.Windows.
RoutedEvent dragEvent, int dragDropKeyStates, ref int effects, System.Windows.DependencyObject target, System.Windows.Point targetPoint) + 0x210 bytes      
     PresentationCore.dll!System.Windows.OleDropTarget.MS.Win32.UnsafeNativeMethods.I
OleDropTarget.OleDrop(object data, int dragDropKeyStates, long point, ref int effects) + 0x91 bytes      
     [Native to Managed Transition]      
     [Managed to Native Transition]      
     PresentationCore.dll!System.Windows.OleServicesContext.OleDoDragDrop(System.Runt
ime.InteropServices.ComTypes.IDataObject dataObject, MS.Win32.UnsafeNativeMethods.IOleDropSource dropSource, int allowedEffects, int[] finalEffect) + 0x7a bytes      
     PresentationCore.dll!System.Windows.DragDrop.OleDoDragDrop(System.Windows.Depend
encyObject dragSource, System.Windows.DataObject dataObject, System.Windows.DragDropEffects allowedEffects) + 0x48 bytes      
     PresentationCore.dll!System.Windows.DragDrop.DoDragDrop(System.Windows.Dependenc
yObject dragSource, object data, System.Windows.DragDropEffects allowedEffects) + 0x52 bytes      
     MindFusion.Diagramming.Wpf.dll!MindFusion.Diagramming.Wpf.NodeListView.OnPreview
MouseMove(System.Windows.Input.MouseEventArgs e) + 0x33e bytes      
     PresentationCore.dll!System.Windows.UIElement.OnPreviewMouseMoveThunk(object sender, System.Windows.Input.MouseEventArgs e) + 0x59 bytes      
     PresentationCore.dll!System.Windows.Input.MouseEventArgs.InvokeEventHandler(Syst
em.Delegate genericHandler, object genericTarget) + 0x34 bytes      
     PresentationCore.dll!System.Windows.RoutedEventArgs.InvokeHandler(System.Delegat
e handler, object target) + 0x36 bytes      
     PresentationCore.dll!System.Windows.RoutedEventHandlerInfo.InvokeHandler(object target, System.Windows.RoutedEventArgs routedEventArgs) + 0x40 bytes      
     PresentationCore.dll!System.Windows.EventRoute.InvokeHandlersImpl(object source, System.Windows.RoutedEventArgs args, bool reRaised) + 0x133 bytes      
     PresentationCore.dll!System.Windows.UIElement.RaiseEventImpl(System.Windows.Depe
ndencyObject sender, System.Windows.RoutedEventArgs args) + 0x79 bytes      
     PresentationCore.dll!System.Windows.UIElement.RaiseTrustedEvent(System.Windows.R
outedEventArgs args) + 0x41 bytes      
     PresentationCore.dll!System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEv
entArgs args, bool trusted) + 0x42 bytes      
     PresentationCore.dll!System.Windows.Input.InputManager.ProcessStagingArea() + 0x1ff bytes      
     PresentationCore.dll!System.Windows.Input.InputManager.ProcessInput(System.Windo
ws.Input.InputEventArgs input) + 0x45 bytes      
     PresentationCore.dll!System.Windows.Input.InputProviderSite.ReportInput(System.W
indows.Input.InputReport inputReport) + 0x62 bytes      
     PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.ReportInput(S
ystem.IntPtr hwnd, System.Windows.Input.InputMode mode, int timestamp, System.Windows.Input.RawMouseActions actions, int x, int y, int wheel) + 0x263 bytes      
     PresentationCore.dll!System.Windows.Interop.HwndMouseInputProvider.FilterMessage
(System.IntPtr hwnd, MS.Internal.Interop.WindowMessage msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x198 bytes      
     PresentationCore.dll!System.Windows.Interop.HwndSource.InputFilterMessage(System
.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0x75 bytes      
     WindowsBase.dll!MS.Win32.HwndWrapper.WndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam, ref bool handled) + 0xbe bytes      
     WindowsBase.dll!MS.Win32.HwndSubclass.DispatcherCallbackOperation(object o) + 0x7d bytes      
     WindowsBase.dll!System.Windows.Threading.ExceptionWrapper.InternalRealCall(Syste
m.Delegate callback, object args, int numArgs) + 0x53 bytes      
     WindowsBase.dll!MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(object source, System.Delegate method, object args, int numArgs, System.Delegate catchHandler) + 0x42 bytes      
     WindowsBase.dll!System.Windows.Threading.Dispatcher.InvokeImpl(System.Windows.Th
reading.DispatcherPriority priority, System.TimeSpan timeout, System.Delegate method, object args, int numArgs) + 0xb4 bytes      
     WindowsBase.dll!MS.Win32.HwndSubclass.SubclassWndProc(System.IntPtr hwnd, int msg, System.IntPtr wParam, System.IntPtr lParam) + 0x104 bytes      
     [Native to Managed Transition]      
     [Managed to Native Transition]      
     WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows
.Threading.DispatcherFrame frame) + 0xc1 bytes      
     WindowsBase.dll!System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Thr
eading.DispatcherFrame frame) + 0x49 bytes      
     WindowsBase.dll!System.Windows.Threading.Dispatcher.Run() + 0x4c bytes      
     PresentationFramework.dll!System.Windows.Application.RunDispatcher(object ignore) + 0x17 bytes      
     PresentationFramework.dll!System.Windows.Application.RunInternal(System.Windows.
Window window) + 0x6f bytes      
     PresentationFramework.dll!System.Windows.Application.Run(System.Windows.Window window) + 0x26 bytes      
     PresentationFramework.dll!System.Windows.Application.Run() + 0x1b bytes      
     Technologist.exe!Technologist.App.Main() + 0x5e bytes      C#
     [Native to Managed Transition]      
     [Managed to Native Transition]      
     mscorlib.dll!System.AppDomain.ExecuteAssembly(string assemblyFile, System.Security.Policy.Evidence assemblySecurity, string[] args) + 0x6d bytes      
     Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.Hosti
ngProcess.HostProc.RunUsersAssembly() + 0x2a bytes      
     mscorlib.dll!System.Threading.ThreadHelper.ThreadStart_Context(object state) + 0x63 bytes      
     mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionCon
text executionContext, System.Threading.ContextCallback callback, object state, bool ignoreSyncCtx) + 0xb0 bytes      
     mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionCon
text executionContext, System.Threading.ContextCallback callback, object state) + 0x2c bytes      
     mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x44 bytes      
     [Native to Managed Transition]      
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Background image
Reply #3 - Jun 20th, 2012 at 9:46am
Print Post  
Is there a problem then if the exception is handled? such as the image not showing?
  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Background image
Reply #4 - Jun 20th, 2012 at 10:25am
Print Post  
Te image is showing. But message litter the output console Smiley
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Background image
Reply #5 - Jun 20th, 2012 at 10:58am
Print Post  
I think you have the "show only my code" debugger option enabled, below is what I see at the top of the call stack when saving bitmaps. Anyway it's thrown and handled internally by the WPF's BitmapFrame class, so I'm afraid you'll have to suffer the littered console Smiley

Code
Select All
 	PresentationCore.dll!System.Windows.Media.Imaging.BitmapImage.Metadata.get() + 0x44 bytes
 	PresentationCore.dll!System.Windows.Media.Imaging.BitmapFrame.Create(System.Windows.Media.Imaging.BitmapSource source = {file:///C:/Users/Stoyo/AppData/Local/Temp/tmp8F8A.tmp}) + 0x2e bytes
 	MindFusion.Diagramming.Wpf.dll!MindFusion.Diagramming.Wpf.Converter.FromImage(System.Windows.Media.Imaging.BitmapSource val = {file:///C:/Users/Stoyo/AppData/Local/Temp/tmp8F8A.tmp}) + 0x70 bytes
 	MindFusion.Diagramming.Wpf.dll!MindFusion.Diagramming.Wpf.XmlPersistContext.P(System.Xml.XmlElement A = {Element, Name="Resources"}) + 0x2df bytes
 	MindFusion.Diagramming.Wpf.dll!MindFusion.Diagramming.Wpf.Diagram.SaveToXml(System.Xml.XmlDocument document = {Document}) + 0x8a0 bytes
 	MindFusion.Diagramming.Wpf.dll!MindFusion.Diagramming.Wpf.Diagram.SaveToXml(string fileName = "D:\\Diagram.diag") + 0x6e bytes
 

  
Back to top
 
IP Logged
 
Hunter
Full Member
***
Offline



Posts: 194
Location: Sevastopol
Joined: Dec 1st, 2009
Re: Background image
Reply #6 - Jun 20th, 2012 at 11:15am
Print Post  
OK Smiley Thanks
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint