Beispiel #1
0
        private static int CompareTrlItems(KeyValuePair <string, KPTranslation> a,
                                           KeyValuePair <string, KPTranslation> b)
        {
            KPTranslationProperties pA = a.Value.Properties;
            KPTranslationProperties pB = b.Value.Properties;

            int c = StrUtil.CompareNaturally(pA.NameEnglish, pB.NameEnglish);

            if (c != 0)
            {
                return(c);
            }

            c = StrUtil.CompareNaturally(pA.NameNative, pB.NameNative);
            if (c != 0)
            {
                return(c);
            }

            c = StrUtil.CompareNaturally(pA.ApplicationVersion, pB.ApplicationVersion);
            if (c != 0)
            {
                return((c < 0) ? 1 : -1);                     // Descending
            }
            return(string.Compare(a.Key, b.Key, StrUtil.CaseIgnoreCmp));
        }
Beispiel #2
0
        public int Compare(object x, object y)
        {
            bool         bSwap = (m_oSort != SortOrder.Ascending);
            ListViewItem lviX = (bSwap ? (ListViewItem)y : (ListViewItem)x);
            ListViewItem lviY = (bSwap ? (ListViewItem)x : (ListViewItem)y);
            string       strL, strR;

            if ((m_nColumn <= 0) || (lviX.SubItems.Count <= m_nColumn) ||
                (lviY.SubItems.Count <= m_nColumn))
            {
                strL = lviX.Text;
                strR = lviY.Text;
            }
            else
            {
                strL = lviX.SubItems[m_nColumn].Text;
                strR = lviY.SubItems[m_nColumn].Text;
            }

            if (m_bCompareTimes)
            {
                if ((strL == m_strNeverExpires) || (strR == m_strNeverExpires))
                {
                    return(strL.CompareTo(strR));
                }

                DateTime dtL = TimeUtil.FromDisplayString(strL);
                DateTime dtR = TimeUtil.FromDisplayString(strR);
                return(dtL.CompareTo(dtR));
            }
            else
            {
                return(StrUtil.CompareNaturally(strL, strR));
            }
        }
Beispiel #3
0
		public int Compare(PwEntry a, PwEntry b)
		{
			string strA = a.Strings.ReadSafe(m_strFieldName);
			string strB = b.Strings.ReadSafe(m_strFieldName);

			if(m_bCompareNaturally) return StrUtil.CompareNaturally(strA, strB);

			return string.Compare(strA, strB, m_bCaseInsensitive);
		}
Beispiel #4
0
        /// <summary>
        /// The compare.
        /// </summary>
        /// <param name="a">
        /// The a.
        /// </param>
        /// <param name="b">
        /// The b.
        /// </param>
        /// <returns>
        /// The <see cref="int"/>.
        /// </returns>
        public int Compare(PwEntry a, PwEntry b)
        {
            string strA = a.Strings.ReadSafe(this.m_strFieldName);
            string strB = b.Strings.ReadSafe(this.m_strFieldName);

            if (this.m_bCompareNaturally)
            {
                return(StrUtil.CompareNaturally(strA, strB));
            }

            return(string.Compare(strA, strB, this.m_bCaseInsensitive ? StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture));
        }
Beispiel #5
0
        private static int CompareProfilesByName(SearchParameters spA, SearchParameters spB)
        {
            if (spA == null)
            {
                Debug.Assert(false); return((spB == null) ? 0 : -1);
            }
            if (spB == null)
            {
                Debug.Assert(false); return(1);
            }

            return(StrUtil.CompareNaturally(spA.Name, spB.Name));
        }
Beispiel #6
0
            public static int CompareByRoot(FsxContext a, FsxContext b)
            {
                if (a == null)
                {
                    Debug.Assert(false); return((b == null) ? 0 : -1);
                }
                if (b == null)
                {
                    Debug.Assert(false); return(1);
                }

                return(StrUtil.CompareNaturally(a.RootDirectory, b.RootDirectory));
            }
Beispiel #7
0
            public static int CompareByPath(FsxResult a, FsxResult b)
            {
                if (a == null)
                {
                    Debug.Assert(false); return((b == null) ? 0 : -1);
                }
                if (b == null)
                {
                    Debug.Assert(false); return(1);
                }

                return(StrUtil.CompareNaturally(a.Path, b.Path));
            }
