public static Image GetImage(string iconId, string defaultId, IIconResourceService iconService, IVirtualFileSystem virtualFs) { try { if (iconId.StartsWith("$(file)/")) { string path = GetPath(iconId.Substring("$(file)/".Length), virtualFs); if (string.IsNullOrEmpty(path)) { return(iconService.GetBitmap(defaultId)); } else { return(Image.FromFile(path)); } } else { return(iconService.GetBitmap(iconId)); } } catch { return(iconService.GetBitmap(defaultId)); } }
public OutlookBar(IPageService pageSvc, IIconResourceService iconService, IPartRegistry partRegsistry, IViewPart viewPart) { _pageSvc = pageSvc; _iconService = iconService; _partRegsistry = partRegsistry; List <string> collection = new List <string>(); string selected = null; System.IO.TextReader textReader = new System.IO.StringReader(viewPart.ConfigurationXml); using (XmlReader reader = XmlReader.Create(textReader, XmlUtils.CreateFragmentReaderSettings(), XmlUtils.CreateParserContext())) { reader.ReadStartElement("viewSet"); //NON-NLS-1 while (reader.IsStartElement("viewBar")) //NON-NLS-1 { string id = XmlUtils.ReadAttribute(reader, "ref"); collection.Add(id); if (string.IsNullOrEmpty(selected)) { selected = id; } else if (0 == string.Compare("true", XmlUtils.ReadOptionalAttributeString(reader, "selected"), true)) { selected = id; } reader.ReadStartElement(); } reader.ReadEndElement(); //while (reader.Read()) //{ // if( reader.IsStartElement("viewBar") ) // collection.Add( XmlUtils.ReadAttribute(reader, "ref") ); //} } foreach (string config in collection) { IViewPart viewBar = _partRegsistry.Get <IViewPart>(config); Add(viewBar.Id, viewBar.Name, _iconService.GetBitmap(viewBar.IconId), viewBar.Widget); if (viewBar.Id == selected) { Switch(selected); } } }
private ToolStripItem CreateItem(IActionHandler actionHandler, ToolbarType type, object contextObject) { ToolStripItem item; switch (actionHandler.Style) { case ActionStyle.MenuItem: item = new ToolStripMenuItem(); break; case ActionStyle.Push: item = new ToolStripMenuItem(); item.Click += RunAction; break; case ActionStyle.Radio: //TODO: create Radio button ... item = new ToolStripMenuItem(); //HACK break; case ActionStyle.Toggle: //TODO: create Checkbox ... item = new ToolStripMenuItem(); //HACK ((ToolStripMenuItem)item).CheckOnClick = true; break; case ActionStyle.Pulldown: //TODO: create ListBox ... item = new ToolStripMenuItem(); //HACK break; case ActionStyle.Separator: item = new ToolStripSeparator(); break; default: item = new ToolStripMenuItem(); return(item); } item.Tag = actionHandler; item.Text = actionHandler.Label; if (!string.IsNullOrEmpty(actionHandler.IconId)) { item.Image = m_IconResourceService.GetBitmap(actionHandler.IconId); } switch (type) { case ToolbarType.Menu: { item.DisplayStyle = ToolStripItemDisplayStyle.ImageAndText; break; } case ToolbarType.Toolbar: { item.DisplayStyle = ToolStripItemDisplayStyle.Image; break; } default: { item.DisplayStyle = ToolStripItemDisplayStyle.Image; break; } } return(item); }
public MessageExplorerWidget(IBundleService bundleService , IIconResourceService iconResourceService , IDbSessionFactory sessionFactory , IPartRegistry partRegistry , IPageService pageService , IVirtualFileSystem virtualFileSystem , IViewPart viewPart) { m_BundleService = bundleService; m_IconResourceService = iconResourceService; m_sessionFactory = sessionFactory; m_PartRegistry = partRegistry; m_PageService = pageService; m_ToolStripFactory = pageService.PageLayoutProvider.ToolbarFactory; m_VirtualFileSystem = virtualFileSystem; m_viewPart = viewPart; InitializeComponent(); m_image_mail = iconResourceService.GetImage("jingxian.ui.icons.mail.png"); m_image_open_mail = iconResourceService.GetIcon("jingxian.ui.icons.maillist.open_mail.ico").ToBitmap(); m_image_close_mail = iconResourceService.GetIcon("jingxian.ui.icons.maillist.close_mail.ico").ToBitmap(); m_image_litter_point = iconResourceService.GetImage("jingxian.ui.icons.maillist.litter_point.png"); m_image_big_point = iconResourceService.GetImage("jingxian.ui.icons.maillist.big_point.png"); m_image_spam = iconResourceService.GetImage("jingxian.ui.icons.maillist.spam.png"); m_image_red_flag = iconResourceService.GetImage("jingxian.ui.icons.maillist.red_flag.png"); m_image_gray_flag = iconResourceService.GetImage("jingxian.ui.icons.maillist.gray_flag.png"); m_image_right = iconResourceService.GetImage("jingxian.ui.icons.maillist.right.png"); m_image_open_mail = iconResourceService.GetIcon("jingxian.ui.icons.maillist.open_mail.ico").ToBitmap(); m_image_close_mail = iconResourceService.GetIcon("jingxian.ui.icons.maillist.close_mail.ico").ToBitmap(); m_image_litter_point = iconResourceService.GetBitmap("jingxian.ui.icons.maillist.litter_point.png"); m_image_big_point = iconResourceService.GetBitmap("jingxian.ui.icons.maillist.big_point.png"); m_image_spam = iconResourceService.GetBitmap("jingxian.ui.icons.maillist.spam.png"); m_image_red_flag = iconResourceService.GetBitmap("jingxian.ui.icons.maillist.red_flag.png"); m_image_gray_flag = iconResourceService.GetBitmap("jingxian.ui.icons.maillist.gray_flag.png"); m_image_right = iconResourceService.GetBitmap("jingxian.ui.icons.maillist.right.png"); LoadAllMessages(); string startView = null; System.IO.TextReader textReader = new System.IO.StringReader(m_viewPart.ConfigurationXml); using (XmlReader reader = XmlReader.Create(textReader, XmlUtils.CreateFragmentReaderSettings(), XmlUtils.CreateParserContext())) { if (reader.IsStartElement("view")) { startView = XmlUtils.ReadRequiredAttributeString(reader, "ref"); } } if (string.IsNullOrEmpty(startView)) { return; } IWorkbenchPart welcomePart; m_PartRegistry.TryGet(jingxian.ui.Constants.WelcomeId, out welcomePart); if (null == welcomePart) { return; } UserControl control = new UserControl(); control.BorderStyle = BorderStyle.Fixed3D; control.Dock = DockStyle.Fill; this.m_splitter.Panel2.Controls.Add(control); Control welcomePage = welcomePart.Widget; welcomePage.Dock = DockStyle.Fill; control.Controls.Add(welcomePage); }
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"]; }