1
0
mirror of https://e.coding.net/circlecloud/SixiBroadcast.git synced 2025-11-24 23:56:05 +00:00

服务器修改为控制台界面 客户端完全隐藏界面...

This commit is contained in:
j502647092
2015-08-07 14:16:44 +08:00
parent e83960ff89
commit e3a249fe54
13 changed files with 152 additions and 361 deletions

View File

@@ -30,57 +30,20 @@
{
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Frm_Client));
this.portT = new System.Windows.Forms.TextBox();
this.listen = new System.Windows.Forms.Button();
this.label2 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.msgbox = new System.Windows.Forms.ListBox();
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.退ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStrip1.SuspendLayout();
this.SuspendLayout();
//
// portT
//
this.portT.Location = new System.Drawing.Point(71, 13);
this.portT.Name = "portT";
this.portT.Size = new System.Drawing.Size(161, 21);
this.portT.TabIndex = 0;
this.portT.Text = "25333";
//
// listen
//
this.listen.Location = new System.Drawing.Point(238, 11);
this.listen.Name = "listen";
this.listen.Size = new System.Drawing.Size(42, 23);
this.listen.TabIndex = 2;
this.listen.Text = "监听";
this.listen.UseVisualStyleBackColor = true;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(12, 16);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(53, 12);
this.label2.TabIndex = 6;
this.label2.Text = "广播端口";
//
// button2
//
this.button2.Location = new System.Drawing.Point(196, 40);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(84, 23);
this.button2.TabIndex = 8;
this.button2.Text = "闪烁测试";
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// msgbox
//
this.msgbox.FormattingEnabled = true;
this.msgbox.ItemHeight = 12;
this.msgbox.Location = new System.Drawing.Point(14, 79);
this.msgbox.Location = new System.Drawing.Point(14, 7);
this.msgbox.Name = "msgbox";
this.msgbox.Size = new System.Drawing.Size(266, 184);
this.msgbox.Size = new System.Drawing.Size(266, 256);
this.msgbox.TabIndex = 10;
//
// notifyIcon
@@ -90,33 +53,43 @@
this.notifyIcon.Visible = true;
this.notifyIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon_MouseDoubleClick);
//
// contextMenuStrip1
//
this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.退ToolStripMenuItem});
this.contextMenuStrip1.Name = "contextMenuStrip1";
this.contextMenuStrip1.Size = new System.Drawing.Size(153, 48);
//
// 退出ToolStripMenuItem
//
this.退ToolStripMenuItem.Name = "退出ToolStripMenuItem";
this.退ToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.退ToolStripMenuItem.Text = "退出";
this.退ToolStripMenuItem.Click += new System.EventHandler(this.退ToolStripMenuItem_Click);
//
// Frm_Client
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 273);
this.Controls.Add(this.msgbox);
this.Controls.Add(this.button2);
this.Controls.Add(this.label2);
this.Controls.Add(this.listen);
this.Controls.Add(this.portT);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "Frm_Client";
this.ShowInTaskbar = false;
this.Text = "客户端";
this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
this.Load += new System.EventHandler(this.Frm_Client_Load);
this.contextMenuStrip1.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox portT;
private System.Windows.Forms.Button listen;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.ListBox msgbox;
private System.Windows.Forms.NotifyIcon notifyIcon;
private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
private System.Windows.Forms.ToolStripMenuItem 退ToolStripMenuItem;
}
}

View File

