c# asp.net 鼠标改变控件坐标位置,更改控件坐标,注册表保存读取,打印,查找局域网内打印机等等收集
作者:佚名    ASP.NET网站开发编辑:admin   更新时间:2022-07-23
c# asp.net 鼠标改变控件坐标位置,更改控件坐标,注册表保存读取,打印,查找局域网内打印机等等收集
界面虽然被我弄的很难看,但功能还可以里边注册表的路径自己设置一下,或者加一个创建注册表的语句,不然会报错前台:
Html代码
- <%@PageLanguage="C#"AutoEventWireup="true"CodeFile="FPSZ.aspx.cs"Inherits="_Default"%>
- <!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <scriptlanguage="javaScript"type="text/Javascript"src="js/Move.js"></script>
- <scriptlanguage="JavaScript"type="text/javascript"src="js/PReview.js"></script>
- <htmlxmlns="http://www.w3.org/1999/xhtml">
- <headrunat="server">
- <title>无标题页</title>
- </head>
- <body>
- <formid="form1"runat="server">
- <!--startprint-->
- <div>
- <div>
- <tablewidth="100%">
- <tr>
- <td>
- <tablewidth="100%">
- <tr>
- <td>
- <asp:PanelID="pnlFPSZ"BorderWidth="1"Width="100%"runat="server">
- <tablewidth="100%">
- <tr>
- <td>
- <tablewidth="100%">
- <tr>
- <tdstyle="height:96px">
- <tablewidth="100%">
- <tr>
- <td>
- <asp:LabelID="lblTKRQ"Text="黑色头发:"runat="server"Font-Underline="true"></asp:Label>
- </td>
- <td>
- <asp:LabelID="lblTKRQText"Text="黑色头发"runat="server"name="label"BackColor="silver"Style="left:335px;position:absolute;top:179px"onclick="getID('lblTKRQText')"Width="50"></asp:Label>
- <asp:HiddenFieldID="lblTKRQText_hdl_Top"runat="server"Value=""/>
- <asp:HiddenFieldID="lblTKRQText_hdl_Left"runat="server"Value=""/>
- </td>
- </tr>
- </table>
- </td>
- <tdstyle="height:96px">
- <tablewidth="100%">
- <tr>
- <td>
- <asp:LabelID="lblMC"Text="紫色头发"runat="server"name="label"BackColor="silver"Style="left:500px;position:absolute;top:179px"onclick="getID('lblMC')"Width="50"></asp:Label>
- <asp:HiddenFieldID="lblMC_hdl_Top"runat="server"Value=""/>
- <asp:HiddenFieldID="lblMC_hdl_Left"runat="server"Value=""/>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr>
- <tdcolspan="1"style="height:340px">
- <tablewidth="100%"border="3">
- <tr>
- <tdstyle="width:155px">
- <asp:LabelID="lblJKDW_XM"Text="黑色头发紫色头发"runat="server"Font-Underline="true"></asp:Label>
- </td>
- <tdstyle="height:41px">
- <asp:LabelID="lblJKDW_XMText"Text="黑紫色头发"runat="server"name="label"BackColor="silver"Style="left:450px;position:absolute;top:272px"onclick="getID('lblJKDW_XMText')"Width="37"></asp:Label>
- <asp:HiddenFieldID="lblJKDW_XMText_hdl_Top"runat="server"Value=""/>
- <asp:HiddenFieldID="lblJKDW_XMText_hdl_Left"runat="server"Value=""/>
- </td>
- <tdstyle="height:41px">
- <tablewidth="100%"border="3">
- <tr>
- <td>
- <asp:LabelID="lblJKFS"Text="北京市"runat="server"Font-Underline="true"></asp:Label>
- </td>
- <td>
-
-
- <asp:LabelID="lblJKFSText"Text="北京市"runat="server"Font-Underline="True"name="label"BackColor="silver"Style="left:850px;position:absolute;top:274px"onclick="getID('lblJKFSText')"Width="27"></asp:Label>
- <asp:HiddenFieldID="lblJKFSText_hdl_Top"runat="server"Value=""/>
- <asp:HiddenFieldID="lblJKFSText_hdl_Left"runat="server"Value=""/>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </asp:Panel>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- </table>
- </div>
- <br/>
- <div>
- <tablewidth="100%">
- <tr>
- <tdstyle="width:104px">
- <asp:LabelID="lblDQDYJ"Text="当前打印机"runat="server"></asp:Label></td>
- <tdstyle="width:175px">
- <asp:DropDownListID="ddlDYJ"runat="server"Width="169px"></asp:DropDownList>
- </td>
- <td>
- <inputid="ibnSY"runat="server"type="button"value="上移"onclick="moveTop()"/>
- </td>
- <td>
- <inputid="ibnXY"runat="server"type="button"value="下移"onclick="moveUnder()"/>
- </td>
- <td>
- <inputid="ibnZY"runat="server"type="button"value="左移"onclick="moveLeft()"/>
- </td>
- <td>
- <inputid="ibnYY"runat="server"type="button"value="右移"onclick="moveRight()"/>
- </td>
- </tr>
- <tr>
- <tdcolspan="2">
- </td>
- <td>
- <asp:ButtonID="ibnBC"Text="保存"runat="server"Visible=trueOnClick="ibnBC_Click"/>
- </td>
- <td>
- <asp:ButtonID="ibnDY"Text="普通打印"runat="server"OnClick="ibnDY_Click"/>
- </td>
- <tdcolspan="2">
- </td>
- </tr>
- </table>
- </div>
- </div>
- <!--endprint-->
- <inputtype="button"name="print"value="预览并打印"onclick="preview()">
- </form>
- </body>
- </html>
后台:
C#代码
- usingSystem;
- usingSystem.Data;
- usingSystem.Configuration;
- usingSystem.Web;
- usingSystem.Web.Security;
- usingSystem.Web.UI;
- usingSystem.Web.UI.WebControls;
- usingSystem.Web.UI.WebControls.WebParts;
- usingSystem.Web.UI.HtmlControls;
- usingSystem.Collections;
- publicpartialclass_Default:System.Web.UI.Page
- {
- Helperapp_Helper=newHelper();
- ArrayListal_DZ=newArrayList();
- stringstr_BL="";
- Hashtablehtbl=newHashtable();
- Hashtablehtbl_Read=newHashtable();
- QuickTestqt=newQuickTest();
- protectedvoidPage_Load(objectsender,EventArgse)
- {
- if(!IsPostBack)
- {
- GetControls(this);
- string[]print=qt.EnumeratePrintersWin();
- ddlDYJ.Items.Insert(0,"--请选择打印机--");//这个是设置插入静态的数据
- for(inti=0;i<print.Length;i++)
- {
- ddlDYJ.Items.Insert(i+1,print[i]);//这个是设置插入静态的数据
- }
- }
- }
- #region提取注册表中节点为BS_EMSYJKDSZ下所有值,赋给Label控件样式
- privatevoidGetControls(Controlc)
- {
- if(cisLabel)
- {
- htbl_Read=app_Helper.get_regist_value("BS_FPSZ");//查找BS_FPSZ节点下的所有值
- foreach(DictionaryEntrydieinhtbl_Read)
- {
- stringwriteKey=die.Key.ToString();
- HashtablewriteStr=(Hashtable)die.Value;
- stringtop_In="";
- stringleft_In="";
- foreach(DictionaryEntrydie_IninwriteStr)
- {
- stringwriteKey_In=die_In.Key.ToString();
- stringwriteStr_In=die_In.Value.ToString();
- if(writeKey_In.Equals("Top"))
- {
- top_In=writeStr_In;
- }
- if(writeKey