Exemple #1
0
        }        //end count

        public int Load(XmlNode nd, Image icoDefault, string baseFolder)
        {
            m_vData = new List <ClipboardEntryLogic>();
            try
            {
                XmlNodeList list = nd.SelectNodes("Settings/ClipBoardList/ClipboardEntry");
                for (int i = 0; i < list.Count; i++)
                {
                    try
                    {
                        string ownerType = XmlUtil.GetStrAtt(list[i], "OwnerType", "");
                        if (ownerType == m_sListType)
                        {
                            m_vData.Add(ClipboardEntryLogic.Load(list[i], m_sListType, icoDefault, baseFolder));
                        }
                    }                    //end try
                    catch (Exception err)
                    {
                        if (err.Message != ClipboardEntryLogic.OWNER_TYPE_MISMATCH)
                        {
                            System.Diagnostics.Trace.WriteLine("Clipboard entry ignored: " + err.Message);
                            FormClipboard.TraceLn(false, "ClipboardList", "Load",
                                                  "{0} Error: {1}", list[i].InnerXml, err.Message);
                        } //end if
                    }     //end catch
                }         //end for
            }             //end try
            catch (Exception err)
            {
                System.Diagnostics.Trace.WriteLine("ClipboardList: " + err.Message);
                FormClipboard.TraceLn(true, "ClipboardList", "Load",
                                      "{0} Error: {1}", m_sListType, err.Message);
            }    //end catch
            return(Count);
        }        //end Load
Exemple #2
0
        }        //end LoadImage

        public override bool Equals(object obj)
        {
            ClipboardEntryLogic clp = (ClipboardEntryLogic)obj;

            if (clp == null)
            {
                return(false);
            }
            return(clp._desc.Equals(_desc) && clp._dataType.Equals(_dataType));
        }        //end Equals
Exemple #3
0
        }        //end GetCurrentEntry

        public int FindEntry(ClipboardEntryLogic clp)
        {
            for (int i = 0; i < m_vData.Count; i++)
            {
                if (GetEntry(i).Equals(clp))
                {
                    return(i);
                }
            }    //end for
            return(-1);
        }        //end FindEntry
Exemple #4
0
		}//end m_btnCancel_Click

		private void m_btnRemove_Click(object sender, EventArgs e)
		{
			if (m_listFavorites.SelectedItems.Count == 0)
				return;

			for (int i = m_listFavorites.SelectedItems.Count - 1; i >= 0; i--)
			{
				ListViewItem itm = m_listFavorites.SelectedItems[i];
				ClipboardEntryLogic entry = (ClipboardEntryLogic)itm.Tag;
				int idx = m_ClipboardFavorites.FindEntry(entry);
				m_ClipboardFavorites.RemoveAt(idx);
				itm.Remove();
			}//end for
		}//end m_btnRemove_Click
Exemple #5
0
		}//end constructor

		private void FormFavorites_Load(object sender, EventArgs e)
		{
			m_listFavorites_SizeChanged(sender, e);
			for (int i = 0; i < m_ClipboardFavorites.Count; i++)
			{
				ClipboardEntryLogic entry = m_ClipboardFavorites.GetEntry(i);
				string sText = entry.ShortDesc();
				int ico = entry._icoItemType;

				ListViewItem itm = m_listFavorites.Items.Add(sText, ico);
				itm.Tag = entry;
			}//end for
			m_listFavorites_SelectedIndexChanged(null, null);
		}//end FormFavorites_Load
Exemple #6
0
		}//end m_btnDown_Click

		private void MoveSelectedItem(bool bUp)
		{
			if (m_listFavorites.SelectedItems.Count == 0)
				return;

			m_listFavorites.BeginUpdate();
			ListViewItem itm = m_listFavorites.SelectedItems[0];
			ClipboardEntryLogic entry = (ClipboardEntryLogic)itm.Tag;
			int idx = m_ClipboardFavorites.FindEntry(entry);
			m_ClipboardFavorites.RemoveAt(idx);
			itm.Remove();

			int nextIdx = bUp ? idx - 1 : idx + 1;

			m_listFavorites.Items.Insert(nextIdx, itm);
			m_ClipboardFavorites.Insert(nextIdx, entry);
			m_listFavorites.EndUpdate();
		}//end MoveSelectedItem
