2008年3月29日 星期六

memo

//private void keyHook_KeyDown(object sender, KeyEventArgs e) private void queryCB_KeyDown(object sender, KeyEventArgs e) {
if (e.Control == true && e.KeyCode == Keys.C) { Clipboard.SetText(queryCB.SelectedText); e.Handled = false; e.SuppressKeyPress = true; return; } else if (e.Control == true && e.KeyCode == Keys.V) { queryCB.Text = Clipboard.GetText(); e.Handled = false; e.SuppressKeyPress = true; return; }
switch (e.KeyCode) { case Keys.RShiftKey: enabledBU_Click(this, new EventArgs()); break; case Keys.Enter: e.Handled = false; e.SuppressKeyPress = true; if(queryCB.Text.Trim().Length >0) beginQueryBU_ButtonClick(this, new EventArgs()); break; case Keys.BrowserBack: e.Handled = false; e.SuppressKeyPress = true; break; case Keys.Back: e.Handled = false; e.SuppressKeyPress = true; if (queryCB.Text.Length > 0) { try { int sLength = queryCB.SelectionLength == 0 ? 1 : queryCB.SelectionLength; int position = queryCB.SelectionLength == 0 ? queryCB.SelectionStart - 1 : queryCB.Text.IndexOf(queryCB.SelectedText); queryCB.Text = queryCB.Text.Remove(position, sLength); queryCB.SelectionStart = position > queryCB.Text.Length ? queryCB.Text.Length : position; queryCB.SelectionLength = 0; queryCB.Select(); } catch { } } break; case Keys.Delete: e.Handled = false; e.SuppressKeyPress = true; if (queryCB.Text.Length > 0 && queryCB.SelectionStart < slength =" queryCB.SelectionLength" position =" queryCB.SelectionStart;" text =" queryCB.Text.Remove(position," selectionstart =" position"> queryCB.Text.Length ? queryCB.Text.Length : position; queryCB.SelectionLength = 0; queryCB.Select(); } break; case Keys.Left: e.Handled = false; e.SuppressKeyPress = true; queryCB.SelectionLength = 0; if (queryCB.SelectionStart > 0) queryCB.SelectionStart = queryCB.SelectionStart - 1; break; case Keys.Right: e.Handled = false; e.SuppressKeyPress = true; queryCB.SelectionLength = 0; if (queryCB.SelectionStart < queryCB.Text.Length) queryCB.SelectionStart = queryCB.SelectionStart + 1; break; case Keys.Down: e.Handled = false; e.SuppressKeyPress = true; break; default: e.Handled = false; e.SuppressKeyPress = true; break; } }

2008年3月24日 星期一

如何將COM元件轉成.Net可以參考的DLL元件

COM COM+是微軟早期開發的元件,數量不在少數,如何引用這些COM元件。
本文以SHDOCVW.DLL這顆元件為例說明如何在.NET開發環境中引用參考:
首先請找到:SN.EXE(C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin)
接著產生一組新的金鑰組並將它寫入指定的檔案。
語法如下:
sn -k trObject.snk
然後利用tlbIMP.exe工具程式,將 COM 型別程式庫中的型別定義轉換為 Common Language Runtime 組件中的等效定義。
語法如下:
tlbimp c:\windows\system32\shdocvw.dll /out:c:\temp\Interop.shdocvw.dll /keyfile:trObject.snk /namespace:ShDocVw
如此就可以產生一顆含有強勢名稱的元件了。

2008年3月13日 星期四

DataTable的序列化和反序列化

來源網址:http://www.cnblogs.com/moonspell/archive/2007/07/17/821201.html
///
/// 序列化DataTable
///

/// DataTable
/// 序列化的DataTable
private static string SerializeDataTableXml(DataTable pDt) {
// 序列化DataTable
StringBuilder sb = new StringBuilder();
XmlWriter writer = XmlWriter.Create(sb);
XmlSerializer serializer = new XmlSerializer(typeof(DataTable));
serializer.Serialize(writer, pDt);
writer.Close();
return sb.ToString();
}

///
/// 反序列化DataTable
///

/// 序列化的DataTable
/// DataTable
public static DataTable DeserializeDataTable(string pXml) {

StringReader strReader = new StringReader(pXml);
XmlReader xmlReader = XmlReader.Create(strReader);
XmlSerializer serializer = new XmlSerializer(typeof(DataTable));

DataTable dt = serializer.Deserialize(xmlReader) as DataTable;

return dt;
}

2008年3月11日 星期二

Ajax Serialization Converters

(jsonserialization)
(converters)
(add type="Microsoft.Web.Preview.Script.Serialization.Converters.DataSetConverter, Microsoft.Web.Preview" name="DataSetConverter")
(add type="Microsoft.Web.Preview.Script.Serialization.Converters.DataRowConverter, Microsoft.Web.Preview" name="DataRowConverter")
(add type="Microsoft.Web.Preview.Script.Serialization.Converters.DataTableConverter, Microsoft.Web.Preview" name="DataTableConverter")
(/converters)
(/jsonserialization)