Esempio n. 1
0
        public static iWindowAttribute Add(string title, iWindow win,
                                           bool visible = true, bool canDock = true, bool register2menu = true)
        {
            uint            uuid = s_uuid++;
            WindowAttribute attr = new WindowAttribute();

            attr.window        = win;
            attr.UUID          = uuid;
            attr.title         = title;
            attr.visible       = visible;
            attr.canDock       = canDock;
            attr.register2menu = register2menu;
            pool.Add(uuid, attr);

            if (visible)
            {
                ShowWindow(uuid);
            }
            else
            {
                CloseWindow(uuid);
            }

            win.Init();

            return(attr);
        }
Esempio n. 2
0
        public static int GetWindowAttribute(WindowHandle window, WindowAttribute attribute)
        {
            var value = glfwGetWindowAttrib(window, attribute);

            CheckError(nameof(GetWindowAttribute));
            return(value);
        }
    /// <summary>
    /// 初始化
    /// </summary>
    /// <param name="assemblyName">窗口类所在的程序集</param>
    public void Initialize(string assemblyName)
    {
        if (string.IsNullOrEmpty(assemblyName))
        {
            throw new ArgumentNullException();
        }
        _assemblyName = assemblyName;

        List <Type> types = AssemblyUtility.GetAssignableAttributeTypes(assemblyName, typeof(UIWindow), typeof(WindowAttribute));

        for (int i = 0; i < types.Count; i++)
        {
            System.Type     type      = types[i];
            WindowAttribute attribute = Attribute.GetCustomAttribute(type, typeof(WindowAttribute)) as WindowAttribute;

            // 判断是否重复
            if (_types.ContainsKey(attribute.WindowType))
            {
                throw new Exception($"Window type {attribute.WindowType} already exist.");
            }

            // 添加到集合
            _types.Add(attribute.WindowType, type);
        }
    }
Esempio n. 4
0
        public static int GetWindowAttribute(WindowPtr window, WindowAttribute attrib)
        {
            var result = glfwGetWindowAttrib(window, attrib);

            CheckError();
            return(result);
        }
Esempio n. 5
0
        // Gets a rectangle value for the given attribute
        private Rectangle GetRectangleValue(WindowAttribute attribute)
        {
            // Stores the result
            Rectangle result = new Rectangle();

            // Native API call
            DwmGetWindowAttribute(hwndForm, attribute, out result, Marshal.SizeOf(result));

            return(result);
        }
Esempio n. 6
0
        // Gets a boolean value for the specified attribute
        private bool GetBoolValue(WindowAttribute attribute)
        {
            // Stores the result
            bool result;

            // Native API call
            DwmGetWindowAttribute(hwndForm, attribute, out result, sizeof(int));

            return(result);
        }
Esempio n. 7
0
File: Form1.cs Progetto: Cothn/SPP
        private void LoadPlugins()
        {
            //плагины
            string        pluginPath   = Path.Combine(Directory.GetCurrentDirectory(), "Plugins");
            DirectoryInfo pluginDirect = new DirectoryInfo(pluginPath);
            //if (!pluginDirect.Exists)
            //{ pluginDirect.Create(); }

            //берем все dll
            var pluginFiles = Directory.GetFiles(pluginPath, "*.dll");

            foreach (var file in pluginFiles)
            {
                //загружаем сборку
                Assembly asm = Assembly.LoadFrom(file);
                //Ищем типы  //type of plugin is AssignableFrom
                var types = asm.GetTypes().Where(t => t.GetInterfaces().Where(j => j.FullName == typeof(FormInterface).FullName).Any());



                foreach (var type in types)
                {
                    var form = asm.CreateInstance(type.FullName) as Form;
                    form.MdiParent     = this;
                    form.StartPosition = FormStartPosition.Manual;

                    object[] attributes = type.GetCustomAttributes(typeof(WindowAttribute), inherit: true);
                    if (attributes.Length != 0)
                    {
                        WindowAttribute windowAttribute = (WindowAttribute)attributes[0];
                        form.Dock = windowAttribute.Dock;
                    }

                    FieldInfo[] fields = type.GetFields();
                    foreach (FieldInfo field in fields)
                    {
                        attributes = field.GetCustomAttributes(typeof(WindowAttribute), inherit: true);
                        if (attributes.Length != 0)
                        {
                            WindowAttribute windowAttribute = (WindowAttribute)attributes[0];
                            Control         butt            = field.GetValue(form) as Control;
                            butt.Dock = windowAttribute.Dock;
                        }
                    }
                    form.Show();
                }
            }
        }
    /// <summary>
    /// 创建类的实例
    /// </summary>
    /// <param name="windowType">窗口类型</param>
    /// <returns>如果类型没有在程序集里定义会发生异常</returns>
    public UIWindow CreateInstance(EWindowType windowType)
    {
        UIWindow window = null;

        if (_types.TryGetValue(windowType, out Type type))
        {
            WindowAttribute attribute = Attribute.GetCustomAttribute(type, typeof(WindowAttribute)) as WindowAttribute;
            window = (UIWindow)Activator.CreateInstance(type);
            window.Init(attribute.WindowType, attribute.WindowLayer);
        }

        if (window == null)
        {
            throw new KeyNotFoundException($"{nameof(UIWindow)} {windowType} is not define in assembly {_assemblyName}");
        }

        return(window);
    }
