コード例 #1
0
        private AssociatedHandler(IAssocHandler handler, IDataObject dao)
        {
            this.Handler = handler;
            this.Dao     = dao;

            this.Name        = handler.GetName();
            this.DisplayName = handler.GetUIName();
        }
コード例 #2
0
ファイル: Assoc.cs プロジェクト: nmoschkin/DataTools5
        /// <summary>
        /// Refresh using the IAssocHandler
        /// </summary>
        /// <param name="handler"></param>
        internal void Refresh(IAssocHandler handler)
        {
            string pth = null;

            int idx = 0;

            _Handler  = handler;
            Preferred = _Handler.IsRecommended() == HResult.Ok;

            string argppsz = ExePath;

            handler.GetName(out argppsz);

            ExePath = argppsz;

            if (File.Exists(ExePath) == false)
            {
                throw new SystemException("Program path not found");
            }

            handler.GetUIName(out string strRet);
            UIName = strRet;

            handler.GetIconLocation(out pth, out idx);
            Icon = Resources.LoadLibraryIcon(pth, idx, IconSize);

            if (Icon is null)
            {
                int iix = (int)NativeShell.Shell_GetCachedImageIndex(pth, idx, 0U);

                switch (IconSize)
                {
                case StandardIcons.Icon256:
                    Icon = Resources.GetFileIconFromIndex(iix, Resources.SystemIconSizes.Jumbo);
                    break;

                case StandardIcons.Icon48:
                    Icon = Resources.GetFileIconFromIndex(iix, Resources.SystemIconSizes.ExtraLarge);
                    break;

                case StandardIcons.Icon32:
                    Icon = Resources.GetFileIconFromIndex(iix, Resources.SystemIconSizes.Large);
                    break;

                default:
                    Icon = Resources.GetFileIconFromIndex(iix, Resources.SystemIconSizes.Small);
                    break;
                }
            }
        }
コード例 #3
0
ファイル: Assoc.cs プロジェクト: nmoschkin/DataTools5
        /// <summary>
        /// Retrieves a UIHandler object base on the IAssocHandler from a cache or creates and returns a new one if it does not already exist.
        /// </summary>
        /// <param name="assoc">The IAssocHandler from which to build the new object.</param>
        /// <param name="ext">The Extension of the file type the IAssocHandler handles.</param>
        /// <returns>A new UIHandler object</returns>
        /// <remarks></remarks>
        internal UIHandler HandlerFromAssocHandler(IAssocHandler assoc, string ext)
        {
            UIHandler HandlerFromAssocHandlerRet = default;
            string    exepath = null;

            assoc.GetName(out exepath);
            foreach (var u in _UICol)
            {
                if ((exepath ?? "") == (u.ExePath ?? ""))
                {
                    u.AddExt(ext);
                    return(u);
                }
            }

            HandlerFromAssocHandlerRet = new UIHandler(assoc, this);
            HandlerFromAssocHandlerRet.AddExt(ext);
            _UICol.Add(HandlerFromAssocHandlerRet);
            return(HandlerFromAssocHandlerRet);
        }