public bool Init(SqlConnection Conn, string strIconDir) { // 初始化数据库连接及数据表 helper.CurrentSqlConnection = Conn; helper.InitCacheTable(); tgaIO.sqlConn = Conn; m_id = -1; tgaIO.StrIconFolder = strIconDir; m_formselector = new FormSelector(); m_formselector.Tag = this; if (m_bEdit) { m_formselector.EnterEditMode(); } FormScan form = new FormScan(); object[] objs = form.Init(Conn, strIconDir, m_formselector.imageIcons); m_formselector.IconsInfo = objs; inited = true; if (objs.Length > 0) { form.ShowDialog(); //显示图像并创建ImageList } else { return(false); } return(true); }
public bool Init(SqlConnection Conn, string strIconDir) { // 初始化数据库连接及数据表 helper.CurrentSqlConnection = Conn; helper.InitCacheTable(); tgaIO.sqlConn = Conn; m_id = -1; tgaIO.StrIconFolder = strIconDir; m_formselector = new FormSelector(); m_formselector.Tag = this; if (m_bEdit) m_formselector.EnterEditMode(); FormScan form = new FormScan(); object[] objs = form.Init(Conn, strIconDir, m_formselector.imageIcons); m_formselector.IconsInfo = objs; inited = true; if (objs.Length > 0) { form.ShowDialog(); //显示图像并创建ImageList } else { return false; } return true; }
public static string tga2rtf(int id, System.Data.SqlClient.SqlConnection conn, string strIconDir) { FormScan form = new FormScan(); string filename = ""; int frame = 0; //查询数据库查得文件名 DataTable tbl = GetDataTable("select * from icon where id=" + id.ToString(), conn); if (tbl.Rows.Count == 0) { return(""); } DataRow row = tbl.Rows[0]; filename = strIconDir + "\\" + row["filename"].ToString(); frame = Convert.ToInt32(row["frame"]); if (!System.IO.File.Exists(filename)) { return(""); } //根据文件名读出图形 Image timg = sprViewer.tga.uitex2img(strIconDir, filename, frame); if (timg == null) { return(""); } //备份剪切板 //Object obj = new Object(); //obj = Clipboard.GetDataObject(); //恢复剪切板 //Clipboard.SetDataObject(obj); //转换图像 Clipboard.SetImage(timg); form.txt.Clear(); form.txt.Paste(); //返回结果 form.txt.SelectAll(); return(form.txt.SelectedRtf); }
private void ReloadUsedCount() { DataTable tbl = FormScan.GetDataTable("select *,(select count(*) from tbl_icon_item where icon.id=tbl_icon_item.iconid) as c from icon"); for (int i = 0; i < tbl.Rows.Count; i++) { DataRow row = tbl.Rows[i]; int id = Convert.ToInt32(row["ID"]); int usedcount = Convert.ToInt32(row["c"]); foreach (object o in m_iconsinfo) { if (o is Info) { Info inf = o as Info; if (inf.id == id) { inf.usedcount = usedcount; } } } } }
private void FormSelector_Shown(object sender, EventArgs e) { Info SelectedInfo = null; foreach (object obj in m_iconsinfo) { Info info = (Info)obj; //ListViewItem item = listview.Items.Add(info.fielname, info.ImageIndex); //item.Tag = info; TreeNode node; if (!treeView.Nodes.ContainsKey(info.kind)) { node = treeView.Nodes.Add(info.kind, info.kind); } else { node = treeView.Nodes[info.kind]; } if (node.Tag == null) { node.Tag = new ArrayList(); } ArrayList arr = (ArrayList)node.Tag; arr.Add(info); m_allicons.Add(info); // ahpho // 在这里加入第二层的处理 TreeNode _2ndNode = null; TreeNode _undefineNode = null; if (!node.Nodes.ContainsKey(m_strUndefined)) { _undefineNode = node.Nodes.Add(m_strUndefined, m_strUndefined); } else { _undefineNode = node.Nodes[m_strUndefined]; } if (info.subKind == string.Empty) { _2ndNode = _undefineNode; } else { if (!node.Nodes.ContainsKey(info.subKind)) { _2ndNode = node.Nodes.Add(info.subKind, info.subKind); } else { _2ndNode = node.Nodes[info.subKind]; } } if (_2ndNode.Tag == null) { _2ndNode.Tag = new ArrayList(); } ArrayList _2ndArr = _2ndNode.Tag as ArrayList; _2ndArr.Add(info); if (SelectedInfo == null && info.id == SelectedID) { SelectedInfo = info; } } if (SelectedInfo != null) { TreeNode _node = FindTreeNodeWithInfo(SelectedInfo); treeView.SelectedNode = _node; // TreeNode[] nodes = treeView.Nodes.Find(SelectedInfo.kind, true); // if (nodes != null && nodes.Length > 0) // treeView.SelectedNode = nodes[0]; } listview.Select(); DataTable tbl = FormScan.GetDataTable("select Tag1 from icon group by Tag1"); foreach (DataRow row in tbl.Rows) { if (row[0].ToString() != string.Empty) { txtTag1.Items.Add(row[0].ToString()); } } tbl = FormScan.GetDataTable("select Tag2 from icon group by Tag2"); foreach (DataRow row in tbl.Rows) { if (row[0].ToString() != string.Empty) { txtTag2.Items.Add(row[0].ToString()); } } }
public static string tga2rtf(int id, System.Data.SqlClient.SqlConnection conn, string strIconDir) { FormScan form = new FormScan(); string filename = ""; int frame = 0; //查询数据库查得文件名 DataTable tbl = GetDataTable("select * from icon where id=" + id.ToString(), conn); if (tbl.Rows.Count == 0) { return (""); } DataRow row = tbl.Rows[0]; filename = strIconDir + "\\" + row["filename"].ToString(); frame = Convert.ToInt32(row["frame"]); if (!System.IO.File.Exists(filename)) { return (""); } //根据文件名读出图形 Image timg = sprViewer.tga.uitex2img(strIconDir, filename, frame); if(timg == null) { return(""); } //备份剪切板 //Object obj = new Object(); //obj = Clipboard.GetDataObject(); //恢复剪切板 //Clipboard.SetDataObject(obj); //转换图像 Clipboard.SetImage(timg); form.txt.Clear(); form.txt.Paste(); //返回结果 form.txt.SelectAll(); return form.txt.SelectedRtf; }