Ejemplo n.º 1
0
        public void SetButtonCellData(String aFilePath)
        {
            if (File.Exists(aFilePath))
            {
                String lExtension = Path.GetExtension(aFilePath).ToLower();

                switch (lExtension)
                {
                case ".lnk":
                {
                    IWshRuntimeLibrary.WshShell     lShell    = new IWshRuntimeLibrary.WshShell();
                    IWshRuntimeLibrary.IWshShortcut lShortCut = (IWshRuntimeLibrary.IWshShortcut)lShell.CreateShortcut(aFilePath);

                    this.mName        = Path.GetFileNameWithoutExtension(aFilePath);
                    this.mLaunchLink  = lShortCut.TargetPath;
                    this.mLaunchArgs  = lShortCut.Arguments;
                    this.mDescription = lShortCut.Description;

                    if (File.Exists(lShortCut.IconLocation))
                    {
                        this.mIconPath = lShortCut.IconLocation;
                    }
                    else if (File.Exists(lShortCut.TargetPath))
                    {
                        this.mIconPath = lShortCut.TargetPath;
                    }
                    else
                    {
                        this.mIconPath = aFilePath;
                    }

                    this.mLaunchType = ConstsAndEnums.LaunchType.Lnk;
                }
                break;

                case ".url":
                default:
                    this.mLaunchLink = aFilePath;
                    this.mName       = Path.GetFileNameWithoutExtension(aFilePath);
                    this.mIconPath   = aFilePath;
                    this.mLaunchType = ConstsAndEnums.LaunchType.File;
                    break;
                }
            }
            else if (Directory.Exists(aFilePath))
            {
                this.mLaunchLink = aFilePath;
                this.mName       = aFilePath;// Path.GetFileNameWithoutExtension(aFilePath);
                this.mIconPath   = aFilePath;
                this.mLaunchType = ConstsAndEnums.LaunchType.Folder;
            }
            else
            {
                throw new Exception(Resources.String_TargetNotExist);
            }
        }
Ejemplo n.º 2
0
 public void InitButtonCellData()
 {
     this.mTabIndex    = 0;
     this.mRowIndex    = 0;
     this.mColumnIndex = 0;
     this.mName        = null;
     this.mDescription = null;
     this.mIconPath    = null;
     this.mLaunchLink  = null;
     this.mLaunchArgs  = null;
     this.mLaunchType  = ConstsAndEnums.LaunchType.Invalid;
 }