コード例 #1
0
        private string GetCategoryFromObject(object obj, int dispid)
        {
            if ((obj != null) && (obj is NativeMethods.ICategorizeProperties))
            {
                NativeMethods.ICategorizeProperties properties = (NativeMethods.ICategorizeProperties)obj;
                try
                {
                    int categoryID = 0;
                    if (properties.MapPropertyToCategory(dispid, ref categoryID) == 0)
                    {
                        string categoryName = null;
                        switch (categoryID)
                        {
                        case -11:
                            return(System.Windows.Forms.SR.GetString("PropertyCategoryDDE"));

                        case -10:
                            return(System.Windows.Forms.SR.GetString("PropertyCategoryScale"));

                        case -9:
                            return(System.Windows.Forms.SR.GetString("PropertyCategoryText"));

                        case -8:
                            return(System.Windows.Forms.SR.GetString("PropertyCategoryList"));

                        case -7:
                            return(System.Windows.Forms.SR.GetString("PropertyCategoryData"));

                        case -6:
                            return(System.Windows.Forms.SR.GetString("PropertyCategoryBehavior"));

                        case -5:
                            return(System.Windows.Forms.SR.GetString("PropertyCategoryAppearance"));

                        case -4:
                            return(System.Windows.Forms.SR.GetString("PropertyCategoryPosition"));

                        case -3:
                            return(System.Windows.Forms.SR.GetString("PropertyCategoryFont"));

                        case -2:
                            return(System.Windows.Forms.SR.GetString("PropertyCategoryMisc"));

                        case -1:
                            return("");
                        }
                        if (properties.GetCategoryName(categoryID, CultureInfo.CurrentCulture.LCID, out categoryName) == 0)
                        {
                            return(categoryName);
                        }
                    }
                }
                catch
                {
                }
            }
            return(null);
        }
コード例 #2
0
        private string GetCategoryFromObject(object obj, int dispid)
        {
            if (obj == null)
            {
                return(null);
            }

            if (obj is NativeMethods.ICategorizeProperties)
            {
                NativeMethods.ICategorizeProperties catObj = (NativeMethods.ICategorizeProperties)obj;

                try {
                    int categoryID = 0;

                    if (NativeMethods.S_OK == catObj.MapPropertyToCategory(dispid, ref categoryID))
                    {
                        string categoryName = null;

                        switch (categoryID)
                        {
                        case NativeMethods.ActiveX.PROPCAT_Nil:
                            return("");

                        case NativeMethods.ActiveX.PROPCAT_Misc:
                            return(SR.GetString(SR.PropertyCategoryMisc));

                        case NativeMethods.ActiveX.PROPCAT_Font:
                            return(SR.GetString(SR.PropertyCategoryFont));

                        case NativeMethods.ActiveX.PROPCAT_Position:
                            return(SR.GetString(SR.PropertyCategoryPosition));

                        case NativeMethods.ActiveX.PROPCAT_Appearance:
                            return(SR.GetString(SR.PropertyCategoryAppearance));

                        case NativeMethods.ActiveX.PROPCAT_Behavior:
                            return(SR.GetString(SR.PropertyCategoryBehavior));

                        case NativeMethods.ActiveX.PROPCAT_Data:
                            return(SR.GetString(SR.PropertyCategoryData));

                        case NativeMethods.ActiveX.PROPCAT_List:
                            return(SR.GetString(SR.PropertyCategoryList));

                        case NativeMethods.ActiveX.PROPCAT_Text:
                            return(SR.GetString(SR.PropertyCategoryText));

                        case NativeMethods.ActiveX.PROPCAT_Scale:
                            return(SR.GetString(SR.PropertyCategoryScale));

                        case NativeMethods.ActiveX.PROPCAT_DDE:
                            return(SR.GetString(SR.PropertyCategoryDDE));
                        }

                        if (NativeMethods.S_OK == catObj.GetCategoryName(categoryID, SafeNativeMethods.GetUserDefaultLCID(), out categoryName))
                        {
                            return(categoryName);
                        }
                    }
                }
                catch (Exception) {
                }
            }
            return(null);
        }