@@ -9,17 +9,18 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Windows.Forms;
using UDPClient.Properties;
namespace UDPClient
{
public partial class Frm_Client : Form
{
Icon ico1 = new Icon("icon.ico");
Icon ico2 = new Icon("clear.ico");
bool is1;
Icon icoOn = Resources.IconOn;
Icon icoOff = Resources.IconOff;
bool isOn;
bool isTwinkle;
static UdpClient client;
static IPEndPoint endpoint;
static IPEndPoint serverendpoint;
static System.Windows.Forms.Timer tmr = new System.Windows.Forms.Timer();
public Frm_Client()
@@ -30,7 +31,7 @@ namespace UDPClient
private void Frm_Client_Load(object sender, EventArgs e)
{
client = new UdpClient(new IPEndPoint(IPAddress.Any, 25333));
endpoint = new IPEndPoint(IPAddress.Any, 0);
serverendpoint = new IPEndPoint(IPAddress.Loopback, 25433);
//启动客户端监听
Thread t = new Thread(new ThreadStart(ClientThread));
t.IsBackground = true;
@@ -43,20 +44,22 @@ namespace UDPClient
tmr.Interval = 390;
tmr.Tick += tmr_Tick;
tmr.Enabled = true;
notifyIcon.ShowBalloonTip(1000, "四喜消息提示", "欢迎使用四喜消息提示系统!", ToolTipIcon.Info);
}
void tmr_Tick(object sender, EventArgs e)
{
if (!isTwinkle) return;
if (is1)
if (isOn)
{
is1 = false;
notifyIcon.Icon = ico2;
isOn = false;
notifyIcon.Icon = icoOff;
}
else
{
is1 = true;
notifyIcon.Icon = ico1;
isOn = true;
notifyIcon.Icon = icoOn;
}
}
public static IPAddress GetHostIP()
@@ -73,7 +76,7 @@ namespace UDPClient
return null;
}
private static void WebListen()
private void WebListen()
{
try
{
@@ -81,7 +84,7 @@ namespace UDPClient
listerner.AuthenticationSchemes = AuthenticationSchemes.Anonymous;//指定身份验证 Anonymous匿名访问
listerner.Prefixes.Add("http://127.0.0.1:2533/web/");
listerner.Start();
Console.WriteLine("WebServer Start Successed.......");
Console.WriteLine("网页服务器开始监听.......");
while (true)
{
//等待请求连接
@@ -94,16 +97,16 @@ namespace UDPClient
IPAddress addr = GetHostIP();
string str = username + " " + (addr == null ? "null" : addr.ToString()) + " 25333";
Console.WriteLine(str);
byte[] buf = Encoding.Default.GetBytes(str);
client.Send(buf, buf.Length, new IPEndPoint(IPAddress.Parse("127.0.0.1"), 25433));
byte[] buf = Encoding.UTF8.GetBytes(str);
client.Send(buf, buf.Length, serverendpoint);
notifyIcon.ShowBalloonTip(1000, "四喜消息提示", "用户登录成功!", ToolTipIcon.Info);
}
ctx.Response.Close();
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine("网页服务器出现错误: " + e.Message);
}
}
@@ -114,30 +117,29 @@ namespace UDPClient
Console.WriteLine("客户端开始监听...");
while (true)
{
byte[] buf = client.Receive(ref endpoint);
string msg = Encoding.Default.GetString(buf);
Console.WriteLine("收到数据: " + msg);
byte[] buf = client.Receive(ref serverendpoint);
string msg = Encoding.UTF8.GetString(buf);
isTwinkle = true;
notifyIcon.ShowBalloonTip(1000,"四喜消息提示","您有新的提醒 请注意查收!",ToolTipIcon.Info);
notifyIcon.ShowBalloonTip(1000, "四喜消息提示", msg, ToolTipIcon.Info);
}
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.WriteLine("UDP客户端出现错误: " + e.Message);
client.Close();
}
}
private void button2_Click(object sender, EventArgs e)
{
isTwinkle = !isTwinkle;
}
private void notifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
{
isTwinkle = false;
notifyIcon.Icon = ico1;
notifyIcon.Icon = icoOn;
}
private void 退ToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
}

View File

@@ -422,6 +422,9 @@
AAAAAwAA////AAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAA=
</value>
</data>
<metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>130, 17</value>
</metadata>
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
AAABAAQAEBAAAAEACABoBQAARgAAADAwAAABACAAqCUAAK4FAAAgIAAAAQAgAKgQAABWKwAAGBgAAAEA

View File

@@ -59,5 +59,25 @@ namespace UDPClient.Properties {
resourceCulture = value;
}
}
/// <summary>
/// 查找类似于 (Icon) 的 System.Drawing.Icon 类型的本地化资源。
/// </summary>
internal static System.Drawing.Icon IconOff {
get {
object obj = ResourceManager.GetObject("IconOff", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
/// <summary>
/// 查找类似于 (Icon) 的 System.Drawing.Icon 类型的本地化资源。
/// </summary>
internal static System.Drawing.Icon IconOn {
get {
object obj = ResourceManager.GetObject("IconOn", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
}
}

View File

@@ -46,7 +46,7 @@
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
@@ -60,6 +60,7 @@
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
@@ -68,9 +69,10 @@
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
@@ -85,9 +87,10 @@
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
@@ -114,4 +117,11 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="IconOff" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\IconOff.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="IconOn" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\IconOn.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -5,12 +5,27 @@
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{69C59230-BE16-4E03-8948-664F78D85698}</ProjectGuid>
<OutputType>Exe</OutputType>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UDPClient</RootNamespace>
<AssemblyName>UDPClient</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PublishUrl>发布\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -78,12 +93,20 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="clear.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="icon.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<None Include="Resources\IconOff.ico" />
<None Include="Resources\IconOn.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.