├── Server
├── RemoteControl.ico
├── App.config
├── Program.cs
├── Properties
│ └── AssemblyInfo.cs
├── Log.cs
├── Task.cs
├── Screenshot.cs
├── Message.cs
├── ControlUser.cs
├── Function.cs
├── MessageQueue.cs
├── Control.cs
├── Net.cs
├── FileSend.cs
├── Process.cs
├── Terminal.cs
├── Configure.cs
└── FileControl.cs
├── Client
├── ic_launcher-web.png
├── libs
│ └── android-support-v4.jar
├── res
│ ├── drawable-hdpi
│ │ ├── file_ico.png
│ │ ├── folder_ico.png
│ │ ├── ic_launcher.png
│ │ ├── start_img.jpg
│ │ ├── vpi__tab_selected_holo.9.png
│ │ ├── vpi__tab_unselected_holo.9.png
│ │ ├── vpi__tab_selected_focused_holo.9.png
│ │ ├── vpi__tab_selected_pressed_holo.9.png
│ │ ├── vpi__tab_unselected_focused_holo.9.png
│ │ └── vpi__tab_unselected_pressed_holo.9.png
│ ├── drawable-mdpi
│ │ ├── ic_launcher.png
│ │ ├── vpi__tab_selected_holo.9.png
│ │ ├── vpi__tab_unselected_holo.9.png
│ │ ├── vpi__tab_selected_focused_holo.9.png
│ │ ├── vpi__tab_selected_pressed_holo.9.png
│ │ ├── vpi__tab_unselected_focused_holo.9.png
│ │ └── vpi__tab_unselected_pressed_holo.9.png
│ ├── drawable-xhdpi
│ │ ├── ic_launcher.png
│ │ ├── vpi__tab_selected_holo.9.png
│ │ ├── vpi__tab_unselected_holo.9.png
│ │ ├── vpi__tab_selected_focused_holo.9.png
│ │ ├── vpi__tab_selected_pressed_holo.9.png
│ │ ├── vpi__tab_unselected_focused_holo.9.png
│ │ └── vpi__tab_unselected_pressed_holo.9.png
│ ├── drawable-xxhdpi
│ │ └── ic_launcher.png
│ ├── values-sw600dp
│ │ └── dimens.xml
│ ├── values
│ │ ├── dimens.xml
│ │ ├── vpi__styles.xml
│ │ ├── styles.xml
│ │ ├── vpi__colors.xml
│ │ ├── vpi__defaults.xml
│ │ ├── strings.xml
│ │ └── vpi__attrs.xml
│ ├── menu
│ │ ├── login.xml
│ │ ├── file.xml
│ │ └── main.xml
│ ├── values-sw720dp-land
│ │ └── dimens.xml
│ ├── layout
│ │ ├── activity_start.xml
│ │ ├── activity_help.xml
│ │ ├── activity_main.xml
│ │ ├── activity_task.xml
│ │ ├── pager_command.xml
│ │ ├── activity_download.xml
│ │ ├── activity_downloading_list_item.xml
│ │ ├── pager_screen_shots.xml
│ │ ├── activity_downloaded_list_item.xml
│ │ ├── pager_message.xml
│ │ ├── pager_screen_shots_list_item.xml
│ │ ├── activity_login.xml
│ │ ├── activity_file_item_dir.xml
│ │ ├── activity_file_item_file.xml
│ │ ├── activity_terminal.xml
│ │ ├── activity_task_item.xml
│ │ ├── activity_file.xml
│ │ └── activity_setting.xml
│ ├── values-v11
│ │ └── styles.xml
│ ├── xml
│ │ └── bg_border_message.xml
│ ├── values-v14
│ │ └── styles.xml
│ ├── color
│ │ ├── vpi__dark_theme.xml
│ │ └── vpi__light_theme.xml
│ └── drawable
│ │ └── vpi__tab_indicator.xml
├── src
│ ├── net
│ │ └── loveyu
│ │ │ └── remotecontrol
│ │ │ ├── RcFile.java
│ │ │ ├── RcNet.java
│ │ │ ├── RcTask.java
│ │ │ ├── RcConfig.java
│ │ │ ├── RcDebug.java
│ │ │ ├── RcLogin.java
│ │ │ ├── RcMessage.java
│ │ │ ├── RcProcess.java
│ │ │ ├── RcQueue.java
│ │ │ ├── RcSendMsg.java
│ │ │ ├── FileAction.java
│ │ │ ├── MessageType.java
│ │ │ ├── PagerEmpty.java
│ │ │ ├── SendMsgType.java
│ │ │ ├── ActivityFile.java
│ │ │ ├── ActivityHelp.java
│ │ │ ├── ActivityLogin.java
│ │ │ ├── ActivityMain.java
│ │ │ ├── ActivityStart.java
│ │ │ ├── ActivityTask.java
│ │ │ ├── PagerCommand.java
│ │ │ ├── PagerFunction.java
│ │ │ ├── PagerMessage.java
│ │ │ ├── TerminalAscii.java
│ │ │ ├── ActivityDownload.java
│ │ │ ├── ActivitySetting.java
│ │ │ ├── ActivityTerminal.java
│ │ │ ├── PagerScreenShots.java
│ │ │ ├── PagerSendNotice.java
│ │ │ ├── PagerSendWarning.java
│ │ │ └── PagerErrorMessage.java
│ └── com
│ │ └── viewpagerindicator
│ │ ├── IconPagerAdapter.java
│ │ ├── PageIndicator.java
│ │ ├── IcsLinearLayout.java
│ │ └── TabPageIndicator.java
├── project.properties
└── AndroidManifest.xml
├── Test
├── Program.cs
├── UdpMessageTest.cs
└── UdpMessageTest.Designer.cs
├── .gitattributes
├── README.md
└── .gitignore
/Server/RemoteControl.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Server/RemoteControl.ico
--------------------------------------------------------------------------------
/Client/ic_launcher-web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/ic_launcher-web.png
--------------------------------------------------------------------------------
/Client/libs/android-support-v4.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/libs/android-support-v4.jar
--------------------------------------------------------------------------------
/Client/res/drawable-hdpi/file_ico.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-hdpi/file_ico.png
--------------------------------------------------------------------------------
/Client/res/drawable-hdpi/folder_ico.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-hdpi/folder_ico.png
--------------------------------------------------------------------------------
/Client/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Client/res/drawable-hdpi/start_img.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-hdpi/start_img.jpg
--------------------------------------------------------------------------------
/Client/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Client/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Client/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/RcFile.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/RcFile.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/RcNet.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/RcNet.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/RcTask.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/RcTask.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/RcConfig.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/RcConfig.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/RcDebug.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/RcDebug.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/RcLogin.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/RcLogin.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/RcMessage.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/RcMessage.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/RcProcess.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/RcProcess.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/RcQueue.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/RcQueue.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/RcSendMsg.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/RcSendMsg.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/FileAction.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/FileAction.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/MessageType.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/MessageType.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/PagerEmpty.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/PagerEmpty.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/SendMsgType.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/SendMsgType.java
--------------------------------------------------------------------------------
/Client/res/drawable-hdpi/vpi__tab_selected_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-hdpi/vpi__tab_selected_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-hdpi/vpi__tab_unselected_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-hdpi/vpi__tab_unselected_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-mdpi/vpi__tab_selected_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-mdpi/vpi__tab_selected_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-mdpi/vpi__tab_unselected_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-mdpi/vpi__tab_unselected_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-xhdpi/vpi__tab_selected_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-xhdpi/vpi__tab_selected_holo.9.png
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/ActivityFile.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/ActivityFile.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/ActivityHelp.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/ActivityHelp.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/ActivityLogin.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/ActivityLogin.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/ActivityMain.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/ActivityMain.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/ActivityStart.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/ActivityStart.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/ActivityTask.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/ActivityTask.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/PagerCommand.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/PagerCommand.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/PagerFunction.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/PagerFunction.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/PagerMessage.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/PagerMessage.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/TerminalAscii.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/TerminalAscii.java
--------------------------------------------------------------------------------
/Client/res/drawable-xhdpi/vpi__tab_unselected_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-xhdpi/vpi__tab_unselected_holo.9.png
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/ActivityDownload.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/ActivityDownload.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/ActivitySetting.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/ActivitySetting.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/ActivityTerminal.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/ActivityTerminal.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/PagerScreenShots.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/PagerScreenShots.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/PagerSendNotice.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/PagerSendNotice.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/PagerSendWarning.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/PagerSendWarning.java
--------------------------------------------------------------------------------
/Client/src/net/loveyu/remotecontrol/PagerErrorMessage.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/src/net/loveyu/remotecontrol/PagerErrorMessage.java
--------------------------------------------------------------------------------
/Server/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/Client/res/drawable-hdpi/vpi__tab_selected_focused_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-hdpi/vpi__tab_selected_focused_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-hdpi/vpi__tab_selected_pressed_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-hdpi/vpi__tab_selected_pressed_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-mdpi/vpi__tab_selected_focused_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-mdpi/vpi__tab_selected_focused_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-mdpi/vpi__tab_selected_pressed_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-mdpi/vpi__tab_selected_pressed_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-xhdpi/vpi__tab_selected_focused_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-xhdpi/vpi__tab_selected_pressed_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-xhdpi/vpi__tab_selected_pressed_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-hdpi/vpi__tab_unselected_focused_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-hdpi/vpi__tab_unselected_focused_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-hdpi/vpi__tab_unselected_pressed_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-hdpi/vpi__tab_unselected_pressed_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-mdpi/vpi__tab_unselected_focused_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-mdpi/vpi__tab_unselected_focused_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-mdpi/vpi__tab_unselected_pressed_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-mdpi/vpi__tab_unselected_pressed_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-xhdpi/vpi__tab_unselected_focused_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-xhdpi/vpi__tab_unselected_focused_holo.9.png
--------------------------------------------------------------------------------
/Client/res/drawable-xhdpi/vpi__tab_unselected_pressed_holo.9.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/loveyu/RemoteControl/master/Client/res/drawable-xhdpi/vpi__tab_unselected_pressed_holo.9.png
--------------------------------------------------------------------------------
/Client/res/values-sw600dp/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Client/res/values/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 16dp
5 | 16dp
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Client/res/menu/login.xml:
--------------------------------------------------------------------------------
1 |
10 |
--------------------------------------------------------------------------------
/Client/src/com/viewpagerindicator/IconPagerAdapter.java:
--------------------------------------------------------------------------------
1 | package com.viewpagerindicator;
2 |
3 | public interface IconPagerAdapter {
4 | /**
5 | * Get icon representing the page at {@code index} in the adapter.
6 | */
7 | int getIconResId(int index);
8 |
9 | // From PagerAdapter
10 | int getCount();
11 | }
12 |
--------------------------------------------------------------------------------
/Client/res/values-sw720dp-land/dimens.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 | 128dp
8 |
9 |
10 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_start.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
--------------------------------------------------------------------------------
/Client/res/values-v11/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/Server/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ServiceProcess;
4 | using System.Text;
5 | using System.Threading;
6 |
7 | namespace RemoteControlService
8 | {
9 | static class Program
10 | {
11 | static void Main()
12 | {
13 | Control control = new Control();
14 | control.Start();//启动服务
15 | control.Terminal();//启动控制台
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/Client/res/xml/bg_border_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
9 |
10 |
15 |
16 |
--------------------------------------------------------------------------------
/Client/res/values-v14/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/Test/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace UdpMessageTest
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// 应用程序的主入口点。
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new UdpMessageTest());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 | *.sln merge=union
7 | *.csproj merge=union
8 | *.vbproj merge=union
9 | *.fsproj merge=union
10 | *.dbproj merge=union
11 |
12 | # Standard to msysgit
13 | *.doc diff=astextplain
14 | *.DOC diff=astextplain
15 | *.docx diff=astextplain
16 | *.DOCX diff=astextplain
17 | *.dot diff=astextplain
18 | *.DOT diff=astextplain
19 | *.pdf diff=astextplain
20 | *.PDF diff=astextplain
21 | *.rtf diff=astextplain
22 | *.RTF diff=astextplain
23 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_help.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/Client/project.properties:
--------------------------------------------------------------------------------
1 | # This file is automatically generated by Android Tools.
2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED!
3 | #
4 | # This file must be checked in Version Control Systems.
5 | #
6 | # To customize properties used by the Ant build system edit
7 | # "ant.properties", and override values to adapt the script to your
8 | # project structure.
9 | #
10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 |
13 | # Project target.
14 | target=android-18
15 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
12 |
13 |
18 |
19 |
--------------------------------------------------------------------------------
/Client/res/menu/file.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/Client/res/menu/main.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Client/res/values/vpi__styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Server/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("远程控制服务器端")]
9 | [assembly: AssemblyDescription("一个基于C#和Android的远程控制软件的服务器端软件")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Loveyu")]
12 | [assembly: AssemblyProduct("RemoteControlService")]
13 | [assembly: AssemblyCopyright("Copyright © Loveyu 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("7d4b0be3-ef5d-4bce-ba48-e94af50b7d14")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/Client/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
7 |
8 |
19 |
20 |
24 |
25 |
29 |
30 |
--------------------------------------------------------------------------------
/Client/res/color/vpi__dark_theme.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Client/res/values/vpi__colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 | #ff000000
19 | #fff3f3f3
20 | @color/vpi__background_holo_light
21 | @color/vpi__background_holo_dark
22 | #ff4c4c4c
23 | #ffb2b2b2
24 | @color/vpi__bright_foreground_holo_light
25 | @color/vpi__bright_foreground_holo_dark
26 |
27 |
--------------------------------------------------------------------------------
/Client/res/color/vpi__light_theme.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_task.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
20 |
28 |
29 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/Client/res/layout/pager_command.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
18 |
19 |
20 |
21 |
22 |
30 |
31 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_download.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
13 |
14 |
18 |
19 |
23 |
24 |
25 |
29 |
30 |
34 |
35 |
36 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_downloading_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
16 |
17 |
27 |
28 |
38 |
39 |
48 |
49 |
--------------------------------------------------------------------------------
/Client/src/com/viewpagerindicator/PageIndicator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 Patrik Akerfeldt
3 | * Copyright (C) 2011 Jake Wharton
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 |
18 | package com.viewpagerindicator;
19 |
20 | import android.support.v4.view.ViewPager;
21 |
22 | /**
23 | * A PageIndicator is responsible to show an visual indicator on the total views
24 | * number and the current visible view.
25 | */
26 | public interface PageIndicator extends ViewPager.OnPageChangeListener {
27 | /**
28 | * Bind the indicator to a ViewPager.
29 | *
30 | * @param view
31 | */
32 | void setViewPager(ViewPager view);
33 |
34 | /**
35 | * Bind the indicator to a ViewPager.
36 | *
37 | * @param view
38 | * @param initialPosition
39 | */
40 | void setViewPager(ViewPager view, int initialPosition);
41 |
42 | /**
43 | * Set the current page of both the ViewPager and indicator.
44 | *
45 | * This must be used if you need to set the page before
46 | * the views are drawn on screen (e.g., default start page).
47 | *
48 | * @param item
49 | */
50 | void setCurrentItem(int item);
51 |
52 | /**
53 | * Set a page change listener which will receive forwarded events.
54 | *
55 | * @param listener
56 | */
57 | void setOnPageChangeListener(ViewPager.OnPageChangeListener listener);
58 |
59 | /**
60 | * Notify the indicator that the fragment list has changed.
61 | */
62 | void notifyDataSetChanged();
63 | }
64 |
--------------------------------------------------------------------------------
/Client/res/layout/pager_screen_shots.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
14 |
15 |
16 |
17 |
27 |
28 |
29 |
30 |
31 |
39 |
40 |
48 |
49 |
57 |
58 |
--------------------------------------------------------------------------------
/Server/Log.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.IO;
5 |
6 | namespace RemoteControlService
7 | {
8 | ///
9 | /// 日志记录类
10 | ///
11 | public class Log
12 | {
13 | ///
14 | /// 调试信息,仅在调试模式时输出
15 | ///
16 | /// 字符串
17 | public static void d(string log)
18 | {
19 | #if DEBUG
20 | write("[Debug]: " + log);
21 | #endif
22 | }
23 |
24 | ///
25 | /// 主要的运行记录
26 | ///
27 | /// 字符串
28 | public static void a(string log)
29 | {
30 | write("[running]: " + log);
31 | }
32 |
33 | ///
34 | /// 网络记录
35 | ///
36 | ///
37 | public static void n(string log)
38 | {
39 | write("[network]: " + log);
40 | }
41 |
42 | ///
43 | /// 处理记录
44 | ///
45 | ///
46 | public static void p(string log)
47 | {
48 | write("[process]: " + log);
49 | }
50 |
51 | ///
52 | /// 消息记录
53 | ///
54 | ///
55 | public static void m(string log)
56 | {
57 | write("[message]: " + log);
58 | }
59 |
60 | ///
61 | /// 文件记录
62 | ///
63 | ///
64 | public static void f(string log)
65 | {
66 | write("[file]: " + log);
67 | }
68 |
69 | ///
70 | /// 将记录写入到输出目标
71 | ///
72 | ///
73 | private static void write(string log)
74 | {
75 | #if DEBUG
76 | Console.WriteLine("[" + notice() + "]" + log);
77 | #else
78 | FileStream fs = new FileStream(Configure.LogPath(),FileMode.Append);
79 | byte[] rb = SendMessage.ToBytes("["+notice()+"]"+log+"\r\n");
80 | fs.Write(rb,0,rb.Length);
81 | fs.Close();
82 | #endif
83 | }
84 |
85 | ///
86 | /// 返回时间提示
87 | ///
88 | /// 格式化后的时间字符串
89 | private static string notice()
90 | {
91 | return DateTime.Now.ToString();
92 | }
93 | }
94 | }
95 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_downloaded_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
19 |
20 |
29 |
30 |
40 |
41 |
52 |
53 |
--------------------------------------------------------------------------------
/Client/res/layout/pager_message.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
13 |
14 |
21 |
22 |
29 |
30 |
38 |
39 |
46 |
47 |
48 |
55 |
56 |
--------------------------------------------------------------------------------
/Client/res/drawable/vpi__tab_indicator.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | 基于C#和Android的远程控制软件
2 | ======================================
3 |
4 | C#作为服务器端软件,支持Net.2.0及以上,Android支持2.3及以上。
5 |
6 | ## 使用说明
7 | ### 服务器端说明
8 | * 首次运行请添加新用户
9 | * config 查看当前运行信息
10 | * user 用户操作命令,别名:u
11 | * add 添加一个用户,别名:a
12 | * delete [name] 删除用户,别名:d
13 | * deleteAll 删除全部用户,别名:da
14 | * offline [name] 下线指定用户,别名:off
15 | * save 保存用户到配置文件,别名:s
16 | * list 查看当前加载的用户信息,别名:s
17 | * help 帮助信息,别名:h,?
18 | * msg 查看消息队列长度,别名:m
19 | * file 查看文件传输服务队列信息,别名:f
20 | * terminal 查看运行的终端,并进行相应操作,别名:ter,t
21 | * 支持参数: reset(重置连接表)
22 | * exit 结束程序运行,别名:q,quit
23 | * startup 生成没有窗口的运行脚本,复制到启动目录实现开机启动,别名:s
24 | * clear 清屏,清空控制台,别名:cls,c
25 | * version 查看版本信息,别名:v
26 | * help 帮助信息,别名:h,--help,/?,\?,?
27 |
28 |
29 | ### 客户端说明
30 |
31 | * 登录说明
32 | * 登录前需要知道服务器的IP地址,当然可以使用域名,如果能够解析
33 | * 用户名和密码需首先到服务器设定,不存在默认密码。
34 | * 如果用不到文件下载服务可以随意填写文件传输服务器IP及端口。
35 | * 配置文件将保存到应用程序目录,无ROOT权限其他程序无法访问,当然,未加密。
36 |
37 | * 执行命令说明
38 | * 提交的命令会在远程的新的DOS窗口中执行
39 | * 这个命令不会返回任何输出内容到控制端,如果需要使用终端命令
40 | * 如果需要多条命令同时执行,可以使用换行分隔或者&分隔,换行最后的作用一样
41 |
42 | * 消息及错误消息说明
43 | * 消息是正常的命令执行状态返回,可以清空,如果数据过多请手动清空
44 | * 错误消息指服务端无法执行选定请求,或者出现错误所返回的状况,这个会存在一个提示信息
45 |
46 | * 常用功能函数说明
47 | * 这是服务器端内置的一系列功能,可以返回一部分消息
48 | * 如果关闭服务器将没有任何提示,此时你可以自觉退出程序。
49 |
50 | * 截图功能说明
51 | * 你可以获取到计算机桌面的实时图片,并且返回当前的列表
52 | * 列表包括一个完整大小图片和缩略图
53 | * 可手动指定缩略图宽度,如果数据异常将返回默认100的宽度值
54 | * 此处下载后可到下载管理中查看
55 |
56 | * 发送消息功能说明
57 | * 发送消息指在计算机桌面弹出一个提示框,在提示框关闭时会返回关闭信息
58 |
59 | * 发送警告功能说明
60 | * 发送警告值在桌面显示警告框,与消息框类似
61 |
62 | * 任务管理功能说明
63 | * 任务管理是将windows上所运行的所有任务分段发送过来
64 | * 对名称进行排序,长按选择一个任务来结束它
65 | * 没有排序功能,结束某一程序后返回状态,之后需要手动刷新列表
66 | * 该列表不会时时更新
67 |
68 | * 文件管理功能说明
69 | * 提供列表,会显示所有可列出盘符
70 | * 如果要对文件进行操作必须先勾选之后在使用按钮
71 | * 支持删除,重命名,和文件的复制操作。如果要对文件夹复制需要使用DOS命令。
72 | * 在菜单中可以选择创建空文件和文件夹
73 | * 可以单独执行文件操作命令,支持,get,delete,rename,move操作,每行一个参数,根目录使用ROOT,如果get对象是个文件,那个将会执行一个下载文件操作
74 |
75 | * 下载管理功能说明
76 | * 该功能不保存任何状态信息,程序结束后内容清空
77 | * 下载列表可能只会显示个别下载进度,添加的任务不会一次性全部添加
78 | * 下载完成后能够调用系统打开文件
79 | * 文件下载目录为SD卡RemoteControl下
80 | * 感觉没有自定义的必要,难道你会用这个来下载大文件么?感觉不现实啊,虽然可以。
81 | * 文件下载没有暂停和取消功能,需要的话自己结束整个程序
82 |
83 | ## 反馈地址
84 |
85 | http://www.loveyu.org/2732.html
86 |
87 | ## 项目主页
88 |
89 | http://www.loveyu.net/RemoteControl
90 |
--------------------------------------------------------------------------------
/Client/res/layout/pager_screen_shots_list_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
7 |
8 |
17 |
18 |
26 |
27 |
35 |
36 |
44 |
45 |
54 |
55 |
64 |
65 |
--------------------------------------------------------------------------------
/Server/Task.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Net;
5 |
6 | namespace RemoteControlService
7 | {
8 | ///
9 | /// 任务管理
10 | ///
11 | public class Task
12 | {
13 | ///
14 | /// 获取任务列表
15 | ///
16 | /// 对应的用户
17 | /// 返回最后一段数组或空,其他数据在获取过程中分段发送
18 | private static byte[] Get(IPEndPoint e)
19 | {
20 | System.Diagnostics.Process[] all;
21 | all = System.Diagnostics.Process.GetProcesses();
22 | string head = "Process\t";
23 | int count = (int)Math.Ceiling(all.Length / 5f);
24 | string rt = head + count + "\n";
25 | string id, name, me, path, time;
26 | int i = 0;
27 | foreach (System.Diagnostics.Process p in all)
28 | {
29 | id = p.Id.ToString();
30 | name = p.ProcessName;
31 | try
32 | {
33 | time = p.StartTime.ToString();
34 | }
35 | catch
36 | {
37 | time = "0";
38 | }
39 | me = p.WorkingSet64.ToString();
40 | try
41 | {
42 | path = p.MainModule.FileName;
43 | }
44 | catch
45 | {
46 | path = "null";
47 | }
48 | rt += id + "\t" + name + "\t" + me + "\t" + time + "\t" + path + "\n";
49 | if (i++ == 4)
50 | {
51 | Net.Get().Send(SendMessage.creatTask(SendMessage.ToBytes(rt), e));
52 | rt = head + --count + "\n";
53 | i = 0;
54 | }
55 | }
56 | return SendMessage.ToBytes(rt);
57 | }
58 |
59 | ///
60 | /// 结束掉某一进程
61 | ///
62 | /// 发送过来的进程ID字符串
63 | /// 返回状态
64 | private static byte[] Kill(string id)
65 | {
66 | try
67 | {
68 | System.Diagnostics.Process p = System.Diagnostics.Process.GetProcessById(int.Parse(id));
69 | p.Kill();
70 | return SendMessage.ToBytes("Killed\n" + id);
71 | }
72 | catch
73 | {
74 | return SendMessage.ToBytes("KillError\n" + id);
75 | }
76 | }
77 |
78 | ///
79 | /// 处理任务命令
80 | ///
81 | /// 客户端发送的命令
82 | /// 客户地址
83 | ///
84 | public static byte[] Process(string cmd, IPEndPoint e)
85 | {
86 | string[] list = cmd.Split('\n');
87 | if (list.Length == 0) return null;
88 | switch (list[0].ToLower())
89 | {
90 | case "get":
91 | return Get(e);
92 | case "kill":
93 | if (list.Length >= 2)
94 | {
95 | return Kill(list[1]);
96 | }
97 | break;
98 | }
99 | return null;
100 | }
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/Client/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
21 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
35 |
36 |
39 |
43 |
47 |
48 |
52 |
53 |
57 |
58 |
62 |
63 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_login.xml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
19 |
20 |
29 |
30 |
39 |
40 |
47 |
48 |
56 |
57 |
66 |
67 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_file_item_dir.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
31 |
32 |
44 |
45 |
54 |
55 |
68 |
69 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_file_item_file.xml:
--------------------------------------------------------------------------------
1 |
2 |
10 |
11 |
18 |
19 |
32 |
33 |
45 |
46 |
55 |
56 |
69 |
70 |
--------------------------------------------------------------------------------
/Client/res/values/vpi__defaults.xml:
--------------------------------------------------------------------------------
1 |
2 |
16 |
17 |
18 | true
19 | #FFFFFFFF
20 | #00000000
21 | 0
22 | 3dp
23 | false
24 | #FFDDDDDD
25 | 1dp
26 |
27 | 12dp
28 | 4dp
29 | 1dp
30 | #FF33B5E5
31 | #FFBBBBBB
32 | true
33 |
34 | 4dp
35 | #FF33B5E5
36 | 2dp
37 | 2
38 | 4dp
39 | 20dp
40 | 7dp
41 | 0
42 | #FFFFFFFF
43 | true
44 | #BBFFFFFF
45 | 15dp
46 | 5dp
47 | 7dp
48 |
49 | true
50 | 300
51 | 400
52 | #FF33B5E5
53 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_terminal.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
14 |
15 |
20 |
21 |
22 |
23 |
32 |
33 |
34 |
35 |
36 |
45 |
46 |
54 |
55 |
64 |
65 |
74 |
75 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_task_item.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
21 |
29 |
30 |
38 |
39 |
47 |
48 |
56 |
57 |
65 |
66 |
75 |
76 |
84 |
85 |
94 |
95 |
96 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 |
46 | [Dd]ebug/
47 | [Rr]elease/
48 | x64/
49 | build/
50 | [Bb]in/
51 | [Oo]bj/
52 |
53 | # MSTest test Results
54 | [Tt]est[Rr]esult*/
55 | [Bb]uild[Ll]og.*
56 |
57 | *_i.c
58 | *_p.c
59 | *.ilk
60 | *.meta
61 | *.obj
62 | *.pch
63 | *.pdb
64 | *.pgc
65 | *.pgd
66 | *.rsp
67 | *.sbr
68 | *.tlb
69 | *.tli
70 | *.tlh
71 | *.tmp
72 | *.tmp_proj
73 | *.log
74 | *.vspscc
75 | *.vssscc
76 | .builds
77 | *.pidb
78 | *.log
79 | *.scc
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 |
89 | # Visual Studio profiler
90 | *.psess
91 | *.vsp
92 | *.vspx
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 |
101 | # TeamCity is a build add-in
102 | _TeamCity*
103 |
104 | # DotCover is a Code Coverage Tool
105 | *.dotCover
106 |
107 | # NCrunch
108 | *.ncrunch*
109 | .*crunch*.local.xml
110 |
111 | # Installshield output folder
112 | [Ee]xpress/
113 |
114 | # DocProject is a documentation generator add-in
115 | DocProject/buildhelp/
116 | DocProject/Help/*.HxT
117 | DocProject/Help/*.HxC
118 | DocProject/Help/*.hhc
119 | DocProject/Help/*.hhk
120 | DocProject/Help/*.hhp
121 | DocProject/Help/Html2
122 | DocProject/Help/html
123 |
124 | # Click-Once directory
125 | publish/
126 |
127 | # Publish Web Output
128 | *.Publish.xml
129 | *.pubxml
130 |
131 | # NuGet Packages Directory
132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133 | #packages/
134 |
135 | # Windows Azure Build Output
136 | csx
137 | *.build.csdef
138 |
139 | # Windows Store app package directory
140 | AppPackages/
141 |
142 | # Others
143 | sql/
144 | *.Cache
145 | ClientBin/
146 | [Ss]tyle[Cc]op.*
147 | ~$*
148 | *~
149 | *.dbmdl
150 | *.[Pp]ublish.xml
151 | *.pfx
152 | *.publishsettings
153 |
154 | # RIA/Silverlight projects
155 | Generated_Code/
156 |
157 | # Backup & report files from converting an old project file to a newer
158 | # Visual Studio version. Backup files are not needed, because we have git ;-)
159 | _UpgradeReport_Files/
160 | Backup*/
161 | UpgradeLog*.XML
162 | UpgradeLog*.htm
163 |
164 | # SQL Server files
165 | App_Data/*.mdf
166 | App_Data/*.ldf
167 |
168 | #############
169 | ## Windows detritus
170 | #############
171 |
172 | # Windows image file caches
173 | Thumbs.db
174 | ehthumbs.db
175 |
176 | # Folder config file
177 | Desktop.ini
178 |
179 | # Recycle Bin used on file shares
180 | $RECYCLE.BIN/
181 |
182 | # Mac crap
183 | .DS_Store
184 |
185 |
186 | #############
187 | ## Python
188 | #############
189 |
190 | *.py[co]
191 |
192 | # Packages
193 | *.egg
194 | *.egg-info
195 | dist/
196 | build/
197 | eggs/
198 | parts/
199 | var/
200 | sdist/
201 | develop-eggs/
202 | .installed.cfg
203 |
204 | # Installer logs
205 | pip-log.txt
206 |
207 | # Unit test / coverage reports
208 | .coverage
209 | .tox
210 |
211 | #Translations
212 | *.mo
213 |
214 | #Mr Developer
215 | .mr.developer.cfg
216 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_file.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
16 |
17 |
25 |
26 |
34 |
35 |
43 |
44 |
52 |
53 |
61 |
62 |
77 |
78 |
86 |
87 |
95 |
96 |
--------------------------------------------------------------------------------
/Server/Screenshot.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Drawing;
5 | using System.Drawing.Imaging;
6 | using System.Windows.Forms;
7 | using System.IO;
8 |
9 | namespace RemoteControlService
10 | {
11 | ///
12 | /// 截图操作类
13 | ///
14 | public class Screenshot
15 | {
16 | ///
17 | /// 缩略图宽度
18 | ///
19 | int width;
20 |
21 | ///
22 | /// 文件保存名(时间格式)
23 | ///
24 | string name;
25 |
26 | ///
27 | /// 完整大小文件保存路径
28 | ///
29 | string fullName;
30 |
31 | ///
32 | /// 完整文件大小
33 | ///
34 | int fullSize;
35 |
36 | ///
37 | /// 缩略图文件保存路径
38 | ///
39 | string thumName;
40 |
41 | ///
42 | /// 缩略图大小
43 | ///
44 | int thumSize;
45 |
46 | ///
47 | /// 截图状态
48 | ///
49 | bool status = true;
50 |
51 | ///
52 | /// 截图构造函数,并进行相应的处理
53 | ///
54 | /// 网络发送过来的缩略图宽度字符串
55 | public Screenshot(string width)
56 | {
57 | try
58 | {
59 | this.width = int.Parse(width);
60 | }
61 | catch
62 | {
63 | this.width = 0;
64 | }
65 | if (this.width < 100) this.width = 100;
66 | Process();
67 | }
68 |
69 | ///
70 | /// 生成截图,并生成文件信息
71 | ///
72 | private void Process()
73 | {
74 | if (CreateName() == false)//文件已存在且创建
75 | return;
76 | Bitmap myImage = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
77 | Graphics g = Graphics.FromImage(myImage);
78 | g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height));
79 | IntPtr dc1 = g.GetHdc();
80 | g.ReleaseHdc(dc1);
81 | myImage.Save(fullName, ImageFormat.Jpeg);
82 | fullSize = (int)new FileInfo(fullName).Length;
83 | if (width >= myImage.Width)
84 | {
85 | thumName = fullName;
86 | thumSize = fullSize;
87 | }
88 | else
89 | {
90 | CreateThumbnails(myImage);
91 | myImage.Dispose();
92 | }
93 | }
94 |
95 | ///
96 | /// 创建截图名称及路径
97 | ///
98 | ///
99 | private bool CreateName()
100 | {
101 | name = DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_fff");
102 | fullName = Configure.ScreenshotPath() + "\\" + name + ".jpg";
103 | thumName = Configure.ScreenshotPath() + "\\" + name + "_w" + width + ".jpg";
104 | if (File.Exists(fullName))
105 | {
106 | try
107 | {
108 | Bitmap myImage = new Bitmap(fullName);
109 | int fullWidth = myImage.Width;
110 | fullSize = (int)new FileInfo(fullName).Length;
111 | if (width >= fullWidth)
112 | {
113 | thumName = fullName;
114 | thumSize = fullSize;
115 | }
116 | else
117 | {
118 | CreateThumbnails(myImage);
119 | myImage.Dispose();
120 | }
121 | }
122 | catch
123 | {
124 | status = false;
125 | }
126 | return false;
127 | }
128 | return true;
129 | }
130 |
131 | ///
132 | /// 获取完整路径
133 | ///
134 | ///
135 | public string getFull()
136 | {
137 | return fullName;
138 | }
139 |
140 | ///
141 | /// 获取完整大小
142 | ///
143 | ///
144 | public int getFullSize()
145 | {
146 | return fullSize;
147 | }
148 |
149 | ///
150 | /// 获取缩略图路径
151 | ///
152 | ///
153 | public string get()
154 | {
155 | return thumName;
156 | }
157 |
158 | ///
159 | /// 获取缩略图大小
160 | ///
161 | ///
162 | public int getSize()
163 | {
164 | return thumSize;
165 | }
166 |
167 | ///
168 | /// 返回截图状态
169 | ///
170 | ///
171 | public bool isOK()
172 | {
173 | return status;
174 | }
175 |
176 | ///
177 | /// 根据原始图像创建缩略图,并保存
178 | ///
179 | /// 截图后的数据
180 | private void CreateThumbnails(Bitmap img)
181 | {
182 | int nw, nh;
183 | nw = width;
184 | nh = width * img.Height / img.Width;
185 | Bitmap nimg = new Bitmap(img, new Size(nw, nh));
186 | nimg.Save(thumName, ImageFormat.Jpeg);
187 | thumSize = (int)(new FileInfo(thumName)).Length;
188 | }
189 | }
190 | }
191 |
--------------------------------------------------------------------------------
/Server/Message.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Net;
5 |
6 | namespace RemoteControlService
7 | {
8 | ///
9 | /// 消息类型
10 | ///
11 | public enum MessageType
12 | {
13 | ///
14 | /// 命令消息,对应字符01
15 | ///
16 | COMMAND,//01
17 |
18 | ///
19 | /// 提示消息,对应字符02
20 | ///
21 | NOTICE,//02
22 |
23 | ///
24 | /// 文件消息,对应字符03
25 | ///
26 | FILE,//03
27 |
28 | ///
29 | /// 警告消息,对应类型04
30 | ///
31 | WARNING,//04
32 |
33 | ///
34 | /// 终端消息,对应字符05
35 | ///
36 | TERMINAL,//05
37 |
38 | ///
39 | /// 函数功能消息,对应字符06
40 | ///
41 | FUNCTION,//06
42 |
43 | ///
44 | /// 回执消息,对应字符07
45 | ///
46 | CALLBACK,//07
47 |
48 | ///
49 | /// 登录消息,对应字符08
50 | ///
51 | LOGIN,//08
52 |
53 | ///
54 | /// 登出消息,对应字符09
55 | ///
56 | LOGOUT,//09
57 |
58 | ///
59 | /// 截图消息,对应字符10
60 | ///
61 | SCREENSHOT,//10
62 |
63 | ///
64 | /// 任务管理消息,对应字符11
65 | ///
66 | TASK,//11
67 | }
68 |
69 | ///
70 | /// 消息结构体
71 | ///
72 | public struct MessageStruct
73 | {
74 | ///
75 | /// 消息ID,长度10
76 | ///
77 | public string Id;//10L
78 |
79 | ///
80 | /// 消息类型,长度2
81 | ///
82 | public MessageType Type;//2L
83 |
84 | ///
85 | /// 消息内容
86 | ///
87 | public string Content;
88 |
89 | ///
90 | /// 消息发送者
91 | ///
92 | public IPEndPoint e;
93 | }
94 |
95 | ///
96 | /// 消息构造类
97 | ///
98 | public class Message
99 | {
100 | ///
101 | /// 原始消息数组
102 | ///
103 | private byte[] NavtiveMessage;
104 |
105 | ///
106 | /// 消息结构体数组
107 | ///
108 | public MessageStruct msg;
109 |
110 | ///
111 | /// 消息检测结果
112 | ///
113 | public bool isOK = false;
114 |
115 | ///
116 | /// 构造消息内容
117 | ///
118 | /// 原始数据
119 | /// 消息发送者
120 | public Message(byte[] bytes, IPEndPoint e)
121 | {
122 | NavtiveMessage = bytes;
123 | msg.e = e;
124 | parse();
125 | }
126 |
127 | ///
128 | /// 开始解析消息
129 | ///
130 | private void parse()
131 | {
132 | if (NavtiveMessage.Length < 13)
133 | {
134 | Log.m("Discard invalid data [length]:" + NavtiveMessage.Length);
135 | return;
136 | }
137 | Log.d("Received:" + Encoding.UTF8.GetString(NavtiveMessage));
138 | msg.Id = subString(0, 10);
139 | string type = subString(10, 2);
140 | switch (type)
141 | {
142 | case "01":
143 | msg.Type = MessageType.COMMAND;
144 | break;
145 | case "02":
146 | msg.Type = MessageType.NOTICE;
147 | break;
148 | case "03":
149 | msg.Type = MessageType.FILE;
150 | break;
151 | case "04":
152 | msg.Type = MessageType.WARNING;
153 | break;
154 | case "05":
155 | msg.Type = MessageType.TERMINAL;
156 | break;
157 | case "06":
158 | msg.Type = MessageType.FUNCTION;
159 | break;
160 | case "07":
161 | msg.Type = MessageType.CALLBACK;
162 | break;
163 | case "08":
164 | msg.Type = MessageType.LOGIN;
165 | break;
166 | case "09":
167 | msg.Type = MessageType.LOGOUT;
168 | break;
169 | case "10":
170 | msg.Type = MessageType.SCREENSHOT;
171 | break;
172 | case "11":
173 | msg.Type = MessageType.TASK;
174 | break;
175 | default:
176 | Log.m("Discard invalid data [type]:" + type);
177 | return;
178 | }
179 | msg.Content = subString(12, -1);
180 | isOK = true;
181 | }
182 |
183 | ///
184 | /// 重原始消失中分离数据
185 | ///
186 | /// 起始位置
187 | /// 长度
188 | /// 字符串
189 | private string subString(int index, int length)
190 | {
191 | if (length == -1) length = NavtiveMessage.Length - index;
192 | byte[] n = new byte[length];
193 | int j = index;
194 | for (int i = 0; i < length; i++)
195 | {
196 | n[i] = NavtiveMessage[j++];
197 | }
198 | return Encoding.UTF8.GetString(n);
199 | }
200 |
201 | }
202 | }
203 |
--------------------------------------------------------------------------------
/Client/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 远程控制
4 | 系统设置
5 | 退出登录
6 | 结束程序
7 | 任务管理
8 | 文件管理
9 | 运行终端
10 | 用户名
11 | 密码
12 | 强制登陆
13 | 登陆
14 | 登陆中....
15 | 用户登陆
16 | 保存信息
17 | 加载中....
18 | 服务器地址
19 | 服务器端口
20 | 文件传输地址
21 | 文件传输端口
22 | 保存
23 | 测试
24 | 测试成功
25 | 配置已保存
26 | 异常错误提示
27 | 配置读取错误
28 | 默认2001
29 | 默认2002
30 | IP或域名
31 | IP或域名
32 | 服务器端口有误
33 | 文件传输服务端口有误
34 | 服务器名有误
35 | 文件传输服务名口有误
36 | 用户名和密码不能为空
37 | 网络未连接
38 | 配置文件保存失败
39 | 网络服务启动异常
40 | 登录超时
41 | 执行命令
42 | 控制页
43 | 功能
44 | 截图
45 | 发送消息
46 | 发送警告
47 | 消息
48 | 错误消息
49 | 发送
50 | 清除
51 | 顶部
52 | 底部
53 | 使用菜单退出
54 | 获取
55 | 截图缩略图宽度
56 | 刷新
57 | 下载
58 | 完整
59 | 下载管理
60 | 下载中
61 | 已下载
62 | RemoteControl
63 | download
64 | log
65 | empty
66 | 删除
67 | 重命名
68 | 复制
69 | 全选
70 | 运行命令
71 | 创建文件夹
72 | 创建空文件
73 | 回到根目录
74 | FILE
75 | 文件
76 | DIR
77 | 文件夹
78 | 上级目录
79 | 返回主界面
80 | 输入文件夹名:
81 | 输入文件名:
82 | 输入新路径:
83 | 输入复制的目标路径:
84 | 确定删除这些文件:
85 | 确定
86 | 取消
87 | 打开文件
88 | PID:
89 | 名称:
90 | 内存:
91 | 路径:
92 | 确定结束此任务?
93 | 终端字符或命令
94 | 清屏
95 | 命令行模式
96 | 字符模式
97 | 帮助
98 |
99 |
--------------------------------------------------------------------------------
/Server/ControlUser.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | namespace RemoteControlService
6 | {
7 | ///
8 | /// 控制台对用户管理的类
9 | ///
10 | public class ControlUser
11 | {
12 | ///
13 | /// 检测是否存在用户,不存在时在终端进行输出
14 | ///
15 | public static void CheckUserEmpty()
16 | {
17 | if (User.UserListCount() == 0)
18 | {
19 | Console.WriteLine("当前不存在任何用户,使用[ user add ]添加用户");
20 | }
21 | }
22 |
23 | ///
24 | /// 对用户操作命令进行操作
25 | ///
26 | /// 参数列表
27 | public static void UserAction(string[] list)
28 | {
29 | if (list.Length <= 1)
30 | {
31 | int count = 0;
32 | Console.WriteLine("当前在线用户: " + (count = User.UserNowCount()));
33 | Console.WriteLine("所有用户数量: " + User.UserListCount());
34 | if (count > 0)
35 | {
36 | Console.WriteLine("在线用户列表:");
37 | foreach (string u in User.UserNowList())
38 | {
39 | Console.WriteLine(" " + u);
40 | }
41 | }
42 | }
43 | else
44 | {
45 | switch (list[1].Trim().ToLower())
46 | {
47 | case "a":
48 | case "add":
49 | string name, password, ip;
50 | name = ReadNoEmptyValue("用户名:");
51 | password = ReadNoEmptyValue("密码:");
52 | ip = ReadNoEmptyValue("IP地址规则,支持正则(*将做完全匹配替换):");
53 | if (User.AddUserToList(name, password, ip))
54 | {
55 | Console.WriteLine("添加用户成功!");
56 | }
57 | else
58 | {
59 | Console.WriteLine("添加用户失败,或许用户已存在!");
60 | }
61 | break;
62 | case "d":
63 | case "delete":
64 | if (list.Length < 3)
65 | {
66 | Console.WriteLine("请尝试命令: user delete [name] | user deleteAll");
67 | }
68 | else
69 | {
70 | if (User.DeleteUser(list[2].Trim()))
71 | {
72 | Console.WriteLine("删除成功!");
73 | }
74 | else
75 | {
76 | Console.WriteLine("删除 " + list[2].Trim() + " 出错!");
77 | }
78 | }
79 | break;
80 | case "off":
81 | case "offline":
82 | if (list.Length < 3)
83 | {
84 | Console.WriteLine("尝试: user offline [name]");
85 | }
86 | else
87 | {
88 | if (User.OfflineUser(list[2].Trim()))
89 | {
90 | Console.WriteLine("下线成功!");
91 | }
92 | else
93 | {
94 | Console.WriteLine("下线 " + list[2].Trim() + " 出错!");
95 | }
96 | }
97 | break;
98 | case "da":
99 | case "deleteall":
100 | User.DeleteAllUser();
101 | if (User.UserListCount() == 0)
102 | {
103 | Console.WriteLine("用户已清空!");
104 | }
105 | else
106 | {
107 | Console.WriteLine("用户清空出错!");
108 | }
109 | break;
110 | case "s":
111 | case "save":
112 | if (Configure.WriteUserList(User.GetUserListTable()))
113 | {
114 | Console.WriteLine("成功保存用户列表!");
115 | }
116 | else
117 | {
118 | Console.WriteLine("保存出现异常");
119 | }
120 | break;
121 | case "l":
122 | case "list":
123 | string[] l = User.UserNowList();
124 | if (l.Length > 0)
125 | {
126 | Console.WriteLine("在线用户列表:");
127 | foreach (string u in l)
128 | {
129 | Console.WriteLine(" " + u);
130 | }
131 | }
132 | else
133 | {
134 | Console.WriteLine("当前没有用户在线.");
135 | }
136 | l = User.UserList();
137 | if (l.Length > 0)
138 | {
139 | Console.WriteLine("\n所有用户列表:");
140 | foreach (string u in l)
141 | {
142 | Console.WriteLine(" " + u);
143 | }
144 | }
145 | else
146 | {
147 | Console.WriteLine("\n系统没有任何用户.");
148 | }
149 | break;
150 | case "h":
151 | case "?":
152 | case "/?":
153 | case "\\?":
154 | case "--help":
155 | case "help":
156 | help();
157 | break;
158 | default:
159 | Console.WriteLine("Usage: user [ add | delete [name] | offline [user] | save | deleteAll | list | help]");
160 | break;
161 | }
162 | }
163 | }
164 |
165 | ///
166 | /// 用户帮助详细信息
167 | ///
168 | public static void help() {
169 | Console.WriteLine(" 详细参数列表:");
170 | Console.WriteLine(" add\t添加一个用户,别名:a");
171 | Console.WriteLine(" delete [name]\t删除用户,别名:d");
172 | Console.WriteLine(" deleteAll\t删除全部用户,别名:da");
173 | Console.WriteLine(" offline [name]\t下线指定用户,别名:off");
174 | Console.WriteLine(" save\t保存用户到配置文件,别名:s");
175 | Console.WriteLine(" list\t查看当前加载的用户信息,别名:s");
176 | Console.WriteLine(" help\t帮助信息,别名:h,?");
177 | }
178 |
179 | ///
180 | /// 获取控制台输入的字符串
181 | ///
182 | /// 输入提示字符
183 | /// 返回输入信息,不允许输入空字符,否则将永远阻塞
184 | private static string ReadNoEmptyValue(string notice)
185 | {
186 | string read = "";
187 | while (true)
188 | {
189 | Console.Write(notice);
190 | read = Console.ReadLine().Trim();
191 | if (read.Length > 0)
192 | {
193 | break;
194 | }
195 | }
196 | return read;
197 | }
198 | }
199 | }
200 |
--------------------------------------------------------------------------------
/Server/Function.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Text;
4 | using System.Runtime.InteropServices;
5 | using System.Management;
6 | using System.Net;
7 |
8 | namespace RemoteControlService
9 | {
10 | ///
11 | /// 功能函数类
12 | ///
13 | public class Function
14 | {
15 |
16 | ///
17 | /// 关闭服务器
18 | ///
19 | ///
20 | public string close()
21 | {
22 | Log.a("Function Close Application");
23 | Net.Get().Stop();
24 | Environment.Exit(0);
25 | return "";
26 | }
27 |
28 |
29 | ///
30 | /// 获取计算机信息
31 | ///
32 | ///
33 | public string info()
34 | {
35 | return "计算机名:" + ComputerInfo.GetComputerName() +
36 | "\n登录用户:" + ComputerInfo.GetUserName() +
37 | "\nIP:\n" + ComputerInfo.GetIPAddress() +
38 | "内存信息:\n" + ComputerInfo.GetMemInfo();
39 | }
40 |
41 | ///
42 | /// 配置文件信息
43 | ///
44 | ///
45 | public string config()
46 | {
47 | string rt = "";
48 | rt += "程序路径: " + System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
49 | rt += "\n工作路径: " + Environment.CurrentDirectory;
50 | rt += "\n服务器端口: " + Net.Get().GetIp();
51 | rt += "\n文件服务器端口: " + FileSend.Get().getIP();
52 | rt += "\n配置文件路径: " + Configure.LogPath();
53 | rt += "\n截图目录: " + Configure.ScreenshotPath();
54 | rt += "\n用户列表: " + Configure.UserListPath();
55 | return rt + "\n";
56 | }
57 |
58 | ///
59 | /// 消息队列信息
60 | ///
61 | ///
62 | public string msg()
63 | {
64 | return "消息队列长度:" + MessageQueue.Get().Length() + "\n";
65 | }
66 |
67 | ///
68 | /// 版本信息
69 | ///
70 | ///
71 | public string version() {
72 | return "版本号:"+System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
73 | }
74 |
75 | ///
76 | /// 文件传输队列信息
77 | ///
78 | ///
79 | public string file()
80 | {
81 | string rt = "等待传输的文件列表:\n";
82 | string[] ls = FileSend.Get().GetPathList();
83 | if (ls.Length > 0)
84 | {
85 | foreach (string s in ls)
86 | {
87 | rt += s + "\n";
88 | }
89 | }
90 | else
91 | {
92 | rt += "列表为空";
93 | }
94 | return rt + "\n";
95 | }
96 | }
97 |
98 | ///
99 | /// 计算机信息获取类
100 | ///
101 | public class ComputerInfo
102 | {
103 | ///
104 | /// 获取IP地址列表
105 | ///
106 | ///
107 | public static string GetIPAddress()
108 | {
109 | IPAddress[] ips = Dns.GetHostAddresses(Dns.GetHostName());
110 | if (ips.Length > 0)
111 | {
112 | string rt = "";
113 | foreach (IPAddress s in ips)
114 | {
115 | rt += s.ToString() + "\n";
116 | }
117 | return rt;
118 | }
119 | else
120 | {
121 | return "127.0.0.1";
122 | }
123 | }
124 |
125 | ///
126 | /// 获取计算机用户名
127 | ///
128 | ///
129 | public static string GetUserName()
130 | {
131 | try
132 | {
133 | string st = "";
134 | ManagementClass mc = new ManagementClass("Win32_ComputerSystem");
135 | ManagementObjectCollection moc = mc.GetInstances();
136 | foreach (ManagementObject mo in moc)
137 | {
138 | st = mo["UserName"].ToString();
139 | }
140 | moc = null;
141 | mc = null;
142 | return st;
143 | }
144 | catch
145 | {
146 | return "unknow";
147 | }
148 | finally
149 | {
150 | }
151 | }
152 |
153 | ///
154 | /// 获取计算机名
155 | ///
156 | ///
157 | public static string GetComputerName()
158 | {
159 | try
160 | {
161 | return System.Environment.GetEnvironmentVariable("ComputerName");
162 | }
163 | catch
164 | {
165 | return "unknow";
166 | }
167 | finally
168 | {
169 | }
170 | }
171 |
172 | ///
173 | /// 获取内存信息
174 | ///
175 | ///
176 | public static string GetMemInfo()
177 | {
178 | Double PhysicalMemorySize = 0, VirtualMemorySize = 0, FreePhysicalMemory = 0;
179 | ManagementClass osClass = new ManagementClass("Win32_OperatingSystem");
180 | foreach (ManagementObject obj in osClass.GetInstances())
181 | {
182 | if (obj["TotalVisibleMemorySize"] != null)
183 | PhysicalMemorySize += (ulong)obj["TotalVisibleMemorySize"] / (double)(1024 * 1024);
184 |
185 | if (obj["TotalVirtualMemorySize"] != null)
186 | VirtualMemorySize += (ulong)obj["TotalVirtualMemorySize"] / (double)(1024 * 1024);
187 |
188 | if (obj["FreePhysicalMemory"] != null)
189 | FreePhysicalMemory += (ulong)obj["FreePhysicalMemory"] / (double)(1024 * 1024);
190 | break;
191 | }
192 |
193 |
194 | return "总内存: " + Math.Round(PhysicalMemorySize, 3).ToString() + "G\n"
195 | + "虚拟内存: " + Math.Round(VirtualMemorySize, 3).ToString() + "G\n"
196 | + "可用内存: " + Math.Round(FreePhysicalMemory, 3).ToString() + "G\n"
197 | + "使用率: " + Math.Round((PhysicalMemorySize - FreePhysicalMemory) / PhysicalMemorySize * 100, 2).ToString() + "%";
198 | }
199 |
200 | }
201 | }
202 |
--------------------------------------------------------------------------------
/Server/MessageQueue.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Net;
7 | using System.IO;
8 |
9 | namespace RemoteControlService
10 | {
11 | ///
12 | /// 消息队列处理
13 | ///
14 | public class MessageQueue
15 | {
16 | ///
17 | /// 消息队列实例
18 | ///
19 | private static readonly MessageQueue instance = new MessageQueue();
20 |
21 | ///
22 | /// 消息队列hash表
23 | ///
24 | private Hashtable queue = new Hashtable();
25 |
26 | ///
27 | /// 消息处理线程
28 | ///
29 | private Thread thread;
30 |
31 | ///
32 | /// 线程运行状态
33 | ///
34 | private volatile bool threadRuning = true;
35 |
36 | ///
37 | /// 最大尝试次数
38 | ///
39 | private const int maxTry = 5;
40 |
41 | ///
42 | /// 私有构造函数
43 | ///
44 | private MessageQueue()
45 | {
46 |
47 | }
48 |
49 | ///
50 | /// 队列检测线程
51 | ///
52 | private void CheckThread()
53 | {
54 | while (threadRuning)
55 | {
56 | string[] t = GetQueueKeys();
57 | if (t.Length > 0)
58 | {
59 | foreach (string id in t)
60 | {
61 | Process(id);
62 | }
63 | }
64 | //Log.d("Check Thread");
65 | Thread.Sleep(4000);
66 | }
67 | }
68 |
69 | ///
70 | /// 队列ID处理
71 | ///
72 | /// 消息ID
73 | private void Process(string id)
74 | {
75 | Log.d("Prcoess queue: " + id);
76 | DateTime now = DateTime.Now;
77 | SendMessage sm;
78 | lock (queue)
79 | {
80 | sm = (SendMessage)queue[id];
81 | }
82 | try
83 | {
84 | if (sm.time.Equals(DateTime.Parse("0001/1/1 0:00:00")) || sm.retransmission > maxTry || sm.time > now)
85 | {
86 | //移除
87 | lock (queue)
88 | {
89 | queue.Remove(id);
90 | }
91 | Log.d("Remove queue: " + id);
92 | return;
93 | }
94 | if (sm.time.AddSeconds(5) < now)
95 | {
96 | //重发
97 | Log.d("Send agin queue: " + id);
98 | Net.Get().Send(sm);
99 | return;
100 | }
101 | }
102 | catch (Exception ex)
103 | {
104 | Log.d("Message Queue Ex:" + ex.Message);
105 | lock (queue)
106 | {
107 | if (queue.Contains(id))
108 | queue.Remove(id);
109 | }
110 | }
111 |
112 | }
113 |
114 | ///
115 | /// 获取队列的消息头
116 | ///
117 | /// 队列keys值数组
118 | private string[] GetQueueKeys()
119 | {
120 | lock (queue)
121 | {
122 | string[] ids = new string[queue.Keys.Count];
123 | int i = 0;
124 | foreach (string id in queue.Keys)
125 | {
126 | ids[i++] = id;
127 | }
128 | return ids;
129 | }
130 | }
131 |
132 | ///
133 | /// 启动消息处理队列
134 | ///
135 | public void Start()
136 | {
137 | threadRuning = true;
138 | thread = new Thread(new ThreadStart(CheckThread));
139 | thread.Name = "Message queue thread";
140 | thread.Start();
141 | }
142 |
143 | ///
144 | /// 停止消息处理队列
145 | ///
146 | public void Stop()
147 | {
148 | threadRuning = false;
149 | if (thread != null && thread.IsAlive)
150 | thread.Abort();
151 | }
152 |
153 | ///
154 | /// 获取实例
155 | ///
156 | /// 单一的消息处理队列实例
157 | public static MessageQueue Get()
158 | {
159 | return instance;
160 | }
161 |
162 | ///
163 | /// 获取队列长度
164 | ///
165 | ///
166 | public int Length()
167 | {
168 | lock (queue)
169 | {
170 | return queue.Count;
171 | }
172 | }
173 |
174 | ///
175 | /// 添加一个未发送的消息到队列
176 | ///
177 | /// 发送消息的实例
178 | public void Add(SendMessage sm)
179 | {
180 | lock (queue)
181 | {
182 | Log.d("Add queue: " + sm.smsg.Id);
183 | queue.Add(sm.smsg.Id, sm);
184 | }
185 | }
186 |
187 | ///
188 | /// 更新队列的消息
189 | ///
190 | /// 原始消失实例
191 | public void Update(SendMessage sm)
192 | {
193 | lock (queue)
194 | {
195 | Log.d("Update queue: " + sm.smsg.Id);
196 | if (queue.Contains(sm.smsg.Id))
197 | {
198 | ((SendMessage)queue[sm.smsg.Id]).time = DateTime.Now;
199 | ++((SendMessage)queue[sm.smsg.Id]).retransmission;
200 | }
201 | }
202 | }
203 |
204 | ///
205 | /// 移除一个队列
206 | ///
207 | /// hash表key
208 | public void Remove(string id)
209 | {
210 | lock (queue)
211 | {
212 | Log.d("Remove queue: " + id);
213 | if (queue.Contains(id))
214 | {
215 | queue.Remove(id);
216 | }
217 | }
218 | }
219 |
220 | ///
221 | /// 移除队列根据用户IP
222 | ///
223 | /// 用户ip及端口
224 | public void RemoveQueue(string e)
225 | {
226 | lock (queue)
227 | {
228 | List list = GetUserKeys(e);
229 | foreach (string id in list)
230 | {
231 | queue.Remove(id);
232 | }
233 | }
234 | }
235 |
236 | ///
237 | /// 获取队列中中用户
238 | ///
239 | /// 格式化为ip:port后的IP用户地址
240 | ///
241 | private List GetUserKeys(string e)
242 | {
243 | List list = new List();
244 | foreach (string id in queue.Keys)
245 | {
246 | if (((SendMessage)queue[id]).smsg.e.ToString() == e)
247 | {
248 | list.Add(id);
249 | }
250 | }
251 | return list;
252 | }
253 | }
254 | }
255 |
--------------------------------------------------------------------------------
/Server/Control.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Windows.Forms;
5 | using System.Threading;
6 | using System.IO;
7 |
8 | namespace RemoteControlService
9 | {
10 | ///
11 | /// 主控制器
12 | ///
13 | public class Control
14 | {
15 | ///
16 | /// 网络主线程
17 | ///
18 | Thread thread;
19 |
20 | ///
21 | /// 启动状态
22 | ///
23 | bool status = false;
24 |
25 | ///
26 | /// 启动网络服务
27 | ///
28 | public void Start()
29 | {
30 | if (!Configure.Load())
31 | {
32 | MessageBox.Show("Remote Sever Configure load faild!");
33 | return;
34 | }
35 | Log.a("Control Start");
36 | if (Net.Get().Start())
37 | {
38 | thread = new Thread(new ThreadStart(ReceivedThread));
39 | thread.Name = "Received thread";
40 | thread.Start();
41 | status = true;
42 | }
43 | else
44 | {
45 | Log.a("Net start error, Control exit");
46 | MessageBox.Show("Remote Sever Start error");
47 | }
48 | }
49 |
50 | ///
51 | /// 网络接收线程
52 | ///
53 | private void ReceivedThread()
54 | {
55 | Net.Get().Receive();
56 | }
57 |
58 | ///
59 | /// 停止网络服务
60 | ///
61 | public void Stop()
62 | {
63 | Log.a("Control Stop");
64 | Net.Get().Stop();
65 | Environment.Exit(0);
66 | }
67 |
68 | ///
69 | /// 控制台主操作
70 | ///
71 | public void Terminal()
72 | {
73 | string[] cmds;
74 | ControlUser.CheckUserEmpty();
75 | while (status)
76 | {
77 | Console.Write("Remote>");
78 | cmds = Console.ReadLine().Trim().Split(' ');
79 | switch (cmds[0].Trim().ToLower())
80 | {
81 | case "":
82 | continue;
83 | case "u":
84 | case "user":
85 | ControlUser.UserAction(cmds);
86 | break;
87 | case "config":
88 | Console.WriteLine("\n" + new Function().config());
89 | break;
90 | case "q":
91 | case "quit":
92 | case "exit":
93 | Stop();
94 | break;
95 | case "m":
96 | case "msg":
97 | Console.WriteLine("\n" + new Function().msg());
98 | break;
99 | case "f":
100 | case "file":
101 | Console.WriteLine("\n" + new Function().file());
102 | break;
103 | case "ter":
104 | case "t":
105 | case "terminal":
106 | TerminalControl(cmds);
107 | break;
108 | case "cls":
109 | case "c":
110 | case "clear":
111 | Console.Clear();
112 | break;
113 | case "s":
114 | case "startup":
115 | CreateStartupFile();
116 | break;
117 | case "v":
118 | case "version":
119 | version();
120 | break;
121 | case "h":
122 | case "help":
123 | case "--help":
124 | case "/?":
125 | case "?":
126 | case "\\?":
127 | help();
128 | break;
129 | default:
130 | Console.WriteLine("Usage: config | user | msg | file | terminal | exit | startup | clear | version | help\n");
131 | break;
132 | }
133 | }
134 | }
135 |
136 | ///
137 | /// 帮助信息
138 | ///
139 | private void help()
140 | {
141 | Console.WriteLine("帮助信息:");
142 | Console.WriteLine("恋羽作品:http://www.loveyu.org");
143 | version();
144 | Console.WriteLine("config\t查看当前运行信息");
145 | Console.WriteLine("user\t用户操作命令,别名:u");
146 | ControlUser.help();
147 | Console.WriteLine("msg\t查看消息队列长度,别名:m");
148 | Console.WriteLine("file\t查看文件传输服务队列信息,别名:f");
149 | Console.WriteLine("terminal\t查看运行的终端,并进行相应操作,别名:ter,t\n\t支持参数: reset(重置连接表)");
150 | Console.WriteLine("exit\t结束程序运行,别名:q,quit");
151 | Console.WriteLine("startup\t生成没有窗口的运行脚本,复制到启动目录实现开机启动,别名:s");
152 | Console.WriteLine("clear\t清屏,清空控制台,别名:cls,c");
153 | Console.WriteLine("version\t查看版本信息,别名:v");
154 | Console.WriteLine("help\t帮助信息,别名:h,--help,/?,\\?,?");
155 | Console.WriteLine();
156 | }
157 |
158 | ///
159 | /// 查看版本信息
160 | ///
161 | private void version()
162 | {
163 | Version vs = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
164 | Console.WriteLine("程序版本: " + vs);
165 | }
166 |
167 | ///
168 | /// 创建无窗口运行脚本文件
169 | ///
170 | private void CreateStartupFile()
171 | {
172 | try
173 | {
174 | StreamWriter sw = new StreamWriter(Configure.RunVbPath(), false);
175 | sw.Write("Set ws = CreateObject(\"Wscript.Shell\")\r\nws.run \"cmd /c " + Configure.RunFilePath().Replace("\\", "\\\\") + "\",vbhide");
176 | sw.Close();
177 | Console.WriteLine("启动脚本已生成,请将其复制到启动目录。\n" + Configure.RunVbPath());
178 | }
179 | catch
180 | {
181 | Console.WriteLine("无法创建启动脚本,请检查路径异常。\n" + Configure.RunVbPath());
182 | }
183 | }
184 |
185 | ///
186 | /// 对客户端开启的DOS窗口进行管理
187 | ///
188 | /// 命令行参数
189 | private void TerminalControl(string[] cmds)
190 | {
191 | if (cmds.Length == 1)
192 | {
193 | string[] l = RemoteControlService.Terminal.Get().GetList();
194 | if (l.Length <= 0)
195 | {
196 | Console.WriteLine("没有远程终端运行");
197 | }
198 | else
199 | {
200 | Console.WriteLine("远程终端列表:");
201 | foreach (string s in l)
202 | {
203 | Console.WriteLine(" " + s);
204 | }
205 | }
206 | }
207 | else
208 | {
209 | if (cmds[1].ToLower() == "reset")
210 | {
211 | RemoteControlService.Terminal.Get().Stop();
212 | RemoteControlService.Terminal.Get().Start();
213 | Console.WriteLine("已重置");
214 | }
215 | else
216 | {
217 | Console.WriteLine("只支持 reset 重置所有连接操作");
218 | }
219 | }
220 | }
221 | }
222 | }
223 |
--------------------------------------------------------------------------------
/Server/Net.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Net;
5 | using System.Net.Sockets;
6 | using System.Threading;
7 |
8 | namespace RemoteControlService
9 | {
10 | ///
11 | /// 异步接收状态信息
12 | ///
13 | public class UdpState
14 | {
15 | ///
16 | /// udp服务对象
17 | ///
18 | public UdpClient u;
19 |
20 | ///
21 | /// 当前连接的用户地址
22 | ///
23 | public IPEndPoint e;
24 | }
25 |
26 | ///
27 | /// 异步发送状态信息
28 | ///
29 | public class UdpSendState
30 | {
31 | ///
32 | /// udp服务对象
33 | ///
34 | public UdpClient u;
35 |
36 | ///
37 | /// 要发送的消息对象
38 | ///
39 | public SendMessage sm;
40 | }
41 |
42 | ///
43 | /// 网络处理线程
44 | ///
45 | public class Net
46 | {
47 | ///
48 | /// udp客户端
49 | ///
50 | private UdpClient udp;
51 |
52 | ///
53 | /// 绑定的ip及端口
54 | ///
55 | private IPEndPoint ipEP;
56 |
57 | ///
58 | /// 网络的单例模式
59 | ///
60 | private static readonly Net instance = new Net();
61 |
62 | ///
63 | /// 接收线程运行状态
64 | ///
65 | private bool Runing = false;
66 |
67 | ///
68 | /// 网络接收事件
69 | ///
70 | private ManualResetEvent udpArrived = new ManualResetEvent(false);
71 |
72 | ///
73 | /// 网络发送事件
74 | ///
75 | private ManualResetEvent udpSent = new ManualResetEvent(false);
76 |
77 | ///
78 | /// 私有构造函数
79 | ///
80 | private Net()
81 | {
82 |
83 | }
84 |
85 | ///
86 | /// 获取单例模式实例
87 | ///
88 | ///
89 | public static Net Get()
90 | {
91 | return instance;
92 |
93 | }
94 |
95 | ///
96 | /// 启动网络线程
97 | ///
98 | /// 启动状态
99 | public bool Start()
100 | {
101 | try
102 | {
103 | ipEP = new IPEndPoint(Configure.ServerIP(), Configure.ServerPort());
104 | Runing = true;
105 | udp = new UdpClient(ipEP);
106 | MessageQueue.Get().Start();
107 | FileSend.Get().Start();
108 | Terminal.Get().Start();
109 | }
110 | catch (Exception ex)
111 | {
112 | Log.a("Net Start Exception:" + ex.StackTrace + ":" + ex.Message);
113 | return false;
114 | }
115 | return true;
116 | }
117 |
118 | ///
119 | /// 停止网络线程
120 | ///
121 | public void Stop()
122 | {
123 | Runing = false;
124 | Terminal.Get().Stop();
125 | FileSend.Get().Stop();
126 | MessageQueue.Get().Stop();
127 | }
128 |
129 | ///
130 | /// 网络接收线程
131 | ///
132 | public void Receive()
133 | {
134 | UdpState s = new UdpState();
135 | s.e = ipEP;
136 | s.u = udp;
137 | Log.a("Net reveive is runing");
138 | while (Runing)
139 | {
140 | try
141 | {
142 | udpArrived.Reset();
143 | udp.BeginReceive(new AsyncCallback(ReceiveCallback), s);
144 | udpArrived.WaitOne();
145 | }
146 | catch (Exception ex)
147 | {
148 | Log.n("Exception:" + ex.Message);
149 | }
150 |
151 | }
152 | }
153 |
154 | ///
155 | /// 异步网络接收回调函数
156 | ///
157 | /// 回调参数
158 | private void ReceiveCallback(IAsyncResult ar)
159 | {
160 | UdpClient u = (UdpClient)((UdpState)(ar.AsyncState)).u;
161 | IPEndPoint e = (IPEndPoint)((UdpState)(ar.AsyncState)).e;
162 | byte[] bytes = null;
163 | try
164 | {
165 | bytes = u.EndReceive(ar, ref e);
166 | }
167 | catch (Exception ex)
168 | {
169 | Log.n("Net data Callback Exception:" + ex.Message);
170 | }
171 | udpArrived.Set();
172 | Log.d("Received");
173 | if (bytes != null)
174 | {
175 | Message msg = new Message(bytes, e);
176 | if (msg.isOK)
177 | new Process(msg);
178 | }
179 |
180 | }
181 |
182 | ///
183 | /// 发送数据包
184 | ///
185 | /// 发送消息数据对象
186 | public void Send(SendMessage sm)
187 | {
188 | try
189 | {
190 | byte[] bytes = sm.getBytes();
191 | if (bytes == null)
192 | {
193 | Log.n("empty data to {" + sm.smsg.e + "}");
194 | return;
195 | }
196 | UdpSendState uss = new UdpSendState();
197 | uss.u = udp;
198 | uss.sm = sm;
199 | udpSent.Reset();
200 | if (sm.smsg.type != SendType.Callback)
201 | {
202 | if (sm.time.Equals(DateTime.Parse("0001/1/1 0:00:00")))
203 | {
204 | sm.time = DateTime.Now;
205 | MessageQueue.Get().Add(sm);
206 | }
207 | else
208 | {
209 | MessageQueue.Get().Update(sm);
210 | }
211 | }
212 | udp.BeginSend(bytes, bytes.Length, sm.smsg.e, new AsyncCallback(SendCallback), uss);
213 | udpSent.WaitOne();
214 | }
215 | catch (Exception ex)
216 | {
217 | Log.n(ex.Message);
218 | }
219 | }
220 |
221 | ///
222 | /// 发送回调方法
223 | ///
224 | /// 回调参数
225 | private void SendCallback(IAsyncResult ar)
226 | {
227 | UdpSendState u = (UdpSendState)ar.AsyncState;
228 | try
229 | {
230 | u.u.EndSend(ar);
231 | }
232 | catch (Exception ex)
233 | {
234 | Log.n("Exception:{" + u.sm.smsg.type.ToString() + "}" + ex.Message);
235 | Net.Get().Send(SendMessage.creatRunError("Data Send ERROR", u.sm.smsg.e));
236 | return;
237 | }
238 | finally
239 | {
240 | udpSent.Set();
241 | }
242 | }
243 |
244 | ///
245 | /// 获取运行的IP信息
246 | ///
247 | /// IP结点信息
248 | public IPEndPoint GetIp()
249 | {
250 | return ipEP;
251 | }
252 | }
253 | }
254 |
--------------------------------------------------------------------------------
/Client/res/layout/activity_setting.xml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
17 |
18 |
23 |
24 |
28 |
29 |
35 |
36 |
43 |
44 |
45 |
46 |
47 |
48 |
52 |
53 |
59 |
60 |
68 |
69 |
70 |
74 |
75 |
81 |
82 |
89 |
90 |
91 |
95 |
96 |
102 |
103 |
111 |
112 |
113 |
117 |
118 |
124 |
125 |
131 |
132 |
133 |
134 |
135 |
--------------------------------------------------------------------------------
/Client/res/values/vpi__attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
--------------------------------------------------------------------------------
/Server/FileSend.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Net;
6 | using System.IO;
7 | using System.Net.Sockets;
8 | using System.Threading;
9 |
10 | namespace RemoteControlService
11 | {
12 | ///
13 | /// 文件传输队列中的文件信息
14 | ///
15 | public class FileSendInfo
16 | {
17 | ///
18 | /// 对应用户的sid,验证用户有效性
19 | ///
20 | public string sid;
21 |
22 | ///
23 | /// 对应的文件信息
24 | ///
25 | public FileInfo fileInfo;
26 |
27 | ///
28 | /// 文件ID,发送给用户,标志该文件的唯一性
29 | ///
30 | public string fileId;
31 | }
32 |
33 | ///
34 | /// 文件传输服务
35 | ///
36 | public class FileSend
37 | {
38 | ///
39 | /// 单例模式实例
40 | ///
41 | private static readonly FileSend instance = new FileSend();
42 |
43 | ///
44 | /// 存储文件队列的hash表
45 | ///
46 | private Hashtable table = new Hashtable();
47 |
48 | ///
49 | /// Tcp监听服务器
50 | ///
51 | private TcpListener tcp;
52 |
53 | ///
54 | /// 服务器监听运行线程
55 | ///
56 | private Thread thread;
57 |
58 | ///
59 | /// 服务器运行标记
60 | ///
61 | private volatile bool runing;
62 |
63 | ///
64 | /// 本地监听信息
65 | ///
66 | private IPEndPoint ep;
67 |
68 | ///
69 | /// 连接监听事件
70 | ///
71 | private ManualResetEvent tcpArrived = new ManualResetEvent(false);
72 |
73 | ///
74 | /// 私有构造函数
75 | ///
76 | private FileSend()
77 | {
78 |
79 | }
80 |
81 | ///
82 | /// 获取对象实例
83 | ///
84 | /// 返回文件传输对象
85 | public static FileSend Get()
86 | {
87 | return instance;
88 | }
89 |
90 | ///
91 | /// 获取文件传输IP
92 | ///
93 | /// IP信息
94 | public IPEndPoint getIP()
95 | {
96 | return ep;
97 | }
98 |
99 | ///
100 | /// 获取文件队列列表
101 | ///
102 | /// 用户打印的数组
103 | public string[] GetPathList() {
104 | string[] rt = null;
105 | lock (table) {
106 | int i = 0;
107 | rt = new string[table.Keys.Count];
108 | foreach(FileSendInfo fsi in table.Values){
109 | rt[i++] = fsi.fileInfo.FullName;
110 | }
111 | }
112 | return rt;
113 | }
114 |
115 | ///
116 | /// 加载配置并启动服务
117 | ///
118 | public void Start()
119 | {
120 | ep = new IPEndPoint(Configure.FileIP(), Configure.FilePort());
121 | tcp = new TcpListener(ep);
122 | thread = new Thread(new ThreadStart(FileSendProcess));
123 | thread.Name = "FileSend Thread";
124 | runing = true;
125 | thread.Start();
126 | }
127 |
128 | ///
129 | /// 文件传输处理进程
130 | ///
131 | private void FileSendProcess()
132 | {
133 | tcp.Start();
134 | while (runing)
135 | {
136 | Log.n("Filesend waiting for a tcp client");
137 | tcpArrived.Reset();
138 | tcp.BeginAcceptTcpClient(new AsyncCallback(tcpCallback), tcp);
139 | tcpArrived.WaitOne();
140 | }
141 | }
142 |
143 | ///
144 | /// 异步调用返回值
145 | ///
146 | /// 异步传输值
147 | private void tcpCallback(IAsyncResult ar)
148 | {
149 | TcpListener listener = (TcpListener)ar.AsyncState;
150 | TcpClient client = listener.EndAcceptTcpClient(ar);
151 | tcpArrived.Set();
152 | IPEndPoint e = (IPEndPoint)client.Client.RemoteEndPoint;
153 | if (User.IpInUser(e) == false)
154 | {
155 | client.Close();
156 | return;
157 | }
158 | NetworkStream ns = client.GetStream();
159 | StreamReader sr = new StreamReader(ns, Encoding.UTF8);
160 | string sid = sr.ReadLine();
161 | Log.d("sid:" + sid);
162 | if (User.TcpUserConfirm(e, sid) == false)
163 | {
164 | client.Close();
165 | return;
166 | }
167 | string fileid = sr.ReadLine();
168 | Log.d("fileid:" + fileid);
169 | FileSendInfo fsi;
170 | try
171 | {
172 | lock (table)
173 | {
174 | if (fileid == null || table.Contains(fileid) == false)
175 | {
176 | client.Close();
177 | return;
178 | }
179 | fsi = (FileSendInfo)table[fileid];
180 | }
181 | if (fsi.sid != sid)
182 | {
183 | client.Close();
184 | return;
185 | }
186 | lock (table)
187 | {
188 | table.Remove(fileid);
189 | }
190 | FileStream fs = fsi.fileInfo.OpenRead();
191 | byte[] tmp = stringToBytes(fs.Length.ToString() + "\n");
192 | ns.Write(tmp, 0, tmp.Length);
193 | ns.Flush();
194 | while (true)
195 | {
196 | if (sr.ReadLine().ToLower() == "send")
197 | {
198 | break;
199 | }
200 | }
201 | Log.d("File output begin");
202 | tmp = new byte[2048];
203 | int rl = 0;
204 | while ((rl = fs.Read(tmp, 0, 2048)) != 0)
205 | {
206 | ns.Write(tmp, 0, rl);
207 | }
208 | fs.Close();
209 | sr.Close();
210 | ns.Close();
211 | Log.d("File output finish");
212 | }
213 | catch (Exception ex)
214 | {
215 | Log.d("Tcp running execption:" + ex.Message);
216 | }
217 | finally
218 | {
219 | client.Close();
220 | }
221 | }
222 |
223 | ///
224 | /// 停止文件传输服务
225 | ///
226 | public void Stop()
227 | {
228 | runing = false;
229 | if (thread != null && thread.IsAlive)
230 | thread.Abort();
231 | if (tcp != null)
232 | tcp.Stop();
233 | }
234 |
235 | ///
236 | /// 添加一个文件到传输队列
237 | ///
238 | /// 文件信息
239 | /// 用户sid
240 | /// 文件传输唯一ID
241 | public string AddFile(FileInfo fi, string sid)
242 | {
243 | FileStream fs = fi.OpenRead();//进行打开测试
244 | fs.Close();
245 | FileSendInfo fsi = new FileSendInfo();
246 | fsi.fileInfo = fi;
247 | fsi.sid = sid;
248 | System.Security.Cryptography.SHA1 hash = System.Security.Cryptography.SHA1.Create();
249 | fsi.fileId = Convert.ToBase64String(hash.ComputeHash(SendMessage.ToBytes(fi.FullName + sid)));
250 | if (table.Contains(fsi.fileId)) return fsi.fileId;
251 | table.Add(fsi.fileId, fsi);
252 | return fsi.fileId;
253 | }
254 |
255 | ///
256 | /// 字符串转字节数组
257 | ///
258 | /// 非空字符串
259 | /// 字符数组
260 | public byte[] stringToBytes(string s)
261 | {
262 | return SendMessage.ToBytes(s);
263 | }
264 | }
265 | }
266 |
--------------------------------------------------------------------------------
/Server/Process.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Reflection;
5 | using System.Windows.Forms;
6 |
7 | namespace RemoteControlService
8 | {
9 | ///
10 | /// 网络处理进程
11 | ///
12 | public class Process
13 | {
14 | ///
15 | /// 获取到到消息信息
16 | ///
17 | Message msg;
18 |
19 | ///
20 | /// 构造新的对象,并在构造函数中执行完全部操作
21 | ///
22 | /// 指定的消息信息
23 | public Process(Message msg)
24 | {
25 | Log.d("Run Process of {" + msg.msg.e + "}");
26 | this.msg = msg;
27 | try
28 | {
29 | Run();
30 | }
31 | catch (Exception ex)
32 | {
33 | Log.p("Exception: " + ex.Message);
34 | }
35 | }
36 |
37 | ///
38 | /// 发送回执给服务器以移除发送队列
39 | ///
40 | private void SendCallback()
41 | {
42 | Net.Get().Send(SendMessage.creatCallback(msg.msg.Id, msg.msg.e));
43 | }
44 |
45 | ///
46 | /// 开始执行指定命令
47 | ///
48 | private void Run()
49 | {
50 | //Log.d("Command:" + msg.msg.Type.ToString());
51 | if (msg.msg.Type == MessageType.CALLBACK)
52 | {
53 | //进行消息回复
54 | ProcessCallback(msg.msg.Content);
55 | return;
56 | }
57 | else
58 | {
59 | SendCallback();
60 | if (User.IsLogin(msg.msg.e) == false)
61 | {
62 | //未登陆用户
63 | if (msg.msg.Type != MessageType.LOGIN)
64 | {
65 | Net.Get().Send(SendMessage.creatLogin("203 Please Login", msg.msg.e));
66 | return;
67 | }
68 | Net.Get().Send(SendMessage.creatLogin(User.Login(msg.msg.e, msg.msg.Content), msg.msg.e));
69 | return;
70 | }
71 | }
72 | switch (msg.msg.Type)
73 | {
74 | case MessageType.NOTICE:
75 | ShowNotice(msg.msg.Content);
76 | break;
77 | case MessageType.FUNCTION:
78 | RunFunc(msg.msg.Content);
79 | break;
80 | case MessageType.WARNING:
81 | ShowWarning(msg.msg.Content);
82 | break;
83 | case MessageType.COMMAND:
84 | RunCommand(msg.msg.Content);
85 | break;
86 | case MessageType.FILE:
87 | RunFileSystem(msg.msg.Content);
88 | break;
89 | case MessageType.SCREENSHOT:
90 | GetScreenshot(msg.msg.Content);
91 | break;
92 | case MessageType.TERMINAL:
93 | RunTreminal(msg.msg.Content);
94 | break;
95 | case MessageType.LOGOUT:
96 | User.Remove(msg.msg.e);
97 | break;
98 | case MessageType.LOGIN:
99 | SendLoggedInformation();
100 | break;
101 | case MessageType.TASK:
102 | SetTask();
103 | break;
104 | default:
105 | SendUnknownType();
106 | break;
107 | }
108 | }
109 |
110 | ///
111 | /// 发送已经登录的提示消息
112 | ///
113 | private void SendLoggedInformation()
114 | {
115 | Net.Get().Send(SendMessage.creatLogin(User.LoggedMsg(), msg.msg.e));
116 | }
117 |
118 | ///
119 | /// 发送当前消息类型未知提示消息
120 | ///
121 | private void SendUnknownType()
122 | {
123 | Net.Get().Send(SendMessage.creatText("Unknown Message Type", msg.msg.e));
124 | }
125 |
126 | ///
127 | /// 处理服务器发送过来的回执
128 | ///
129 | /// 队列的ID号
130 | private void ProcessCallback(string id)
131 | {
132 | Log.d("Callback:" + id.Split('\t')[1]);
133 | MessageQueue.Get().Remove(id);
134 | }
135 |
136 | ///
137 | /// 执行指定的功能函数,并且发送返回值作为提示信息
138 | ///
139 | /// 功能方法名
140 | private void RunFunc(string str)
141 | {
142 | Function func = new Function();
143 | MethodInfo[] mis = func.GetType().GetMethods();
144 | foreach (MethodInfo mi in mis)
145 | {
146 | if (mi.Name == str)
147 | {
148 | Log.p("Run Func: " + str);
149 | string rt = (string)mi.Invoke(func, null);
150 | if (rt != null && rt != "")
151 | {
152 | Net.Get().Send(SendMessage.creatText(rt, msg.msg.e));
153 | }
154 | return;
155 | }
156 | }
157 | Log.p("No found Func: " + str);
158 | Net.Get().Send(SendMessage.creatRunError("No found Function To Run", msg.msg.e));
159 | }
160 |
161 | ///
162 | /// 在计算机桌面显示一个Notice信息,关闭时返回关闭状态
163 | ///
164 | /// 要显示的内容
165 | private void ShowNotice(string content)
166 | {
167 | MessageBox.Show(content, "远程控制提示信息", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
168 | Net.Get().Send(SendMessage.creatText("Notice Closed!", msg.msg.e));
169 | }
170 |
171 | ///
172 | /// 在计算机桌面显示警告,关闭时返回关闭状态
173 | ///
174 | /// 警告内容
175 | private void ShowWarning(string content)
176 | {
177 | MessageBox.Show(content, "远程控制警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
178 | Net.Get().Send(SendMessage.creatText("Warning Closed!", msg.msg.e));
179 | }
180 |
181 | ///
182 | /// 运行命令,运行结束后返回命令已执行消息
183 | ///
184 | /// 命令字符串,多命令换行
185 | private void RunCommand(string cmd)
186 | {
187 | cmd = cmd.Replace("\n", " & ");
188 | System.Diagnostics.Process cmdProcess = System.Diagnostics.Process.Start("cmd.exe", "/C " + cmd);
189 | cmdProcess.WaitForExit();
190 | Net.Get().Send(SendMessage.creatText("Command already running!\n"+cmd, msg.msg.e));
191 | }
192 |
193 | ///
194 | /// 执行文件操作信息
195 | ///
196 | /// 要操作的文件路径
197 | private void RunFileSystem(string path)
198 | {
199 | FileControl fc = new FileControl(path, msg.msg.e);
200 | byte[] rt = fc.Callback();
201 | if (rt == null || rt.Length < 1)
202 | {
203 | string err = fc.GetError();
204 | if (err == "") err = "File operation returns a null value";
205 | Net.Get().Send(SendMessage.creatRunError(err, msg.msg.e));
206 | }
207 | else
208 | {
209 | Net.Get().Send(SendMessage.creatFile(rt, msg.msg.e));
210 | }
211 | }
212 |
213 | ///
214 | /// 获取当前桌面截图,并返回两个文件路径信息
215 | ///
216 | /// 缩略图宽度,默认100
217 | private void GetScreenshot(string width)
218 | {
219 | Screenshot s = new Screenshot(width);
220 | if (!s.isOK())
221 | {
222 | Net.Get().Send(SendMessage.creatRunError("Screenshot cann't create or found", msg.msg.e));
223 | }
224 | else
225 | {
226 | Net.Get().Send(SendMessage.creatPicture(s.getFull(), s.getFullSize(), s.get(), s.getSize(), msg.msg.e));
227 | }
228 | }
229 |
230 | ///
231 | /// 执行终端命令,每用户一个终端
232 | ///
233 | /// 命令内容
234 | private void RunTreminal(string content)
235 | {
236 | Terminal.Get().Run(content, msg.msg.e);
237 | }
238 |
239 | ///
240 | /// 对任务进行操作,发送任务列表或操作提示
241 | ///
242 | private void SetTask()
243 | {
244 | byte[] rt = Task.Process(msg.msg.Content, msg.msg.e);
245 | if (rt != null && rt.Length > 0)
246 | {
247 | Net.Get().Send(SendMessage.creatTask(rt, msg.msg.e));
248 | }
249 | }
250 | }
251 | }
252 |
--------------------------------------------------------------------------------
/Server/Terminal.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using System.Collections.Generic;
4 | using System.Text;
5 | using System.Net;
6 | using System.Threading;
7 |
8 | namespace RemoteControlService
9 | {
10 | ///
11 | /// 每个终端信息
12 | ///
13 | public class TerminalInfo
14 | {
15 | ///
16 | /// 终端消息写入事件
17 | ///
18 | private ManualResetEvent processWriteWaite = new ManualResetEvent(false);
19 |
20 | ///
21 | /// 终端的命令
22 | ///
23 | private string cmd = null;
24 |
25 | ///
26 | /// 写线程
27 | ///
28 | private Thread wThread;
29 |
30 | ///
31 | /// 读线程
32 | ///
33 | private Thread rThread;
34 |
35 | ///
36 | /// 错误读取线程
37 | ///
38 | private Thread eThread;
39 |
40 | ///
41 | /// 事件运行标记
42 | ///
43 | public bool eventHandled = false;
44 |
45 | ///
46 | /// 运行的终端进程
47 | ///
48 | System.Diagnostics.Process p;
49 |
50 | ///
51 | /// 用户地址
52 | ///
53 | IPEndPoint e;
54 |
55 | ///
56 | /// 构造函数,启用线程
57 | ///
58 | /// 用户地址
59 | public TerminalInfo(IPEndPoint e)
60 | {
61 | this.e = e;
62 | p = new System.Diagnostics.Process();
63 | p.StartInfo.FileName = "cmd.exe";
64 | p.StartInfo.UseShellExecute = false;
65 | p.StartInfo.RedirectStandardInput = true;
66 | p.StartInfo.RedirectStandardOutput = true;
67 | p.StartInfo.RedirectStandardError = true;
68 | //p.StartInfo.StandardOutputEncoding = Encoding.UTF8;
69 | p.StartInfo.CreateNoWindow = true;
70 | p.Exited += new EventHandler(myProcess_Exited);
71 | p.Start();
72 | wThread = new Thread(new ThreadStart(WriteThread));
73 | rThread = new Thread(new ThreadStart(ReadThread));
74 | eThread = new Thread(new ThreadStart(ErrorThread));
75 | wThread.Name = "Terminal write thread";
76 | rThread.Name = "Terminal read thread";
77 | eThread.Name = "Terminal error thread";
78 | wThread.Start();
79 | rThread.Start();
80 | eThread.Start();
81 | }
82 |
83 | ///
84 | /// 写线程,一旦收到数据立即写入
85 | ///
86 | private void WriteThread()
87 | {
88 | while (!eventHandled)
89 | {
90 | processWriteWaite.Reset();
91 | if (cmd != null)
92 | {
93 | p.StandardInput.Write(cmd);
94 | p.StandardInput.Flush();
95 | cmd = null;
96 | }
97 | processWriteWaite.WaitOne();
98 | }
99 | }
100 |
101 | ///
102 | /// 读线程,每次读取4097字节数据发送到客户端
103 | ///
104 | private void ReadThread()
105 | {
106 | while (!eventHandled)
107 | {
108 | Thread.Sleep(20);
109 | try
110 | {
111 | char[] buf = new char[4097];
112 | int rl = p.StandardOutput.Read(buf, 0, 4097);
113 | Log.d("Send terminal read:" + rl);
114 | Net.Get().Send(SendMessage.creatTerminal(new string(buf, 0, rl), e));
115 | }
116 | catch (Exception ex)
117 | {
118 | Log.d("Terminal ex:" + ex.Message);
119 | myProcess_Exited(null, null);
120 | return;
121 | }
122 | }
123 | }
124 |
125 | ///
126 | /// 读取错误输出发送到客户端
127 | ///
128 | private void ErrorThread()
129 | {
130 | while (!eventHandled)
131 | {
132 | Thread.Sleep(20);
133 | try
134 | {
135 | char[] buf = new char[4097];
136 | int rl = p.StandardError.Read(buf, 0, 4097);
137 | Log.d("Send terminal error:" + rl);
138 | Net.Get().Send(SendMessage.creatTerminalError(new string(buf, 0, rl), e));
139 | }
140 | catch (Exception ex)
141 | {
142 | Log.d("Terminal ex:" + ex.Message);
143 | myProcess_Exited(null, null);
144 | return;
145 | }
146 | }
147 | }
148 |
149 | ///
150 | /// 退出终端
151 | ///
152 | ///
153 | ///
154 | private void myProcess_Exited(object sender, System.EventArgs e)
155 | {
156 | eventHandled = true;
157 | Log.d("Terminal Exited");
158 | processWriteWaite.Set();
159 | Remove();
160 | }
161 |
162 | ///
163 | /// 写入数据到终端
164 | ///
165 | ///
166 | public void Write(string str)
167 | {
168 | cmd = str;
169 | Log.d("Terminal get char:" + cmd);
170 | processWriteWaite.Set();
171 | }
172 |
173 | ///
174 | /// 移除终端
175 | ///
176 | public void Remove()
177 | {
178 | try
179 | {
180 | eventHandled = true;
181 | wThread.Abort();
182 | rThread.Abort();
183 | eThread.Abort();
184 | p.Kill();
185 | }
186 | catch
187 | {
188 | }
189 | }
190 | }
191 |
192 | ///
193 | /// 终端控制
194 | ///
195 | public class Terminal
196 | {
197 | ///
198 | /// 终端单例模式实例
199 | ///
200 | private static readonly Terminal instance = new Terminal();
201 |
202 | ///
203 | /// 终端列表
204 | ///
205 | private Hashtable table = new Hashtable();
206 |
207 | ///
208 | /// 私有构造函数
209 | ///
210 | private Terminal() { }
211 |
212 | ///
213 | /// 获取实例
214 | ///
215 | ///
216 | public static Terminal Get()
217 | {
218 | return instance;
219 | }
220 |
221 | ///
222 | /// 获取终端列表为一个字符串数组输出
223 | ///
224 | ///
225 | public string[] GetList()
226 | {
227 | string[] rt = null;
228 | lock (table)
229 | {
230 | rt = new string[table.Count];
231 | int i = 0;
232 | foreach (string e in table.Keys)
233 | {
234 | rt[i++] = e;
235 | }
236 | }
237 | return rt;
238 | }
239 |
240 | ///
241 | /// 启动终端
242 | ///
243 | public void Start()
244 | {
245 |
246 | }
247 |
248 | ///
249 | /// 终止所有终端
250 | ///
251 | public void Stop()
252 | {
253 | lock (table)
254 | {
255 | if (table.Keys.Count > 0)
256 | {
257 | string[] hl = new string[table.Keys.Count];
258 | table.Keys.CopyTo(hl, 0);
259 | foreach (string s in hl)
260 | {
261 | ((TerminalInfo)table[s]).Remove();
262 | table.Remove(s);
263 | }
264 | }
265 | }
266 | }
267 |
268 | ///
269 | /// 在用户自己终端上运行指定线程
270 | ///
271 | /// 用户命令
272 | /// 用户地址
273 | public void Run(string cmd, IPEndPoint e)
274 | {
275 | string name = e.ToString();
276 | lock (table)
277 | {
278 | if (table.Contains(name) == false)
279 | {
280 | TerminalInfo ti = new TerminalInfo(e);
281 | table.Add(name, ti);
282 | }
283 | else if (((TerminalInfo)table[name]).eventHandled == true)
284 | {
285 | TerminalInfo ti = new TerminalInfo(e);
286 | table.Remove(name);
287 | table.Add(name, ti);
288 | }
289 | ((TerminalInfo)table[name]).Write(cmd);
290 | }
291 | }
292 | }
293 | }
294 |
--------------------------------------------------------------------------------
/Client/src/com/viewpagerindicator/IcsLinearLayout.java:
--------------------------------------------------------------------------------
1 | package com.viewpagerindicator;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Canvas;
6 | import android.graphics.drawable.Drawable;
7 | import android.view.View;
8 | import android.widget.LinearLayout;
9 |
10 | /**
11 | * A simple extension of a regular linear layout that supports the divider API
12 | * of Android 4.0+. The dividers are added adjacent to the children by changing
13 | * their layout params. If you need to rely on the margins which fall in the
14 | * same orientation as the layout you should wrap the child in a simple
15 | * {@link android.widget.FrameLayout} so it can receive the margin.
16 | */
17 | class IcsLinearLayout extends LinearLayout {
18 | private static final int[] LL = new int[] {
19 | /* 0 */ android.R.attr.divider,
20 | /* 1 */ android.R.attr.showDividers,
21 | /* 2 */ android.R.attr.dividerPadding,
22 | };
23 | private static final int LL_DIVIDER = 0;
24 | private static final int LL_SHOW_DIVIDER = 1;
25 | private static final int LL_DIVIDER_PADDING = 2;
26 |
27 | private Drawable mDivider;
28 | private int mDividerWidth;
29 | private int mDividerHeight;
30 | private int mShowDividers;
31 | private int mDividerPadding;
32 |
33 |
34 | public IcsLinearLayout(Context context, int themeAttr) {
35 | super(context);
36 |
37 | TypedArray a = context.obtainStyledAttributes(null, LL, themeAttr, 0);
38 | setDividerDrawable(a.getDrawable(IcsLinearLayout.LL_DIVIDER));
39 | mDividerPadding = a.getDimensionPixelSize(LL_DIVIDER_PADDING, 0);
40 | mShowDividers = a.getInteger(LL_SHOW_DIVIDER, SHOW_DIVIDER_NONE);
41 | a.recycle();
42 | }
43 |
44 | public void setDividerDrawable(Drawable divider) {
45 | if (divider == mDivider) {
46 | return;
47 | }
48 | mDivider = divider;
49 | if (divider != null) {
50 | mDividerWidth = divider.getIntrinsicWidth();
51 | mDividerHeight = divider.getIntrinsicHeight();
52 | } else {
53 | mDividerWidth = 0;
54 | mDividerHeight = 0;
55 | }
56 | setWillNotDraw(divider == null);
57 | requestLayout();
58 | }
59 |
60 | @Override
61 | protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
62 | final int index = indexOfChild(child);
63 | final int orientation = getOrientation();
64 | final LayoutParams params = (LayoutParams) child.getLayoutParams();
65 | if (hasDividerBeforeChildAt(index)) {
66 | if (orientation == VERTICAL) {
67 | //Account for the divider by pushing everything up
68 | params.topMargin = mDividerHeight;
69 | } else {
70 | //Account for the divider by pushing everything left
71 | params.leftMargin = mDividerWidth;
72 | }
73 | }
74 |
75 | final int count = getChildCount();
76 | if (index == count - 1) {
77 | if (hasDividerBeforeChildAt(count)) {
78 | if (orientation == VERTICAL) {
79 | params.bottomMargin = mDividerHeight;
80 | } else {
81 | params.rightMargin = mDividerWidth;
82 | }
83 | }
84 | }
85 | super.measureChildWithMargins(child, parentWidthMeasureSpec, widthUsed, parentHeightMeasureSpec, heightUsed);
86 | }
87 |
88 | @Override
89 | protected void onDraw(Canvas canvas) {
90 | if (mDivider != null) {
91 | if (getOrientation() == VERTICAL) {
92 | drawDividersVertical(canvas);
93 | } else {
94 | drawDividersHorizontal(canvas);
95 | }
96 | }
97 | super.onDraw(canvas);
98 | }
99 |
100 | private void drawDividersVertical(Canvas canvas) {
101 | final int count = getChildCount();
102 | for (int i = 0; i < count; i++) {
103 | final View child = getChildAt(i);
104 |
105 | if (child != null && child.getVisibility() != GONE) {
106 | if (hasDividerBeforeChildAt(i)) {
107 | final android.widget.LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) child.getLayoutParams();
108 | final int top = child.getTop() - lp.topMargin/* - mDividerHeight*/;
109 | drawHorizontalDivider(canvas, top);
110 | }
111 | }
112 | }
113 |
114 | if (hasDividerBeforeChildAt(count)) {
115 | final View child = getChildAt(count - 1);
116 | int bottom = 0;
117 | if (child == null) {
118 | bottom = getHeight() - getPaddingBottom() - mDividerHeight;
119 | } else {
120 | //final LayoutParams lp = (LayoutParams) child.getLayoutParams();
121 | bottom = child.getBottom()/* + lp.bottomMargin*/;
122 | }
123 | drawHorizontalDivider(canvas, bottom);
124 | }
125 | }
126 |
127 | private void drawDividersHorizontal(Canvas canvas) {
128 | final int count = getChildCount();
129 | for (int i = 0; i < count; i++) {
130 | final View child = getChildAt(i);
131 |
132 | if (child != null && child.getVisibility() != GONE) {
133 | if (hasDividerBeforeChildAt(i)) {
134 | final android.widget.LinearLayout.LayoutParams lp = (android.widget.LinearLayout.LayoutParams) child.getLayoutParams();
135 | final int left = child.getLeft() - lp.leftMargin/* - mDividerWidth*/;
136 | drawVerticalDivider(canvas, left);
137 | }
138 | }
139 | }
140 |
141 | if (hasDividerBeforeChildAt(count)) {
142 | final View child = getChildAt(count - 1);
143 | int right = 0;
144 | if (child == null) {
145 | right = getWidth() - getPaddingRight() - mDividerWidth;
146 | } else {
147 | //final LayoutParams lp = (LayoutParams) child.getLayoutParams();
148 | right = child.getRight()/* + lp.rightMargin*/;
149 | }
150 | drawVerticalDivider(canvas, right);
151 | }
152 | }
153 |
154 | private void drawHorizontalDivider(Canvas canvas, int top) {
155 | mDivider.setBounds(getPaddingLeft() + mDividerPadding, top,
156 | getWidth() - getPaddingRight() - mDividerPadding, top + mDividerHeight);
157 | mDivider.draw(canvas);
158 | }
159 |
160 | private void drawVerticalDivider(Canvas canvas, int left) {
161 | mDivider.setBounds(left, getPaddingTop() + mDividerPadding,
162 | left + mDividerWidth, getHeight() - getPaddingBottom() - mDividerPadding);
163 | mDivider.draw(canvas);
164 | }
165 |
166 | private boolean hasDividerBeforeChildAt(int childIndex) {
167 | if (childIndex == 0 || childIndex == getChildCount()) {
168 | return false;
169 | }
170 | if ((mShowDividers & SHOW_DIVIDER_MIDDLE) != 0) {
171 | boolean hasVisibleViewBefore = false;
172 | for (int i = childIndex - 1; i >= 0; i--) {
173 | if (getChildAt(i).getVisibility() != GONE) {
174 | hasVisibleViewBefore = true;
175 | break;
176 | }
177 | }
178 | return hasVisibleViewBefore;
179 | }
180 | return false;
181 | }
182 | }
183 |
--------------------------------------------------------------------------------
/Test/UdpMessageTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows.Forms;
10 | using System.Net.Sockets;
11 | using System.Net;
12 | using System.Threading;
13 | using System.IO;
14 |
15 | namespace UdpMessageTest
16 | {
17 | public partial class UdpMessageTest : Form
18 | {
19 | UdpClient udp;
20 | public delegate void AddText(string str);
21 | AddText addTextDelegate;
22 | private volatile bool rcving = false;
23 | static long id = 0;
24 | string sid = "";
25 | public UdpMessageTest()
26 | {
27 | addTextDelegate = new AddText(addText);
28 | InitializeComponent();
29 | }
30 | private void addText(string str)
31 | {
32 | if (richTextBox_received.InvokeRequired)
33 | {
34 | richTextBox_received.Invoke(addTextDelegate, str);
35 | }
36 | else
37 | {
38 | richTextBox_received.Text += str;
39 | }
40 | }
41 | private void button_connect_Click(object sender, EventArgs e)
42 | {
43 | try
44 | {
45 | udp = new UdpClient();
46 | udp.Connect(new IPEndPoint(IPAddress.Parse(textBox_ip.Text), int.Parse(textBox_port.Text)));
47 | button_close.Enabled = true;
48 | button_connect.Enabled = false;
49 | button_send.Enabled = true;
50 | rcving = true;
51 | Thread thread = new Thread(new ThreadStart(ReceivedThread));
52 | thread.Start();
53 | }
54 | catch (Exception ex)
55 | {
56 | MessageBox.Show(ex.Message);
57 | }
58 | }
59 | private void ReceivedThread()
60 | {
61 | while (rcving)
62 | {
63 | try
64 | {
65 | IPEndPoint e = new IPEndPoint(IPAddress.Any, 0);
66 | byte[] bytes = udp.Receive(ref e);
67 | Process(bytes, e);
68 | }
69 | catch (Exception ex)
70 | {
71 | Console.WriteLine(ex.Message);
72 | }
73 | }
74 | }
75 |
76 | private void Process(byte[] bs, IPEndPoint e)
77 | {
78 |
79 | StreamReader sr = new StreamReader(new MemoryStream(bs, false), Encoding.UTF8);
80 | try
81 | {
82 | string head = sr.ReadLine();
83 | string[] info = head.Split('\t');
84 | if (info[2] == "01") return;
85 | addText(string.Format("[{0}]:Date:{1};ID:{2};TYPE:{3};\n", e, info[0], info[1], info[2]));
86 | byte[] send = Encoding.UTF8.GetBytes(string.Format("{0:0000000000}", id++) + "07" + info[0] + "\t" + info[1]);
87 | udp.Send(send, send.Length);
88 | if (info[2] == "05")
89 | {
90 | head = sr.ReadLine();
91 | string[] info2 = head.Split('\t');
92 | switch (info2[0].ToLower())
93 | {
94 | case "dir":
95 | addText("Get Dir info:\n" + info2[1] + "\t" + info2[1] + "\t" + info2[1] + "\n");
96 | break;
97 | case "file":
98 | addText("Get File info:\npath:" + info2[1] + " size:" + info2[2] + " FileId:" + info2[3] + "\n");
99 | Thread thread = new Thread(new ParameterizedThreadStart(GetFile));
100 | thread.Name = "file received thread";
101 | thread.Start(info2);
102 | break;
103 | default:
104 | addText(head + "\n");
105 | break;
106 | }
107 | }
108 | if (info[2] == "03")
109 | {
110 | head = sr.ReadLine();
111 | if (head.Substring(0, 3) == "200")
112 | {
113 | sid = head.Substring(4);
114 | addText("Login Success" + "\n");
115 | }
116 | else
117 | {
118 | addText("Login error: " + head + "\n");
119 | }
120 | return;
121 | }
122 | if (info[2] == "07" || info[2] == "08")
123 | addText(sr.ReadToEnd());
124 | else addText(sr.ReadToEnd() + "\n");
125 | }
126 | catch (Exception ex)
127 | {
128 | Console.WriteLine(ex.Message);
129 | }
130 | finally
131 | {
132 | sr.Close();
133 | }
134 | }
135 | private void GetFile(Object obj)
136 | {
137 | string[] info = (string[])obj;
138 | TcpClient client = new TcpClient();
139 | client.Connect(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9875));
140 | if (client.Connected)
141 | {
142 | try
143 | {
144 | addText("Begin Read file thread\n");
145 | NetworkStream ns = client.GetStream();
146 | StreamReader sr = new StreamReader(ns);
147 | byte[] btmp = stringToBytes(sid + "\n");
148 | ns.Write(btmp, 0, btmp.Length);
149 | btmp = stringToBytes(info[3] + "\n");
150 | ns.Write(btmp, 0, btmp.Length);
151 | ns.Flush();
152 | string tmp = sr.ReadLine();
153 | if (tmp == null)
154 | {
155 | client.Close();
156 | addText("File thread no file");
157 | return;
158 | }
159 | Console.WriteLine(tmp);
160 | long size = long.Parse(tmp);
161 |
162 | if (size >= 0)
163 | {
164 | addText("Begin Read file\n");
165 | FileStream fs = new FileStream("E:\\" + Path.GetFileName(info[1]), FileMode.Create);
166 | byte[] bytes = new byte[2048];
167 | int rl = 0;
168 | btmp = stringToBytes("send\nsend\n");
169 | ns.Write(btmp, 0, btmp.Length);
170 | ns.Flush();
171 | BinaryReader br = new BinaryReader(sr.BaseStream);
172 | long read = 0;
173 | double percentage = 0, tmp_f;
174 | while ((rl = br.Read(bytes, 0, 2048)) != 0)
175 | {
176 | fs.Write(bytes, 0, rl);
177 | read += rl;
178 | tmp_f = read * 100 / size;
179 | if (tmp_f > percentage)
180 | {
181 | percentage = tmp_f;
182 | addText("Download:" + percentage + "\n");
183 | }
184 | }
185 | addText("Download complete\n");
186 | fs.Close();
187 | if (read != size)
188 | {
189 | addText("Read size is" + read + ", but file size is " + size + "\n");
190 | }
191 | }
192 | else
193 | {
194 | addText("File size is " + size + ",read error\n");
195 | }
196 | ns.Close();
197 | client.Close();
198 | }
199 | catch (Exception ex)
200 | {
201 | Console.WriteLine(ex.StackTrace);
202 | MessageBox.Show(ex.Message);
203 | }
204 | }
205 | else
206 | {
207 | MessageBox.Show("Cann't connected");
208 | }
209 | }
210 | private void button_close_Click(object sender, EventArgs e)
211 | {
212 | if (udp != null)
213 | {
214 | udp.Close();
215 | udp = null;
216 | }
217 | button_close.Enabled = false;
218 | button_connect.Enabled = true;
219 | button_send.Enabled = false;
220 | rcving = false;
221 | }
222 |
223 | private void button_send_Click(object sender, EventArgs e)
224 | {
225 | try
226 | {
227 | if (udp == null)
228 | {
229 | MessageBox.Show("未连接");
230 | return;
231 | }
232 | byte[] bytes = Encoding.UTF8.GetBytes(string.Format("{0:0000000000}", id++) + comboBox.Text + richTextBox_Send.Text);
233 | udp.Send(bytes, bytes.Length);
234 | }
235 | catch (Exception ex)
236 | {
237 | MessageBox.Show(ex.Message);
238 | }
239 | }
240 |
241 | private void UdpMessageTest_FormClosing(object sender, FormClosingEventArgs e)
242 | {
243 | button_close_Click(null, null);
244 | }
245 |
246 | private void button_clearReceived_Click(object sender, EventArgs e)
247 | {
248 | richTextBox_received.Text = "";
249 | }
250 | public byte[] stringToBytes(string s)
251 | {
252 | return Encoding.UTF8.GetBytes(s);
253 | }
254 |
255 | private void button_login_Click(object sender, EventArgs e)
256 | {
257 | try
258 | {
259 | if (udp == null)
260 | {
261 | MessageBox.Show("未连接");
262 | return;
263 | }
264 | byte[] bytes = Encoding.UTF8.GetBytes(string.Format("{0:0000000000}08admin\nadmin\ntrue", id++));
265 | udp.Send(bytes, bytes.Length);
266 | }
267 | catch (Exception ex)
268 | {
269 | MessageBox.Show(ex.Message);
270 | }
271 | }
272 | }
273 | }
274 |
--------------------------------------------------------------------------------
/Server/Configure.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Net;
5 | using System.IO;
6 |
7 | namespace RemoteControlService
8 | {
9 | ///
10 | /// 配文件静态类
11 | ///
12 | public class Configure
13 | {
14 | ///
15 | /// 程序运行路径
16 | ///
17 | private static string RunPath;
18 |
19 | ///
20 | /// 程序文件所在路径
21 | ///
22 | private static string RunFile = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
23 |
24 | ///
25 | /// 程序名称
26 | ///
27 | private static string RunName;
28 |
29 | ///
30 | /// 配置文件路径
31 | ///
32 | private static string ConfigPath;
33 |
34 | ///
35 | /// 服务器监听的UDP端口
36 | ///
37 | private static int _ServerPort = 0;
38 |
39 | ///
40 | /// 文件传输服务的tcp监听端口
41 | ///
42 | private static int _FilePort = 0;
43 |
44 | ///
45 | /// 服务器监听IP
46 | ///
47 | private static IPAddress _ServerIP;
48 |
49 | ///
50 | /// 文件传输监听IP
51 | ///
52 | private static IPAddress _FileIP;
53 |
54 | ///
55 | /// 根目录地址
56 | ///
57 | private static string _RootPath;
58 |
59 | ///
60 | /// 日志文件路径
61 | ///
62 | private static string _LogPath;
63 |
64 | ///
65 | /// 截图保存文件夹
66 | ///
67 | private static string _ScreenshotPath;
68 |
69 | ///
70 | /// 用户列表文件路径
71 | ///
72 | private static string _UserListPath;
73 |
74 | ///
75 | /// 生成的vb启动文件路径
76 | ///
77 | private static string RunVb;
78 |
79 | ///
80 | /// 开始加载配置文件
81 | ///
82 | /// 能否成功加载
83 | public static bool Load()
84 | {
85 | try
86 | {
87 | FileInfo fi = new FileInfo(RunFile);
88 | RunPath = fi.DirectoryName;
89 | RunName = fi.Name;
90 | ConfigPath = RunFile + ".conf";
91 | RunVb = RunFile + ".vbs";
92 | if (File.Exists(ConfigPath))
93 | {
94 | ReadConfig();
95 | }
96 | else
97 | {
98 | WriteConfig();
99 | }
100 | Environment.CurrentDirectory = _RootPath;
101 |
102 | ReadUserList();
103 |
104 | return true;
105 | }
106 | catch
107 | {
108 | return false;
109 | }
110 | }
111 |
112 | ///
113 | /// 读取用户列表并写入内存
114 | ///
115 | /// 异常或文件过大则返回false
116 | private static bool ReadUserList()
117 | {
118 | try
119 | {
120 | if (new FileInfo(UserListPath()).Exists == false)
121 | {
122 | return true;
123 | }
124 | StreamReader sr = new StreamReader(UserListPath());
125 | if (sr.BaseStream.Length > 100000)
126 | {
127 | sr.Close();
128 | return true;
129 | }
130 | string content = sr.ReadToEnd();
131 | sr.Close();
132 | User.GetUserInfo(content.Split('\n'));
133 | }
134 | catch (Exception ex)
135 | {
136 | Log.a("Read User list Exception:" + ex.Message);
137 | return false;
138 | }
139 | return true;
140 | }
141 |
142 | ///
143 | /// 将用户列表数据保存到文件
144 | ///
145 | /// 使用制表符分割的数据列表
146 | /// 能否成功写入数据
147 | public static bool WriteUserList(string content)
148 | {
149 | if (content.Trim().Length == 0) return false;
150 | try
151 | {
152 | StreamWriter sw = new StreamWriter(UserListPath(), false);
153 | sw.Write(content);
154 | sw.Close();
155 | return true;
156 | }
157 | catch (Exception ex)
158 | {
159 | Log.a("Write config Ex:" + ex.Message);
160 | return false;
161 | }
162 | }
163 |
164 | ///
165 | /// 读取配置文件,信息并创建默认信息
166 | ///
167 | private static void ReadConfig()
168 | {
169 | StreamReader sr = new StreamReader(ConfigPath);
170 | if (sr.BaseStream.Length > 100000)
171 | {
172 | sr.Close();
173 | WriteConfig();
174 | return;
175 | }
176 | string content = sr.ReadToEnd();
177 | string[] list = content.Split('\n');
178 | foreach (string str in list)
179 | {
180 | string[] t = str.Trim().Split('\t');
181 | if (t.Length == 2)
182 | {
183 | switch (t[0].Trim().ToLower())
184 | {
185 | case "serverip":
186 | _ServerIP = IPAddress.Parse(t[1].Trim());
187 | break;
188 | case "serverport":
189 | _ServerPort = int.Parse(t[1].Trim());
190 | break;
191 | case "fileip":
192 | _FileIP = IPAddress.Parse(t[1].Trim());
193 | break;
194 | case "fileport":
195 | _FilePort = int.Parse(t[1].Trim());
196 | break;
197 | case "rootpath":
198 | if (Directory.Exists(t[1].Trim()))
199 | {
200 | _RootPath = t[1].Trim();
201 | }
202 | break;
203 | case "logpath":
204 | if (new FileInfo(t[1].Trim()).Directory.Exists)
205 | {
206 | _LogPath = t[1].Trim();
207 | }
208 | break;
209 | case "screenshotpath":
210 | if (Directory.Exists(t[1].Trim()))
211 | {
212 | _ScreenshotPath = t[1].Trim();
213 | }
214 | break;
215 | }
216 | }
217 | }
218 | _UserListPath = RootPath() + "\\user.conf";
219 | Log.a("Config Prot:udp->" + _ServerPort + ",tcp->" + _FilePort);
220 | sr.Close();
221 | }
222 |
223 | ///
224 | /// 将默认数据写入配置文件
225 | ///
226 | private static void WriteConfig()
227 | {
228 | StreamWriter fs = new StreamWriter(ConfigPath);
229 | fs.WriteLine("ServerIP\t" + ServerIP());
230 | fs.WriteLine("ServerPort\t" + ServerPort());
231 | fs.WriteLine("FileIP\t" + FileIP());
232 | fs.WriteLine("FilePort\t" + FilePort());
233 | fs.WriteLine("RootPath\t" + RootPath());
234 | fs.WriteLine("LogPath\t" + LogPath());
235 | fs.WriteLine("ScreenshotPath\t" + ScreenshotPath());
236 | fs.Close();
237 | }
238 |
239 | ///
240 | /// 获取服务器UDP端口
241 | ///
242 | /// 指定或默认端口2001
243 | public static int ServerPort()
244 | {
245 | if (_ServerPort == 0)
246 | _ServerPort = 2001;
247 | return _ServerPort;
248 | }
249 |
250 | ///
251 | /// 文件传输TCP端口号
252 | ///
253 | /// 指定值或默认2002
254 | public static int FilePort()
255 | {
256 | if (_FilePort == 0)
257 | _FilePort = 2002;
258 | return _FilePort;
259 | }
260 |
261 | ///
262 | /// 返回服务器UDP监听IP
263 | ///
264 | /// 未指定则为默认Any
265 | public static IPAddress ServerIP()
266 | {
267 | if (_ServerIP == null)
268 | _ServerIP = IPAddress.Any;
269 | return _ServerIP;
270 | }
271 |
272 | ///
273 | /// 返回文件服务器TCP监听IP
274 | ///
275 | /// 未指定则为默认Any
276 | public static IPAddress FileIP()
277 | {
278 | if (_FileIP == null)
279 | _FileIP = IPAddress.Any;
280 | return _FileIP;
281 | }
282 |
283 | ///
284 | /// 获取运行更目录
285 | ///
286 | /// 默认为执行文件下的Remote
287 | public static string RootPath()
288 | {
289 | if (_RootPath == null)
290 | {
291 | _RootPath = RunPath + "\\Remote";
292 | if (Directory.Exists(_RootPath) == false)
293 | {
294 | Directory.CreateDirectory(_RootPath);
295 | }
296 | }
297 | return _RootPath;
298 | }
299 |
300 | ///
301 | /// 获取日志文件路径
302 | ///
303 | /// 默认为Root目录下run.log
304 | public static string LogPath()
305 | {
306 | if (_LogPath == null)
307 | {
308 | string dir = RunPath + "\\Remote";
309 | if (Directory.Exists(dir) == false)
310 | {
311 | Directory.CreateDirectory(dir);
312 | }
313 | _LogPath = dir + "\\run.log";
314 | }
315 | return _LogPath;
316 | }
317 |
318 | ///
319 | /// 获取截图文件保存路径
320 | ///
321 | /// 默认为Root目录下Screenshot
322 | public static string ScreenshotPath()
323 | {
324 | if (_ScreenshotPath == null)
325 | {
326 | _ScreenshotPath = RunPath + "\\Remote\\Screenshot";
327 | if (Directory.Exists(_ScreenshotPath) == false)
328 | {
329 | Directory.CreateDirectory(_ScreenshotPath);
330 | }
331 | }
332 | return _ScreenshotPath;
333 | }
334 |
335 | ///
336 | /// 获取用户列表路径
337 | ///
338 | /// 为Root下user.conf,无法修改
339 | public static string UserListPath()
340 | {
341 | if (_UserListPath == null)
342 | {
343 | _UserListPath = _RootPath + "\\user.conf";
344 | }
345 | return _UserListPath;
346 | }
347 |
348 | ///
349 | /// 生成的无窗口运行脚本路径
350 | ///
351 | /// 返回可执行文件后加.vbs的脚本路径
352 | public static string RunVbPath()
353 | {
354 | if (RunVb == null)
355 | {
356 | RunVb = RunFile + ".vbs";
357 | }
358 | return RunVb;
359 | }
360 |
361 | ///
362 | /// 获取可执行文件路径
363 | ///
364 | /// 返回路径
365 | public static string RunFilePath()
366 | {
367 | return RunFile;
368 | }
369 | }
370 | }
371 |
--------------------------------------------------------------------------------
/Server/FileControl.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.IO;
5 | using System.Net;
6 |
7 | namespace RemoteControlService
8 | {
9 | ///
10 | /// 远程文件控制类
11 | ///
12 | public class FileControl
13 | {
14 | ///
15 | /// 远程操作路径
16 | ///
17 | string path;
18 |
19 | ///
20 | /// 对应的命令参数
21 | ///
22 | string[] cmd;
23 |
24 | ///
25 | /// 首条命令
26 | ///
27 | string action = "";
28 |
29 | ///
30 | /// 错误信息
31 | ///
32 | string error = "";
33 |
34 | ///
35 | /// 用户IP路径
36 | ///
37 | private IPEndPoint e;
38 |
39 | ///
40 | /// 构造函数,创建一个新的对象
41 | ///
42 | /// 命令字符串
43 | /// ip地址路径
44 | public FileControl(string cmd, IPEndPoint e)
45 | {
46 | this.e = e;
47 | this.cmd = cmd.Split('\n');
48 | if (this.cmd.Length < 2)
49 | {
50 | error = "102 Invalid file manipulation commands";
51 | return;
52 | }
53 | this.action = this.cmd[0];
54 | this.path = this.cmd[1];
55 | }
56 |
57 | ///
58 | /// 回调函数,通过新的对象进行操作,返回对应byte数据进行返回
59 | ///
60 | /// 返回null表示一个错误,将对客户端返回错误消息
61 | public byte[] Callback()
62 | {
63 | try
64 | {
65 | if (error != "") return null;
66 | switch (action.ToUpper())
67 | {
68 | case "GET":
69 | if (path == "ROOT")
70 | {
71 | return GetRootFileList();
72 | }
73 | if (File.Exists(path))
74 | {
75 | return ReadFile(path);
76 | }
77 | if (Directory.Exists(path))
78 | {
79 | return ReadDirectory(path);
80 | }
81 | error = "101 File no found";
82 | return null;
83 | case "DELETE":
84 | return DeletePath();
85 | case "RENAME":
86 | return Rename();
87 | case "MKFILE":
88 | return MakeFile();
89 | case "MKDIR":
90 | return MakeDir();
91 | case "COPY":
92 | return Copy();
93 | }
94 | }
95 | catch (Exception ex)
96 | {
97 | Log.f("File Exception:" + ex.Message);
98 | }
99 | return null;
100 | }
101 |
102 | ///
103 | /// 获取错误消息
104 | ///
105 | /// 错误消息
106 | public string GetError()
107 | {
108 | return error;
109 | }
110 |
111 | ///
112 | /// 获取根目录的文件列表
113 | ///
114 | /// 读取到的所有盘符及盘符大小
115 | private byte[] GetRootFileList()
116 | {
117 | string rt = "DIR\tTYPE\tNAME\tDATE\tSIZE\tROOT\n";
118 | string tmp;
119 | DriveInfo[] drives = DriveInfo.GetDrives();
120 | foreach (DriveInfo info in drives)
121 | {
122 | try
123 | {
124 | tmp = "DIR\t" + info.Name + "\t0\t" + info.TotalSize + "\n";
125 |
126 | }
127 | catch
128 | {
129 | tmp = "DIR\t" + info.Name + "\t0\t0\n";
130 | }
131 | rt += tmp;
132 | }
133 | return SendMessage.ToBytes(rt);
134 | }
135 |
136 | ///
137 | /// 读取文件信息,且加入文件传输队列
138 | ///
139 | /// 要读取的文件路径
140 | /// 返回一个文件下载操作,null为错误
141 | private byte[] ReadFile(string path)
142 | {
143 | try
144 | {
145 | FileInfo fi = new FileInfo(path);
146 | long size = fi.Length;
147 | string fileid = FileSend.Get().AddFile(fi, User.GetSid(e));
148 | return SendMessage.ToBytes("FILE\t" + path + "\t" + size + "\t" + fileid);
149 | }
150 | catch
151 | {
152 | error = "File no found or read error";
153 | }
154 | return null;
155 | }
156 |
157 | ///
158 | /// 读取一个存在路径的文件夹列表信息
159 | ///
160 | /// 要读取的文件夹
161 | ///
162 | private byte[] ReadDirectory(string dir)
163 | {
164 | DirectoryInfo di = new DirectoryInfo(dir + "\\");
165 | string rt = "DIR\tTYPE\tNAME\tDATE\tSIZE\t" + dir + "\n";
166 | string tmp;
167 | try
168 | {
169 | foreach (DirectoryInfo fi in di.GetDirectories())
170 | {
171 | tmp = "DIR\t" + fi.FullName + "\t" + ConvertDateTimeInt(fi.LastWriteTime) + "\n";
172 | rt += tmp;
173 | }
174 | foreach (FileInfo fi in di.GetFiles())
175 | {
176 | tmp = "FILE\t" + fi.FullName + "\t" + ConvertDateTimeInt(fi.LastWriteTime) + "\t" + fi.Length + "\n";
177 | rt += tmp;
178 | }
179 | }
180 | catch
181 | {
182 | error = "Directory no found";
183 | }
184 | return SendMessage.ToBytes(rt);
185 | }
186 |
187 | ///
188 | /// 删除指定路径
189 | ///
190 | /// 删除路径的状态
191 | private byte[] DeletePath()
192 | {
193 | try
194 | {
195 | if (File.Exists(path))
196 | {
197 | File.Delete(path);
198 | return SendMessage.ToBytes("DELETE\tFILE\t" + path);
199 | }
200 | if (Directory.Exists(path))
201 | {
202 | if (cmd.Length > 2)
203 | {
204 | Directory.Delete(path, (cmd[2].ToLower() == "true") ? true : false);
205 | }
206 | else
207 | {
208 | Directory.Delete(path);
209 | }
210 | return SendMessage.ToBytes("DELETE\tDIR\t" + path);
211 | }
212 | error = "Path no found";
213 | return null;
214 | }
215 | catch
216 | {
217 | error = "Delete path error";
218 | return null;
219 | }
220 | }
221 |
222 | ///
223 | /// 对文件或文件夹进行重命名操作
224 | ///
225 | /// 返回操作的状态
226 | private byte[] Rename()
227 | {
228 | string src = path;
229 | if (cmd.Length < 3)
230 | {
231 | error = "Target file parameter does not exist";
232 | return null;
233 | }
234 | string dst = cmd[2];
235 | if (dst == "" || src == "")
236 | {
237 | error = "Parameter can not be null";
238 | return null;
239 | }
240 | if (Exists(dst))
241 | {
242 | error = "Rename the target already exists";
243 | return null;
244 | }
245 | if (File.Exists(src))
246 | {
247 | try
248 | {
249 | File.Move(src, dst);
250 | return SendMessage.ToBytes("RENAME\tFILE\t" + src + "\t" + dst);
251 | }
252 | catch
253 | {
254 | error = "File move error";
255 | return null;
256 | }
257 | }
258 | if (Directory.Exists(src))
259 | {
260 | try
261 | {
262 | Directory.Move(src, dst);
263 | return SendMessage.ToBytes("RENAME\tDIR\t" + src + "\t" + dst);
264 | }
265 | catch
266 | {
267 | error = "Directory move error";
268 | return null;
269 | }
270 | }
271 | return null;
272 | }
273 |
274 | ///
275 | /// 创建一个空的文件
276 | ///
277 | /// 返回状态信息
278 | private byte[] MakeFile()
279 | {
280 | if (Exists(path) == false)
281 | {
282 | try
283 | {
284 | File.Create(path).Close();
285 | return SendMessage.ToBytes("MKFILE\t" + path);
286 | }
287 | catch
288 | {
289 | error = "file carete error";
290 | return null;
291 | }
292 | }
293 | error = "file path is exists";
294 | return null;
295 | }
296 |
297 | ///
298 | /// 创建指定文件夹
299 | ///
300 | /// 返回状态信息
301 | private byte[] MakeDir()
302 | {
303 | if (Exists(path) == false)
304 | {
305 | try
306 | {
307 | Directory.CreateDirectory(path);
308 | return SendMessage.ToBytes("MKDIR\t" + path);
309 | }
310 | catch
311 | {
312 | error = "directrory create error";
313 | return null;
314 | }
315 | }
316 | error = "directory path is exists";
317 | return null;
318 | }
319 |
320 | ///
321 | /// 复制文件操作,如果是文件夹则操作失败
322 | ///
323 | /// 返回状态
324 | private byte[] Copy()
325 | {
326 | if (cmd.Length < 3)
327 | {
328 | error = "Copy destination parameter does not exist";
329 | return null;
330 | }
331 | string dst = cmd[2];
332 | if (Exists(dst))
333 | {
334 | error = "Target file already exists";
335 | return null;
336 | }
337 | try
338 | {
339 | if (File.Exists(path))
340 | {
341 | File.Copy(path, dst);
342 | return SendMessage.ToBytes("COPY\tFILE\t" + path + "\t" + dst);
343 | }
344 | if (Directory.Exists(path))
345 | {
346 | error = "Please copy the files using the command line";
347 | return null;
348 | }
349 | }
350 | catch
351 | {
352 | error = "Copy path error";
353 | return null;
354 | }
355 | error = "unknown file type can not copy";
356 | return null;
357 | }
358 |
359 | ///
360 | /// 存在性判断,不区分文件或文件夹
361 | ///
362 | /// 指定路径
363 | /// 任意存在则为真
364 | private bool Exists(string path)
365 | {
366 | return File.Exists(path) || Directory.Exists(path);
367 | }
368 |
369 | ///
370 | /// 将时间转换为时间戳
371 | ///
372 | /// 指定的时间
373 | /// 至1970年来的时间
374 | public static int ConvertDateTimeInt(System.DateTime time)
375 | {
376 | System.DateTime startTime = TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
377 | return (int)(time - startTime).TotalSeconds;
378 | }
379 | }
380 | }
381 |
--------------------------------------------------------------------------------
/Client/src/com/viewpagerindicator/TabPageIndicator.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright (C) 2011 The Android Open Source Project
3 | * Copyright (C) 2011 Jake Wharton
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package com.viewpagerindicator;
18 |
19 | import net.loveyu.remotecontrol.R;
20 | import android.content.Context;
21 | import android.support.v4.view.PagerAdapter;
22 | import android.support.v4.view.ViewPager;
23 | import android.support.v4.view.ViewPager.OnPageChangeListener;
24 | import android.util.AttributeSet;
25 | import android.view.View;
26 | import android.view.ViewGroup;
27 | import android.widget.HorizontalScrollView;
28 | import android.widget.LinearLayout;
29 | import android.widget.TextView;
30 |
31 | import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
32 | import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
33 |
34 | /**
35 | * This widget implements the dynamic action bar tab behavior that can change
36 | * across different configurations or circumstances.
37 | */
38 | public class TabPageIndicator extends HorizontalScrollView implements PageIndicator {
39 | /** Title text used when no title is provided by the adapter. */
40 | private static final CharSequence EMPTY_TITLE = "";
41 |
42 | /**
43 | * Interface for a callback when the selected tab has been reselected.
44 | */
45 | public interface OnTabReselectedListener {
46 | /**
47 | * Callback when the selected tab has been reselected.
48 | *
49 | * @param position Position of the current center item.
50 | */
51 | void onTabReselected(int position);
52 | }
53 |
54 | private Runnable mTabSelector;
55 |
56 | private final OnClickListener mTabClickListener = new OnClickListener() {
57 | public void onClick(View view) {
58 | TabView tabView = (TabView)view;
59 | final int oldSelected = mViewPager.getCurrentItem();
60 | final int newSelected = tabView.getIndex();
61 | mViewPager.setCurrentItem(newSelected);
62 | if (oldSelected == newSelected && mTabReselectedListener != null) {
63 | mTabReselectedListener.onTabReselected(newSelected);
64 | }
65 | }
66 | };
67 |
68 | private final IcsLinearLayout mTabLayout;
69 |
70 | private ViewPager mViewPager;
71 | private ViewPager.OnPageChangeListener mListener;
72 |
73 | private int mMaxTabWidth;
74 | private int mSelectedTabIndex;
75 |
76 | private OnTabReselectedListener mTabReselectedListener;
77 |
78 | public TabPageIndicator(Context context) {
79 | this(context, null);
80 | }
81 |
82 | public TabPageIndicator(Context context, AttributeSet attrs) {
83 | super(context, attrs);
84 | setHorizontalScrollBarEnabled(false);
85 |
86 | mTabLayout = new IcsLinearLayout(context, R.attr.vpiTabPageIndicatorStyle);
87 | addView(mTabLayout, new ViewGroup.LayoutParams(WRAP_CONTENT, MATCH_PARENT));
88 | }
89 |
90 | public void setOnTabReselectedListener(OnTabReselectedListener listener) {
91 | mTabReselectedListener = listener;
92 | }
93 |
94 | @Override
95 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
96 | final int widthMode = MeasureSpec.getMode(widthMeasureSpec);
97 | final boolean lockedExpanded = widthMode == MeasureSpec.EXACTLY;
98 | setFillViewport(lockedExpanded);
99 |
100 | final int childCount = mTabLayout.getChildCount();
101 | if (childCount > 1 && (widthMode == MeasureSpec.EXACTLY || widthMode == MeasureSpec.AT_MOST)) {
102 | if (childCount > 2) {
103 | mMaxTabWidth = (int)(MeasureSpec.getSize(widthMeasureSpec) * 0.4f);
104 | } else {
105 | mMaxTabWidth = MeasureSpec.getSize(widthMeasureSpec) / 2;
106 | }
107 | } else {
108 | mMaxTabWidth = -1;
109 | }
110 |
111 | final int oldWidth = getMeasuredWidth();
112 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
113 | final int newWidth = getMeasuredWidth();
114 |
115 | if (lockedExpanded && oldWidth != newWidth) {
116 | // Recenter the tab display if we're at a new (scrollable) size.
117 | setCurrentItem(mSelectedTabIndex);
118 | }
119 | }
120 |
121 | private void animateToTab(final int position) {
122 | final View tabView = mTabLayout.getChildAt(position);
123 | if (mTabSelector != null) {
124 | removeCallbacks(mTabSelector);
125 | }
126 | mTabSelector = new Runnable() {
127 | public void run() {
128 | final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2;
129 | smoothScrollTo(scrollPos, 0);
130 | mTabSelector = null;
131 | }
132 | };
133 | post(mTabSelector);
134 | }
135 |
136 | @Override
137 | public void onAttachedToWindow() {
138 | super.onAttachedToWindow();
139 | if (mTabSelector != null) {
140 | // Re-post the selector we saved
141 | post(mTabSelector);
142 | }
143 | }
144 |
145 | @Override
146 | public void onDetachedFromWindow() {
147 | super.onDetachedFromWindow();
148 | if (mTabSelector != null) {
149 | removeCallbacks(mTabSelector);
150 | }
151 | }
152 |
153 | private void addTab(int index, CharSequence text, int iconResId) {
154 | final TabView tabView = new TabView(getContext());
155 | tabView.mIndex = index;
156 | tabView.setFocusable(true);
157 | tabView.setOnClickListener(mTabClickListener);
158 | tabView.setText(text);
159 |
160 | if (iconResId != 0) {
161 | tabView.setCompoundDrawablesWithIntrinsicBounds(iconResId, 0, 0, 0);
162 | }
163 |
164 | mTabLayout.addView(tabView, new LinearLayout.LayoutParams(0, MATCH_PARENT, 1));
165 | }
166 |
167 | @Override
168 | public void onPageScrollStateChanged(int arg0) {
169 | if (mListener != null) {
170 | mListener.onPageScrollStateChanged(arg0);
171 | }
172 | }
173 |
174 | @Override
175 | public void onPageScrolled(int arg0, float arg1, int arg2) {
176 | if (mListener != null) {
177 | mListener.onPageScrolled(arg0, arg1, arg2);
178 | }
179 | }
180 |
181 | @Override
182 | public void onPageSelected(int arg0) {
183 | setCurrentItem(arg0);
184 | if (mListener != null) {
185 | mListener.onPageSelected(arg0);
186 | }
187 | }
188 |
189 | @Override
190 | public void setViewPager(ViewPager view) {
191 | if (mViewPager == view) {
192 | return;
193 | }
194 | if (mViewPager != null) {
195 | mViewPager.setOnPageChangeListener(null);
196 | }
197 | final PagerAdapter adapter = view.getAdapter();
198 | if (adapter == null) {
199 | throw new IllegalStateException("ViewPager does not have adapter instance.");
200 | }
201 | mViewPager = view;
202 | view.setOnPageChangeListener(this);
203 | notifyDataSetChanged();
204 | }
205 |
206 | public void notifyDataSetChanged() {
207 | mTabLayout.removeAllViews();
208 | PagerAdapter adapter = mViewPager.getAdapter();
209 | IconPagerAdapter iconAdapter = null;
210 | if (adapter instanceof IconPagerAdapter) {
211 | iconAdapter = (IconPagerAdapter)adapter;
212 | }
213 | final int count = adapter.getCount();
214 | for (int i = 0; i < count; i++) {
215 | CharSequence title = adapter.getPageTitle(i);
216 | if (title == null) {
217 | title = EMPTY_TITLE;
218 | }
219 | int iconResId = 0;
220 | if (iconAdapter != null) {
221 | iconResId = iconAdapter.getIconResId(i);
222 | }
223 | addTab(i, title, iconResId);
224 | }
225 | if (mSelectedTabIndex > count) {
226 | mSelectedTabIndex = count - 1;
227 | }
228 | setCurrentItem(mSelectedTabIndex);
229 | requestLayout();
230 | }
231 |
232 | @Override
233 | public void setViewPager(ViewPager view, int initialPosition) {
234 | setViewPager(view);
235 | setCurrentItem(initialPosition);
236 | }
237 |
238 | @Override
239 | public void setCurrentItem(int item) {
240 | if (mViewPager == null) {
241 | throw new IllegalStateException("ViewPager has not been bound.");
242 | }
243 | mSelectedTabIndex = item;
244 | mViewPager.setCurrentItem(item);
245 |
246 | final int tabCount = mTabLayout.getChildCount();
247 | for (int i = 0; i < tabCount; i++) {
248 | final View child = mTabLayout.getChildAt(i);
249 | final boolean isSelected = (i == item);
250 | child.setSelected(isSelected);
251 | if (isSelected) {
252 | animateToTab(item);
253 | }
254 | }
255 | }
256 |
257 | @Override
258 | public void setOnPageChangeListener(OnPageChangeListener listener) {
259 | mListener = listener;
260 | }
261 |
262 | private class TabView extends TextView {
263 | private int mIndex;
264 |
265 | public TabView(Context context) {
266 | super(context, null, R.attr.vpiTabPageIndicatorStyle);
267 | }
268 |
269 | @Override
270 | public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
271 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
272 |
273 | // Re-measure if we went beyond our maximum size.
274 | if (mMaxTabWidth > 0 && getMeasuredWidth() > mMaxTabWidth) {
275 | super.onMeasure(MeasureSpec.makeMeasureSpec(mMaxTabWidth, MeasureSpec.EXACTLY),
276 | heightMeasureSpec);
277 | }
278 | }
279 |
280 | public int getIndex() {
281 | return mIndex;
282 | }
283 | }
284 | }
285 |
--------------------------------------------------------------------------------
/Test/UdpMessageTest.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace UdpMessageTest
2 | {
3 | partial class UdpMessageTest
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.textBox_ip = new System.Windows.Forms.TextBox();
32 | this.label_ip = new System.Windows.Forms.Label();
33 | this.textBox_port = new System.Windows.Forms.TextBox();
34 | this.label1 = new System.Windows.Forms.Label();
35 | this.button_connect = new System.Windows.Forms.Button();
36 | this.panel1 = new System.Windows.Forms.Panel();
37 | this.button_login = new System.Windows.Forms.Button();
38 | this.button_clearReceived = new System.Windows.Forms.Button();
39 | this.comboBox = new System.Windows.Forms.ComboBox();
40 | this.button_send = new System.Windows.Forms.Button();
41 | this.button_close = new System.Windows.Forms.Button();
42 | this.splitContainer = new System.Windows.Forms.SplitContainer();
43 | this.richTextBox_Send = new System.Windows.Forms.RichTextBox();
44 | this.richTextBox_received = new System.Windows.Forms.RichTextBox();
45 | this.panel1.SuspendLayout();
46 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
47 | this.splitContainer.Panel1.SuspendLayout();
48 | this.splitContainer.Panel2.SuspendLayout();
49 | this.splitContainer.SuspendLayout();
50 | this.SuspendLayout();
51 | //
52 | // textBox_ip
53 | //
54 | this.textBox_ip.Location = new System.Drawing.Point(41, 12);
55 | this.textBox_ip.Name = "textBox_ip";
56 | this.textBox_ip.Size = new System.Drawing.Size(88, 21);
57 | this.textBox_ip.TabIndex = 0;
58 | this.textBox_ip.Text = "127.0.0.1";
59 | //
60 | // label_ip
61 | //
62 | this.label_ip.AutoSize = true;
63 | this.label_ip.Location = new System.Drawing.Point(12, 15);
64 | this.label_ip.Name = "label_ip";
65 | this.label_ip.Size = new System.Drawing.Size(23, 12);
66 | this.label_ip.TabIndex = 1;
67 | this.label_ip.Text = "IP:";
68 | //
69 | // textBox_port
70 | //
71 | this.textBox_port.Location = new System.Drawing.Point(184, 12);
72 | this.textBox_port.Name = "textBox_port";
73 | this.textBox_port.Size = new System.Drawing.Size(62, 21);
74 | this.textBox_port.TabIndex = 0;
75 | this.textBox_port.Text = "2001";
76 | //
77 | // label1
78 | //
79 | this.label1.AutoSize = true;
80 | this.label1.Location = new System.Drawing.Point(143, 15);
81 | this.label1.Name = "label1";
82 | this.label1.Size = new System.Drawing.Size(35, 12);
83 | this.label1.TabIndex = 1;
84 | this.label1.Text = "Port:";
85 | //
86 | // button_connect
87 | //
88 | this.button_connect.Location = new System.Drawing.Point(252, 12);
89 | this.button_connect.Name = "button_connect";
90 | this.button_connect.Size = new System.Drawing.Size(75, 23);
91 | this.button_connect.TabIndex = 2;
92 | this.button_connect.Text = "连接";
93 | this.button_connect.UseVisualStyleBackColor = true;
94 | this.button_connect.Click += new System.EventHandler(this.button_connect_Click);
95 | //
96 | // panel1
97 | //
98 | this.panel1.Controls.Add(this.button_login);
99 | this.panel1.Controls.Add(this.button_clearReceived);
100 | this.panel1.Controls.Add(this.comboBox);
101 | this.panel1.Controls.Add(this.button_send);
102 | this.panel1.Controls.Add(this.button_close);
103 | this.panel1.Controls.Add(this.button_connect);
104 | this.panel1.Controls.Add(this.label1);
105 | this.panel1.Controls.Add(this.textBox_port);
106 | this.panel1.Controls.Add(this.label_ip);
107 | this.panel1.Controls.Add(this.textBox_ip);
108 | this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
109 | this.panel1.Location = new System.Drawing.Point(0, 0);
110 | this.panel1.Name = "panel1";
111 | this.panel1.Size = new System.Drawing.Size(776, 41);
112 | this.panel1.TabIndex = 0;
113 | //
114 | // button_login
115 | //
116 | this.button_login.Location = new System.Drawing.Point(689, 12);
117 | this.button_login.Name = "button_login";
118 | this.button_login.Size = new System.Drawing.Size(75, 23);
119 | this.button_login.TabIndex = 6;
120 | this.button_login.Text = "登录";
121 | this.button_login.UseVisualStyleBackColor = true;
122 | this.button_login.Click += new System.EventHandler(this.button_login_Click);
123 | //
124 | // button_clearReceived
125 | //
126 | this.button_clearReceived.Location = new System.Drawing.Point(414, 12);
127 | this.button_clearReceived.Name = "button_clearReceived";
128 | this.button_clearReceived.Size = new System.Drawing.Size(63, 23);
129 | this.button_clearReceived.TabIndex = 5;
130 | this.button_clearReceived.Text = "清空";
131 | this.button_clearReceived.UseVisualStyleBackColor = true;
132 | this.button_clearReceived.Click += new System.EventHandler(this.button_clearReceived_Click);
133 | //
134 | // comboBox
135 | //
136 | this.comboBox.FormattingEnabled = true;
137 | this.comboBox.Items.AddRange(new object[] {
138 | "01",
139 | "02",
140 | "03",
141 | "04",
142 | "05",
143 | "06",
144 | "07",
145 | "08",
146 | "09",
147 | "10",
148 | "11",
149 | "12",
150 | "13"});
151 | this.comboBox.Location = new System.Drawing.Point(483, 14);
152 | this.comboBox.Name = "comboBox";
153 | this.comboBox.Size = new System.Drawing.Size(121, 20);
154 | this.comboBox.TabIndex = 4;
155 | this.comboBox.Text = "08";
156 | //
157 | // button_send
158 | //
159 | this.button_send.Enabled = false;
160 | this.button_send.Location = new System.Drawing.Point(610, 12);
161 | this.button_send.Name = "button_send";
162 | this.button_send.Size = new System.Drawing.Size(75, 23);
163 | this.button_send.TabIndex = 3;
164 | this.button_send.Text = "发送";
165 | this.button_send.UseVisualStyleBackColor = true;
166 | this.button_send.Click += new System.EventHandler(this.button_send_Click);
167 | //
168 | // button_close
169 | //
170 | this.button_close.Enabled = false;
171 | this.button_close.Location = new System.Drawing.Point(333, 12);
172 | this.button_close.Name = "button_close";
173 | this.button_close.Size = new System.Drawing.Size(75, 23);
174 | this.button_close.TabIndex = 3;
175 | this.button_close.Text = "断开";
176 | this.button_close.UseVisualStyleBackColor = true;
177 | this.button_close.Click += new System.EventHandler(this.button_close_Click);
178 | //
179 | // splitContainer
180 | //
181 | this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
182 | this.splitContainer.Location = new System.Drawing.Point(0, 41);
183 | this.splitContainer.Name = "splitContainer";
184 | this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
185 | //
186 | // splitContainer.Panel1
187 | //
188 | this.splitContainer.Panel1.Controls.Add(this.richTextBox_Send);
189 | //
190 | // splitContainer.Panel2
191 | //
192 | this.splitContainer.Panel2.Controls.Add(this.richTextBox_received);
193 | this.splitContainer.Size = new System.Drawing.Size(776, 479);
194 | this.splitContainer.SplitterDistance = 100;
195 | this.splitContainer.TabIndex = 1;
196 | //
197 | // richTextBox_Send
198 | //
199 | this.richTextBox_Send.BorderStyle = System.Windows.Forms.BorderStyle.None;
200 | this.richTextBox_Send.Dock = System.Windows.Forms.DockStyle.Fill;
201 | this.richTextBox_Send.Location = new System.Drawing.Point(0, 0);
202 | this.richTextBox_Send.Name = "richTextBox_Send";
203 | this.richTextBox_Send.Size = new System.Drawing.Size(776, 100);
204 | this.richTextBox_Send.TabIndex = 0;
205 | this.richTextBox_Send.Text = "";
206 | //
207 | // richTextBox_received
208 | //
209 | this.richTextBox_received.BorderStyle = System.Windows.Forms.BorderStyle.None;
210 | this.richTextBox_received.Dock = System.Windows.Forms.DockStyle.Fill;
211 | this.richTextBox_received.Location = new System.Drawing.Point(0, 0);
212 | this.richTextBox_received.Name = "richTextBox_received";
213 | this.richTextBox_received.Size = new System.Drawing.Size(776, 375);
214 | this.richTextBox_received.TabIndex = 0;
215 | this.richTextBox_received.Text = "";
216 | //
217 | // UdpMessageTest
218 | //
219 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
220 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
221 | this.ClientSize = new System.Drawing.Size(776, 520);
222 | this.Controls.Add(this.splitContainer);
223 | this.Controls.Add(this.panel1);
224 | this.Name = "UdpMessageTest";
225 | this.Text = "UDP消息测试";
226 | this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.UdpMessageTest_FormClosing);
227 | this.panel1.ResumeLayout(false);
228 | this.panel1.PerformLayout();
229 | this.splitContainer.Panel1.ResumeLayout(false);
230 | this.splitContainer.Panel2.ResumeLayout(false);
231 | ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
232 | this.splitContainer.ResumeLayout(false);
233 | this.ResumeLayout(false);
234 |
235 | }
236 |
237 | #endregion
238 |
239 | private System.Windows.Forms.TextBox textBox_ip;
240 | private System.Windows.Forms.Label label_ip;
241 | private System.Windows.Forms.TextBox textBox_port;
242 | private System.Windows.Forms.Label label1;
243 | private System.Windows.Forms.Button button_connect;
244 | private System.Windows.Forms.Panel panel1;
245 | private System.Windows.Forms.SplitContainer splitContainer;
246 | private System.Windows.Forms.RichTextBox richTextBox_received;
247 | private System.Windows.Forms.RichTextBox richTextBox_Send;
248 | private System.Windows.Forms.Button button_send;
249 | private System.Windows.Forms.Button button_close;
250 | private System.Windows.Forms.ComboBox comboBox;
251 | private System.Windows.Forms.Button button_clearReceived;
252 | private System.Windows.Forms.Button button_login;
253 |
254 | }
255 | }
256 |
257 |
--------------------------------------------------------------------------------