示例#1
0
        private void AddAppByShellExpand(string strShell, string strName,
                                         string strIconExe)
        {
            if (string.IsNullOrEmpty(strShell))
            {
                return;
            }

            if (string.IsNullOrEmpty(strName))
            {
                strName = strShell;
            }

            Image img = null;

            if (!string.IsNullOrEmpty(strIconExe))
            {
                img = FileIcons.GetImageForPath(strIconExe, null, true, true);
            }

            OpenWithItem owi = new OpenWithItem(strShell, OwFilePathType.ShellExpand,
                                                strName, img, m_dynMenu);

            m_lOpenWith.Add(owi);
        }
示例#2
0
        private bool AddAppByFile(string strAppCmdLine, string strName)
        {
            if (string.IsNullOrEmpty(strAppCmdLine))
            {
                return(false);                                                // No assert
            }
            string strPath = UrlUtil.GetShortestAbsolutePath(
                UrlUtil.GetQuotedAppPath(strAppCmdLine).Trim());

            if (strPath.Length == 0)
            {
                Debug.Assert(false); return(false);
            }

            foreach (OpenWithItem it in m_lOpenWith)
            {
                if (it.FilePath.Equals(strPath, StrUtil.CaseIgnoreCmp))
                {
                    return(false);                    // Already have an item for this
                }
            }

            // Filter non-existing/legacy applications
            try { if (!File.Exists(strPath))
                  {
                      return(false);
                  }
            }
            catch (Exception) { Debug.Assert(false); return(false); }

            if (string.IsNullOrEmpty(strName))
            {
                strName = UrlUtil.StripExtension(UrlUtil.GetFileName(strPath));
            }

            // Image img = UIUtil.GetFileIcon(strPath, DpiUtil.ScaleIntX(16),
            //	DpiUtil.ScaleIntY(16));
            Image img = FileIcons.GetImageForPath(strPath, null, true, true);

            OpenWithItem owi = new OpenWithItem(strPath, OwFilePathType.Executable,
                                                strName, img, m_dynMenu);

            m_lOpenWith.Add(owi);
            return(true);
        }