private static string AttachmentUnknown(IResource attach) { string iconFileName = Path.Combine(Path.GetTempPath(), _AttachIconFileName); string attachFileName = attach.GetStringProp(Core.Props.Name); if (!String.IsNullOrEmpty(attachFileName)) { Icon icon = FileIcons.GetFileLargeIcon(attachFileName); if (icon != null) { Image img = GraphicalUtils.ConvertIco2Bmp(icon, _backBrush); img.Save(iconFileName, ImageFormat.Png); } else { CreateUnknownTypeAttachmentIconPath(iconFileName); } } else { CreateUnknownTypeAttachmentIconPath(iconFileName); } string fragment = "<div class=\"picture ico\"><p><img src=\"" + iconFileName + "\" /></p></div>\n"; fragment += "<p class=\"content\">"; string preview = attach.GetPropText(Core.Props.PreviewText); fragment += !String.IsNullOrEmpty(preview) ? preview : _NoPreviewTemplate; fragment += "</p>\n\n"; return(fragment); }
public Icon GetResourceIcon(IResource resource) { IResource source = FileResourceManager.GetSource(resource); Icon icon; if (source == null || source.Type != "Weblink") { icon = FileIcons.GetFileSmallIcon(resource.GetPropText(Core.Props.Name)); } else { string path = string.Empty; try { Uri uri = new Uri(source.GetPropText("URL")); string query = uri.Query; if (query.Length > 1) { query = query.Substring(1); // skip leading '?' int i = query.IndexOf('='); if (i >= 0 && i < query.Length) { query = query.Substring(i + 1); } if (query.Length > 0) { return(FileIcons.GetFileSmallIcon(query)); } } path = uri.LocalPath; } catch {} icon = FileIcons.GetFileSmallIcon(path); } return(icon); }
public Icon GetResourceIcon(IResource resource) { return(FileIcons.GetFileSmallIcon(resource.GetPropText("Name"))); }
private void OnFormLoad(object sender, EventArgs e) { if ((m_pd == null) && (m_pg == null)) { Debug.Assert(false); throw new InvalidOperationException(); } GlobalWindowManager.AddWindow(this); string strTitle = (m_bExport ? KPRes.ExportFileTitle : KPRes.ImportFileTitle); string strDesc = (m_bExport ? KPRes.ExportFileDesc : KPRes.ImportFileDesc); Image img = (m_bExport ? Properties.Resources.B48x48_Folder_Txt : Properties.Resources.B48x48_Folder_Download); BannerFactory.CreateBannerEx(this, m_bannerImage, img, strTitle, strDesc); this.Icon = AppIcons.Default; this.Text = strTitle; UIUtil.ConfigureToolTip(m_ttRect); UIUtil.SetToolTip(m_ttRect, m_btnSelFile, StrUtil.TrimDots( KPRes.SelectFile, true), true); m_lvFormats.ShowGroups = true; int w = m_lvFormats.ClientSize.Width - UIUtil.GetVScrollBarWidth(); m_lvFormats.Columns.Add(string.Empty, w - 1); List <Image> lImages = new List <Image>(); Dictionary <string, FormatGroupEx> dictGroups = new Dictionary <string, FormatGroupEx>(); foreach (FileFormatProvider f in Program.FileFormatPool) { if (m_bExport && !f.SupportsExport) { continue; } if (!m_bExport && !f.SupportsImport) { continue; } string strDisplayName = f.DisplayName; if (string.IsNullOrEmpty(strDisplayName)) { Debug.Assert(false); continue; } string strAppGroup = f.ApplicationGroup; if (string.IsNullOrEmpty(strAppGroup)) { strAppGroup = KPRes.General; } FormatGroupEx grp; if (!dictGroups.TryGetValue(strAppGroup, out grp)) { grp = new FormatGroupEx(strAppGroup); dictGroups[strAppGroup] = grp; } ListViewItem lvi = new ListViewItem(strDisplayName); lvi.Group = grp.Group; lvi.Tag = f; img = f.SmallIcon; if (img == null) { string strExt = f.DefaultExtension; if (!string.IsNullOrEmpty(strExt)) { strExt = UIUtil.GetPrimaryFileTypeExt(strExt); } if (!string.IsNullOrEmpty(strExt)) { img = FileIcons.GetImageForExtension(strExt, null); } } if (img == null) { img = Properties.Resources.B16x16_Folder_Inbox; } int iImage = lImages.IndexOf(img); if (iImage < 0) { iImage = lImages.Count; lImages.Add(img); } lvi.ImageIndex = iImage; grp.Items.Add(lvi); } foreach (FormatGroupEx formatGroup in dictGroups.Values) { m_lvFormats.Groups.Add(formatGroup.Group); foreach (ListViewItem lvi in formatGroup.Items) { m_lvFormats.Items.Add(lvi); } } m_ilFormats = UIUtil.BuildImageListUnscaled(lImages, DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16)); m_lvFormats.SmallImageList = m_ilFormats; if (m_bExport) { m_grpFiles.Text = KPRes.Destination; UIUtil.SetText(m_lblFiles, KPRes.File + ":"); UIUtil.SetButtonImage(m_btnSelFile, Properties.Resources.B16x16_FileSaveAs, false); m_lnkFileFormats.Enabled = false; m_lnkFileFormats.Visible = false; } else // Import { m_grpFiles.Text = KPRes.Source; UIUtil.SetButtonImage(m_btnSelFile, Properties.Resources.B16x16_Folder_Yellow_Open, false); m_grpExport.Enabled = false; m_grpExportPost.Enabled = false; } m_cbExportMasterKeySpec.Checked = Program.Config.Defaults.ExportMasterKeySpec; m_cbExportParentGroups.Checked = Program.Config.Defaults.ExportParentGroups; m_cbExportPostOpen.Checked = Program.Config.Defaults.ExportPostOpen; m_cbExportPostShow.Checked = Program.Config.Defaults.ExportPostShow; UpdateUIState(); }
private void appendResults(GrepSearchResult result) { if (result == null) { return; } // Populate icon list string ext = Path.GetExtension(result.FileNameDisplayed); if (!treeViewExtensionList.Contains(ext)) { treeViewExtensionList.Add(ext); FileIcons.LoadImageList(treeViewExtensionList.ToArray()); tvSearchResult.ImageList = FileIcons.SmallIconList; } bool isFileReadOnly = Utils.IsReadOnly(result); string displayedName = Path.GetFileName(result.FileNameDisplayed); if (Properties.Settings.Default.ShowFilePathInResults && result.FileNameDisplayed.Contains(Utils.GetBaseFolder(tbFolderName.Text) + "\\")) { displayedName = result.FileNameDisplayed.Substring(Utils.GetBaseFolder(tbFolderName.Text).Length + 1); } int lineCount = Utils.MatchCount(result); if (lineCount > 0) { displayedName = string.Format("{0} ({1})", displayedName, lineCount); } if (isFileReadOnly) { displayedName = displayedName + " [read-only]"; } TreeNode node = new TreeNode(displayedName); node.Tag = result; tvSearchResult.Nodes.Add(node); node.ImageKey = ext; node.SelectedImageKey = node.ImageKey; node.StateImageKey = node.ImageKey; if (isFileReadOnly) { node.ForeColor = Color.DarkGray; } if (result.SearchResults != null) { for (int i = 0; i < result.SearchResults.Count; i++) { GrepSearchResult.GrepLine line = result.SearchResults[i]; string lineSummary = line.LineText.Replace("\n", "").Replace("\t", "").Replace("\r", "").Trim(); if (lineSummary.Length == 0) { lineSummary = " "; } else if (lineSummary.Length > 100) { lineSummary = lineSummary.Substring(0, 100) + "..."; } string lineNumber = (line.LineNumber == -1 ? "" : line.LineNumber + ": "); TreeNode lineNode = new TreeNode(lineNumber + lineSummary); lineNode.ImageKey = "%line%"; lineNode.SelectedImageKey = lineNode.ImageKey; lineNode.StateImageKey = lineNode.ImageKey; lineNode.Tag = line.LineNumber; if (!line.IsContext && Properties.Settings.Default.ShowLinesInContext) { lineNode.ForeColor = Color.Red; } node.Nodes.Add(lineNode); } } }