void DataContextChanged(IntPtr dependency_object, IntPtr propertyChangedEventArgs, ref MoonError error, IntPtr closure) { try { var fe = (FrameworkElement)NativeDependencyObjectHelper.Lookup(dependency_object); PropertyPathWalker.Update(fe.DataContext); // OneTime bindings refresh when the datacontext changes. As these bindings do not listen // for the ValueChanged notifications from the PropertyPathWalker we need to force a refresh if (Binding.Mode == BindingMode.OneTime) { Refresh(); } } catch (Exception ex) { try { error = new MoonError(ex); } catch { } } }
private static void UnmanagedPropertyChangedCallbackSafe(IntPtr dependency_object, IntPtr propertyChangeArgs, ref MoonError error, IntPtr unused) { try { try { UnmanagedPropertyChangedCallback(dependency_object, NativeMethods.property_changed_event_args_get_property(propertyChangeArgs), NativeMethods.property_changed_event_args_get_old_value(propertyChangeArgs), NativeMethods.property_changed_event_args_get_new_value(propertyChangeArgs)); } catch (Exception ex) { error = new MoonError(ex); } } catch (Exception ex) { try { Console.WriteLine("Moonlight: Unhandled exception in DependencyProperty.UnmanagedPropertyChangedCallback: {0}", ex.Message); } catch { } } }
static Size InvokeArrangeOverride(FrameworkElement fe, Size finalSize, ref MoonError error) { try { return(fe.ArrangeOverride(finalSize)); } catch (Exception ex) { try { if (fe != null) { //LayoutInformation.SetLayoutExceptionElement (Deployment.Current.Dispatcher, fe); error = new MoonError(ex); } } catch (Exception ex2) { try { Console.WriteLine("Leaked exception: {0}", ex2); } catch { // Ignore } } } return(new Size()); }
static Size InvokeArrangeOverride(IntPtr fwe_ptr, Size finalSize, ref MoonError error) { FrameworkElement fe = null; try { fe = (FrameworkElement)NativeDependencyObjectHelper.Lookup(fwe_ptr); return(fe.ArrangeOverride(finalSize)); } catch (Exception ex) { try { if (fe != null) { LayoutInformation.SetLayoutExceptionElement(Deployment.Current.Dispatcher, fe); } error = new MoonError(ex); } catch (Exception ex2) { try { Console.WriteLine("Leaked exception: {0}", ex2); } catch { // Ignore } } } return(new Size()); }
private static void CustomUnmanagedPropertyChangedCallbackSafe(IntPtr dependency_object, IntPtr propertyChangeArgs, ref MoonError error, IntPtr unused) { DependencyProperty property; DependencyObject obj; try { try { IntPtr uprop = NativeMethods.property_changed_event_args_get_property(propertyChangeArgs); if (!properties.TryGetValue(uprop, out property)) { Console.Error.WriteLine("DependencyProperty.CustomUnmanagedPropertyChangedCallback: Couldn't find the managed DependencyProperty corresponding with native {0}/{1}", uprop, NativeMethods.property_changed_event_args_get_id(propertyChangeArgs)); return; } obj = NativeDependencyObjectHelper.Lookup(dependency_object) as DependencyObject; if (obj == null) { return; } InvokeChangedCallback(obj, property, property.change_cb, Value.ToObject(property.PropertyType, NativeMethods.property_changed_event_args_get_old_value(propertyChangeArgs)), Value.ToObject(property.PropertyType, NativeMethods.property_changed_event_args_get_new_value(propertyChangeArgs))); } catch (Exception ex) { error = new MoonError(ex); } } catch (Exception ex) { try { Console.WriteLine("Moonlight: Unhandled exception in DependencyProperty.UnmanagedPropertyChangedCallback: {0}", ex.Message); } catch { } } }
internal ExceptionRoutedEventArgs(MoonError err) { ErrorException = NativeMethods.CreateManagedException(err); }
void IListenPropertyChanged.OnPropertyChanged(IntPtr dependency_object, IntPtr property_changed_event_args, ref MoonError error, IntPtr closure) { try { UpdateValue(); if (Next != null) { Next.SetSource(Value); } } catch (Exception ex) { try { Console.WriteLine("Unhandled exception in StandardPropertyPathNode.DBChanged: {0}", ex); } catch { // Ignore } } }
static void InvokePropertyChangeHandler(int token, IntPtr sender, IntPtr args, ref MoonError error, IntPtr closure) { try { var o = (DependencyObject)NativeDependencyObjectHelper.Lookup(sender); if (o != null) { for (int i = 0; i < o.propertyChangedHandlers.Count; i++) { if (o.propertyChangedHandlers [i].Key == token) { o.propertyChangedHandlers [i].Value(sender, args, ref error, closure); break; } } } } catch (Exception ex) { try { Console.WriteLine("Unhandled exception in DependencyObject.PropertyChangeHandler_cb: {0}", ex); } catch { } } }
void IListenPropertyChanged.OnPropertyChanged(IntPtr dependency_object, IntPtr propertyChangeArgs, ref MoonError error, IntPtr unused) { try { // Type converting doesn't happen for TemplateBindings Updating = true; try { Target.SetValue(TargetProperty, GetValue(null)); } catch { Target.SetValue(TargetProperty, TargetProperty.GetDefaultValue(Target)); } } catch (Exception ex) { error = new MoonError(ex); } finally { Updating = false; } }