Esempio n. 9
0
 /// <summary>
 /// Changes an attribute for the specified window.
 /// </summary>
 /// <param name="hWnd">A handle to the window and, indirectly, the class to which the window belongs.</param>
 /// <param name="attribute">An enumeration value that specifies the window attribute to replace.</param>
 /// <param name="dwNewLong">The replacement value.</param>
 /// <returns></returns>
 public static IntPtr SetWindowLongPtr(IntPtr hWnd, WindowAttribute attribute, IntPtr dwNewLong)
 => IntPtr.Size == 4
         ? SetWindowLongPtr32(hWnd, (int)attribute, dwNewLong)
         : SetWindowLongPtr64(hWnd, (int)attribute, dwNewLong);
Esempio n. 10
0
 public static extern void SetWindowAttrib(Window window, WindowAttribute attrib, bool value);
Esempio n. 11
0
 public static extern int GetWindowAttrib(IntPtr window, WindowAttribute attrib);
Esempio n. 12
0
 private static extern void DwmSetWindowAttribute(IntPtr hwnd, WindowAttribute attribute, ref int attributeValue, int attributeSize);
 private static extern int DwmSetWindowAttribute(IntPtr hwnd, WindowAttribute dwAttribute, ref object pvAttribute, int pvAttributeSize);
Esempio n. 14
0
 public static extern int DwmSetWindowAttribute(IntPtr hwnd,
                                                WindowAttribute dwAttribute, ref bool pvAttribute, int cbAttribute);
Esempio n. 15
0
 public static extern int GetWindowAttrib(Window window, [MarshalAs(UnmanagedType.I4)] WindowAttribute attribibute);
 public static extern int DwmSetWindowAttribute(IntPtr hwnd,
   WindowAttribute dwAttribute, ref bool pvAttribute, int cbAttribute);
Esempio n. 17
0
 public static bool Contains(this WindowAttribute atr1, WindowAttribute atr2)
 {
     return((atr1 & atr2) == atr2);
 }
Esempio n. 18
0
 public static void SetWindowAttribute(WindowHandle window, WindowAttribute attribute, bool value)
 {
     glfwSetWindowAttrib(window, attribute, value ? 1 : 0);
     CheckError(nameof(SetWindowAttribute));
 }
Esempio n. 19
0
 public static void SetWindowCreationHint(WindowAttribute hint, int value)
 {
     SetWindowCreationHint((WindowCreationHint)hint, value);
 }
Esempio n. 20
0
 public static void SetWindowCreationHint(WindowAttribute hint, bool value)
 {
     SetWindowCreationHint((WindowCreationHint)hint, value ? 1 : 0);
 }
Esempio n. 21
0
 // Sets an int value for the specified attribute
 private void SetIntValue(WindowAttribute attribute, ref int value)
 {
     // Native API call
     DwmSetWindowAttribute(hwndForm, attribute, ref value, sizeof(int));
 }
Esempio n. 22
0
        // Gets a rectangle value for the given attribute
        private Rectangle GetRectangleValue(WindowAttribute attribute)
        {
            // Stores the result
            Rectangle result = new Rectangle();

            // Native API call
            DwmGetWindowAttribute(hwndForm, attribute, out result, Marshal.SizeOf(result));

            return result;
        }
Esempio n. 23
0
        // Gets a boolean value for the specified attribute
        private bool GetBoolValue(WindowAttribute attribute)
        {
            // Stores the result
            bool result;

            // Native API call
            DwmGetWindowAttribute(hwndForm, attribute, out result, sizeof(int));

            return result;
        }
Esempio n. 24
0
 public static extern int glfwGetWindowAttrib(WindowPtr window, WindowAttribute attrib);
Esempio n. 25
0
 // Sets an int value for the specified attribute
 private void SetIntValue(WindowAttribute attribute, ref int value)
 {
     // Native API call
     DwmSetWindowAttribute(hwndForm, attribute, ref value, sizeof(int));
 }
Esempio n. 26
0
 /// <summary>
 /// Retrieves information about a specified window.
 /// </summary>
 /// <param name="hWnd">A handle to the window and, indirectly, the class to which the window belongs.</param>
 /// <param name="attribute">An enumeration value that specifies the window attribute to retrieve.</param>
 /// <returns>The requested value if successful; otherwise, zero.</returns>
 public static IntPtr GetWindowLongPtr(IntPtr hWnd, WindowAttribute attribute)
 => IntPtr.Size == 4 ? GetWindowLongPtr32(hWnd, (int)attribute) : GetWindowLongPtr64(hWnd, (int)attribute);
Esempio n. 27
0
 private static extern void glfwSetWindowAttrib(WindowHandle window, WindowAttribute attribute, int value);
Esempio n. 28
0
 public static extern void glfwSetWindowAttrib(Window *window, WindowAttribute attrib, int value);
Esempio n. 29
0
 private static extern void DwmGetWindowAttribute(IntPtr hwnd, WindowAttribute attribute, out Rectangle attributeValue, int attributeSize);
Esempio n. 30
0
 public static extern void WindowHint(WindowAttribute hint, int value);
Esempio n. 31
0
 private static extern void DwmSetWindowAttribute(IntPtr hwnd, WindowAttribute attribute, ref int attributeValue, int attributeSize);
Esempio n. 32
0
 private static extern int glfwGetWindowAttrib(WindowHandle window, WindowAttribute attribute);
Esempio n. 33
0
 private static extern void DwmGetWindowAttribute(IntPtr hwnd, WindowAttribute attribute, out Rectangle attributeValue, int attributeSize);