当前位置: 首页>>代码示例>>C#>>正文


C# PwDatabase.GetCustomIconIndex方法代码示例

本文整理汇总了C#中KeePassLib.PwDatabase.GetCustomIconIndex方法的典型用法代码示例。如果您正苦于以下问题:C# PwDatabase.GetCustomIconIndex方法的具体用法?C# PwDatabase.GetCustomIconIndex怎么用?C# PwDatabase.GetCustomIconIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KeePassLib.PwDatabase的用法示例。


在下文中一共展示了PwDatabase.GetCustomIconIndex方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ImportIcon

        private static void ImportIcon(XmlNode xn, PwEntry pe, PwDatabase pd)
        {
            XmlNode xnIcon = xn.Attributes.GetNamedItem("ICON");
            if(xnIcon == null) return;

            string strIcon = xnIcon.Value;
            if(!StrUtil.IsDataUri(strIcon)) { Debug.Assert(false); return; }

            try
            {
                byte[] pbImage = StrUtil.DataUriToData(strIcon);
                if((pbImage == null) || (pbImage.Length == 0)) { Debug.Assert(false); return; }

                Image img = GfxUtil.LoadImage(pbImage);
                if(img == null) { Debug.Assert(false); return; }

                byte[] pbPng;
                int wMax = PwCustomIcon.MaxWidth;
                int hMax = PwCustomIcon.MaxHeight;
                if((img.Width <= wMax) && (img.Height <= hMax))
                {
                    MemoryStream msPng = new MemoryStream();
                    img.Save(msPng, ImageFormat.Png);
                    pbPng = msPng.ToArray();
                    msPng.Close();
                }
                else
                {
                    Image imgSc = GfxUtil.ScaleImage(img, wMax, hMax);

                    MemoryStream msPng = new MemoryStream();
                    imgSc.Save(msPng, ImageFormat.Png);
                    pbPng = msPng.ToArray();
                    msPng.Close();

                    imgSc.Dispose();
                }
                img.Dispose();

                PwUuid pwUuid = null;
                int iEx = pd.GetCustomIconIndex(pbPng);
                if(iEx >= 0) pwUuid = pd.CustomIcons[iEx].Uuid;
                else
                {
                    pwUuid = new PwUuid(true);
                    pd.CustomIcons.Add(new PwCustomIcon(pwUuid, pbPng));
                    pd.UINeedsIconUpdate = true;
                    pd.Modified = true;
                }
                pe.CustomIconUuid = pwUuid;
            }
            catch(Exception) { Debug.Assert(false); }
        }
开发者ID:Stoom,项目名称:KeePass,代码行数:53,代码来源:MozillaBookmarksHtml100.cs

示例2: InitalizeList

        void InitalizeList(bool autodetect)
        {
            mCustomTreeViewEx.BeginUpdate();
              mCustomTreeViewEx.Nodes.Clear();
              mCachedNow = DateTime.Now;
              bool entriesFound = false;

              foreach (var db in ext.pluginHost.MainWindow.DocumentManager.GetOpenDatabases()) {
            mActiveDb = db;
            UpdateImageLists();

            TreeNode rootNode = null;
            var rootGroup = mActiveDb.RootGroup;
            if (rootGroup != null) {
              int nIconID = ((!rootGroup.CustomIconUuid.EqualsValue(PwUuid.Zero)) ?
            ((int)PwIcon.Count + mActiveDb.GetCustomIconIndex(
            rootGroup.CustomIconUuid)) : (int)rootGroup.IconId);
              if (rootGroup.Expires && (rootGroup.ExpiryTime <= mCachedNow)) {
            nIconID = (int)PwIcon.Expired;
              }

              rootNode = new TreeNode(rootGroup.Name, nIconID, nIconID);
              rootNode.Tag = rootGroup;
              rootNode.ForeColor = SystemColors.GrayText;

              if (mBoldFont != null) {
            rootNode.NodeFont = mBoldFont;
              }
              rootNode.ToolTipText = db.IOConnectionInfo.GetDisplayName();

              mCustomTreeViewEx.Nodes.Add(rootNode);

              entriesFound |= RecursiveAddGroup(rootNode, rootGroup, autodetect);
            }

            if (rootNode != null) {
              rootNode.Expand();
            }
              }
              mCustomTreeViewEx.EndUpdate();

              if (!entriesFound) {
            if (autodetect) {
              MessageService.ShowWarning("No entries with SSH keys were found.");
              Close();
            } else {
              // Use timer so that this dialog finishes displaying before attempting
              // the auto-detect routine.
              var autodetectDialogDelayTimer = new Timer();
              autodetectDialogDelayTimer.Interval = 100;
              autodetectDialogDelayTimer.Tick += (sender, e) =>
              {
            autodetectDialogDelayTimer.Stop();
            AskShouldAutodetect();
              };
              autodetectDialogDelayTimer.Start();
            }
              }
        }
开发者ID:dlech,项目名称:KeeAgent,代码行数:59,代码来源:EntryPickerDialog.cs


注:本文中的KeePassLib.PwDatabase.GetCustomIconIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。