├── .gitattributes
├── .gitignore
├── LICENSE
├── Pictures
├── 20180521165256.png
├── 20180521165319.png
├── 20180521165413.png
└── 20180521165433.png
├── README.md
├── ezAria2.sln
├── ezAria2
├── About.xaml
├── About.xaml.cs
├── AddTask.xaml
├── AddTask.xaml.cs
├── App.config
├── App.xaml
├── App.xaml.cs
├── Controllers
│ ├── Charts.cs
│ ├── ConfigInfo.cs
│ ├── Methods.cs
│ ├── ProgressController.cs
│ ├── Statics.cs
│ └── Tasks.cs
├── MainIcon.ico
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── DataSources
│ │ ├── App.datasource
│ │ ├── ConfigControler.datasource
│ │ ├── MainWindow.datasource
│ │ ├── Settings.datasource
│ │ ├── TaskManager.datasource
│ │ ├── ezAria2.Properties.Resources.datasource
│ │ └── ezAria2.Properties.Settings.datasource
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Resources
│ ├── Download.ico
│ ├── bonfire-1849089_640.png
│ ├── cbuod-gwj75-004.ico
│ ├── cloud-2044797_640.png
│ ├── cloud-2044820_640.png
│ ├── cloud-2044822_640.png
│ ├── cup-1849083_640.png
│ ├── edit-1103599_640.png
│ ├── gear-1077550_640.png
│ ├── icon40
│ │ ├── Download.png
│ │ ├── New Copy.png
│ │ ├── bt.png
│ │ ├── cancel.png
│ │ ├── cancel_1.png
│ │ ├── link.png
│ │ ├── start.png
│ │ ├── web.png
│ │ └── 空投.png
│ ├── icon70
│ │ ├── Download.png
│ │ ├── New Copy.png
│ │ ├── bt.png
│ │ ├── cancel.png
│ │ ├── cancel_1.png
│ │ ├── link.png
│ │ ├── start.png
│ │ ├── web.png
│ │ └── 空投.png
│ ├── logo.png
│ ├── logo2.png
│ ├── play-1073616_640.png
│ ├── setting2.png
│ ├── stopwatch-1849088_640.png
│ └── store-1103556_640.png
├── Settings.xaml
├── Settings.xaml.cs
├── Simple Styles.xaml
├── TaskManager.xaml
├── TaskManager.xaml.cs
├── aria2c.exe
├── ezAria2.csproj
├── ezAria2.xml
├── json.conf
└── packages.config
└── toolkit
├── Arthas
├── Arthas.csproj
├── Arthas.snk
├── Controls
│ ├── Converter
│ │ ├── CornerRadiusToDouble.cs
│ │ ├── DoubleFactor.cs
│ │ ├── DoubleToCornerRadius.cs
│ │ ├── DoubleToThickness.cs
│ │ └── StringToVisibility.cs
│ ├── Metro
│ │ ├── MetroBorder.cs
│ │ ├── MetroButton.cs
│ │ ├── MetroCanvasGrid.cs
│ │ ├── MetroColorPicker.xaml
│ │ ├── MetroColorPicker.xaml.cs
│ │ ├── MetroComboBox.cs
│ │ ├── MetroComboBoxItem.cs
│ │ ├── MetroContextMenu.cs
│ │ ├── MetroExpander.cs
│ │ ├── MetroFocusButton.cs
│ │ ├── MetroGroupBox.cs
│ │ ├── MetroImage.cs
│ │ ├── MetroMenuItem.cs
│ │ ├── MetroMenuSeparator.cs
│ │ ├── MetroMenuTabControl.cs
│ │ ├── MetroMenuTabItem.cs
│ │ ├── MetroPath.cs
│ │ ├── MetroProgressBar.cs
│ │ ├── MetroRichTextBox.cs
│ │ ├── MetroScrollViewer.cs
│ │ ├── MetroSwitch.cs
│ │ ├── MetroTabControl.cs
│ │ ├── MetroTabItem.cs
│ │ ├── MetroTextBlock.cs
│ │ ├── MetroTextBox.cs
│ │ ├── MetroTextButton.cs
│ │ ├── MetroThumb.cs
│ │ ├── MetroTitleMenu.cs
│ │ ├── MetroTitleMenuItem.cs
│ │ ├── MetroVisualElement.cs
│ │ ├── MetroWaterfallFlow.cs
│ │ ├── MetroWebBrowser.xaml
│ │ ├── MetroWebBrowser.xaml.cs
│ │ └── MetroWindow.cs
│ └── Utility.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── Resources
│ ├── Icon.png
│ └── Thumbs.db
├── Themes
│ ├── Generic.xaml
│ ├── Metro
│ │ ├── Metro.xaml
│ │ ├── MetroBase.xaml
│ │ ├── MetroButton.xaml
│ │ ├── MetroCanvasGrid.xaml
│ │ ├── MetroComboBox.xaml
│ │ ├── MetroComboBoxItem.xaml
│ │ ├── MetroContextMenu.xaml
│ │ ├── MetroExpander.xaml
│ │ ├── MetroFocusButton.xaml
│ │ ├── MetroGroupBox.xaml
│ │ ├── MetroImage.xaml
│ │ ├── MetroMenuItem.xaml
│ │ ├── MetroMenuSeparator.xaml
│ │ ├── MetroMenuTabControl.xaml
│ │ ├── MetroMenuTabItem.xaml
│ │ ├── MetroPath.xaml
│ │ ├── MetroProgressBar.xaml
│ │ ├── MetroRichTextBox.xaml
│ │ ├── MetroScrollViewer.xaml
│ │ ├── MetroSwitch.xaml
│ │ ├── MetroTabControl.xaml
│ │ ├── MetroTabItem.xaml
│ │ ├── MetroTextBlock.xaml
│ │ ├── MetroTextBox.xaml
│ │ ├── MetroTextButton.xaml
│ │ ├── MetroTitleMenu.xaml
│ │ ├── MetroTitleMenuItem.xaml
│ │ ├── MetroVisualElement.xaml
│ │ ├── MetroWaterfallFlow.xaml
│ │ ├── MetroWindow.xaml
│ │ └── MetroWindow.xaml.cs
│ └── Theme.cs
└── Utility
│ ├── Computer
│ ├── Screen.cs
│ └── TaskBarPostion.cs
│ ├── Element
│ ├── ElementBase.cs
│ └── VisualObj.cs
│ └── Media
│ ├── HsbaColor.cs
│ ├── ResObj.cs
│ ├── RgbaColor.cs
│ ├── StreamObj.cs
│ └── Utility.cs
├── FlyingAria2c
├── Aria2Lib
│ ├── Aria2cMethords.cs
│ ├── Aria2cProgressHandle.cs
│ ├── File.cs
│ └── JsonRpcConnection.cs
├── DownloadTask.cs
├── Downloader.cs
├── FlyingAria2c.csproj
├── Properties
│ └── AssemblyInfo.cs
├── aria2c.exe
└── packages.config
└── websocket-sharp
├── AssemblyInfo.cs
├── ByteOrder.cs
├── CloseEventArgs.cs
├── CloseStatusCode.cs
├── CompressionMethod.cs
├── ErrorEventArgs.cs
├── Ext.cs
├── Fin.cs
├── HttpBase.cs
├── HttpRequest.cs
├── HttpResponse.cs
├── LogData.cs
├── LogLevel.cs
├── Logger.cs
├── Mask.cs
├── MessageEventArgs.cs
├── Net
├── AuthenticationBase.cs
├── AuthenticationChallenge.cs
├── AuthenticationResponse.cs
├── AuthenticationSchemes.cs
├── Chunk.cs
├── ChunkStream.cs
├── ChunkedRequestStream.cs
├── ClientSslConfiguration.cs
├── Cookie.cs
├── CookieCollection.cs
├── CookieException.cs
├── EndPointListener.cs
├── EndPointManager.cs
├── HttpBasicIdentity.cs
├── HttpConnection.cs
├── HttpDigestIdentity.cs
├── HttpHeaderInfo.cs
├── HttpHeaderType.cs
├── HttpListener.cs
├── HttpListenerAsyncResult.cs
├── HttpListenerContext.cs
├── HttpListenerException.cs
├── HttpListenerPrefix.cs
├── HttpListenerPrefixCollection.cs
├── HttpListenerRequest.cs
├── HttpListenerResponse.cs
├── HttpRequestHeader.cs
├── HttpResponseHeader.cs
├── HttpStatusCode.cs
├── HttpStreamAsyncResult.cs
├── HttpUtility.cs
├── HttpVersion.cs
├── InputChunkState.cs
├── InputState.cs
├── LineState.cs
├── NetworkCredential.cs
├── QueryStringCollection.cs
├── ReadBufferState.cs
├── RequestStream.cs
├── ResponseStream.cs
├── ServerSslConfiguration.cs
├── WebHeaderCollection.cs
└── WebSockets
│ ├── HttpListenerWebSocketContext.cs
│ ├── TcpListenerWebSocketContext.cs
│ └── WebSocketContext.cs
├── Opcode.cs
├── PayloadData.cs
├── Rsv.cs
├── Server
├── HttpRequestEventArgs.cs
├── HttpServer.cs
├── IWebSocketSession.cs
├── ServerState.cs
├── WebSocketBehavior.cs
├── WebSocketServer.cs
├── WebSocketServiceHost.cs
├── WebSocketServiceHost`1.cs
├── WebSocketServiceManager.cs
└── WebSocketSessionManager.cs
├── WebSocket.cs
├── WebSocketException.cs
├── WebSocketFrame.cs
├── WebSocketState.cs
├── doc
├── .gitignore
└── doc.sh
├── websocket-sharp.csproj
└── websocket-sharp.snk
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/Pictures/20180521165256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/Pictures/20180521165256.png
--------------------------------------------------------------------------------
/Pictures/20180521165319.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/Pictures/20180521165319.png
--------------------------------------------------------------------------------
/Pictures/20180521165413.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/Pictures/20180521165413.png
--------------------------------------------------------------------------------
/Pictures/20180521165433.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/Pictures/20180521165433.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ezAria2
2 | 一个ARIA2的windows GUI项目,完全基于.net,而非web ui加壳。
3 |
4 | ## 项目截图
5 |
6 | 
7 |
8 | 
9 |
10 | 
11 |
12 | 
13 |
14 | ## 开发进度
15 | * 180519 完成设置页面的设计和变量绑定
16 | * 180607 完善设置页面逻辑
17 | * 180723 修复了remove()方法的逻辑错误,修复了一部分令人智熄的bug,添加速度曲线图
18 |
19 | ## 已知问题
20 | * 已完成列表中的文件图标,透明背景会变成黑色。
21 | * 如果一个磁力任务当前没有速度,则无法正确暂停
22 |
23 | ## 预期功能
24 |
25 | 1. 使用GUI实现aria2的所有命令
26 | 2. 完成对aria2 Notice的解析
27 | 3. 自动转换来自其他下载工具的专用链接,如果支持则自动下载
28 |
29 | ## 许可和引用
30 |
31 | * 依照GPL V2许可发布
32 | * [Arthas的WPF开源控件类库](https://github.com/1217950746/Arthas-WPFUI)MIT许可
33 | * [Websocket-Sharp](https://github.com/sta/websocket-sharp)MIT许可
34 | * [KnownFolders](https://github.com/Syroot/KnownFolders)MIT许可
35 | * [DMSkin.WPF控件库](https://github.com/944095635/DMSkin-for-WPF)MIT许可
36 | * [Notifications土司通知](https://github.com/Federerer/Notifications.Wpf)MIT许可
37 | * [Live-Charts一个很棒的动态图表控件库](https://github.com/Live-Charts/Live-Charts)MIT许可
38 |
--------------------------------------------------------------------------------
/ezAria2/About.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/ezAria2/About.xaml.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Controls.Metro;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using System.Windows;
8 | using System.Windows.Controls;
9 | using System.Windows.Data;
10 | using System.Windows.Documents;
11 | using System.Windows.Input;
12 | using System.Windows.Media;
13 | using System.Windows.Media.Imaging;
14 | using System.Windows.Shapes;
15 |
16 | namespace ezAria2
17 | {
18 | ///
19 | /// About.xaml 的交互逻辑
20 | ///
21 | public partial class About : MetroWindow
22 | {
23 | public About()
24 | {
25 | InitializeComponent();
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/ezAria2/AddTask.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/ezAria2/AddTask.xaml.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Controls.Metro;
2 | using Microsoft.Win32;
3 | using System;
4 | using System.Threading.Tasks;
5 | using System.Windows;
6 |
7 |
8 | namespace ezAria2
9 | {
10 | ///
11 | /// AddTask.xaml 的交互逻辑
12 | ///
13 | public partial class AddTask : MetroWindow
14 | {
15 | public AddTask()
16 | {
17 | InitializeComponent();
18 | }
19 |
20 | private void MetroTextBox_GotFocus(object sender, RoutedEventArgs e)
21 | {
22 | if(UriBox.Text== "请输入链接地址,每行一个独立的下载任务")
23 | {
24 | UriBox.Text = "";
25 | BT.IsEnabled = false;
26 | MT.IsEnabled = false;
27 | }
28 | }
29 |
30 | private void MetroButton_Click_Add(object sender, RoutedEventArgs e)
31 | {
32 | Add();
33 | Close();
34 | }
35 |
36 | private void MetroButton_Click_Cancle(object sender, RoutedEventArgs e)
37 | {
38 | Close();
39 | }
40 | private async void Add()
41 | {
42 | string[] DownloadUris = UriBox.Text.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
43 | foreach (string uri in DownloadUris)
44 | {
45 | await Aria2Methords.AddUri(uri);
46 | }
47 | }
48 |
49 | private void MenuItem_Click(object sender, RoutedEventArgs e)
50 | {
51 | IDataObject iData = Clipboard.GetDataObject();
52 | if (iData.GetDataPresent(DataFormats.Text))
53 | {
54 | UriBox.Text = (string)iData.GetData(DataFormats.Text)+Environment.NewLine;
55 | UriBox.Select(UriBox.Text.Length, 0);
56 | }
57 | }
58 |
59 | private async void BT_Click(object sender, RoutedEventArgs e)
60 | {
61 | OpenFileDialog openFileDialog = new OpenFileDialog()
62 | {
63 | Filter = "BT下载的种子文件 (*.torrent)|*.torrent"
64 | };
65 | var result = openFileDialog.ShowDialog();
66 | if (result == true)
67 | {
68 | await Aria2Methords.AddTorrent(openFileDialog.FileName);
69 | Close();
70 | }
71 | }
72 |
73 | private async void MT_Click(object sender, RoutedEventArgs e)
74 | {
75 | OpenFileDialog openFileDialog = new OpenFileDialog()
76 | {
77 | Filter = "MetaLink文件 (*.metalink)|*.metalink"
78 | };
79 | var result = openFileDialog.ShowDialog();
80 | if (result == true)
81 | {
82 | await Aria2Methords.AddMetalink(openFileDialog.FileName);
83 | Close();
84 | }
85 | }
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/ezAria2/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/ezAria2/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/ezAria2/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Diagnostics;
2 | using System.Reflection;
3 | using System.Threading;
4 | using System.Windows;
5 |
6 | namespace ezAria2
7 | {
8 | ///
9 | /// App.xaml 的交互逻辑
10 | ///
11 | public partial class App : Application
12 | {
13 | static Mutex mutex;
14 | public App()
15 | {
16 | mutex = new Mutex(true, "ezAria2 GUI",out bool IsSuccessful);
17 | if (!IsSuccessful)
18 | {
19 | mutex.Close();
20 | var instance = RunningInstance();
21 | //将实例放置到前台
22 | //HandleRunningInstance(instance);
23 | Shutdown();
24 | }
25 | }
26 |
27 | public static Process RunningInstance()
28 | {
29 | Process current = Process.GetCurrentProcess();
30 | Process[] processes = Process.GetProcessesByName(current.ProcessName);
31 | //Loop through the running processes in with the same name
32 | foreach (Process process in processes)
33 | {
34 | //Ignore the current process
35 | if (process.Id != current.Id)
36 | {
37 | //Make sure that the process is running from the exe file.
38 | if (Assembly.GetExecutingAssembly().Location.Replace("/", @"\") == current.MainModule.FileName)
39 | {
40 | //Return the other process instance.
41 | return process;
42 | }
43 | }
44 | }
45 | //No other instance was found, return null.
46 | return null;
47 | }
48 |
49 | //public static void HandleRunningInstance(Process instance)
50 | //{
51 | // ShowWindowAsync(instance.MainWindowHandle, WS_SHOWNORMAL); //显示,可以注释掉
52 | // SetForegroundWindow(instance.MainWindowHandle); //放到前端
53 | //}
54 |
55 | //[DllImport("User32.dll")]
56 | //private static extern bool ShowWindowAsync(IntPtr hWnd, int cmdShow);
57 |
58 | //[DllImport("User32.dll")]
59 | //internal static extern bool SetForegroundWindow(IntPtr hWnd);
60 | //private const int WS_SHOWNORMAL = 1;
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ezAria2/Controllers/ProgressController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using System.Windows.Forms;
4 |
5 | namespace ezAria2
6 | {
7 | public class ProgressController//这个类控制托盘按钮
8 | {
9 | private NotifyIcon NotifyIcon;
10 | private void InitialTray()
11 | {
12 | //菜单项在这里
13 | ContextMenu ContextMenu = new ContextMenu();
14 | //ContextMenu.MenuItems.Add(new MenuItem("粘贴"));
15 | //ContextMenu.MenuItems.Add(new MenuItem("粘贴"));
16 | ContextMenu.MenuItems.Add(new MenuItem("退出", new EventHandler(Quit)));
17 | //设置托盘的各个属性
18 | NotifyIcon = new NotifyIcon
19 | {
20 | BalloonTipText = "服务运行中...",//托盘气泡显示内容
21 | BalloonTipTitle = "ezAria2",
22 | Text = "ezAria2",
23 | Visible = true,//托盘按钮是否可见
24 | Icon = Properties.Resources.Download
25 | //SystemIcons.Question,//托盘中显示的图标
26 | };
27 | NotifyIcon.ShowBalloonTip(500);//托盘气泡显示时间
28 | NotifyIcon.MouseDoubleClick += NotifyIcon_MouseDoubleClick;
29 | NotifyIcon.ContextMenu = ContextMenu;
30 | NotifyIcon.DoubleClick += new EventHandler(ShowMainWindow);
31 | }
32 |
33 | private void ShowMainWindow(object sender, EventArgs e)
34 | {
35 | var MainWindow = System.Windows.Application.Current.MainWindow;
36 | if (MainWindow==null)
37 | {
38 | MainWindow = new MainWindow();
39 | MainWindow.Show();
40 | }
41 | else
42 | {
43 | //如果MainWindow存在,则将其置顶
44 | }
45 | }
46 |
47 | private void Quit(object sender, EventArgs e)
48 | {
49 | System.Windows.Application.Current.Shutdown();
50 | }
51 |
52 | private void NotifyIcon_MouseDoubleClick(object sender, MouseEventArgs e)
53 | {
54 | MainWindow MainWindow = (MainWindow)System.Windows.Application.Current.MainWindow;
55 | if (MainWindow==null)
56 | {
57 | MainWindow = new MainWindow();
58 | MainWindow.Show();
59 | }
60 |
61 | }
62 | public ProgressController()
63 | {
64 | InitialTray();
65 | }
66 | public void Dispose()
67 | {
68 | NotifyIcon.Dispose();
69 | }
70 | ~ProgressController()
71 | {
72 | Dispose();
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/ezAria2/Controllers/Statics.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.IO;
4 | using System.Windows;
5 | using System.Windows.Threading;
6 |
7 | namespace ezAria2
8 | {
9 | ///
10 | /// 保存所有的全局资源
11 | ///
12 | public static class Stc
13 | {
14 | private static Process Aria2Process;//aria2c的进程
15 |
16 | ///
17 | /// 与Aria2C进程的连接,协议是WebSocket
18 | ///
19 | public static JRCtler Line;
20 | ///
21 | /// Make给aria2c.exe的配置文件
22 | ///
23 | public static ConfigInformation GloConf;
24 | ///
25 | /// 系统托盘的图标
26 | ///
27 | public static ProgressController ProCtl;
28 | ///
29 | /// 一个Timer,每秒触发一次
30 | ///
31 | //public static DispatcherTimer dispatcherTimer = new DispatcherTimer();
32 | ///
33 | /// ezAria2 GUI的配置文件
34 | ///
35 | public static ApplicationConfig Config=new ApplicationConfig();
36 |
37 | private static void Quit(object sender, ExitEventArgs e)//程序关闭事件
38 | {
39 | ProCtl.Dispose();
40 | Aria2Methords.ShutDown();
41 | }
42 |
43 | private static void Crash(object sender, DispatcherUnhandledExceptionEventArgs e)//程序崩溃事件
44 | {
45 | Aria2Process.Kill();
46 | ProCtl.Dispose();
47 | }
48 |
49 | static Stc()
50 | {
51 | ConfigController Start = new ConfigController();
52 | //判断几个关键的文件和路径是否存在
53 | if (!File.Exists(Start.Configs.Save_session))
54 | {
55 | File.Create(Start.Configs.Save_session).Close();
56 | }
57 | if (!File.Exists(Start.Configs.Input_file))
58 | {
59 | File.Create(Start.Configs.Input_file).Close();
60 | }
61 | if (!Directory.Exists(Start.Configs.Dir))
62 | {
63 | Directory.CreateDirectory(Start.Configs.Dir);
64 | }
65 | //if (!File.Exists(@"HistoryList.log"))
66 | //{
67 | // File.Create(@"HistoryList.log").Close();
68 | //}
69 | Start.Make();
70 | Aria2Process = new Process();
71 | Aria2Process.StartInfo.FileName = Config.Aria2cPath;
72 | Aria2Process.StartInfo.CreateNoWindow = true;
73 | Aria2Process.StartInfo.Arguments = @"--conf-path="+ Config.Aria2cConfigPath;
74 | Aria2Process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
75 | Aria2Process.Start();
76 | GloConf = Start.Configs;//给全局配置变量赋值,同时初始化所有其他全局变量
77 | Config.WebSocketPath = string.Format("ws://127.0.0.1:{0}/jsonrpc", GloConf.Rpc_listen_port);
78 | Config.Rpc_secret = GloConf.Rpc_secret;
79 | Line = new JRCtler(Config.WebSocketPath);//这里的逻辑重新梳理后,可以允许ezAria2作为客户端,控制其他主机的下载服务
80 | ProCtl = new ProgressController();
81 | Application.Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
82 | Application.Current.Exit += new ExitEventHandler(Quit);
83 | Application.Current.DispatcherUnhandledException += new DispatcherUnhandledExceptionEventHandler(Crash);
84 | //dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
85 | //dispatcherTimer.Start();
86 | }
87 | }
88 |
89 | }
90 |
--------------------------------------------------------------------------------
/ezAria2/MainIcon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/MainIcon.ico
--------------------------------------------------------------------------------
/ezAria2/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Controls.Metro;
2 | using System;
3 | using System.Windows;
4 | using System.Windows.Threading;
5 |
6 | namespace ezAria2
7 | {
8 | ///
9 | /// MainWindow.xaml 的交互逻辑
10 | ///
11 | public partial class MainWindow : MetroWindow
12 | {
13 | private DispatcherTimer dispatcherTimer = new DispatcherTimer();
14 |
15 | ///
16 | /// 正在进行的任务列表
17 | ///
18 | public static TaskList TaskData = new TaskList();
19 | ///
20 | /// 已完成任务列表
21 | ///
22 | public static HistoryList HistoryData = new HistoryList();
23 |
24 | public MainWindow()
25 | {
26 | InitializeComponent();
27 | dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
28 | dispatcherTimer.Start();
29 | dispatcherTimer.Tick += new EventHandler(ListRefresh);
30 | TaskData.TaskFinished += HistoryData.TaskCompleted;
31 | TasksInProgress.ItemsSource = TaskData;
32 | FinishedList.ItemsSource = HistoryData;
33 | Informations.DataContext = Stc.Config;
34 | }
35 |
36 | private void SettingButton_Click(object sender, RoutedEventArgs e)
37 | {
38 | Settings set = new Settings();
39 | set.Show();
40 |
41 | }
42 |
43 | private async void ListRefresh(object sender, EventArgs e)
44 | {
45 | dispatcherTimer.Tick -= new EventHandler(ListRefresh);
46 | try
47 | {
48 | await TaskData.Update();
49 | }
50 | finally
51 | {
52 | dispatcherTimer.Tick += new EventHandler(ListRefresh);
53 | }
54 | }
55 |
56 |
57 | private void MetroTitleMenuItem_Click(object sender, RoutedEventArgs e)
58 | {
59 | Application.Current.Shutdown();
60 | }
61 |
62 | private async void MetroBorder_MouseLeftButtonUp(object sender, RoutedEventArgs e)
63 | {
64 | if (TasksInProgress.SelectedItem != null)
65 | {
66 | await ((TaskLite)TasksInProgress.SelectedItem).Remove();
67 | }
68 | }
69 |
70 | private void MetroBorder_MouseLeftButtonUp_NewTask(object sender, RoutedEventArgs e)
71 | {
72 | AddTask Task = new AddTask();
73 | Task.Show();
74 | }
75 |
76 | private void MetroBorder_MouseLeftButtonUp_StateChange(object sender, RoutedEventArgs e)
77 | {
78 | if(TasksInProgress.SelectedItem!=null)
79 | {
80 | ((TaskLite)TasksInProgress.SelectedItem).StateChangeFunction();
81 | }
82 | }
83 |
84 | private void Button_Click(object sender, RoutedEventArgs e)
85 | {
86 | AddTask Task = new AddTask();
87 | Task.Show();
88 | }
89 |
90 | private void AboutButton_Click(object sender, RoutedEventArgs e)
91 | {
92 | About about = new About();
93 | about.Show();
94 | }
95 |
96 | private void Test_Click(object sender, RoutedEventArgs e)
97 | {
98 | if(TasksInProgress.SelectedItem!=null)
99 | {
100 | TaskManager TaskManager = new TaskManager((TaskLite)TasksInProgress.SelectedItem);
101 | TaskManager.Show();
102 | }
103 | }
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/ezAria2/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // 有关程序集的一般信息由以下
8 | // 控制。更改这些特性值可修改
9 | // 与程序集关联的信息。
10 | [assembly: AssemblyTitle("ezAria2")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("ezAria2")]
15 | [assembly: AssemblyCopyright("Copyright © 2018")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // 将 ComVisible 设置为 false 会使此程序集中的类型
20 | //对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
21 | //请将此类型的 ComVisible 特性设置为 true。
22 | [assembly: ComVisible(false)]
23 |
24 | //若要开始生成可本地化的应用程序,请设置
25 | //.csproj 文件中的 CultureYouAreCodingWith
26 | //例如,如果您在源文件中使用的是美国英语,
27 | //使用的是美国英语,请将 设置为 en-US。 然后取消
28 | //对以下 NeutralResourceLanguage 特性的注释。 更新
29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置
36 | //(未在页面中找到资源时使用,
37 | //或应用程序资源字典中找到时使用)
38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
39 | //(未在页面中找到资源时使用,
40 | //、应用程序或任何主题专用资源字典中找到时使用)
41 | )]
42 |
43 |
44 | // 程序集的版本信息由下列四个值组成:
45 | //
46 | // 主版本
47 | // 次版本
48 | // 生成号
49 | // 修订号
50 | //
51 | // 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
52 | // 方法是按如下所示使用“*”: :
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/ezAria2/Properties/DataSources/App.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | ezAria2.App, ezAria2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/ezAria2/Properties/DataSources/ConfigControler.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | ezAria2.ConfigControler, ezAria2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/ezAria2/Properties/DataSources/MainWindow.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | ezAria2.MainWindow, ezAria2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/ezAria2/Properties/DataSources/Settings.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | ezAria2.Settings, ezAria2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/ezAria2/Properties/DataSources/TaskManager.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | ezAria2.TaskManager, ezAria2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/ezAria2/Properties/DataSources/ezAria2.Properties.Resources.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | ezAria2.Properties.Resources, Properties.Resources.Designer.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/ezAria2/Properties/DataSources/ezAria2.Properties.Settings.datasource:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 | ezAria2.Properties.Settings, Properties.Resources.Designer.cs.dll, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
10 |
--------------------------------------------------------------------------------
/ezAria2/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ezAria2.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ezAria2.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 使用此强类型资源类,为所有资源查找
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
65 | ///
66 | internal static System.Drawing.Icon cbuod_gwj75_004 {
67 | get {
68 | object obj = ResourceManager.GetObject("cbuod_gwj75_004", resourceCulture);
69 | return ((System.Drawing.Icon)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// 查找类似于 (图标) 的 System.Drawing.Icon 类型的本地化资源。
75 | ///
76 | internal static System.Drawing.Icon Download {
77 | get {
78 | object obj = ResourceManager.GetObject("Download", resourceCulture);
79 | return ((System.Drawing.Icon)(obj));
80 | }
81 | }
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/ezAria2/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace ezAria2.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/ezAria2/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/ezAria2/Resources/Download.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/Download.ico
--------------------------------------------------------------------------------
/ezAria2/Resources/bonfire-1849089_640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/bonfire-1849089_640.png
--------------------------------------------------------------------------------
/ezAria2/Resources/cbuod-gwj75-004.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/cbuod-gwj75-004.ico
--------------------------------------------------------------------------------
/ezAria2/Resources/cloud-2044797_640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/cloud-2044797_640.png
--------------------------------------------------------------------------------
/ezAria2/Resources/cloud-2044820_640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/cloud-2044820_640.png
--------------------------------------------------------------------------------
/ezAria2/Resources/cloud-2044822_640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/cloud-2044822_640.png
--------------------------------------------------------------------------------
/ezAria2/Resources/cup-1849083_640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/cup-1849083_640.png
--------------------------------------------------------------------------------
/ezAria2/Resources/edit-1103599_640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/edit-1103599_640.png
--------------------------------------------------------------------------------
/ezAria2/Resources/gear-1077550_640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/gear-1077550_640.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon40/Download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon40/Download.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon40/New Copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon40/New Copy.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon40/bt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon40/bt.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon40/cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon40/cancel.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon40/cancel_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon40/cancel_1.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon40/link.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon40/link.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon40/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon40/start.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon40/web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon40/web.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon40/空投.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon40/空投.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon70/Download.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon70/Download.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon70/New Copy.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon70/New Copy.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon70/bt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon70/bt.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon70/cancel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon70/cancel.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon70/cancel_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon70/cancel_1.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon70/link.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon70/link.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon70/start.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon70/start.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon70/web.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon70/web.png
--------------------------------------------------------------------------------
/ezAria2/Resources/icon70/空投.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/icon70/空投.png
--------------------------------------------------------------------------------
/ezAria2/Resources/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/logo.png
--------------------------------------------------------------------------------
/ezAria2/Resources/logo2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/logo2.png
--------------------------------------------------------------------------------
/ezAria2/Resources/play-1073616_640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/play-1073616_640.png
--------------------------------------------------------------------------------
/ezAria2/Resources/setting2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/setting2.png
--------------------------------------------------------------------------------
/ezAria2/Resources/stopwatch-1849088_640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/stopwatch-1849088_640.png
--------------------------------------------------------------------------------
/ezAria2/Resources/store-1103556_640.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/Resources/store-1103556_640.png
--------------------------------------------------------------------------------
/ezAria2/Settings.xaml.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Controls.Metro;
2 | using Arthas.Utility.Media;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Globalization;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using System.Windows;
10 | using System.Windows.Controls;
11 | using System.Windows.Data;
12 | using System.Windows.Documents;
13 | using System.Windows.Forms;
14 | using System.Windows.Input;
15 | using System.Windows.Media;
16 | using System.Windows.Media.Imaging;
17 | using System.Windows.Shapes;
18 |
19 | namespace ezAria2
20 | {
21 | ///
22 | /// Settings.xaml 的交互逻辑
23 | ///
24 | public partial class Settings : MetroWindow
25 | {
26 |
27 | private ConfigInformation Conf =new ConfigInformation();
28 |
29 | private FolderBrowserDialog folderBrowserDialog=new FolderBrowserDialog();
30 |
31 | public Settings()
32 | {
33 | Conf = Stc.GloConf.Copy();
34 | InitializeComponent();
35 | DataContext = Conf;
36 | }
37 |
38 | ///
39 | /// 依照目前的代码,任何设置均将在下次启动时生效。即时更新的机制有待补充
40 | ///
41 | ///
42 | ///
43 | private void Enter_Click(object sender, RoutedEventArgs e)
44 | {
45 | Stc.GloConf = Conf;
46 | ConfigController Save = new ConfigController(Conf);
47 | Save.SavingConfigFile();
48 | Close();
49 | }
50 |
51 | private void Cancel_Click(object sender, RoutedEventArgs e)
52 | {
53 | Close();
54 | }
55 |
56 | private void FolderBrowserDialogButton_Click(object sender, RoutedEventArgs e)
57 | {
58 | folderBrowserDialog.ShowDialog();
59 | Conf.Dir = folderBrowserDialog.SelectedPath;
60 | }
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/ezAria2/TaskManager.xaml.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Controls.Metro;
2 | using System.Threading.Tasks;
3 |
4 | namespace ezAria2
5 | {
6 | ///
7 | /// TaskManager.xaml 的交互逻辑
8 | ///
9 | public partial class TaskManager : MetroWindow
10 | {
11 | ///
12 | /// View Model
13 | ///
14 | private SpeedChart MainChart { get; set; }
15 |
16 | private TaskInformation MainInformation { get; set; }
17 |
18 | public TaskManager(TaskLite e)
19 | {
20 | InitializeComponent();
21 | MainChart = new SpeedChart();
22 | Chart.DataContext = MainChart;
23 | MainInformation = new TaskInformation(e);
24 | Lists.DataContext = MainInformation;
25 | StartSpeedUpdate();
26 | FilesListBox.ItemsSource = MainInformation.FilesList;
27 | PeersListBox.ItemsSource = MainInformation.Peers;
28 | }
29 |
30 | private async Task SpeedUpdate()
31 | {
32 | MainChart.Add(await MainInformation.GetSpeed());
33 | System.Threading.Thread.Sleep(1000);
34 | }
35 |
36 | private async void StartSpeedUpdate()
37 | {
38 | await Task.Run( async () =>
39 | {
40 | while (true)
41 | {
42 | await SpeedUpdate();
43 | }
44 | });
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/ezAria2/aria2c.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/ezAria2/aria2c.exe
--------------------------------------------------------------------------------
/ezAria2/ezAria2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | {"dir":"downloads","disk_cache":"32M","file_allocation":"falloc","continue":"true","max_concurrent_downloads":"5","max_connection_per_server":"5","min_split_size":"10M","split":"5","max_overall_download_limit":"0","max_download_limit":"0","max_overall_upload_limit":"0","max_upload_limit":"0","disable_ipv6":"true","timeout":"60","max_tries":"5","retry_wait":"0","input_file":"aria2.session","save_session":"aria2.session","save_session_interval":"60","enable_rpc":"true","rpc_allow_origin_all":"true","rpc_listen_all":"true","event_poll":"select","rpc_listen_port":"6800","rpc_secret":"ZBkouKMFgjLNHCow","follow_torrent":"true","listen_port":"51413","bt_max_peers":"55","enable_dht":"false","enable_dht6":"false","dht_listen_port":"6881-6999","bt_enable_lpd":"false","enable_peer_exchange":"false","bt_request_peer_speed_limit":"50K","peer_id_prefix":"_TR2770_","user_agent":"Transmission/2.77","seed_ratio":"0","force_save":"false","bt_hash_check_seed":"true","bt_seed_unverified":"true","bt_save_metadata":"true"}
5 |
6 |
7 |
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ezAria2/json.conf:
--------------------------------------------------------------------------------
1 | {"dir":"","disk_cache":"32M","file_allocation":"falloc","continue":"true","max_concurrent_downloads":"5","max_connection_per_server":"5","min_split_size":"10M","split":"5","max_overall_download_limit":"0","max_download_limit":"0","max_overall_upload_limit":"0","max_upload_limit":"0","disable_ipv6":"true","timeout":"60","max_tries":"5","retry_wait":"0","input_file":"aria2.session","save_session":"aria2.session","save_session_interval":"60","enable_rpc":"true","rpc_allow_origin_all":"true","rpc_listen_all":"true","event_poll":"select","rpc_listen_port":"6800","rpc_secret":"","follow_torrent":"true","listen_port":"51413","bt_max_peers":"55","enable_dht":"false","enable_dht6":"false","dht_listen_port":"6881-6999","bt_enable_lpd":"false","enable_peer_exchange":"false","bt_request_peer_speed_limit":"50K","peer_id_prefix":"_TR2770_","user_agent":"Transmission/2.77","seed_ratio":"0","force_save":"false","bt_hash_check_seed":"true","bt_seed_unverified":"true","bt_save_metadata":"true"}
--------------------------------------------------------------------------------
/ezAria2/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Arthas.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/toolkit/Arthas/Arthas.snk
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Converter/CornerRadiusToDouble.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace Arthas.Controls.Converter
7 | {
8 | public class CornerRadiusToDouble : IValueConverter
9 | {
10 | public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
11 | {
12 | if (parameter != null)
13 | {
14 | return ((CornerRadius)value).TopLeft * System.Convert.ToDouble(parameter);
15 | }
16 | return ((CornerRadius)value).TopLeft;
17 | }
18 |
19 | public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
20 | {
21 | if (parameter != null)
22 | {
23 | return new CornerRadius((double)value/ System.Convert.ToDouble(parameter));
24 | }
25 | return new CornerRadius((double)value);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Converter/DoubleFactor.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows.Data;
4 |
5 | namespace Arthas.Controls.Converter
6 | {
7 | public class DoubleFactor : IValueConverter
8 | {
9 | public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
10 | {
11 | if (value == null)
12 | {
13 | return 0.0;
14 | }
15 | else if (parameter == null)
16 | {
17 | return System.Convert.ToDouble(value);
18 | }
19 | else
20 | {
21 | return System.Convert.ToDouble(value) * System.Convert.ToDouble(parameter);
22 | }
23 | }
24 |
25 | public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
26 | {
27 | if (value == null)
28 | {
29 | return 0.0;
30 | }
31 | else if (parameter == null)
32 | {
33 | return System.Convert.ToDouble(value);
34 | }
35 | else
36 | {
37 | return System.Convert.ToDouble(value) / System.Convert.ToDouble(parameter);
38 | }
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Converter/DoubleToCornerRadius.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace Arthas.Controls.Converter
7 | {
8 | public class DoubleToCornerRadius : IValueConverter
9 | {
10 | public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
11 | {
12 | if (parameter != null)
13 | {
14 | return new CornerRadius((double)value / System.Convert.ToDouble(parameter));
15 | }
16 | return new CornerRadius((double)value);
17 | }
18 |
19 | public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
20 | {
21 | if (parameter != null)
22 | {
23 | return ((CornerRadius)value).TopLeft * System.Convert.ToDouble(parameter);
24 | }
25 | return ((CornerRadius)value).TopLeft;
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Converter/DoubleToThickness.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Globalization;
4 | using System.Windows;
5 | using System.Windows.Data;
6 |
7 | namespace Arthas.Controls.Converter
8 | {
9 | public class DoubleToThickness : IValueConverter
10 | {
11 | public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
12 | {
13 | if (value != null)
14 | {
15 | if (parameter != null)
16 | {
17 | switch (parameter.ToString())
18 | {
19 | case "Left":
20 | return new Thickness(System.Convert.ToDouble(value), 0, 0, 0);
21 | case "Top":
22 | return new Thickness(0, System.Convert.ToDouble(value), 0, 0);
23 | case "Right":
24 | return new Thickness(0, 0, System.Convert.ToDouble(value), 0);
25 | case "Buttom":
26 | return new Thickness(0, 0, 0, System.Convert.ToDouble(value));
27 | case "LeftTop":
28 | return new Thickness(System.Convert.ToDouble(value), System.Convert.ToDouble(value), 0, 0);
29 | case "LeftButtom":
30 | return new Thickness(System.Convert.ToDouble(value), 0, 0, System.Convert.ToDouble(value));
31 | case "RightTop":
32 | return new Thickness(0, System.Convert.ToDouble(value), System.Convert.ToDouble(value), 0);
33 | case "RigthButtom":
34 | return new Thickness(0, 0, System.Convert.ToDouble(value), System.Convert.ToDouble(value));
35 | case "LeftRight":
36 | return new Thickness(System.Convert.ToDouble(value), 0, System.Convert.ToDouble(value), 0);
37 | case "TopButtom":
38 | return new Thickness(0, System.Convert.ToDouble(value), 0, System.Convert.ToDouble(value));
39 | default:
40 | return new Thickness(System.Convert.ToDouble(value));
41 | }
42 | }
43 | return new Thickness(System.Convert.ToDouble(value));
44 | }
45 | return new Thickness(0);
46 | }
47 |
48 | public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
49 | {
50 | if (value != null)
51 | {
52 | if (parameter != null)
53 | {
54 | switch (parameter.ToString())
55 | {
56 | case "Left":
57 | return ((Thickness)value).Left;
58 | case "Top":
59 | return ((Thickness)value).Top;
60 | case "Right":
61 | return ((Thickness)value).Right;
62 | case "Buttom":
63 | return ((Thickness)value).Bottom;
64 | default:
65 | return ((Thickness)value).Left;
66 | }
67 | }
68 | return ((Thickness)value).Left;
69 | }
70 | return 0.0;
71 | }
72 | }
73 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Converter/StringToVisibility.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Globalization;
3 | using System.Windows;
4 | using System.Windows.Data;
5 |
6 | namespace Arthas.Controls.Converter
7 | {
8 | public class StringToVisibility : IValueConverter
9 | {
10 | public object Convert(object value, System.Type targetType, object parameter, CultureInfo culture)
11 | {
12 | return value == null || value.ToString() == "" ? Visibility.Hidden : Visibility.Visible;
13 | }
14 |
15 | public object ConvertBack(object value, System.Type targetType, object parameter, CultureInfo culture)
16 | {
17 | return value;
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroBorder.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 |
5 | namespace Arthas.Controls.Metro
6 | {
7 | public class MetroBorder : Border
8 | {
9 | public static readonly DependencyProperty AutoCornerRadiusProperty = ElementBase.Property(nameof(AutoCornerRadiusProperty));
10 | public bool AutoCornerRadius { get { return (bool)GetValue(AutoCornerRadiusProperty); } set { SetValue(AutoCornerRadiusProperty, value); } }
11 | public MetroBorder()
12 | {
13 | Loaded += delegate { SizeChang(); };
14 | SizeChanged += delegate { SizeChang(); };
15 | }
16 |
17 | void SizeChang()
18 | {
19 | if (AutoCornerRadius)
20 | {
21 | if (IsLoaded)
22 | {
23 | CornerRadius = new CornerRadius(ActualWidth >= ActualHeight ? ActualHeight / 2 : ActualWidth / 2);
24 | }
25 | }
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroButton.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Controls.Primitives;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public enum ButtonState
9 | {
10 | None,
11 | Red,
12 | Green
13 | }
14 |
15 | public class MetroButton : Button
16 | {
17 | public static readonly DependencyProperty MetroButtonStateProperty = ElementBase.Property(nameof(MetroButtonStateProperty), ButtonState.None);
18 |
19 | public ButtonState MetroButtonState { get { return (ButtonState)GetValue(MetroButtonStateProperty); } set { SetValue(MetroButtonStateProperty, value); } }
20 |
21 | public MetroButton()
22 | {
23 | Utility.Refresh(this);
24 | }
25 |
26 | static MetroButton()
27 | {
28 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroCanvasGrid.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 |
5 | namespace Arthas.Controls.Metro
6 | {
7 | public class MetroCanvasGrid : ContentControl
8 | {
9 | public static readonly DependencyProperty ViewportProperty = ElementBase.Property(nameof(ViewportProperty));
10 | public Rect Viewport { get { return (Rect)GetValue(ViewportProperty); } set { SetValue(ViewportProperty, value); } }
11 |
12 | public static readonly DependencyProperty GridOpacityProperty = ElementBase.Property(nameof(GridOpacityProperty));
13 | public static readonly DependencyProperty GridSizeProperty = ElementBase.Property(nameof(GridSizeProperty));
14 | public static readonly DependencyProperty CornerRadiusProperty = ElementBase.Property(nameof(CornerRadiusProperty));
15 |
16 | public double GridOpacity { get { return (double)GetValue(GridOpacityProperty); } set { SetValue(GridOpacityProperty, value); } }
17 | public CornerRadius CornerRadius { get { return (CornerRadius)GetValue(CornerRadiusProperty); } set { SetValue(CornerRadiusProperty, value); } }
18 |
19 | public bool IsApplyTheme { get; set; } = true;
20 |
21 | public MetroCanvasGrid()
22 | {
23 | Utility.Refresh(this);
24 | }
25 |
26 | static MetroCanvasGrid()
27 | {
28 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroComboBox.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public class MetroComboBox : ComboBox
9 | {
10 | public static readonly DependencyProperty TitleProperty = ElementBase.Property(nameof(TitleProperty), "");
11 | public static readonly DependencyProperty IconProperty = ElementBase.Property(nameof(IconProperty), null);
12 |
13 | public string Title { get { return (string)GetValue(TitleProperty); } set { SetValue(TitleProperty, value); } }
14 | public ImageSource Icon { get { return (ImageSource)GetValue(IconProperty); } set { SetValue(IconProperty, value); } }
15 |
16 | public MetroComboBox()
17 | {
18 | Utility.Refresh(this);
19 | }
20 |
21 | static MetroComboBox()
22 | {
23 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroComboBoxItem.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows.Controls;
3 |
4 | namespace Arthas.Controls.Metro
5 | {
6 | public class MetroComboBoxItem : ComboBoxItem
7 | {
8 | public MetroComboBoxItem()
9 | {
10 | Utility.Refresh(this);
11 | }
12 |
13 | static MetroComboBoxItem()
14 | {
15 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroContextMenu.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows.Controls;
3 |
4 | namespace Arthas.Controls.Metro
5 | {
6 | public class MetroContextMenu : ContextMenu
7 | {
8 | public MetroContextMenu()
9 | {
10 | Utility.Refresh(this);
11 | }
12 |
13 | static MetroContextMenu()
14 | {
15 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroFocusButton.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public class MetroFocusButton : Button
9 | {
10 | public static readonly DependencyProperty MouseMoveForegroundProperty = ElementBase.Property(nameof(MouseMoveForegroundProperty));
11 | public static readonly DependencyProperty MouseMoveBorderBrushProperty = ElementBase.Property(nameof(MouseMoveBorderBrushProperty));
12 | public static readonly new DependencyProperty BorderThicknessProperty = ElementBase.Property(nameof(BorderThicknessProperty));
13 | public static readonly DependencyProperty MouseMoveBorderThicknessProperty = ElementBase.Property(nameof(MouseMoveBorderThicknessProperty));
14 | public static readonly DependencyProperty StrokeDashArrayProperty = ElementBase.Property(nameof(StrokeDashArrayProperty));
15 | public static readonly DependencyProperty MouseMoveStrokeDashArrayProperty = ElementBase.Property(nameof(MouseMoveStrokeDashArrayProperty));
16 | public static readonly DependencyProperty CornerRadiusProperty = ElementBase.Property(nameof(CornerRadiusProperty));
17 |
18 | public Brush MouseMoveForeground { get { return (Brush)GetValue(MouseMoveForegroundProperty); } set { SetValue(MouseMoveForegroundProperty, value); } }
19 | public Brush MouseMoveBorderBrush { get { return (Brush)GetValue(MouseMoveBorderBrushProperty); } set { SetValue(MouseMoveBorderBrushProperty, value); } }
20 | public new double BorderThickness { get { return (double)GetValue(BorderThicknessProperty); } set { SetValue(BorderThicknessProperty, value); } }
21 | public double MouseMoveBorderThickness { get { return (double)GetValue(MouseMoveBorderThicknessProperty); } set { SetValue(MouseMoveBorderThicknessProperty, value); } }
22 | public DoubleCollection StrokeDashArray { get { return (DoubleCollection)GetValue(StrokeDashArrayProperty); } set { SetValue(StrokeDashArrayProperty, value); } }
23 | public DoubleCollection MouseMoveStrokeDashArray { get { return (DoubleCollection)GetValue(MouseMoveStrokeDashArrayProperty); } set { SetValue(MouseMoveStrokeDashArrayProperty, value); } }
24 | public double CornerRadius { get { return (double)GetValue(CornerRadiusProperty); } set { SetValue(CornerRadiusProperty, value); } }
25 |
26 | static MetroFocusButton()
27 | {
28 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroGroupBox.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows.Controls;
3 |
4 | namespace Arthas.Controls.Metro
5 | {
6 | public class MetroGroupBox : GroupBox
7 | {
8 | static MetroGroupBox()
9 | {
10 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroImage.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using Arthas.Utility.Media;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Media;
6 |
7 | namespace Arthas.Controls.Metro
8 | {
9 | public class MetroImage : ContentControl
10 | {
11 | public static readonly DependencyProperty SourceProperty = ElementBase.Property(nameof(SourceProperty));
12 | public static readonly DependencyProperty StretchProperty = ElementBase.Property(nameof(StretchProperty));
13 | public static readonly DependencyProperty StretchDirectionProperty = ElementBase.Property(nameof(StretchDirectionProperty));
14 | public static readonly DependencyProperty ImageWidthProperty = ElementBase.Property(nameof(ImageWidthProperty));
15 | public static readonly DependencyProperty ImageHeightProperty = ElementBase.Property(nameof(ImageHeightProperty));
16 | public static readonly DependencyProperty ImageVerticalAlignmentProperty = ElementBase.Property(nameof(ImageVerticalAlignmentProperty));
17 | public static readonly DependencyProperty ImageHorizontalAlignmentProperty = ElementBase.Property(nameof(ImageHorizontalAlignmentProperty));
18 |
19 | public ImageSource Source { get { return (ImageSource)GetValue(SourceProperty); } set { SetValue(SourceProperty, value); } }
20 | public Stretch Stretch { get { return (Stretch)GetValue(StretchProperty); } set { SetValue(StretchProperty, value); } }
21 | public StretchDirection StretchDirection { get { return (StretchDirection)GetValue(StretchDirectionProperty); } set { SetValue(StretchDirectionProperty, value); } }
22 | public double ImageWidth { get { return (double)GetValue(ImageWidthProperty); } set { SetValue(ImageWidthProperty, value); } }
23 | public double ImageHeight { get { return (double)GetValue(ImageHeightProperty); } set { SetValue(ImageHeightProperty, value); } }
24 | public VerticalAlignment ImageVerticalAlignment { get { return (VerticalAlignment)GetValue(ImageVerticalAlignmentProperty); } set { SetValue(ImageVerticalAlignmentProperty, value); } }
25 | public HorizontalAlignment ImageHorizontalAlignment { get { return (HorizontalAlignment)GetValue(ImageHorizontalAlignmentProperty); } set { SetValue(ImageHorizontalAlignmentProperty, value); } }
26 |
27 | static MetroImage()
28 | {
29 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
30 | }
31 |
32 | public MetroImage()
33 | {
34 |
35 | }
36 |
37 | public MetroImage(ImageSource image)
38 | {
39 | Source = image;
40 | }
41 |
42 |
43 | }
44 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroMenuItem.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public class MetroMenuItem : MenuItem
9 | {
10 | public static readonly new DependencyProperty IconProperty = ElementBase.Property(nameof(IconProperty), null);
11 |
12 | public new ImageSource Icon { get { return (ImageSource)GetValue(IconProperty); } set { SetValue(IconProperty, value); } }
13 |
14 | public MetroMenuItem()
15 | {
16 | Utility.Refresh(this);
17 | }
18 |
19 | static MetroMenuItem()
20 | {
21 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroMenuSeparator.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows.Controls;
3 |
4 | namespace Arthas.Controls.Metro
5 | {
6 | public class MetroMenuSeparator : Separator
7 | {
8 | static MetroMenuSeparator()
9 | {
10 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroMenuTabControl.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Diagnostics;
3 | using System.Windows;
4 | using System.Windows.Controls;
5 | using System.Windows.Input;
6 |
7 | namespace Arthas.Controls.Metro
8 | {
9 | public class MetroMenuTabControl : TabControl
10 | {
11 | public static readonly DependencyProperty TabPanelVerticalAlignmentProperty = ElementBase.Property(nameof(TabPanelVerticalAlignmentProperty), VerticalAlignment.Top);
12 | public static readonly DependencyProperty OffsetProperty = ElementBase.Property(nameof(OffsetProperty), new Thickness(0));
13 | public static readonly DependencyProperty IconModeProperty = ElementBase.Property(nameof(IconModeProperty), false);
14 |
15 | public static RoutedUICommand IconModeClickCommand = ElementBase.Command(nameof(IconModeClickCommand));
16 |
17 | public VerticalAlignment TabPanelVerticalAlignment { get { return (VerticalAlignment)GetValue(TabPanelVerticalAlignmentProperty); } set { SetValue(TabPanelVerticalAlignmentProperty, value); } }
18 | public Thickness Offset { get { return (Thickness)GetValue(OffsetProperty); } set { SetValue(OffsetProperty, value); } }
19 | public bool IconMode { get { return (bool)GetValue(IconModeProperty); } set { SetValue(IconModeProperty, value); GoToState(); } }
20 |
21 | void GoToState()
22 | {
23 | ElementBase.GoToState(this, IconMode ? "EnterIconMode" : "ExitIconMode");
24 | }
25 |
26 | void SelectionState()
27 | {
28 | if (IconMode)
29 | {
30 | ElementBase.GoToState(this, "SelectionStartIconMode");
31 | ElementBase.GoToState(this, "SelectionEndIconMode");
32 | }
33 | else
34 | {
35 | ElementBase.GoToState(this, "SelectionStart");
36 | ElementBase.GoToState(this, "SelectionEnd");
37 | }
38 | }
39 |
40 | public MetroMenuTabControl()
41 | {
42 | Loaded += delegate { GoToState(); ElementBase.GoToState(this, IconMode ? "SelectionLoadedIconMode" : "SelectionLoaded"); };
43 | SelectionChanged += delegate (object sender, SelectionChangedEventArgs e) { if (e.Source is MetroMenuTabControl) { SelectionState(); } };
44 | CommandBindings.Add(new CommandBinding(IconModeClickCommand, delegate { IconMode = !IconMode; GoToState();}));
45 |
46 | Utility.Refresh(this);
47 | }
48 |
49 | static MetroMenuTabControl()
50 | {
51 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroMenuTabItem.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public class MetroMenuTabItem : TabItem
9 | {
10 | public static readonly DependencyProperty IconProperty = ElementBase.Property(nameof(IconProperty), null);
11 | public static readonly DependencyProperty IconMoveProperty = ElementBase.Property(nameof(IconMoveProperty), null);
12 | public static readonly DependencyProperty TextHorizontalAlignmentProperty = ElementBase.Property(nameof(TextHorizontalAlignmentProperty), HorizontalAlignment.Right);
13 |
14 | public ImageSource Icon { get { return (ImageSource)GetValue(IconProperty); } set { SetValue(IconProperty, value); } }
15 | public ImageSource IconMove { get { return (ImageSource)GetValue(IconMoveProperty); } set { SetValue(IconMoveProperty, value); } }
16 | public HorizontalAlignment TextHorizontalAlignment { get { return (HorizontalAlignment)GetValue(TextHorizontalAlignmentProperty); } set { SetValue(TextHorizontalAlignmentProperty, value); } }
17 |
18 | static MetroMenuTabItem()
19 | {
20 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroPath.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public class MetroPath : ContentControl
9 | {
10 | public static readonly DependencyProperty DataProperty = ElementBase.Property(nameof(DataProperty));
11 |
12 | public Geometry Data { get { return (Geometry)GetValue(DataProperty); } set { SetValue(DataProperty, value); } }
13 |
14 | static MetroPath()
15 | {
16 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroProgressBar.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 |
5 | namespace Arthas.Controls.Metro
6 | {
7 | public enum ProgressBarState
8 | {
9 | None,
10 | Error,
11 | Wait
12 | }
13 |
14 | public class MetroProgressBar : ProgressBar
15 | {
16 | public static readonly DependencyProperty ProgressBarStateProperty = ElementBase.Property(nameof(ProgressBarStateProperty));
17 | public static readonly DependencyProperty CornerRadiusProperty = ElementBase.Property(nameof(CornerRadiusProperty));
18 | public static readonly DependencyProperty TitleProperty = ElementBase.Property(nameof(TitleProperty));
19 | public static readonly DependencyProperty HintProperty = ElementBase.Property(nameof(HintProperty));
20 | public static readonly DependencyProperty ProgressBarHeightProperty = ElementBase.Property(nameof(ProgressBarHeightProperty));
21 | public static readonly DependencyProperty TextHorizontalAlignmentProperty = ElementBase.Property(nameof(TextHorizontalAlignmentProperty));
22 |
23 | public ProgressBarState ProgressBarState { get { return (ProgressBarState)GetValue(ProgressBarStateProperty); } set { SetValue(ProgressBarStateProperty, value); } }
24 | public CornerRadius CornerRadius { get { return (CornerRadius)GetValue(CornerRadiusProperty); } set { SetValue(CornerRadiusProperty, value); } }
25 | public string Title { get { return (string)GetValue(TitleProperty); } set { SetValue(TitleProperty, value); } }
26 | public string Hint { get { return (string)GetValue(HintProperty); } set { SetValue(HintProperty, value); } }
27 | public double ProgressBarHeight { get { return (double)GetValue(ProgressBarHeightProperty); } set { SetValue(ProgressBarHeightProperty, value); } }
28 | public HorizontalAlignment TextHorizontalAlignment { get { return (HorizontalAlignment)GetValue(TextHorizontalAlignmentProperty); } set { SetValue(TextHorizontalAlignmentProperty, value); } }
29 |
30 | public MetroProgressBar()
31 | {
32 | Utility.Refresh(this);
33 | ValueChanged += delegate
34 | {
35 | if (Hint == null||Hint.EndsWith(" %"))
36 | {
37 | Hint = ((int)(Value / Maximum * 100)).ToString() + " %";
38 | }
39 | };
40 | }
41 |
42 | static MetroProgressBar()
43 | {
44 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroScrollViewer.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Input;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public class MetroScrollViewer : ScrollViewer
9 | {
10 | public static readonly DependencyProperty FloatProperty = ElementBase.Property(nameof(FloatProperty));
11 | public static readonly DependencyProperty AutoLimitMouseProperty = ElementBase.Property(nameof(AutoLimitMouseProperty));
12 | public static readonly DependencyProperty VerticalMarginProperty = ElementBase.Property(nameof(VerticalMarginProperty));
13 | public static readonly DependencyProperty HorizontalMarginProperty = ElementBase.Property(nameof(HorizontalMarginProperty));
14 |
15 | public bool Float { get { return (bool)GetValue(FloatProperty); } set { SetValue(FloatProperty, value); } }
16 | public bool AutoLimitMouse { get { return (bool)GetValue(AutoLimitMouseProperty); } set { SetValue(AutoLimitMouseProperty, value); } }
17 | public Thickness VerticalMargin { get { return (Thickness)GetValue(VerticalMarginProperty); } set { SetValue(VerticalMarginProperty, value); } }
18 | public Thickness HorizontalMargin { get { return (Thickness)GetValue(HorizontalMarginProperty); } set { SetValue(HorizontalMarginProperty, value); } }
19 |
20 | public MetroScrollViewer()
21 | {
22 | Utility.Refresh(this);
23 | }
24 |
25 | static MetroScrollViewer()
26 | {
27 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroSwitch.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls.Primitives;
4 |
5 | namespace Arthas.Controls.Metro
6 | {
7 | public class MetroSwitch : ToggleButton
8 | {
9 | public static readonly DependencyProperty TextHorizontalAlignmentProperty = ElementBase.Property(nameof(TextHorizontalAlignmentProperty), HorizontalAlignment.Left);
10 | public static readonly DependencyProperty CornerRadiusProperty = ElementBase.Property(nameof(CornerRadiusProperty), new CornerRadius(10));
11 | public static readonly DependencyProperty BorderCornerRadiusProperty = ElementBase.Property(nameof(BorderCornerRadiusProperty), new CornerRadius(12));
12 |
13 | public HorizontalAlignment TextHorizontalAlignment { get { return (HorizontalAlignment)GetValue(TextHorizontalAlignmentProperty); } set { SetValue(TextHorizontalAlignmentProperty, value); } }
14 | public CornerRadius CornerRadius { get { return (CornerRadius)GetValue(CornerRadiusProperty); } set { SetValue(CornerRadiusProperty, value); } }
15 | public CornerRadius BorderCornerRadius { get { return (CornerRadius)GetValue(BorderCornerRadiusProperty); } set { SetValue(BorderCornerRadiusProperty, value); } }
16 |
17 | public MetroSwitch()
18 | {
19 | Loaded += delegate { ElementBase.GoToState(this, (bool)IsChecked ? "OpenLoaded" : "CloseLoaded"); };
20 | }
21 |
22 | protected override void OnChecked(RoutedEventArgs e)
23 | {
24 | base.OnChecked(e);
25 | ElementBase.GoToState(this, "Open");
26 | }
27 |
28 | protected override void OnUnchecked(RoutedEventArgs e)
29 | {
30 | base.OnChecked(e);
31 | ElementBase.GoToState(this, "Close");
32 | }
33 |
34 | static MetroSwitch()
35 | {
36 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
37 | }
38 | }
39 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroTabControl.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows.Controls;
3 |
4 | namespace Arthas.Controls.Metro
5 | {
6 | public class MetroTabControl : TabControl
7 | {
8 | void SelectionState()
9 | {
10 | ElementBase.GoToState(this, "SelectionStart");
11 | ElementBase.GoToState(this, "SelectionEnd");
12 | }
13 |
14 | public MetroTabControl()
15 | {
16 | Loaded += delegate { ElementBase.GoToState(this, "SelectionLoaded"); };
17 | SelectionChanged += delegate (object sender, SelectionChangedEventArgs e) { if (e.Source is MetroTabControl) { SelectionState(); } };
18 | Utility.Refresh(this);
19 | }
20 |
21 | static MetroTabControl()
22 | {
23 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
24 | }
25 | }
26 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroTabItem.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public class MetroTabItem : TabItem
9 | {
10 | public static readonly DependencyProperty IconProperty = ElementBase.Property(nameof(IconProperty), null);
11 |
12 | public ImageSource Icon { get { return (ImageSource)GetValue(IconProperty); } set { SetValue(IconProperty, value); } }
13 |
14 | static MetroTabItem()
15 | {
16 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroTextBlock.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Controls;
2 |
3 | namespace Arthas.Controls.Metro
4 | {
5 | /*
6 | public class MetroTextBlock : ContentControl
7 | {
8 |
9 | public static readonly DependencyProperty SpacingProperty = ElementBase.Property(nameof(SpacingProperty), new Thickness(0.25));
10 | public Thickness Spacing
11 | {
12 | get { return (Thickness)GetValue(SpacingProperty); }
13 | set { SetValue(SpacingProperty, value); }
14 | }
15 | public static readonly DependencyProperty TextProperty = ElementBase.Property(nameof(TextProperty), "");
16 | public string Text
17 | {
18 | get { return (string)GetValue(TextProperty); }
19 | set { SetValue(TextProperty, value); }
20 | }
21 | static MetroTextBlock()
22 | {
23 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
24 | }
25 | }
26 | */
27 | public class MetroTextBlock : TextBlock
28 | {
29 |
30 | }
31 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroTextButton.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows.Controls;
3 |
4 | namespace Arthas.Controls.Metro
5 | {
6 | public class MetroTextButton : Button
7 | {
8 | static MetroTextButton()
9 | {
10 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
11 | }
12 | }
13 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroThumb.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System;
3 | using System.Windows;
4 | using System.Windows.Controls.Primitives;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public class MetroThumb : Thumb
9 | {
10 | public double OldX { get; set; } = 0.0;
11 | public double OldY { get; set; } = 0.0;
12 | public double OffsetX { get; set; } = 0.0;
13 | public double OffsetY { get; set; } = 0.0;
14 |
15 | public static readonly DependencyProperty XProperty = ElementBase.Property(nameof(XProperty), -1);
16 | public static readonly DependencyProperty YProperty = ElementBase.Property(nameof(YProperty), -1);
17 |
18 | public double X { get { return (double)GetValue(XProperty) - OffsetX; } set { SetValue(XProperty, value + OffsetX); Change(); } }
19 | public double Y { get { return (double)GetValue(YProperty) - OffsetY; } set { SetValue(YProperty, value + OffsetY); Change(); } }
20 |
21 | public event EventHandler ValueChange;
22 |
23 | public MetroThumb()
24 | {
25 | Focusable = true;
26 | FocusVisualStyle = null;
27 |
28 | Loaded += delegate
29 | {
30 | X = (double)GetValue(XProperty) == -1 ? 0 : X;
31 | Y = (double)GetValue(YProperty) == -1 ? 0 : Y;
32 | };
33 | DragStarted += delegate (object sender, DragStartedEventArgs e)
34 | {
35 | Focus();
36 |
37 | OldX = e.HorizontalOffset;
38 | OldY = e.VerticalOffset;
39 |
40 | X = OldX;
41 | Y = OldY;
42 | };
43 | DragDelta += delegate (object sender, DragDeltaEventArgs e)
44 | {
45 | double x = OldX + e.HorizontalChange;
46 | double y = OldY + e.VerticalChange;
47 |
48 | if (x < 0) X = 0;
49 | else if (x > ActualWidth) X = ActualWidth;
50 | else X = x;
51 |
52 | if (y < 0) Y = 0;
53 | else if (y > ActualHeight) Y = ActualHeight;
54 | else Y = y;
55 | };
56 | }
57 |
58 | public double XPercent { get { return X / ActualWidth; } set { X = ActualWidth * value; } }
59 | public double YPercent { get { return Y / ActualHeight; } set { Y = ActualHeight * value; } }
60 |
61 | void Change()
62 | {
63 | if (ValueChange != null) { ValueChange(this, null); }
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroTitleMenu.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows.Controls;
3 |
4 | namespace Arthas.Controls.Metro
5 | {
6 | public class MetroTitleMenu : Menu
7 | {
8 | public MetroTitleMenu()
9 | {
10 | Utility.Refresh(this);
11 | }
12 |
13 | static MetroTitleMenu()
14 | {
15 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroTitleMenuItem.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public class MetroTitleMenuItem : MenuItem
9 | {
10 | public static readonly new DependencyProperty IconProperty = ElementBase.Property(nameof(IconProperty), null);
11 |
12 | public new ImageSource Icon { get { return (ImageSource)GetValue(IconProperty); } set { SetValue(IconProperty, value); } }
13 |
14 | public MetroTitleMenuItem()
15 | {
16 | Utility.Refresh(this);
17 | }
18 |
19 | static MetroTitleMenuItem()
20 | {
21 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroVisualElement.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Utility.Element;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Media;
5 |
6 | namespace Arthas.Controls.Metro
7 | {
8 | public class MetroVisualElement: ContentControl
9 | {
10 | public static readonly DependencyProperty VisualProperty = ElementBase.Property(nameof(VisualProperty));
11 | public static readonly DependencyProperty VisualOpacityProperty = ElementBase.Property(nameof(VisualOpacityProperty));
12 | public static readonly DependencyProperty VisualBlurRadiusProperty = ElementBase.Property(nameof(VisualBlurRadiusProperty));
13 | public static readonly DependencyProperty LeftProperty = ElementBase.Property(nameof(LeftProperty));
14 | public static readonly DependencyProperty TopProperty = ElementBase.Property(nameof(TopProperty));
15 |
16 | public Visual Visual { get { return (Visual)GetValue(VisualProperty); } set { SetValue(VisualProperty, value); } }
17 | public new double VisualOpacity { get { return (double)GetValue(VisualOpacityProperty); } set { SetValue(VisualOpacityProperty, value); } }
18 | public double VisualBlurRadius { get { return (double)GetValue(VisualBlurRadiusProperty); } set { SetValue(VisualBlurRadiusProperty, value); } }
19 | public double Left { get { return (double)GetValue(LeftProperty); } set { SetValue(LeftProperty, value); } }
20 | public double Top { get { return (double)GetValue(TopProperty); } set { SetValue(TopProperty, value); } }
21 |
22 | public MetroVisualElement()
23 | {
24 | Utility.Refresh(this);
25 | }
26 |
27 | static MetroVisualElement()
28 | {
29 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroWebBrowser.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroWebBrowser.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 | using System.Diagnostics;
4 | using System.Reflection;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 |
8 | namespace Arthas.Controls.Metro
9 | {
10 | public partial class MetroWebBrowser : UserControl
11 | {
12 | public bool InDesignMode { get; set; } = false;
13 | public Uri Source
14 | {
15 | get
16 | {
17 | return web.Url;
18 | }
19 | set
20 | {
21 | if (!DesignerProperties.GetIsInDesignMode(this) || InDesignMode)
22 | {
23 | webp.Visibility = Visibility.Visible;
24 | web.Url = value;
25 | }
26 | }
27 | }
28 |
29 | public string Document
30 | {
31 | get { return web.DocumentText; }
32 | set
33 | {
34 | if (!DesignerProperties.GetIsInDesignMode(this) || InDesignMode)
35 | {
36 | webp.Visibility = Visibility.Visible;
37 | web.DocumentText = value;
38 | }
39 | }
40 | }
41 |
42 | public MetroWebBrowser()
43 | {
44 | InitializeComponent();
45 | web.NewWindow += delegate (object sender, CancelEventArgs e)
46 | {
47 | if (web.StatusText.StartsWith("http", StringComparison.CurrentCultureIgnoreCase))
48 | {
49 | Navigate(web.StatusText);
50 | }
51 | // 禁止跳出当前窗口
52 | e.Cancel = true;
53 | };
54 | }
55 |
56 | public void Navigate(string url)
57 | {
58 | // web.Navigate(new Uri(url));
59 | Source = new Uri(url);
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Metro/MetroWindow.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Themes;
2 | using Arthas.Utility.Element;
3 | using System;
4 | using System.Windows;
5 | using System.Windows.Input;
6 | using System.Windows.Media;
7 |
8 | namespace Arthas.Controls.Metro
9 | {
10 | public class MetroWindow : Window
11 | {
12 | public static readonly DependencyProperty IsSubWindowShowProperty = ElementBase.Property(nameof(IsSubWindowShowProperty), false);
13 | public static readonly DependencyProperty MenuProperty = ElementBase.Property(nameof(MenuProperty), null);
14 | public static readonly new DependencyProperty BorderBrushProperty = ElementBase.Property(nameof(BorderBrushProperty));
15 | public static readonly DependencyProperty TitleForegroundProperty = ElementBase.Property(nameof(TitleForegroundProperty));
16 |
17 | public bool IsSubWindowShow { get { return (bool)GetValue(IsSubWindowShowProperty); } set { SetValue(IsSubWindowShowProperty, value); GoToState(); } }
18 | public object Menu { get { return GetValue(MenuProperty); } set { SetValue(MenuProperty, value); } }
19 | public new Brush BorderBrush { get { return (Brush)GetValue(BorderBrushProperty); } set { SetValue(BorderBrushProperty, value); BorderBrushChange(value); } }
20 | public Brush TitleForeground { get { return (Brush)GetValue(TitleForegroundProperty); } set { SetValue(TitleForegroundProperty, value); } }
21 |
22 | void BorderBrushChange(Brush brush)
23 | {
24 | if (IsLoaded)
25 | {
26 | Theme.Switch(this);
27 | }
28 | }
29 |
30 | void GoToState()
31 | {
32 | ElementBase.GoToState(this, IsSubWindowShow ? "Enabled" : "Disable");
33 | }
34 |
35 | public object ReturnValue { get; set; } = null;
36 | public bool EscClose { get; set; } = false;
37 |
38 | protected override void OnInitialized(EventArgs e)
39 | {
40 | base.OnInitialized(e);
41 |
42 | WindowStartupLocation = WindowStartupLocation.CenterScreen;
43 | AllowsTransparency = false;
44 | if (WindowStyle == WindowStyle.None)
45 | {
46 | WindowStyle = WindowStyle.SingleBorderWindow;
47 | }
48 | }
49 |
50 | public MetroWindow()
51 | {
52 | // 修复WindowChrome导致的窗口大小错误
53 | var sizeToContent = SizeToContent.Manual;
54 | Loaded += (ss, ee) =>
55 | {
56 | sizeToContent = SizeToContent;
57 | };
58 | ContentRendered += (ss, ee) =>
59 | {
60 | SizeToContent = SizeToContent.Manual;
61 | Width = ActualWidth;
62 | Height = ActualHeight;
63 | SizeToContent = sizeToContent;
64 | };
65 |
66 | KeyUp += delegate (object sender, KeyEventArgs e)
67 | {
68 | if (e.Key == Key.Escape && EscClose)
69 | {
70 | Close();
71 | }
72 | };
73 | StateChanged += delegate
74 | {
75 | if (ResizeMode == ResizeMode.CanMinimize || ResizeMode == ResizeMode.NoResize)
76 | {
77 | if (WindowState == WindowState.Maximized)
78 | {
79 | WindowState = WindowState.Normal;
80 | }
81 | }
82 | };
83 | Utility.Refresh(this);
84 | }
85 |
86 | static MetroWindow()
87 | {
88 | ElementBase.DefaultStyle(DefaultStyleKeyProperty);
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Controls/Utility.cs:
--------------------------------------------------------------------------------
1 | using Arthas.Controls.Metro;
2 | using Arthas.Utility.Media;
3 | using System.ComponentModel;
4 | using System.Windows;
5 |
6 | namespace Arthas.Controls
7 | {
8 | public class Utility
9 | {
10 | ///
11 | /// 刷新样式
12 | ///
13 | ///
14 | public static void Refresh(FrameworkElement control)
15 | {
16 | if (control == null)
17 | {
18 | return;
19 | }
20 | if (!DesignerProperties.GetIsInDesignMode(control))
21 | {
22 | if (control.IsLoaded)
23 | {
24 | SetColor(control);
25 | }
26 | else
27 | {
28 | control.Loaded += delegate { SetColor(control); };
29 | }
30 | }
31 | }
32 |
33 | static void SetColor(FrameworkElement control)
34 | {
35 | var mw = Window.GetWindow(control) is MetroWindow ? Window.GetWindow(control) as MetroWindow : null;
36 | if (mw != null)
37 | {
38 | if (control is MetroTitleMenu) { (control as MetroTitleMenu).Background = mw.BorderBrush; }
39 | if (control is MetroTitleMenuItem) { (control as MetroTitleMenuItem).Background = mw.BorderBrush; }
40 | if (control is MetroMenuItem) { (control as MetroMenuItem).Background = mw.BorderBrush; }
41 | if (control is MetroContextMenu) { (control as MetroContextMenu).Background = mw.BorderBrush; }
42 | if (control is MetroTextBox) { (control as MetroTextBox).BorderBrush = mw.BorderBrush; }
43 | if (control is MetroButton) { (control as MetroButton).Background = mw.BorderBrush; }
44 | if (control is MetroMenuTabControl) { (control as MetroMenuTabControl).BorderBrush = mw.BorderBrush; }
45 | if (control is MetroRichTextBox) { (control as MetroRichTextBox).MouseMoveThemeBorderBrush = mw.BorderBrush; }
46 | if (control is MetroCanvasGrid) { if ((control as MetroCanvasGrid).IsApplyTheme) (control as MetroCanvasGrid).Background = new RgbaColor(mw.BorderBrush).OpaqueSolidColorBrush; }
47 | if (control is MetroColorPicker) { (control as MetroColorPicker).BorderBrush = mw.BorderBrush; }
48 | }
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // 有关程序集的一般信息由以下
8 | // 控制。更改这些特性值可修改
9 | // 与程序集关联的信息。
10 | [assembly: AssemblyTitle("Arthas")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("Arthas")]
15 | [assembly: AssemblyCopyright("Copyright © 2016")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | //将 ComVisible 设置为 false 将使此程序集中的类型
20 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
21 | //请将此类型的 ComVisible 特性设置为 true。
22 | [assembly: ComVisible(false)]
23 |
24 | //若要开始生成可本地化的应用程序,请
25 | // 中的 .csproj 文件中
26 | //例如,如果您在源文件中使用的是美国英语,
27 | //使用的是美国英语,请将 设置为 en-US。 然后取消
28 | //对以下 NeutralResourceLanguage 特性的注释。 更新
29 | //以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly:ThemeInfo(
35 | ResourceDictionaryLocation.None, //主题特定资源词典所处位置
36 | //(当资源未在页面
37 | //或应用程序资源字典中找到时使用)
38 | ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
39 | //(当资源未在页面
40 | //、应用程序或任何主题专用资源字典中找到时使用)
41 | )]
42 |
43 |
44 | // 程序集的版本信息由下列四个值组成:
45 | //
46 | // 主版本
47 | // 次版本
48 | // 生成号
49 | // 修订号
50 | //
51 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
52 | // 方法是按如下所示使用“*”: :
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Arthas.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Arthas.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 使用此强类型资源类,为所有资源查找
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.42000
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Arthas.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.0.1.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Resources/Icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/toolkit/Arthas/Resources/Icon.png
--------------------------------------------------------------------------------
/toolkit/Arthas/Resources/Thumbs.db:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/toolkit/Arthas/Resources/Thumbs.db
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Generic.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/Metro.xaml:
--------------------------------------------------------------------------------
1 |
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 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroBase.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroCanvasGrid.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
51 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroComboBox.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
38 |
39 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroComboBoxItem.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroContextMenu.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
30 |
31 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroGroupBox.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
31 |
32 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroImage.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
27 |
28 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroMenuSeparator.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
17 |
18 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroPath.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
25 |
26 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroTextBlock.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
37 |
42 |
43 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroTextButton.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
48 |
49 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroTitleMenu.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
28 |
29 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroVisualElement.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
36 |
37 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroWaterfallFlow.xaml:
--------------------------------------------------------------------------------
1 |
4 |
5 |
6 |
7 |
8 |
15 |
16 |
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Metro/MetroWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace Arthas.Themes.Metro
4 | {
5 | public partial class MetroWindow
6 | {
7 | void Minimized(object sender, RoutedEventArgs e)
8 | {
9 | Window.GetWindow(sender as FrameworkElement).WindowState = WindowState.Minimized;
10 | }
11 | void Normal(object sender, RoutedEventArgs e)
12 | {
13 | Window.GetWindow(sender as FrameworkElement).WindowState = WindowState.Normal;
14 | }
15 | void Maximized(object sender, RoutedEventArgs e)
16 | {
17 | Window.GetWindow(sender as FrameworkElement).WindowState = WindowState.Maximized;
18 | }
19 | void Close(object sender, RoutedEventArgs e)
20 | {
21 | Window.GetWindow(sender as FrameworkElement).Close();
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Themes/Theme.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Media;
3 |
4 | namespace Arthas.Themes
5 | {
6 | public class Theme
7 | {
8 | public static void Switch(Visual myVisual)
9 | {
10 | for (int i = 0; i < VisualTreeHelper.GetChildrenCount(myVisual); i++)
11 | {
12 | Visual childVisual = (Visual)VisualTreeHelper.GetChild(myVisual, i);
13 | if (childVisual != null)
14 | {
15 | Controls.Utility.Refresh(childVisual as FrameworkElement);
16 | Switch(childVisual);
17 | }
18 | }
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Utility/Computer/TaskBarPostion.cs:
--------------------------------------------------------------------------------
1 | namespace Arthas.Utility.Computer
2 | {
3 | ///
4 | /// 任务栏位置
5 | ///
6 | public enum TaskBarPostion
7 | {
8 | ///
9 | /// 上边
10 | ///
11 | Top,
12 | ///
13 | /// 左边
14 | ///
15 | Left,
16 | ///
17 | /// 右边
18 | ///
19 | Right,
20 | ///
21 | /// 下边
22 | ///
23 | Bottom,
24 | ///
25 | /// 隐藏
26 | ///
27 | Hide
28 | }
29 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Utility/Element/ElementBase.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 | using System.Windows.Input;
3 |
4 | namespace Arthas.Utility.Element
5 | {
6 | public class ElementBase
7 | {
8 | ///
9 | /// 注册属性
10 | /// public static readonly DependencyProperty Property = Utility.Property(string,T);
11 | ///
12 | /// this
13 | /// 如:string,bool
14 | /// 属性名
15 | /// 属性值
16 | ///
17 | public static DependencyProperty Property(string name, propertyType defaultValue)
18 | {
19 | return DependencyProperty.Register(name.Replace("Property", ""), typeof(propertyType), typeof(thisType), new PropertyMetadata(defaultValue));
20 | }
21 |
22 | ///
23 | /// 注册属性
24 | /// public static readonly DependencyProperty Property = Utility.Property(string,T);
25 | ///
26 | ///
27 | ///
28 | ///
29 | ///
30 | public static DependencyProperty Property(string name)
31 | {
32 | return DependencyProperty.Register(name.Replace("Property", ""), typeof(propertyType), typeof(thisType));
33 | }
34 |
35 | ///
36 | /// 注册事件
37 | /// public static readonly RoutedEvent NameRoutedEvent = Utility.RoutedEvent(string,T);
38 | /// public event EventHandler Name { add { AddHandler(EventHandler, value); } remove { RemoveHandler(EventHandler, value); } }
39 | ///
40 | ///
41 | ///
42 | ///
43 | ///
44 | public static RoutedEvent RoutedEvent(string name)
45 | {
46 | return EventManager.RegisterRoutedEvent(name.Replace("Event", ""), RoutingStrategy.Bubble, typeof(propertyType), typeof(thisType));
47 | }
48 |
49 | ///
50 | /// 默认样式
51 | /// Utility.DefaultStyle(DefaultStyleKeyProperty);
52 | ///
53 | /// this
54 | /// DefaultStyleKeyProperty
55 | public static void DefaultStyle(DependencyProperty dp)
56 | {
57 | dp.OverrideMetadata(typeof(thisType), new FrameworkPropertyMetadata(typeof(thisType)));
58 | }
59 |
60 | ///
61 | /// 初始化一个 Command
62 | ///
63 | ///
64 | ///
65 | ///
66 | public static RoutedUICommand Command(string name)
67 | {
68 | return new RoutedUICommand(name, name, typeof(thisType));
69 | }
70 |
71 | ///
72 | /// 切换状态
73 | ///
74 | ///
75 | ///
76 | public static string GoToState(FrameworkElement element, string state)
77 | {
78 | VisualStateManager.GoToState(element, state, false);
79 | return state;
80 | }
81 | }
82 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Utility/Element/VisualObj.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Media;
3 |
4 | namespace Arthas.Utility.Element
5 | {
6 | public class VisualObj
7 | {
8 | public static void ActionOnAllElement(Visual visual, Action action)
9 | {
10 | for (int i = 0; i < VisualTreeHelper.GetChildrenCount(visual); i++)
11 | {
12 | Visual childVisual = (Visual)VisualTreeHelper.GetChild(visual, i);
13 | if (childVisual != null)
14 | {
15 | action(childVisual);
16 | ActionOnAllElement(childVisual, action);
17 | }
18 | }
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Utility/Media/HsbaColor.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Media;
2 |
3 | namespace Arthas.Utility.Media
4 | {
5 | public class HsbaColor
6 | {
7 | double h = 0, s = 0, b = 0, a = 0;
8 | ///
9 | /// 0 - 359,360 = 0
10 | ///
11 | public double H { get { return h; } set { h = value < 0 ? 0 : value >= 360 ? 0 : value; } }
12 | ///
13 | /// 0 - 1
14 | ///
15 | public double S { get { return s; } set { s = value < 0 ? 0 : value > 1 ? 1 : value; } }
16 | ///
17 | /// 0 - 1
18 | ///
19 | public double B { get { return b; } set { b = value < 0 ? 0 : value > 1 ? 1 : value; } }
20 | ///
21 | /// 0 - 1
22 | ///
23 | public double A { get { return a; } set { a = value < 0 ? 0 : value > 1 ? 1 : value; } }
24 | ///
25 | /// 亮度 0 - 100
26 | ///
27 | public int Y { get { return RgbaColor.Y; } }
28 |
29 | public HsbaColor() { H = 0; S = 0; B = 1; A = 1; }
30 | public HsbaColor(double h, double s, double b, double a = 1) { H = h; S = s; B = b; A = a; }
31 | public HsbaColor(int r, int g, int b, int a = 255)
32 | {
33 | HsbaColor hsba = Utility.RgbaToHsba(new RgbaColor(r, g, b, a));
34 | H = hsba.H;
35 | S = hsba.S;
36 | B = hsba.B;
37 | A = hsba.A;
38 | }
39 | public HsbaColor(Brush brush)
40 | {
41 | HsbaColor hsba = Utility.RgbaToHsba(new RgbaColor(brush));
42 | H = hsba.H;
43 | S = hsba.S;
44 | B = hsba.B;
45 | A = hsba.A;
46 | }
47 | public HsbaColor(string hexColor)
48 | {
49 | HsbaColor hsba = Utility.RgbaToHsba(new RgbaColor(hexColor));
50 | H = hsba.H;
51 | S = hsba.S;
52 | B = hsba.B;
53 | A = hsba.A;
54 | }
55 |
56 |
57 | public Color Color { get { return RgbaColor.Color; } }
58 | public Color OpaqueColor { get { return RgbaColor.OpaqueColor; } }
59 | public SolidColorBrush SolidColorBrush { get { return RgbaColor.SolidColorBrush; } }
60 | public SolidColorBrush OpaqueSolidColorBrush { get { return RgbaColor.OpaqueSolidColorBrush; } }
61 |
62 | public string HexString { get { return Color.ToString(); } }
63 | public string RgbaString { get { return RgbaColor.RgbaString; } }
64 |
65 | public RgbaColor RgbaColor { get { return Utility.HsbaToRgba(this); } }
66 | }
67 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Utility/Media/ResObj.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Reflection;
3 | using System.Windows.Media;
4 |
5 | namespace Arthas.Utility.Media
6 | {
7 | public class ResObj
8 | {
9 | static Stream Get(Assembly assembly, string path)
10 | {
11 | return assembly.GetManifestResourceStream(assembly.GetName().Name + "." + path);
12 | }
13 |
14 | public static string GetString(Assembly assembly, string path)
15 | {
16 | try
17 | {
18 | return StreamObj.ToString(Get(assembly, path));
19 | }
20 | catch
21 | {
22 | return null;
23 | }
24 | }
25 |
26 | public static ImageSource GetImageSource(Assembly assembly, string path)
27 | {
28 | try
29 | {
30 | return StreamObj.ToImageSource(Get(assembly, path));
31 | }
32 | catch
33 | {
34 | return null;
35 | }
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Utility/Media/RgbaColor.cs:
--------------------------------------------------------------------------------
1 | using System.Windows.Media;
2 |
3 | namespace Arthas.Utility.Media
4 | {
5 | public class RgbaColor
6 | {
7 | int r = 0, g = 0, b = 0, a = 0;
8 | ///
9 | /// 0 - 255
10 | ///
11 | public int R { get { return r; } set { r = value < 0 ? 0 : value > 255 ? 255 : value; } }
12 | ///
13 | /// 0 - 255
14 | ///
15 | public int G { get { return g; } set { g = value < 0 ? 0 : value > 255 ? 255 : value; } }
16 | ///
17 | /// 0 - 255
18 | ///
19 | public int B { get { return b; } set { b = value < 0 ? 0 : value > 255 ? 255 : value; } }
20 | ///
21 | /// 0 - 255
22 | ///
23 | public int A { get { return a; } set { a = value < 0 ? 0 : value > 255 ? 255 : value; } }
24 | ///
25 | /// 亮度 0 - 100
26 | ///
27 | public int Y { get { return Utility.GetBrightness(R, G, B); } }
28 |
29 | public RgbaColor() { R = 255; G = 255; B = 255; A = 255; }
30 | public RgbaColor(int r, int g, int b, int a = 255) { R = r; G = g; B = b; A = a; }
31 | public RgbaColor(Brush brush)
32 | {
33 | if (brush != null)
34 | {
35 | R = ((SolidColorBrush)brush).Color.R;
36 | G = ((SolidColorBrush)brush).Color.G;
37 | B = ((SolidColorBrush)brush).Color.B;
38 | A = ((SolidColorBrush)brush).Color.A;
39 | }
40 | else
41 | {
42 | R = G = B = A = 255;
43 | }
44 | }
45 | public RgbaColor(double h, double s, double b, double a = 1)
46 | {
47 | RgbaColor rgba = Utility.HsbaToRgba(new HsbaColor(h, s, b, a));
48 | R = rgba.R;
49 | G = rgba.G;
50 | B = rgba.B;
51 | A = rgba.A;
52 |
53 | }
54 | public RgbaColor(string hexColor)
55 | {
56 | try
57 | {
58 | Color color;
59 | if (hexColor.Substring(0, 1) == "#") color = (Color)ColorConverter.ConvertFromString(hexColor);
60 | else color = (Color)ColorConverter.ConvertFromString("#" + hexColor);
61 | R = color.R;
62 | G = color.G;
63 | B = color.B;
64 | A = color.A;
65 | }
66 | catch
67 | {
68 |
69 | }
70 | }
71 |
72 | public Color Color { get { return Color.FromArgb((byte)A, (byte)R, (byte)G, (byte)B); } }
73 | public Color OpaqueColor { get { return Color.FromArgb((byte)255.0, (byte)R, (byte)G, (byte)B); } }
74 | public SolidColorBrush SolidColorBrush { get { return new SolidColorBrush(Color); } }
75 | public SolidColorBrush OpaqueSolidColorBrush { get { return new SolidColorBrush(OpaqueColor); } }
76 |
77 | public string HexString { get { return Color.ToString(); } }
78 | public string RgbaString { get { return R + "," + G + "," + B + "," + A; } }
79 |
80 | public HsbaColor HsbaColor { get { return Utility.RgbaToHsba(this); } }
81 | }
82 | }
--------------------------------------------------------------------------------
/toolkit/Arthas/Utility/Media/StreamObj.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Windows.Media;
3 | using System.Windows.Media.Imaging;
4 |
5 | namespace Arthas.Utility.Media
6 | {
7 | public class StreamObj
8 | {
9 | public static string ToString(Stream stream)
10 | {
11 | try { return new StreamReader(stream).ReadToEnd(); }
12 | catch { return ""; }
13 | }
14 |
15 | public static ImageSource ToImageSource(Stream stream)
16 | {
17 | try
18 | {
19 | BitmapImage bitmapImage = new BitmapImage();
20 | bitmapImage.BeginInit();
21 | bitmapImage.CacheOption = BitmapCacheOption.OnLoad;
22 | bitmapImage.StreamSource = stream;
23 | bitmapImage.EndInit();
24 |
25 | return bitmapImage;
26 | }
27 | catch { return null; }
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/toolkit/FlyingAria2c/Aria2Lib/File.cs:
--------------------------------------------------------------------------------
1 | using Newtonsoft.Json;
2 |
3 | namespace FlyingAria2c.Aria2Lib
4 | {
5 | struct File
6 | {
7 | [JsonProperty(PropertyName = "index")]
8 | public string Index { get; set; }
9 |
10 | [JsonProperty(PropertyName = "path")]
11 | public string Path { get; set; }
12 |
13 | [JsonProperty(PropertyName = "length")]
14 | public string Length { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/toolkit/FlyingAria2c/Downloader.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using FlyingAria2c.Aria2Lib;
7 |
8 | namespace FlyingAria2c
9 | {
10 | internal class Downloader
11 | {
12 | internal static Aria2cProgressHandle ProgressHandle;
13 |
14 | internal static JsonRpcConnection RpcConnection;
15 |
16 | static Downloader()
17 | {
18 | ProgressHandle = new Aria2cProgressHandle(@"aria2c.exe", Path.GetTempPath());
19 | RpcConnection = new JsonRpcConnection(ProgressHandle);
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/toolkit/FlyingAria2c/FlyingAria2c.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {25677591-187D-4D06-9712-D8DBE4A6C450}
8 | Library
9 | Properties
10 | FlyingAria2c
11 | FlyingAria2c
12 | v4.6
13 | 512
14 | true
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 | false
26 |
27 |
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 | false
35 |
36 |
37 |
38 | ..\packages\Newtonsoft.Json.11.0.2\lib\net45\Newtonsoft.Json.dll
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | ..\packages\WebSocketSharp-NonPreRelease.1.0.0\lib\net35\websocket-sharp.dll
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 | Always
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/toolkit/FlyingAria2c/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("FlyingAria2c")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("FlyingAria2c")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
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("25677591-187d-4d06-9712-d8dbe4a6c450")]
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 |
--------------------------------------------------------------------------------
/toolkit/FlyingAria2c/aria2c.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/toolkit/FlyingAria2c/aria2c.exe
--------------------------------------------------------------------------------
/toolkit/FlyingAria2c/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 |
4 | // Information about this assembly is defined by the following attributes.
5 | // Change them to the values specific to your project.
6 |
7 | [assembly: AssemblyTitle("websocket-sharp")]
8 | [assembly: AssemblyDescription("A C# implementation of the WebSocket protocol client and server")]
9 | [assembly: AssemblyConfiguration("")]
10 | [assembly: AssemblyCompany("")]
11 | [assembly: AssemblyProduct("websocket-sharp.dll")]
12 | [assembly: AssemblyCopyright("sta.blockhead")]
13 | [assembly: AssemblyTrademark("")]
14 | [assembly: AssemblyCulture("")]
15 |
16 | // The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17 | // The form "{Major}.{Minor}.*" will automatically update the build and revision,
18 | // and "{Major}.{Minor}.{Build}.*" will update just the revision.
19 |
20 | [assembly: AssemblyVersion("1.0.2.*")]
21 |
22 | // The following attributes are used to specify the signing key for the assembly,
23 | // if desired. See the Mono documentation for more information about signing.
24 |
25 | //[assembly: AssemblyDelaySign(false)]
26 | //[assembly: AssemblyKeyFile("")]
27 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/ByteOrder.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * ByteOrder.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2012-2015 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp
32 | {
33 | ///
34 | /// Specifies the byte order.
35 | ///
36 | public enum ByteOrder
37 | {
38 | ///
39 | /// Specifies Little-endian.
40 | ///
41 | Little,
42 | ///
43 | /// Specifies Big-endian.
44 | ///
45 | Big
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/CompressionMethod.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * CompressionMethod.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2013-2017 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp
32 | {
33 | ///
34 | /// Specifies the method for compression.
35 | ///
36 | ///
37 | /// The methods are defined in
38 | ///
39 | /// Compression Extensions for WebSocket.
40 | ///
41 | public enum CompressionMethod : byte
42 | {
43 | ///
44 | /// Specifies no compression.
45 | ///
46 | None,
47 | ///
48 | /// Specifies DEFLATE.
49 | ///
50 | Deflate
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/ErrorEventArgs.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * ErrorEventArgs.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2012-2016 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | #region Contributors
30 | /*
31 | * Contributors:
32 | * - Frank Razenberg
33 | */
34 | #endregion
35 |
36 | using System;
37 |
38 | namespace WebSocketSharp
39 | {
40 | ///
41 | /// Represents the event data for the event.
42 | ///
43 | ///
44 | ///
45 | /// That event occurs when the gets an error.
46 | ///
47 | ///
48 | /// If you would like to get the error message, you should access
49 | /// the property.
50 | ///
51 | ///
52 | /// And if the error is due to an exception, you can get it by accessing
53 | /// the property.
54 | ///
55 | ///
56 | public class ErrorEventArgs : EventArgs
57 | {
58 | #region Private Fields
59 |
60 | private Exception _exception;
61 | private string _message;
62 |
63 | #endregion
64 |
65 | #region Internal Constructors
66 |
67 | internal ErrorEventArgs (string message)
68 | : this (message, null)
69 | {
70 | }
71 |
72 | internal ErrorEventArgs (string message, Exception exception)
73 | {
74 | _message = message;
75 | _exception = exception;
76 | }
77 |
78 | #endregion
79 |
80 | #region Public Properties
81 |
82 | ///
83 | /// Gets the exception that caused the error.
84 | ///
85 | ///
86 | /// An instance that represents the cause of
87 | /// the error if it is due to an exception; otherwise, .
88 | ///
89 | public Exception Exception {
90 | get {
91 | return _exception;
92 | }
93 | }
94 |
95 | ///
96 | /// Gets the error message.
97 | ///
98 | ///
99 | /// A that represents the error message.
100 | ///
101 | public string Message {
102 | get {
103 | return _message;
104 | }
105 | }
106 |
107 | #endregion
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Fin.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Fin.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2012-2015 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp
32 | {
33 | ///
34 | /// Indicates whether a WebSocket frame is the final frame of a message.
35 | ///
36 | ///
37 | /// The values of this enumeration are defined in
38 | /// Section 5.2 of RFC 6455.
39 | ///
40 | internal enum Fin : byte
41 | {
42 | ///
43 | /// Equivalent to numeric value 0. Indicates more frames of a message follow.
44 | ///
45 | More = 0x0,
46 | ///
47 | /// Equivalent to numeric value 1. Indicates the final frame of a message.
48 | ///
49 | Final = 0x1
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/LogLevel.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * LogLevel.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2013-2015 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp
32 | {
33 | ///
34 | /// Specifies the logging level.
35 | ///
36 | public enum LogLevel
37 | {
38 | ///
39 | /// Specifies the bottom logging level.
40 | ///
41 | Trace,
42 | ///
43 | /// Specifies the 2nd logging level from the bottom.
44 | ///
45 | Debug,
46 | ///
47 | /// Specifies the 3rd logging level from the bottom.
48 | ///
49 | Info,
50 | ///
51 | /// Specifies the 3rd logging level from the top.
52 | ///
53 | Warn,
54 | ///
55 | /// Specifies the 2nd logging level from the top.
56 | ///
57 | Error,
58 | ///
59 | /// Specifies the top logging level.
60 | ///
61 | Fatal
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Mask.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Mask.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2012-2015 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp
32 | {
33 | ///
34 | /// Indicates whether the payload data of a WebSocket frame is masked.
35 | ///
36 | ///
37 | /// The values of this enumeration are defined in
38 | /// Section 5.2 of RFC 6455.
39 | ///
40 | internal enum Mask : byte
41 | {
42 | ///
43 | /// Equivalent to numeric value 0. Indicates not masked.
44 | ///
45 | Off = 0x0,
46 | ///
47 | /// Equivalent to numeric value 1. Indicates masked.
48 | ///
49 | On = 0x1
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/AuthenticationSchemes.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * AuthenticationSchemes.cs
4 | *
5 | * This code is derived from AuthenticationSchemes.cs (System.Net) of Mono
6 | * (http://www.mono-project.com).
7 | *
8 | * The MIT License
9 | *
10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
11 | * Copyright (c) 2012-2016 sta.blockhead
12 | *
13 | * Permission is hereby granted, free of charge, to any person obtaining a copy
14 | * of this software and associated documentation files (the "Software"), to deal
15 | * in the Software without restriction, including without limitation the rights
16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | * copies of the Software, and to permit persons to whom the Software is
18 | * furnished to do so, subject to the following conditions:
19 | *
20 | * The above copyright notice and this permission notice shall be included in
21 | * all copies or substantial portions of the Software.
22 | *
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | * THE SOFTWARE.
30 | */
31 | #endregion
32 |
33 | #region Authors
34 | /*
35 | * Authors:
36 | * - Atsushi Enomoto
37 | */
38 | #endregion
39 |
40 | using System;
41 |
42 | namespace WebSocketSharp.Net
43 | {
44 | ///
45 | /// Specifies the scheme for authentication.
46 | ///
47 | public enum AuthenticationSchemes
48 | {
49 | ///
50 | /// No authentication is allowed.
51 | ///
52 | None,
53 | ///
54 | /// Specifies digest authentication.
55 | ///
56 | Digest = 1,
57 | ///
58 | /// Specifies basic authentication.
59 | ///
60 | Basic = 8,
61 | ///
62 | /// Specifies anonymous authentication.
63 | ///
64 | Anonymous = 0x8000
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/Chunk.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Chunk.cs
4 | *
5 | * This code is derived from ChunkStream.cs (System.Net) of Mono
6 | * (http://www.mono-project.com).
7 | *
8 | * The MIT License
9 | *
10 | * Copyright (c) 2003 Ximian, Inc (http://www.ximian.com)
11 | * Copyright (c) 2014-2015 sta.blockhead
12 | *
13 | * Permission is hereby granted, free of charge, to any person obtaining a copy
14 | * of this software and associated documentation files (the "Software"), to deal
15 | * in the Software without restriction, including without limitation the rights
16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | * copies of the Software, and to permit persons to whom the Software is
18 | * furnished to do so, subject to the following conditions:
19 | *
20 | * The above copyright notice and this permission notice shall be included in
21 | * all copies or substantial portions of the Software.
22 | *
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | * THE SOFTWARE.
30 | */
31 | #endregion
32 |
33 | #region Authors
34 | /*
35 | * Authors:
36 | * - Gonzalo Paniagua Javier
37 | */
38 | #endregion
39 |
40 | using System;
41 |
42 | namespace WebSocketSharp.Net
43 | {
44 | internal class Chunk
45 | {
46 | #region Private Fields
47 |
48 | private byte[] _data;
49 | private int _offset;
50 |
51 | #endregion
52 |
53 | #region Public Constructors
54 |
55 | public Chunk (byte[] data)
56 | {
57 | _data = data;
58 | }
59 |
60 | #endregion
61 |
62 | #region Public Properties
63 |
64 | public int ReadLeft {
65 | get {
66 | return _data.Length - _offset;
67 | }
68 | }
69 |
70 | #endregion
71 |
72 | #region Public Methods
73 |
74 | public int Read (byte[] buffer, int offset, int count)
75 | {
76 | var left = _data.Length - _offset;
77 | if (left == 0)
78 | return left;
79 |
80 | if (count > left)
81 | count = left;
82 |
83 | Buffer.BlockCopy (_data, _offset, buffer, offset, count);
84 | _offset += count;
85 |
86 | return count;
87 | }
88 |
89 | #endregion
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/HttpBasicIdentity.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * HttpBasicIdentity.cs
4 | *
5 | * This code is derived from HttpListenerBasicIdentity.cs (System.Net) of
6 | * Mono (http://www.mono-project.com).
7 | *
8 | * The MIT License
9 | *
10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
11 | * Copyright (c) 2014-2017 sta.blockhead
12 | *
13 | * Permission is hereby granted, free of charge, to any person obtaining a copy
14 | * of this software and associated documentation files (the "Software"), to deal
15 | * in the Software without restriction, including without limitation the rights
16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | * copies of the Software, and to permit persons to whom the Software is
18 | * furnished to do so, subject to the following conditions:
19 | *
20 | * The above copyright notice and this permission notice shall be included in
21 | * all copies or substantial portions of the Software.
22 | *
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | * THE SOFTWARE.
30 | */
31 | #endregion
32 |
33 | #region Authors
34 | /*
35 | * Authors:
36 | * - Gonzalo Paniagua Javier
37 | */
38 | #endregion
39 |
40 | using System;
41 | using System.Security.Principal;
42 |
43 | namespace WebSocketSharp.Net
44 | {
45 | ///
46 | /// Holds the username and password from an HTTP Basic authentication attempt.
47 | ///
48 | public class HttpBasicIdentity : GenericIdentity
49 | {
50 | #region Private Fields
51 |
52 | private string _password;
53 |
54 | #endregion
55 |
56 | #region Internal Constructors
57 |
58 | internal HttpBasicIdentity (string username, string password)
59 | : base (username, "Basic")
60 | {
61 | _password = password;
62 | }
63 |
64 | #endregion
65 |
66 | #region Public Properties
67 |
68 | ///
69 | /// Gets the password from a basic authentication attempt.
70 | ///
71 | ///
72 | /// A that represents the password.
73 | ///
74 | public virtual string Password {
75 | get {
76 | return _password;
77 | }
78 | }
79 |
80 | #endregion
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/HttpHeaderInfo.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * HttpHeaderInfo.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2013-2014 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp.Net
32 | {
33 | internal class HttpHeaderInfo
34 | {
35 | #region Private Fields
36 |
37 | private string _name;
38 | private HttpHeaderType _type;
39 |
40 | #endregion
41 |
42 | #region Internal Constructors
43 |
44 | internal HttpHeaderInfo (string name, HttpHeaderType type)
45 | {
46 | _name = name;
47 | _type = type;
48 | }
49 |
50 | #endregion
51 |
52 | #region Internal Properties
53 |
54 | internal bool IsMultiValueInRequest {
55 | get {
56 | return (_type & HttpHeaderType.MultiValueInRequest) == HttpHeaderType.MultiValueInRequest;
57 | }
58 | }
59 |
60 | internal bool IsMultiValueInResponse {
61 | get {
62 | return (_type & HttpHeaderType.MultiValueInResponse) == HttpHeaderType.MultiValueInResponse;
63 | }
64 | }
65 |
66 | #endregion
67 |
68 | #region Public Properties
69 |
70 | public bool IsRequest {
71 | get {
72 | return (_type & HttpHeaderType.Request) == HttpHeaderType.Request;
73 | }
74 | }
75 |
76 | public bool IsResponse {
77 | get {
78 | return (_type & HttpHeaderType.Response) == HttpHeaderType.Response;
79 | }
80 | }
81 |
82 | public string Name {
83 | get {
84 | return _name;
85 | }
86 | }
87 |
88 | public HttpHeaderType Type {
89 | get {
90 | return _type;
91 | }
92 | }
93 |
94 | #endregion
95 |
96 | #region Public Methods
97 |
98 | public bool IsMultiValue (bool response)
99 | {
100 | return (_type & HttpHeaderType.MultiValue) == HttpHeaderType.MultiValue
101 | ? (response ? IsResponse : IsRequest)
102 | : (response ? IsMultiValueInResponse : IsMultiValueInRequest);
103 | }
104 |
105 | public bool IsRestricted (bool response)
106 | {
107 | return (_type & HttpHeaderType.Restricted) == HttpHeaderType.Restricted
108 | ? (response ? IsResponse : IsRequest)
109 | : false;
110 | }
111 |
112 | #endregion
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/HttpHeaderType.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * HttpHeaderType.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2013-2014 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp.Net
32 | {
33 | [Flags]
34 | internal enum HttpHeaderType
35 | {
36 | Unspecified = 0,
37 | Request = 1,
38 | Response = 1 << 1,
39 | Restricted = 1 << 2,
40 | MultiValue = 1 << 3,
41 | MultiValueInRequest = 1 << 4,
42 | MultiValueInResponse = 1 << 5
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/HttpVersion.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * HttpVersion.cs
4 | *
5 | * This code is derived from System.Net.HttpVersion.cs of Mono
6 | * (http://www.mono-project.com).
7 | *
8 | * The MIT License
9 | *
10 | * Copyright (c) 2012-2014 sta.blockhead
11 | *
12 | * Permission is hereby granted, free of charge, to any person obtaining a copy
13 | * of this software and associated documentation files (the "Software"), to deal
14 | * in the Software without restriction, including without limitation the rights
15 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 | * copies of the Software, and to permit persons to whom the Software is
17 | * furnished to do so, subject to the following conditions:
18 | *
19 | * The above copyright notice and this permission notice shall be included in
20 | * all copies or substantial portions of the Software.
21 | *
22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28 | * THE SOFTWARE.
29 | */
30 | #endregion
31 |
32 | #region Authors
33 | /*
34 | * Authors:
35 | * - Lawrence Pit
36 | */
37 | #endregion
38 |
39 | using System;
40 |
41 | namespace WebSocketSharp.Net
42 | {
43 | ///
44 | /// Provides the HTTP version numbers.
45 | ///
46 | public class HttpVersion
47 | {
48 | #region Public Fields
49 |
50 | ///
51 | /// Provides a instance for the HTTP/1.0.
52 | ///
53 | public static readonly Version Version10 = new Version (1, 0);
54 |
55 | ///
56 | /// Provides a instance for the HTTP/1.1.
57 | ///
58 | public static readonly Version Version11 = new Version (1, 1);
59 |
60 | #endregion
61 |
62 | #region Public Constructors
63 |
64 | ///
65 | /// Initializes a new instance of the class.
66 | ///
67 | public HttpVersion ()
68 | {
69 | }
70 |
71 | #endregion
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/InputChunkState.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * InputChunkState.cs
4 | *
5 | * This code is derived from ChunkStream.cs (System.Net) of Mono
6 | * (http://www.mono-project.com).
7 | *
8 | * The MIT License
9 | *
10 | * Copyright (c) 2003 Ximian, Inc (http://www.ximian.com)
11 | * Copyright (c) 2014-2015 sta.blockhead
12 | *
13 | * Permission is hereby granted, free of charge, to any person obtaining a copy
14 | * of this software and associated documentation files (the "Software"), to deal
15 | * in the Software without restriction, including without limitation the rights
16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | * copies of the Software, and to permit persons to whom the Software is
18 | * furnished to do so, subject to the following conditions:
19 | *
20 | * The above copyright notice and this permission notice shall be included in
21 | * all copies or substantial portions of the Software.
22 | *
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | * THE SOFTWARE.
30 | */
31 | #endregion
32 |
33 | #region Authors
34 | /*
35 | * Authors:
36 | * - Gonzalo Paniagua Javier
37 | */
38 | #endregion
39 |
40 | using System;
41 |
42 | namespace WebSocketSharp.Net
43 | {
44 | internal enum InputChunkState
45 | {
46 | None,
47 | Data,
48 | DataEnded,
49 | Trailer,
50 | End
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/InputState.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * InputState.cs
4 | *
5 | * This code is derived from HttpConnection.cs (System.Net) of Mono
6 | * (http://www.mono-project.com).
7 | *
8 | * The MIT License
9 | *
10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
11 | * Copyright (c) 2014-2015 sta.blockhead
12 | *
13 | * Permission is hereby granted, free of charge, to any person obtaining a copy
14 | * of this software and associated documentation files (the "Software"), to deal
15 | * in the Software without restriction, including without limitation the rights
16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | * copies of the Software, and to permit persons to whom the Software is
18 | * furnished to do so, subject to the following conditions:
19 | *
20 | * The above copyright notice and this permission notice shall be included in
21 | * all copies or substantial portions of the Software.
22 | *
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | * THE SOFTWARE.
30 | */
31 | #endregion
32 |
33 | #region Authors
34 | /*
35 | * Authors:
36 | * - Gonzalo Paniagua Javier
37 | */
38 | #endregion
39 |
40 | using System;
41 |
42 | namespace WebSocketSharp.Net
43 | {
44 | internal enum InputState
45 | {
46 | RequestLine,
47 | Headers
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/LineState.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * LineState.cs
4 | *
5 | * This code is derived from HttpConnection.cs (System.Net) of Mono
6 | * (http://www.mono-project.com).
7 | *
8 | * The MIT License
9 | *
10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
11 | * Copyright (c) 2014-2015 sta.blockhead
12 | *
13 | * Permission is hereby granted, free of charge, to any person obtaining a copy
14 | * of this software and associated documentation files (the "Software"), to deal
15 | * in the Software without restriction, including without limitation the rights
16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | * copies of the Software, and to permit persons to whom the Software is
18 | * furnished to do so, subject to the following conditions:
19 | *
20 | * The above copyright notice and this permission notice shall be included in
21 | * all copies or substantial portions of the Software.
22 | *
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | * THE SOFTWARE.
30 | */
31 | #endregion
32 |
33 | #region Authors
34 | /*
35 | * Authors:
36 | * - Gonzalo Paniagua Javier
37 | */
38 | #endregion
39 |
40 | using System;
41 |
42 | namespace WebSocketSharp.Net
43 | {
44 | internal enum LineState
45 | {
46 | None,
47 | Cr,
48 | Lf
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/QueryStringCollection.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * QueryStringCollection.cs
4 | *
5 | * This code is derived from System.Net.HttpUtility.cs of Mono
6 | * (http://www.mono-project.com).
7 | *
8 | * The MIT License
9 | *
10 | * Copyright (c) 2005-2009 Novell, Inc. (http://www.novell.com)
11 | * Copyright (c) 2014 sta.blockhead
12 | *
13 | * Permission is hereby granted, free of charge, to any person obtaining a copy
14 | * of this software and associated documentation files (the "Software"), to deal
15 | * in the Software without restriction, including without limitation the rights
16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | * copies of the Software, and to permit persons to whom the Software is
18 | * furnished to do so, subject to the following conditions:
19 | *
20 | * The above copyright notice and this permission notice shall be included in
21 | * all copies or substantial portions of the Software.
22 | *
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | * THE SOFTWARE.
30 | */
31 | #endregion
32 |
33 | #region Authors
34 | /*
35 | * Authors:
36 | * - Patrik Torstensson
37 | * - Wictor Wilén (decode/encode functions)
38 | * - Tim Coleman
39 | * - Gonzalo Paniagua Javier
40 | */
41 | #endregion
42 |
43 | using System;
44 | using System.Collections.Specialized;
45 | using System.Text;
46 |
47 | namespace WebSocketSharp.Net
48 | {
49 | internal sealed class QueryStringCollection : NameValueCollection
50 | {
51 | public override string ToString ()
52 | {
53 | var cnt = Count;
54 | if (cnt == 0)
55 | return String.Empty;
56 |
57 | var output = new StringBuilder ();
58 | var keys = AllKeys;
59 | foreach (var key in keys)
60 | output.AppendFormat ("{0}={1}&", key, this [key]);
61 |
62 | if (output.Length > 0)
63 | output.Length--;
64 |
65 | return output.ToString ();
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Net/ReadBufferState.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * ReadBufferState.cs
4 | *
5 | * This code is derived from ChunkedInputStream.cs (System.Net) of Mono
6 | * (http://www.mono-project.com).
7 | *
8 | * The MIT License
9 | *
10 | * Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
11 | * Copyright (c) 2014-2015 sta.blockhead
12 | *
13 | * Permission is hereby granted, free of charge, to any person obtaining a copy
14 | * of this software and associated documentation files (the "Software"), to deal
15 | * in the Software without restriction, including without limitation the rights
16 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17 | * copies of the Software, and to permit persons to whom the Software is
18 | * furnished to do so, subject to the following conditions:
19 | *
20 | * The above copyright notice and this permission notice shall be included in
21 | * all copies or substantial portions of the Software.
22 | *
23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
29 | * THE SOFTWARE.
30 | */
31 | #endregion
32 |
33 | #region Authors
34 | /*
35 | * Authors:
36 | * - Gonzalo Paniagua Javier
37 | */
38 | #endregion
39 |
40 | using System;
41 |
42 | namespace WebSocketSharp.Net
43 | {
44 | internal class ReadBufferState
45 | {
46 | #region Private Fields
47 |
48 | private HttpStreamAsyncResult _asyncResult;
49 | private byte[] _buffer;
50 | private int _count;
51 | private int _initialCount;
52 | private int _offset;
53 |
54 | #endregion
55 |
56 | #region Public Constructors
57 |
58 | public ReadBufferState (
59 | byte[] buffer, int offset, int count, HttpStreamAsyncResult asyncResult)
60 | {
61 | _buffer = buffer;
62 | _offset = offset;
63 | _count = count;
64 | _initialCount = count;
65 | _asyncResult = asyncResult;
66 | }
67 |
68 | #endregion
69 |
70 | #region Public Properties
71 |
72 | public HttpStreamAsyncResult AsyncResult {
73 | get {
74 | return _asyncResult;
75 | }
76 |
77 | set {
78 | _asyncResult = value;
79 | }
80 | }
81 |
82 | public byte[] Buffer {
83 | get {
84 | return _buffer;
85 | }
86 |
87 | set {
88 | _buffer = value;
89 | }
90 | }
91 |
92 | public int Count {
93 | get {
94 | return _count;
95 | }
96 |
97 | set {
98 | _count = value;
99 | }
100 | }
101 |
102 | public int InitialCount {
103 | get {
104 | return _initialCount;
105 | }
106 |
107 | set {
108 | _initialCount = value;
109 | }
110 | }
111 |
112 | public int Offset {
113 | get {
114 | return _offset;
115 | }
116 |
117 | set {
118 | _offset = value;
119 | }
120 | }
121 |
122 | #endregion
123 | }
124 | }
125 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Opcode.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Opcode.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2012-2016 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp
32 | {
33 | ///
34 | /// Indicates the WebSocket frame type.
35 | ///
36 | ///
37 | /// The values of this enumeration are defined in
38 | ///
39 | /// Section 5.2 of RFC 6455.
40 | ///
41 | internal enum Opcode : byte
42 | {
43 | ///
44 | /// Equivalent to numeric value 0. Indicates continuation frame.
45 | ///
46 | Cont = 0x0,
47 | ///
48 | /// Equivalent to numeric value 1. Indicates text frame.
49 | ///
50 | Text = 0x1,
51 | ///
52 | /// Equivalent to numeric value 2. Indicates binary frame.
53 | ///
54 | Binary = 0x2,
55 | ///
56 | /// Equivalent to numeric value 8. Indicates connection close frame.
57 | ///
58 | Close = 0x8,
59 | ///
60 | /// Equivalent to numeric value 9. Indicates ping frame.
61 | ///
62 | Ping = 0x9,
63 | ///
64 | /// Equivalent to numeric value 10. Indicates pong frame.
65 | ///
66 | Pong = 0xa
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Rsv.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * Rsv.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2012-2015 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp
32 | {
33 | ///
34 | /// Indicates whether each RSV (RSV1, RSV2, and RSV3) of a WebSocket frame is non-zero.
35 | ///
36 | ///
37 | /// The values of this enumeration are defined in
38 | /// Section 5.2 of RFC 6455.
39 | ///
40 | internal enum Rsv : byte
41 | {
42 | ///
43 | /// Equivalent to numeric value 0. Indicates zero.
44 | ///
45 | Off = 0x0,
46 | ///
47 | /// Equivalent to numeric value 1. Indicates non-zero.
48 | ///
49 | On = 0x1
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Server/IWebSocketSession.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * IWebSocketSession.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2013-2014 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 | using WebSocketSharp.Net.WebSockets;
31 |
32 | namespace WebSocketSharp.Server
33 | {
34 | ///
35 | /// Exposes the properties used to access the information in a session in a WebSocket service.
36 | ///
37 | public interface IWebSocketSession
38 | {
39 | #region Properties
40 |
41 | ///
42 | /// Gets the information in the connection request to the WebSocket service.
43 | ///
44 | ///
45 | /// A that provides the access to the connection request.
46 | ///
47 | WebSocketContext Context { get; }
48 |
49 | ///
50 | /// Gets the unique ID of the session.
51 | ///
52 | ///
53 | /// A that represents the unique ID of the session.
54 | ///
55 | string ID { get; }
56 |
57 | ///
58 | /// Gets the WebSocket subprotocol used in the session.
59 | ///
60 | ///
61 | /// A that represents the subprotocol if any.
62 | ///
63 | string Protocol { get; }
64 |
65 | ///
66 | /// Gets the time that the session has started.
67 | ///
68 | ///
69 | /// A that represents the time that the session has started.
70 | ///
71 | DateTime StartTime { get; }
72 |
73 | ///
74 | /// Gets the state of the used in the session.
75 | ///
76 | ///
77 | /// One of the enum values, indicates the state of
78 | /// the used in the session.
79 | ///
80 | WebSocketState State { get; }
81 |
82 | #endregion
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Server/ServerState.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * ServerState.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2013-2014 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp.Server
32 | {
33 | internal enum ServerState
34 | {
35 | Ready,
36 | Start,
37 | ShuttingDown,
38 | Stop
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/Server/WebSocketServiceHost`1.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * WebSocketServiceHost`1.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2015-2017 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp.Server
32 | {
33 | internal class WebSocketServiceHost : WebSocketServiceHost
34 | where TBehavior : WebSocketBehavior
35 | {
36 | #region Private Fields
37 |
38 | private Func _creator;
39 |
40 | #endregion
41 |
42 | #region Internal Constructors
43 |
44 | internal WebSocketServiceHost (
45 | string path, Func creator, Logger log
46 | )
47 | : this (path, creator, null, log)
48 | {
49 | }
50 |
51 | internal WebSocketServiceHost (
52 | string path,
53 | Func creator,
54 | Action initializer,
55 | Logger log
56 | )
57 | : base (path, log)
58 | {
59 | _creator = createCreator (creator, initializer);
60 | }
61 |
62 | #endregion
63 |
64 | #region Public Properties
65 |
66 | public override Type BehaviorType {
67 | get {
68 | return typeof (TBehavior);
69 | }
70 | }
71 |
72 | #endregion
73 |
74 | #region Private Methods
75 |
76 | private Func createCreator (
77 | Func creator, Action initializer
78 | )
79 | {
80 | if (initializer == null)
81 | return creator;
82 |
83 | return () => {
84 | var ret = creator ();
85 | initializer (ret);
86 |
87 | return ret;
88 | };
89 | }
90 |
91 | #endregion
92 |
93 | #region Protected Methods
94 |
95 | protected override WebSocketBehavior CreateSession ()
96 | {
97 | return _creator ();
98 | }
99 |
100 | #endregion
101 | }
102 | }
103 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/WebSocketException.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * WebSocketException.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2012-2016 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp
32 | {
33 | ///
34 | /// The exception that is thrown when a fatal error occurs in
35 | /// the WebSocket communication.
36 | ///
37 | public class WebSocketException : Exception
38 | {
39 | #region Private Fields
40 |
41 | private CloseStatusCode _code;
42 |
43 | #endregion
44 |
45 | #region Internal Constructors
46 |
47 | internal WebSocketException ()
48 | : this (CloseStatusCode.Abnormal, null, null)
49 | {
50 | }
51 |
52 | internal WebSocketException (Exception innerException)
53 | : this (CloseStatusCode.Abnormal, null, innerException)
54 | {
55 | }
56 |
57 | internal WebSocketException (string message)
58 | : this (CloseStatusCode.Abnormal, message, null)
59 | {
60 | }
61 |
62 | internal WebSocketException (CloseStatusCode code)
63 | : this (code, null, null)
64 | {
65 | }
66 |
67 | internal WebSocketException (string message, Exception innerException)
68 | : this (CloseStatusCode.Abnormal, message, innerException)
69 | {
70 | }
71 |
72 | internal WebSocketException (CloseStatusCode code, Exception innerException)
73 | : this (code, null, innerException)
74 | {
75 | }
76 |
77 | internal WebSocketException (CloseStatusCode code, string message)
78 | : this (code, message, null)
79 | {
80 | }
81 |
82 | internal WebSocketException (
83 | CloseStatusCode code, string message, Exception innerException
84 | )
85 | : base (message ?? code.GetMessage (), innerException)
86 | {
87 | _code = code;
88 | }
89 |
90 | #endregion
91 |
92 | #region Public Properties
93 |
94 | ///
95 | /// Gets the status code indicating the cause of the exception.
96 | ///
97 | ///
98 | /// One of the enum values that represents
99 | /// the status code indicating the cause of the exception.
100 | ///
101 | public CloseStatusCode Code {
102 | get {
103 | return _code;
104 | }
105 | }
106 |
107 | #endregion
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/WebSocketState.cs:
--------------------------------------------------------------------------------
1 | #region License
2 | /*
3 | * WebSocketState.cs
4 | *
5 | * The MIT License
6 | *
7 | * Copyright (c) 2010-2016 sta.blockhead
8 | *
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy
10 | * of this software and associated documentation files (the "Software"), to deal
11 | * in the Software without restriction, including without limitation the rights
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 | * copies of the Software, and to permit persons to whom the Software is
14 | * furnished to do so, subject to the following conditions:
15 | *
16 | * The above copyright notice and this permission notice shall be included in
17 | * all copies or substantial portions of the Software.
18 | *
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 | * THE SOFTWARE.
26 | */
27 | #endregion
28 |
29 | using System;
30 |
31 | namespace WebSocketSharp
32 | {
33 | ///
34 | /// Indicates the state of a WebSocket connection.
35 | ///
36 | ///
37 | /// The values of this enumeration are defined in
38 | ///
39 | /// The WebSocket API.
40 | ///
41 | public enum WebSocketState : ushort
42 | {
43 | ///
44 | /// Equivalent to numeric value 0. Indicates that the connection has not
45 | /// yet been established.
46 | ///
47 | Connecting = 0,
48 | ///
49 | /// Equivalent to numeric value 1. Indicates that the connection has
50 | /// been established, and the communication is possible.
51 | ///
52 | Open = 1,
53 | ///
54 | /// Equivalent to numeric value 2. Indicates that the connection is
55 | /// going through the closing handshake, or the close method has
56 | /// been invoked.
57 | ///
58 | Closing = 2,
59 | ///
60 | /// Equivalent to numeric value 3. Indicates that the connection has
61 | /// been closed or could not be established.
62 | ///
63 | Closed = 3
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/doc/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore MonoDevelop build results.
2 |
3 | html
4 | mdoc
5 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/doc/doc.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | #
3 | # @(#) doc.sh ver.0.0.2 2013.01.24
4 | #
5 | # Usage:
6 | # doc.sh
7 | #
8 | # Description:
9 | # Creating documentation for websocket-sharp.
10 | #
11 | ###########################################################################
12 |
13 | SRC_DIR="../bin/Release_Ubuntu"
14 | XML="${SRC_DIR}/websocket-sharp.xml"
15 | DLL="${SRC_DIR}/websocket-sharp.dll"
16 |
17 | DOC_DIR="."
18 | MDOC_DIR="${DOC_DIR}/mdoc"
19 | HTML_DIR="${DOC_DIR}/html"
20 |
21 | createDir() {
22 | if [ ! -d $1 ]; then
23 | mkdir -p $1
24 | fi
25 | }
26 |
27 | set -e
28 | createDir ${MDOC_DIR}
29 | createDir ${HTML_DIR}
30 | mdoc update --delete -fno-assembly-versions -i ${XML} -o ${MDOC_DIR}/ ${DLL}
31 | mdoc export-html -o ${HTML_DIR}/ ${MDOC_DIR}/
32 |
--------------------------------------------------------------------------------
/toolkit/websocket-sharp/websocket-sharp.snk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Cdorey/ezAria2/c6a15ee6e0155a4b296a5600d5b40613ff77165f/toolkit/websocket-sharp/websocket-sharp.snk
--------------------------------------------------------------------------------