Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
 /// <summary>
 /// Sets custom providers to load resources.
 /// </summary>
 public static void SetResourceProvider(Provider provider)
 {
     Noesis_SetResourceProviders_(
         Extend.GetInstanceHandle(provider.XamlProvider),
         Extend.GetInstanceHandle(provider.TextureProvider),
         Extend.GetInstanceHandle(provider.FontProvider));
 }
Esempio n. 3
0
        /// <summary>
        /// Enumerates all the faces found in the provided font stream resource
        /// </summary>
        public static void EnumFontFaces(Stream font, FontFaceInfoCallback callback)
        {
            Faces faces = new Faces {
                Callback = callback
            };
            int callbackId = faces.GetHashCode();

            _facesCallbacks[callbackId] = faces;
            Noesis_EnumFontFaces(Extend.GetInstanceHandle(font), callbackId, _fontFaces);
            _facesCallbacks.Remove(callbackId);
        }
Esempio n. 4
0
        /// <summary>
        /// Finds dependencies to other XAMLS and resources (fonts, textures, sounds...).
        /// </summary>
        /// <param name="xaml">Stream with xaml content.</param>
        /// <param name="folder">Root directory used for relative dependencies.</param>
        /// <param name="callback">Called for each dependency found.</param>
        public static void GetXamlDependencies(Stream xaml, string folder,
                                               XamlDependencyCallback callback)
        {
            Deps deps = new Deps {
                Callback = callback
            };
            int callbackId = deps.GetHashCode();

            _depsCallbacks[callbackId] = deps;
            Noesis_GetXamlDependencies(Extend.GetInstanceHandle(xaml), folder, callbackId, _xamlDep);
            _depsCallbacks.Remove(callbackId);
        }
Esempio n. 5
0
 /// <summary>
 /// Sets TextureProvider to load texture resources.
 /// </summary>
 public static void SetTextureProvider(TextureProvider provider)
 {
     Noesis_SetTextureProvider(Extend.GetInstanceHandle(provider));
 }
Esempio n. 6
0
 /// <summary>
 /// Sets XamlProvider to load XAML resources.
 /// </summary>
 public static void SetXamlProvider(XamlProvider provider)
 {
     Noesis_SetXamlProvider(Extend.GetInstanceHandle(provider));
 }
Esempio n. 7
0
 /// <summary>
 /// Loads contents of the specified component from a XAML.
 /// Used from InitializeComponent; supplied component must match the type of the XAML root
 /// </summary>
 public static void LoadComponent(object component, string filename)
 {
     Noesis_LoadComponent(Extend.GetInstanceHandle(component), filename);
 }
Esempio n. 8
0
 /// <summary>
 /// Sets a collection of application-scope resources, such as styles and brushes. Provides a
 /// simple way to support a consistent theme across your application.
 /// </summary>
 /// <param name="resources">Application resources.</param>
 public static void SetApplicationResources(ResourceDictionary resources)
 {
     Noesis_SetApplicationResources(Extend.GetInstanceHandle(resources));
 }
Esempio n. 9
0
 private static void DoDragDropHelper(DependencyObject source, object data,
                                      DragDropEffects allowedEffects, int callbackId, Callback_DragDropCompleted callback)
 {
     DragDrop_DoDragDrop(DependencyObject.getCPtr(source), Extend.GetInstanceHandle(data),
                         (int)allowedEffects, callbackId, callback);
 }
Esempio n. 10
0
 /// <summary>
 /// Sets FontProvider to load font resources.
 /// </summary>
 public static void SetFontProvider(FontProvider provider)
 {
     Noesis_SetFontProvider_(Extend.GetInstanceHandle(provider));
 }
Esempio n. 11
0
 /// <summary>
 /// Loads contents of the specified component from a XAML.
 /// Used from InitializeComponent; supplied component must match the type of the XAML root
 /// </summary>
 public static void LoadComponent(object component, string xaml)
 {
     Noesis_LoadComponent_(Extend.GetInstanceHandle(component), xaml);
 }
Esempio n. 12
0
        /// <summary>
        /// Loads a XAML resource from a Stream.
        /// </summary>
        /// <param name="stream">Stream with xaml contents.</param>
        /// <param name="filename">Path to the resource.</param>
        /// <returns>Root of the loaded XAML.</returns>
        public static object LoadXaml(Stream stream, string filename)
        {
            IntPtr root = Noesis_LoadStreamXaml(Extend.GetInstanceHandle(stream), filename ?? string.Empty);

            return(Extend.GetProxy(root, true));
        }
Esempio n. 13
0
 /// <summary>
 /// Sets Theme resources.
 /// </summary>
 /// <param name="theme">Dictionary with default styles for all controls.</param>
 public static void SetTheme(ResourceDictionary theme)
 {
     Noesis_SetTheme_(Extend.GetInstanceHandle(theme));
 }