private void btnBrowserForIcon_Click(object sender, System.EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter           = "Images|*.jpg;*.gif;*.png|All files|*.*";
            ofd.CheckFileExists  = true;
            ofd.DereferenceLinks = true;

            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            try
            {
                Image  img  = Image.FromFile(ofd.FileName);
                string path = _virtualFs.GetBinPath("icons");
                if (!System.IO.Directory.Exists(path))
                {
                    System.IO.Directory.CreateDirectory(path);
                }

                string imageFile = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(ofd.FileName);
                System.IO.File.Copy(ofd.FileName, System.IO.Path.Combine(path, imageFile));
                imageFile = "$(file)\\icons\\" + imageFile;
                iconComboBox.Add(imageFile, img);
                iconComboBox.Select(imageFile);
            }
            catch
            {
                MessageBox.Show("无效图片 - " + ofd.FileName);
            }
        }
Example #2
0
        public static string GetPath(string path, IVirtualFileSystem virtualFs)
        {
            if (System.IO.Path.IsPathRooted(path))
            {
                return(System.IO.File.Exists(path) ? path : null);
            }

            path = virtualFs.GetBinPath(path);

            if (System.IO.File.Exists(path))
            {
                return(System.IO.Path.GetFullPath(path));
            }

            return(null);
        }
Example #3
0
        public ComponentFileSystem(string binPath, IVirtualFileSystem parent, string component)
        {
            if (string.IsNullOrEmpty(component))
            {
                throw new ArgumentNullException("component");
            }

            if (null == parent)
            {
                throw new ArgumentNullException("parent");
            }


            _parent    = parent;
            _binPath   = binPath;
            _component = component;

            if (string.IsNullOrEmpty(_binPath))
            {
                _binPath = _parent.GetBinPath("components");
                _binPath = Path.Combine(_binPath, _component);
            }
        }
        public FolderPropertyDlg(IExtensionRegistry extensionRegistry
                                 , IHierarchyDecoratorService contentService
                                 , IIconResourceService iconResourceService
                                 , IVirtualFileSystem virtualFs
                                 , FolderWithBLOBs folder)
        {
            _extensionRegistry   = extensionRegistry;
            _contentService      = contentService;
            _iconResourceService = iconResourceService;
            _virtualFs           = virtualFs;

            InitializeComponent();
            this.archivingSettingPane.Initialize(extensionRegistry);


            foreach (string path in System.IO.Directory.GetFiles(_virtualFs.GetBinPath("icons")))
            {
                try
                {
                    Bitmap img = new Bitmap(Image.FromFile(path));
                    img.MakeTransparent();
                    string imageFile = "$(file)\\icons\\" + System.IO.Path.GetFileName(path);

                    iconComboBox.Add(imageFile, img);
                }
                catch
                { }
            }


            string[] icons = new string[] { "jingxian.ui.icons.edit.png",
                                            "jingxian.folder.attachments.png",
                                            "jingxian.folder.calendar.png",
                                            "jingxian.folder.draft.png",
                                            "jingxian.folder.dynamicfolder.png",
                                            "jingxian.folder.inbox.png",
                                            "jingxian.folder.junk.png",
                                            "jingxian.folder.mailinglist.png",
                                            "jingxian.folder.newsgroup.png",
                                            "jingxian.folder.note.png",
                                            "jingxian.folder.outbox.png",
                                            "jingxian.folder.sent.png",
                                            "jingxian.folder.standard.png",
                                            "jingxian.folder.today.png",
                                            "jingxian.folder.trash.png" };

            foreach (string path in icons)
            {
                try
                {
                    Bitmap img = _iconResourceService.GetBitmap(path);
                    img.MakeTransparent();
                    iconComboBox.Add(path, img);
                }
                catch
                { }
            }

            //foreach (object obj in _contentService.GetChildren(_iconResourceService))
            //{
            //    PropertyContentProvider contentProvider = obj as PropertyContentProvider;
            //    if (null == contentProvider || "allIcons" != contentProvider.Name )
            //        continue;
            //}


            if (null == folder)
            {
                return;
            }

            _folder = folder;
            this.txtFolderCaption.Text = folder.Name;
            this.iconComboBox.Select(folder.Icon);

            this.archivingSettingPane.Time   = _folder.Misc["Timeout"];
            this.archivingSettingPane.Action = _folder.Misc["ActionOfTimeout"];
        }