//////////////////////////////////////////////////////////////////////////////////////////////// public static IntPtr Box(object val) { BoxDelegate boxFunction; if (_boxFunctions.TryGetValue(val.GetType(), out boxFunction)) { return(RegisterPendingRelease(boxFunction(val))); } else if (val.GetType().GetTypeInfo().IsEnum) { _boxFunctions.TryGetValue(typeof(int), out boxFunction); return(RegisterPendingRelease(boxFunction((int)Convert.ToInt64(val)))); } else if (val is Type) { ResourceKeyType resourceKey = GetResourceKeyType((Type)val); HandleRef handle = BaseComponent.getCPtr(resourceKey); BaseComponent.AddReference(handle.Handle); return(RegisterPendingRelease(handle.Handle)); } else { return(IntPtr.Zero); } }
/// <summary> Registers a class handler for a particular routed event, with the option to handle events where event data is already marked handled.</summary> /// <param name="classType">The type of the class that is declaring class handling.</param> /// <param name="routedEvent">The routed event identifier of the event to handle.</param> /// <param name="handler">A reference to the class handler implementation.</param> /// <param name="handledEventsToo">true to invoke this class handler even if arguments of the routed event have been marked as handled; false to retain the default behavior of not invoking the handler on any marked-handled event.</param> public static void RegisterClassHandler(Type classType, RoutedEvent routedEvent, Delegate handler, bool handledEventsToo) { if (classType == null) { throw new ArgumentNullException("classType"); } if (routedEvent == null) { throw new ArgumentNullException("routedEvent"); } if (handler == null) { throw new ArgumentNullException("handler"); } if (!typeof(UIElement).IsAssignableFrom(classType)) { throw new ArgumentException("Illegal class type " + classType.FullName); } if (!IsLegalHandler(routedEvent, handler)) { throw new ArgumentException("Illegal Handler type for " + routedEvent.Name + " event"); } ClassHandlerInfo c = AddClassHandler(routedEvent, handler); Noesis_EventManager_RegisterClassHandler(Extend.GetNativeType(classType), BaseComponent.getCPtr(routedEvent).Handle, handledEventsToo, Extend.GetInstanceHandle(c).Handle, _classHandler); }
private static void EnsureEventsProperty() { if (BaseComponent.getCPtr(EventsProperty).Handle == IntPtr.Zero) { EventsProperty = DependencyProperty.Register( "Events", typeof(EventHandlerStore), typeof(EventHandlerStore), new PropertyMetadata(null)); } }
/// <summary> /// Initializes the Renderer with the specified render device. /// </summary> /// <param name="vgOptions">Vector graphics options.</param> public void Init(RenderDevice device) { if (device == null) { throw new ArgumentNullException("device"); } Noesis_Renderer_Init(CPtr, BaseComponent.getCPtr(device)); }
/// <summary> /// Updates texture mipmap copying the given data to desired position. The passed data is /// tightly packed (no extra pitch). Origin is located at the left of the first scanline /// </summary> public void UpdateTexture(Texture texture, uint level, uint x, uint y, uint width, uint height, byte[] data) { if (texture == null) { throw new ArgumentNullException("texture"); } if (data == null) { throw new ArgumentNullException("data"); } Noesis_RenderDevice_UpdateTexture(CPtr, BaseComponent.getCPtr(texture), level, x, y, width, height, data); }
public static void RemoveHandler(UIElement element, RoutedEvent routedEvent, Delegate handler) { if (element == null) { throw new ArgumentNullException("element"); } if (routedEvent == null) { throw new ArgumentNullException("routedEvent"); } if (handler == null) { throw new ArgumentNullException("handler"); } if (!EventManager.IsLegalHandler(routedEvent, handler)) { throw new ArgumentException("Illegal Handler type for " + routedEvent.Name + " event"); } EnsureEventsProperty(); EventHandlerStore events = (EventHandlerStore)element.GetValue(EventsProperty); if (events == null) { return; } IntPtr routedEventPtr = BaseComponent.getCPtr(routedEvent).Handle; long routedEventKey = routedEventPtr.ToInt64(); Delegate eventHandler; if (!events._binds.TryGetValue(routedEventKey, out eventHandler)) { return; } eventHandler = Delegate.Remove(eventHandler, handler); events._binds[routedEventKey] = eventHandler; if (eventHandler == null) { Noesis_RoutedEvent_Unbind(_raiseRoutedEvent, events._element, routedEventPtr); events._binds.Remove(routedEventKey); } }
private static HandleRef RegisterContent(FrameworkElement content) { sContentPtr = BaseComponent.getCPtr(content); return(sContentPtr); }
/// <summary> /// Looks for the view where the node is connected to /// </summary> /// <returns>A null reference if node is not connected to a View</returns> public static View Find(BaseComponent node) { IntPtr view = Noesis_View_Find(BaseComponent.getCPtr(node)); return((View)Noesis.Extend.GetProxy(view, false)); }
internal View(FrameworkElement content) { _view = new BaseComponent(Noesis_View_Create_(BaseComponent.getCPtr(content)), true); _renderer = new Renderer(this); _content = content; }
private static long Key(RoutedEvent routedEvent) { return(BaseComponent.getCPtr(routedEvent).Handle.ToInt64()); }
private EventHandlerStore(UIElement element) { _element = BaseComponent.getCPtr(element).Handle; }
internal View(FrameworkElement content) : this(Noesis_View_Create(BaseComponent.getCPtr(content)), true) { }