}//end Load public bool Import(string sHistoryFileName, ClipboardList listMain, ClipboardList listFavorites, Image icoDefault) { try { try { DotNetZip.UnZipFiles(GetZipFilePath(sHistoryFileName), Path.GetDirectoryName(GetZipFilePath(sHistoryFileName))); }//end try catch (Exception err) { FormClipboard.TraceLn(true, "Settings", "Load", "Unzip: {0} Error: {1}", sHistoryFileName, err.Message); }//end catch XmlDocument doc = new XmlDocument(); doc.Load(sHistoryFileName); XmlNode root = doc.SelectSingleNode("Settings"); listMain.Load(doc, icoDefault, Path.GetDirectoryName(sHistoryFileName)); listFavorites.Load(doc, icoDefault, Path.GetDirectoryName(sHistoryFileName)); listMain.MAX_HISTORY = globalSettings.BufferMaxLen; listFavorites.MAX_HISTORY = globalSettings.BufferMaxLen; //File.Delete(sHistoryFileName); return(true); }//end try catch (Exception err) { FormClipboard.TraceLn(true, "Settings", "Load", "{0} Error: {1}", sHistoryFileName, err.Message); return(false); }//end catch }
} //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
public void Save(string sHistoryFileName, string sSettingsFileName, ClipboardList listMain, ClipboardList listFavorites) { globalSettings.Save(sSettingsFileName); try { IZip zip = null; try { zip = new DotNetZip(GetZipFilePath(sHistoryFileName), true); } catch (Exception err) { FormClipboard.TraceLn(true, "Settings", "Save", "Create Zip: {0} Error: {1}", sHistoryFileName, err.Message); }//end catch XmlDocument doc = new XmlDocument(); XmlNode root = doc.CreateNode(XmlNodeType.Element, "Settings", ""); root = doc.AppendChild(root); listMain.Save(root, zip); listFavorites.Save(root, zip); doc.PreserveWhitespace = true; XmlUtil.SaveXmlDocFormatted(doc, sHistoryFileName); zip.Add(sHistoryFileName); zip.Close(); File.Delete(sHistoryFileName); }//end try catch (Exception err) { FormClipboard.TraceLn(true, "Settings", "Save", "Exception: {0}", err.Message); } //end catch } //end save
}//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(); }
public void SetRichText(RichTextBox box, PictureBox lblApp, Label lblType) { box.SuspendLayout(); bool bReadOnly = box.ReadOnly; box.ReadOnly = false; try { lblApp.Image = _icoAppFrom; lblType.ImageIndex = _icoItemType; box.Clear(); if (_dataType == DataFormats.Rtf) { box.Rtf = (string)_data; } else if (_dataType == DataFormats.Bitmap || _dataType == DataFormats.Dib) { box.Paste(); } else //text, picture, file etc. { box.Text = _desc; } //box.SelectAll(); } catch (Exception err) { System.Diagnostics.Trace.WriteLine("ClipboardList: " + err.Message); FormClipboard.TraceLn(true, "ClipboardList", "SetRichText", "_dataType = '{0}' Error: {1}", _dataType, err.Message); } box.ReadOnly = bReadOnly; box.ResumeLayout(); } //end SetRichText
} //end CreateEmpty public void Save(XmlNode ndParent, IZip zip, string sImageFileName) { if (_data == null) { return; } string Value = ""; string Type = ""; if (_dataType == DataFormats.Text || _dataType == DataFormats.UnicodeText || _dataType == DataFormats.Rtf) { Type = _dataType; Value = (string)_data; } //end if else if (_dataType == DataFormats.FileDrop) { Type = _dataType; String[] sv = (String[])_data; StringBuilder sb = new StringBuilder(12); for (int i = 0; i < sv.Length; i++) { sb.Append(sv[i]); if (i != sv.Length - 1) { sb.Append('|'); } } //end for Value = sb.ToString(); } //end if else //do not know how to save { return; } try { File.Delete(sImageFileName); _icoAppFrom.Save(sImageFileName); if (zip != null) { zip.Add(sImageFileName); File.Delete(sImageFileName); } //end if System.Diagnostics.Trace.WriteLine( "File: " + Path.GetFileName(sImageFileName) + " Entry: " + ShortDesc()); } //end try catch (Exception err) { System.Diagnostics.Trace.WriteLine("Archiving Error: " + err.ToString()); FormClipboard.TraceLn(true, "ClipboardEntry", "Save", "{0} Error: {1}", sImageFileName, err.Message); } //end catch XmlNode ndEntry = XmlUtil.AddNewNode(ndParent, "ClipboardEntry", Value); XmlUtil.UpdStrAtt(ndEntry, "OwnerType", _ownerType); XmlUtil.UpdStrAtt(ndEntry, "Type", Type); XmlUtil.UpdStrAtt(ndEntry, "Ico", sImageFileName); } //end Save
public ClipboardMessageFilter(FormClipboard frm) { _frm = frm; }
} //end CaptureMouse /// <summary> /// Handles all mouse move messages sent to the Spy Window /// </summary> private void HandleMouseMovements() { // if we're not capturing, then bail out if (!_capturing) { return; } try { // capture the window under the cursor's position _hCurrentWindow = User32.WindowFromPoint(Cursor.Position); // if the window we're over, is not the same as the one before, and we had one before, refresh it if (_hPreviousWindow != IntPtr.Zero && _hPreviousWindow != _hCurrentWindow) { WindowHighlighter.Refresh(_hPreviousWindow); } // if we didn't find a window.. that's pretty hard to imagine. lol if (_hCurrentWindow == IntPtr.Zero) { m_txtHandle.Text = ""; m_txtClass.Text = ""; m_txtCaption.Text = ""; m_txtStyle.Text = ""; m_txtRect.Text = ""; } //end if else { // save the window we're over _hPreviousWindow = _hCurrentWindow; m_txtProcess.Text = GetProcessPath(_hCurrentWindow); m_txtHandle.Text = string.Format("{0}", _hCurrentWindow.ToInt32().ToString()); m_txtClass.Text = this.GetClassName(_hCurrentWindow); m_txtCaption.Text = User32.GetWindowText(_hCurrentWindow); if (m_txtClass.Text == "Edit" || m_txtCaption.Text == "") { m_txtCaption.Text = User32.GetText(_hCurrentWindow); } //end if User32.GetWindowRect(_hCurrentWindow, out User32.RECT rc); User32EnumChildWindows.EnumChildWindows(_hCurrentWindow, m_txtCaption.Text); // rect m_txtRect.Text = string.Format( "[{0} x {1}], ({2})", rc.Right - rc.Left, rc.Bottom - rc.Top, rc.ToString()); // highlight the window WindowHighlighter.Highlight(_hCurrentWindow); } //end else } //end try catch (Exception err) { Debug.WriteLine("HandleMouseMovements: " + err); FormClipboard.TraceLn(false, "FormSpyWindow", "HandleMouseMovements", "Error: {0}", err.Message); } //end catch } //end HandleMouseMovements