Exemple #1
0
        public bool Update()
        {
            if (Clipboard.ContainsText())
            {
                var snapshot = new ClipboardSnapshot().Initialize(true);
                if (snapshot == null)
                {
                    return(false);
                }

                if (this.IsNew(snapshot))
                {
                    var snapshot2 = new ClipboardSnapshot().Initialize(false);
                    if (snapshot2 != null)
                    {
                        this.Snapshots.Add(snapshot2);
                        if (this.Snapshots.Count > MAX_ENTRY)
                        {
                            this.Snapshots.RemoveAt(0);
                        }
                        return(true);
                    }
                }
            }
            return(false);
        }
Exemple #2
0
        private bool IsNew(ClipboardSnapshot snapshot)
        {
            try {
                if (this.Snapshots.Count == 0)
                {
                    return(true);
                }

                foreach (var s in this.Snapshots)
                {
                    if (s.Equals(snapshot))
                    {
                        return(false);
                    }
                }

                return(true);
            }
            catch (System.Exception ex) {
                if (_errorCounter++ < 3)
                {
                    Util.MsgBoxError("IsNew() {0}".FormatString(ex.ToString()));
                }
                return(false);
            }
        }