Beispiel #8
0
        public int Compare(PwEntry a, PwEntry b)
        {
            string strA = a.Strings.ReadSafe(m_strFieldName);
            string strB = b.Strings.ReadSafe(m_strFieldName);

            if (m_bCompareNaturally)
            {
                return(StrUtil.CompareNaturally(strA, strB));
            }

#if KeePass2PCL || KeePassRT
            return(string.Compare(strA, strB, m_bCaseInsensitive ?
                                  StringComparison.CurrentCultureIgnoreCase : StringComparison.CurrentCulture));
#else
            return(string.Compare(strA, strB, m_bCaseInsensitive));
#endif
        }
        public static int CompareProfilesByName(PwProfile a, PwProfile b)
        {
            if (a == b)
            {
                return(0);
            }
            if (a == null)
            {
                Debug.Assert(false); return(-1);
            }
            if (b == null)
            {
                Debug.Assert(false); return(1);
            }

            return(StrUtil.CompareNaturally(a.Name, b.Name));
        }
 public int Compare(ListViewItem x, ListViewItem y)
 {
     Debug.Assert((x != null) && (y != null));
     return(StrUtil.CompareNaturally(x.Text, y.Text));
 }
 public int Compare(TreeNode x, TreeNode y)
 {
     Debug.Assert((x != null) && (y != null));
     return(StrUtil.CompareNaturally(x.Text, y.Text));
 }
Beispiel #12
0
        private void RecreateCustomIconList(PwUuid puSelect)
        {
            StringBuilder sb = new StringBuilder();

            List <ListViewItem> lUnnamed = new List <ListViewItem>();
            List <ListViewItem> lNamed   = new List <ListViewItem>();

            for (int i = 0; i < m_pd.CustomIcons.Count; ++i)
            {
                PwCustomIcon ci     = m_pd.CustomIcons[i];
                bool         bMulti = (ci.Name == MultipleValuesEx.CueString);

                ListViewItem lvi = new ListViewItem();
                if (ci.Name.Length == 0)
                {
                    lvi.Text = lUnnamed.Count.ToString();
                    lUnnamed.Add(lvi);
                }
                else
                {
                    lvi.Text = ci.Name;
                    if (bMulti)
                    {
                        lUnnamed.Insert(0, lvi);
                    }
                    else
                    {
                        lNamed.Add(lvi);
                    }
                }

                lvi.ImageIndex = i;
                lvi.Tag        = ci;

                Image img = ci.GetImage();
                if (bMulti)
                {
                    lvi.ToolTipText = ci.Name;
                }
                else if (img != null)
                {
                    if (sb.Length != 0)
                    {
                        sb.Remove(0, sb.Length);
                    }

                    if (ci.Name.Length != 0)
                    {
                        sb.AppendLine(ci.Name);
                    }
                    sb.Append(img.Width);
                    sb.Append(" \u00D7 ");
                    sb.Append(img.Height);
                    sb.AppendLine(" px");
                    sb.Append(StrUtil.FormatDataSizeKB((ulong)ci.ImageDataPng.Length));
#if DEBUG
                    if (ci.LastModificationTime.HasValue)
                    {
                        sb.AppendLine();
                        sb.Append("((( ");                         // Debug indicator
                        sb.Append(TimeUtil.ToDisplayString(ci.LastModificationTime.Value));
                        sb.Append(" )))");                         // Debug indicator
                    }
#endif

                    lvi.ToolTipText = sb.ToString();
                }
            }

            Comparison <ListViewItem> f = delegate(ListViewItem x, ListViewItem y)
            {
                string strX = (((x != null) ? x.Text : null) ?? string.Empty);
                string strY = (((y != null) ? y.Text : null) ?? string.Empty);
                return(StrUtil.CompareNaturally(strX, strY));
            };
            lNamed.Sort(f);

            List <ListViewItem> lAll = new List <ListViewItem>(lUnnamed.Count + lNamed.Count);
            lAll.AddRange(lUnnamed);
            lAll.AddRange(lNamed);

            ImageList ilCustom = UIUtil.BuildImageList(m_pd.CustomIcons,
                                                       DpiUtil.ScaleIntX(16), DpiUtil.ScaleIntY(16));

            m_lvCustomIcons.BeginUpdate();
            m_lvCustomIcons.Items.Clear();

            m_lvCustomIcons.SmallImageList = ilCustom;
            m_lvCustomIcons.Items.AddRange(lAll.ToArray());

            m_lvCustomIcons.EndUpdate();

            SelectCustomIcon(puSelect);             // Doesn't always work before EndUpdate()
        }
Beispiel #13
0
 public int Compare(PwGroup a, PwGroup b)
 {
     return(StrUtil.CompareNaturally(a.Name, b.Name));
 }