Exemple #7
0
		}//end m_listFavorites_SelectedIndexChanged

		private void m_listFavorites_DoubleClick(object sender, EventArgs e)
		{
			if ( m_listFavorites.SelectedItems.Count == 0 )
				return;

			try
			{
				ClipboardEntryLogic entry = (ClipboardEntryLogic)m_listFavorites.SelectedItems[0].Tag;
				entry.Put();
			}//end try
			catch ( Exception err )
			{
				System.Diagnostics.Trace.WriteLine("m_listFavorites_DoubleClick::Error: " + err.Message);
				FormClipboard.TraceLn(true, "FormFavorites", "m_listFavorites_DoubleClick",
					"Error: {0}", err.Message);
			}//end catch
			this.Close();
		}
Exemple #8
0
        }        //end AddEntry

        public bool AddEntry(ClipboardEntryLogic clp)
        {
            if (clp.IsEmpty)
            {
                m_EmptyEntry            = clp;
                m_EmptyEntry._ownerType = m_sListType;

                return(false); //not added
            }                  //end if

            m_bClipboardIsEmpty = false;

            int idx = FindEntry(clp);

            if (idx == 0)      //latest entry - already in
            {
                return(false); //not added
            }
            if (idx > 0)       //if exist - remove earlier
            {
                //restore first app ico - problems with first loading when clipboard not empty
                clp.SetAppIcon(GetEntry(idx)._icoAppFrom);
                m_vData[idx].DisposeImage();
                m_vData.RemoveAt(idx);
            }            //end if

            ClipboardEntryLogic c = clp.Clone();

            c._ownerType = this.m_sListType;
            m_vData.Insert(0, c);

            while (m_vData.Count > MAX_HISTORY) //if too big - remove from the end
            {
                m_vData[MAX_HISTORY].DisposeImage();
                m_vData.RemoveAt(MAX_HISTORY);
            }
            m_vData.TrimExcess();

            return(true);
        }        //end AddEntry
Exemple #9
0
        }        //end RemoveAt

        internal void Insert(int idx, ClipboardEntryLogic entry)
        {
            m_vData.Insert(idx, entry);
        } //end Insert
Exemple #10
0
 public ClipboardList(string sListType, ImageList list)
 {
     m_sListType = sListType;
     ClipboardEntryLogic.m_ImageList = list;
     m_EmptyEntry = ClipboardEntryLogic.CreateEmpty(sListType);
 }        //end constructor
Exemple #11
0
        }        //end Save

        //for load from Xml
        public static ClipboardEntryLogic Load(XmlNode nd, string sOwnerType, Image icoDefault, string baseFolder)
        {
            ClipboardEntryLogic entry = new ClipboardEntryLogic(sOwnerType);

            entry._dataType  = XmlUtil.GetStrAtt(nd, "Type", DataFormats.Text);
            entry._svFormats = new string[] { entry._dataType };

            entry._ownerType = XmlUtil.GetStrAtt(nd, "OwnerType", "");
            if (entry._ownerType != sOwnerType)
            {
                throw new Exception(OWNER_TYPE_MISMATCH);
            }

            string Value          = nd.InnerText;
            string sImageFileName = XmlUtil.GetStrAtt(nd, "Ico", "Image001");
            Image  ico            = LoadImage(Path.Combine(baseFolder, sImageFileName), icoDefault);

            entry._icoAppFrom = ico;
            if (ico == null)
            {
                entry._icoAppFrom = new Bitmap(16, 16);
            }

            if (entry._dataType == DataFormats.Rtf)
            {
                entry._icoItemType = 2;
                entry._data        = Value;
                m_RtfBox.Rtf       = Value;
                entry._desc        = m_RtfBox.Text;
                if (entry._desc.Trim().Length == 0)
                {
                    entry._desc = "--Rtf Binary--";
                }
            }            //end if
            else if (entry._dataType == DataFormats.UnicodeText)
            {
                entry._icoItemType = 1;
                entry._data        = Value;
                entry._desc        = Value;
            }            //end else if
            else if (entry._dataType == DataFormats.Text)
            {
                entry._icoItemType = 0;
                entry._data        = Value;
                entry._desc        = Value;
            }            //end else if
            else if (entry._dataType == DataFormats.FileDrop)
            {
                entry._icoItemType = 4;
                String[] sv = Value.Split('|');
                entry._data = sv;
                entry._desc = entry.FileDropListDesc(sv);
            }            //end else if
            else
            {
                throw new Exception("Unknown clipboard format");
            }            //end else

            System.Diagnostics.Trace.WriteLine(
                "File: " + Path.GetFileName(sImageFileName) +
                " Entry: " + entry.ShortDesc());

            return(entry);
        }        //end Load