eDCenter 从2007年3月之后, 一直沉寂。
2008年5月接到的一个厂家询问, 我决定重新启动eDCenter 软件, 希望能带来好运!
Tuesday, June 10, 2008
Restart eDCenter Dev and sales
Posted by
WadeLiu
at
11:22 PM
0
comments
Labels: eDCenter
Freesoftware and opensoftwares
优秀开源和免费软件下载网站有:
http://portableapps.com/
http://nirsoft.net/
http://www.pendriveapps.com/
http://www.downloadsquad.com/
http://www.osalt.com/
24 Killer Portable Apps For Your USB Flash Drive
http://www.downloadsquad.com/2008/09/02/24-killer-portable-apps-for-your-usb-flash-drive/
Database Browser(Portable Edition,支持Oracle, SQL Server,ODBC)
http://www.dbsoftlab.com/index.php/Freeware/Database-Browser.html
NetSetManagement (portable Edition) 方便切换多个IP和网关
http://www.pendriveapps.com/2008/03/31/netsetman-portable-network-settings-manager/
WinDirStatPortable(分析磁盘文件的占用情况)
http://portableapps.com/apps/utilities/windirstat_portable
PidginPortable(MSN, QQ等IM 客户端)
http://portableapps.com/apps/internet/pidgin_portable
EraserPortable(securely Delete file/folder)
http://portableapps.com/apps/utilities/eraser_portable
MyUninstaller(非常好用的卸载工具)
http://www.nirsoft.net/utils/myuninst.html
Sumatra PDF Portable (PDF Reader)
http://portableapps.com/apps/office/sumatra_pdf_portable
Keepass--Protect your password
http://keepass.info/
italc--Local network computer projector, for team learning and team computer control.
http://italc.sourceforge.net
Desktops--Virtual Windows desktop manager, just like linux multi-desktop
http://technet.microsoft.com/en-us/sysinternals/cc817881.aspx
EyeDefender--Alert you when you have used computer for a period
http://eterlab.com/
Locate--Just the linux locate command
http://locate32.webhop.org/
WordWeb--English thesaurus and dictionary lookup
http://wordweb.info/free/
Posted by
WadeLiu
at
10:49 PM
0
comments
Labels: Uncategorized
Monday, May 26, 2008
How to hide or show TabPage of TabControl
C# 的TabControl功能严重不足, 尤其是你用它来制作Wizard界面时候, 下面代码会有所帮助的.
namespace LiuHarry.Utils.Components
{
using System;
using System.Windows.Forms;
public class TabControlHelper
{
private TabControl m_tabControl;
public TabControlHelper(TabControl tabCtrl)
{
this.m_tabControl = tabCtrl;
}
public void HideTabPage(TabPage tp)
{
if (this.m_tabControl.TabPages.Contains(tp))
{
this.m_tabControl.TabPages.Remove(tp);
}
}
private void InsertTabPage(TabPage tabpage, int index)
{
if ((index < 0) || (index > this.m_tabControl.TabCount))
{
throw new ArgumentException("Index out of Range.");
}
this.m_tabControl.TabPages.Add(tabpage);
if (index < (this.m_tabControl.TabCount - 1))
{
do
{
this.SwapTabPages(tabpage, this.m_tabControl.TabPages[this.m_tabControl.TabPages.IndexOf(tabpage) - 1]);
}
while (this.m_tabControl.TabPages.IndexOf(tabpage) != index);
}
this.m_tabControl.SelectedTab = tabpage;
}
public void ShowTabPage(TabPage tp)
{
this.ShowTabPage(tp, this.m_tabControl.TabPages.Count);
}
public void ShowTabPage(TabPage tp, int index)
{
if (!this.m_tabControl.TabPages.Contains(tp))
{
this.InsertTabPage(tp, index);
}
}
private void SwapTabPages(TabPage tp1, TabPage tp2)
{
if (!(this.m_tabControl.TabPages.Contains(tp1) && this.m_tabControl.TabPages.Contains(tp2)))
{
throw new ArgumentException("TabPages must be in the TabControls TabPageCollection.");
}
int index = this.m_tabControl.TabPages.IndexOf(tp1);
int num2 = this.m_tabControl.TabPages.IndexOf(tp2);
this.m_tabControl.TabPages[index] = tp2;
this.m_tabControl.TabPages[num2] = tp1;
this.m_tabControl.SelectedIndex = this.m_tabControl.SelectedIndex;
string text = tp1.Text;
string str2 = tp2.Text;
tp1.Text = str2;
tp2.Text = text;
}
}
}
Posted by
WadeLiu
at
9:48 PM
0
comments
Labels: Uncategorized
DataGridViewHelper class
DataGridView这个控件在开发中经常会被用到, C#的组件总觉得不如Delphi组件那么容易使用, 怎样在Grid上选择一个Row, 怎样选择一个Cell, 我就被block了好久. 下面是代码:
namespace LiuHarry.Utils.Components
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Windows.Forms;
public class DataGridViewHelper
{
private DataGridView m_DataGridView;
private SortedList<string, string> m_MapListFieldColumn = new SortedList<string, string>();
private DataView m_ShowedDataViewInGrid;
public DataGridViewHelper(DataGridView dataGridView, DataView showedDataViewInGrid)
{
this.m_DataGridView = dataGridView;
this.m_ShowedDataViewInGrid = showedDataViewInGrid;
this.InitFieldColumnMapList();
}
private string _GetGridViewColumnName(string dataFieldName)
{
for (int i = 0; i < this.m_DataGridView.Columns.Count; i++)
{
if (this.m_DataGridView.Columns[i].DataPropertyName == dataFieldName)
{
return this.m_DataGridView.Columns[i].Name;
}
}
return "";
}
private void InitFieldColumnMapList()
{
this.m_MapListFieldColumn.Clear();
for (int i = 0; i < this.m_ShowedDataViewInGrid.Table.Columns.Count; i++)
{
string columnName = this.m_ShowedDataViewInGrid.Table.Columns[i].ColumnName;
string str2 = this._GetGridViewColumnName(columnName);
this.m_MapListFieldColumn.Add(columnName, str2);
}
}
public string QuickFindGridViewColumnName(string dataFieldName)
{
int num = this.m_MapListFieldColumn.IndexOfKey(dataFieldName);
if (num < 0)
{
throw new Exception("There no a column in DataGridView corresponding DataFieldName=" + dataFieldName);
}
return this.m_MapListFieldColumn.Values[num];
}
public void SelectAndScrollToCell(string fieldName, object fieldValue)
{
this.m_DataGridView.ClearSelection();
if ((fieldName != null) && (fieldValue != null))
{
string str = this.QuickFindGridViewColumnName(fieldName);
foreach (DataGridViewRow row in (IEnumerable) this.m_DataGridView.Rows)
{
if (object.Equals(row.Cells[str].Value, fieldValue))
{
this.m_DataGridView.CurrentCell = row.Cells[str];
this.m_DataGridView.CurrentCell.Selected = true;
break;
}
}
}
}
public void SelectRow(object valueOfSortedField)
{
DataView showedDataViewInGrid = this.m_ShowedDataViewInGrid;
this.m_DataGridView.ClearSelection();
if ((showedDataViewInGrid != null) && (valueOfSortedField != null))
{
int num = showedDataViewInGrid.Find(valueOfSortedField);
if (num >= 0)
{
this.m_DataGridView.Rows[num].Selected = true;
}
}
}
public SortedList<string, string> MapListFieldColumn
{
get
{
return this.m_MapListFieldColumn;
}
}
}
}
Posted by
WadeLiu
at
9:42 PM
0
comments
Labels: Uncategorized
Managed ExecuteShell API
namespace LiuHarry.Utils.Foundation
{
using System;
using System.Diagnostics;
public class CommandShell
{
public static string RunCmd(string command)
{
Process process = new Process();
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = "/c " + command;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardInput = true;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
return process.StandardOutput.ReadToEnd();
}
public static void CallWindowsApp()
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
//call calculator
proc.StartInfo.FileName="calc";
proc.Start();
}
public static void GotoWebSite()
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="iexplore";
proc.StartInfo.Arguments=http://www.microsoft.com;
proc.Start();
proc.WaitForExit();
MessageBox.Show("You have just visited www.microsoft.com");
}
public static void OpenWordDocument()
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="winword";
proc.StartInfo.Arguments="C:DotnetstuffTestWordDoc.doc";
proc.Start();
}
public static void ExecuteBatchFile()
{
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents=false;
proc.StartInfo.FileName="c:dotnetstuff
etdrv.bat";
proc.Start();
MessageBox.Show("Map Drive Created");
}
}
}
Posted by
WadeLiu
at
9:09 PM
0
comments
Labels: Uncategorized
How to create a new XmlElement
XmlNode是一个Context相关的对象, 你不能直接调用XmlNode的构造子来创建一个XmlNode. 要创建一个XmlNode有两个方法. 假设要在xmlParentNode下创建一个newNode.
方法1: 通过XmlDocument的CreateElement方法创建一个XmlNode
public XmlElement CreateElement(prefix,localName,namespaceURI),如果元素带有namespace,必须加上namespaceURI, 比如:
步骤1:XmlElement newNode= docNode.CreateElement("w", "br", "http://schemas.openxmlformats.org/wordprocessingml/2006/main");
步骤2:xmlParentNode.InsertAfter(br, rNode.FirstChild);
方法2: 不是直接创建XmlElement,而是通过修改xmlParentNode的InnerXml文本, 来增加一个节点.记住:如果新加的内容包含前缀,一定要加上namespace URI.否则会报错的.
xmlParentNode.InnerXml= @"<w:r xmlns:w=""http://schemas.openxmlformats.org/wordprocessingml/2006/main""><w:rPr>
</w:rPr>
<w:br/>
<w:t>Some string </w:t></w:r>";
Posted by
WadeLiu
at
6:42 PM
0
comments
Labels: Uncategorized
Tuesday, May 6, 2008
How to design a class which has absolute readonly List property
有时候, 我们设计的类,包含一个Collection对象, 要求该类的使用者可以访问这个Collection属性, 而不能修改Collection的Item, 比如一个容器类.
如果这个属性是List<T>类型的话, 即使该Collection属性只有getter方法, 也无法阻止容器类的使用者修改的Collection的元素.
.Net的System.Collections.ObjectModel命名空间中包含一个ReadOnlyCollection<T>,
可以帮你做到对Collection的绝对只读封装. 其实ReadOnlyCollection类实现了IList<T>接口, 但它没有将Items属性设置public, 而是将它设为protected,
这样就ReadOnlyCollection对象就不能得到Items属性, 但可以通过属性索引来查的单个元素的值.ReadOnlyCollection的这种实现方法值得好好学习.
.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: Consolas, "Courier New", Courier, Monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }
/// <summary>
/// CtrlContainer的使用者
/// </summary>
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
CtrlContainer cc = new CtrlContainer("file1.dfm");
//可以通过cc.ListControl属性增加一个元素
cc.ListControl.Add("ImageBox");
//不能可以通过cc.ReadOnlyListControl属性增加或修改一个元素, 只能读取某个元素
string firstControlName = cc.ReadOnlyListControl[0];
MessageBox.Show(firstControlName);
}
}
/// <summary>
/// 一个展现ReadOnlyCollection的Demo Class,
/// 这个类是一个Control的容器类, 它通过分析一个dfm文件, 获取该文件包含的所有Control,
/// 不允许CtrlContainer类的使用者修改Control的列表
/// </summary>
public class CtrlContainer
{
private List<string> m_ListControl = new List<string>();
/// <summary>
/// 这个只读属性其实并不能很好地防止CtrlContainer类的使用者修改m_ListControl的元素,
/// 因为他仍然可以使用ListControl.Add()等方法.
/// </summary>
public List<string> ListControl
{
get { return m_ListControl; }
}
//using System.Collections.ObjectModel;
ReadOnlyCollection<string> m_ReadOnlyListControl;
/// <summary>
/// 这个属性可以确保CtrlContainer类的使用者不能修改m_ListControl的元素, 只能读取m_ListControl的元素
/// </summary>
public ReadOnlyCollection<string> ReadOnlyListControl
{
get { return m_ReadOnlyListControl; }
}
public CtrlContainer(string dfmFileName)
{
//parse the dfm file, and extract all controls
m_ListControl.Add("Button");
// 因为m_ListControl是以引用的方式传给ReadOnlyCollection,
// 所以, 无论是在创建m_ReadOnlyListControl之前或之后, 对m_ListControl的元素进行操作, 都将反映到m_ReadOnlyListControl上
m_ReadOnlyListControl = new ReadOnlyCollection<string>(m_ListControl);
m_ListControl.Add("Richbox");
m_ListControl.Add("ComboBox");
}
}
Posted by
WadeLiu
at
12:36 AM
0
comments
Labels: Uncategorized