Root/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 | using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.Collections; using System.IO; using System.Web; using System.Diagnostics; using MyDownloader.Core; using MyDownloader.Core.Common; using MyDownloader.App.SingleInstancing; using MyDownloader.Extension.AutoDownloads; using MyDownloader.Core.Extensions; using MyDownloader.Extension.SpeedLimit; using MyDownloader.Extension.Video; using MyDownloader.Extension.WindowsIntegration.ClipboardMonitor; namespace MyDownloader.App.UI { public partial class MainForm : Form, ISingleInstanceEnforcer { SpeedLimitExtension speedLimit; public MainForm() { InitializeComponent(); downloadList1.SelectionChange += new EventHandler(downloadList1_SelectionChange); downloadList1.UpdateUI(); speedLimit = (SpeedLimitExtension)App.Instance.GetExtensionByType( typeof (SpeedLimitExtension)); this .KeyUp+= new KeyEventHandler(MainForm_KeyUp); this .KeyPreview = true ; } void downloadList1_SelectionChange( object sender, EventArgs e) { int cnt = downloadList1.SelectedCount; bool isSelected = cnt > 0; bool isSelectedOnlyOne = cnt == 1; removeToolStripMenuItem.Enabled = isSelected; removeCompletedToolStripMenuItem.Enabled = isSelected; toolStart.Enabled = isSelected; toolPause.Enabled = isSelected; toolRemove.Enabled = isSelected; copyURLToClipboardToolStripMenuItem1.Enabled = isSelectedOnlyOne; toolMoveSelectionsDown.Enabled = isSelected; toolMoveSelectionsUp.Enabled = isSelected; } private void tmrRefresh_Tick( object sender, EventArgs e) { string strRate; if (speedLimit.CurrentEnabled) { strRate = String.Format( "[{0:0.##} kpbs] {1:0.##} kbps" , speedLimit.CurrentMaxRate / 1024.0, DownloadManager.Instance.TotalDownloadRate / 1024.0); } else { strRate = String.Format( "{0:0.##} kbps" , DownloadManager.Instance.TotalDownloadRate / 1024.0); } toolStripScheduler.Checked = downloadList1.SchedulerStarted(); toolStripLblRateTxt.Text = strRate; notifyIcon.Text = String.Concat( this .Text, "\n" , toolStripLblRate.Text, " " , strRate); downloadList1.UpdateList(); } private void MainForm_Load( object sender, EventArgs e) { LoadViewSettings(); notifyIcon.Icon = this .Icon; notifyIcon.Text = this .Text; notifyIcon.Visible = true ; } private void toolNewDownload_Click( object sender, EventArgs e) { downloadList1.NewFileDownload( null , true ); } private void toolStart_Click( object sender, EventArgs e) { downloadList1.StartSelections(); } private void toolPause_Click( object sender, EventArgs e) { downloadList1.Pause(); } private void toolPauseAll_Click( object sender, EventArgs e) { downloadList1.PauseAll(); } private void toolRemove_Click( object sender, EventArgs e) { downloadList1.RemoveSelections(); } private void toolRemoveCompleted_Click( object sender, EventArgs e) { downloadList1.RemoveCompleted(); } private void toolOptions_Click( object sender, EventArgs e) { using (OptionsForm options = new OptionsForm()) { options.ShowDialog(); } } private void toolAbout_Click( object sender, EventArgs e) { using (AboutForm about = new AboutForm()) { about.ShowDialog(); } } #region ISingleInstanceEnforcer Members public void OnMessageReceived(MessageEventArgs e) { string [] args = ( string [])e.Message; if (args.Length == 2 && args[0] == "/sw" ) { this .BeginInvoke((MethodInvoker) delegate { downloadList1.NewDownloadFromData(args[1]); }); } else { downloadList1.AddDownloadURLs(ResourceLocation.FromURLArray(args), 1, null , 0); } } public void OnNewInstanceCreated(EventArgs e) { this .Focus(); } #endregion private void LoadViewSettings() { downloadList1.LoadSettingsView(); toolStripMain.Visible = Settings.Default.ViewToolbar; if (toolStripMain.Visible) { faTabStrip1.Top = menuBarStrip.Height + toolStripMain.Top + 1; } else { faTabStrip1.Top = menuBarStrip.Height + 4; } faTabStrip1.Height = this .ClientSize.Height - statusStrip1.Height - faTabStrip1.Top; gridToolStripMenuItem.Checked = Settings.Default.ViewGrid; segmentsToolStripMenuItem.Checked = Settings.Default.ViewTransDetails; toolbarToolStripMenuItem.Checked = Settings.Default.ViewToolbar; } private void exitToolStripMenuItem_Click( object sender, EventArgs e) { Close(); } private void newBatchDownloadToolStripMenuItem_Click( object sender, EventArgs e) { downloadList1.NewBatchDownload(); } private void viewMenuClickClick( object sender, EventArgs e) { ToolStripMenuItem menu = ((ToolStripMenuItem)sender); menu.Checked = !menu.Checked; Settings.Default.ViewGrid = gridToolStripMenuItem.Checked; Settings.Default.ViewToolbar = toolbarToolStripMenuItem.Checked; Settings.Default.ViewTransDetails = segmentsToolStripMenuItem.Checked; LoadViewSettings(); } private void MainForm_FormClosing( object sender, FormClosingEventArgs e) { Settings.Default.Save(); } private void showHideToolStripMenuItem_Click( object sender, EventArgs e) { ShowHideForm(); } public void ShowHideForm() { if ( this .Visible) { HideForm(); } else { ShowForm(); LoadViewSettings(); } } public void ShowForm() { this .ShowInTaskbar = true ; this .Visible = true ; this .WindowState = FormWindowState.Normal; } public void HideForm() { this .ShowInTaskbar = false ; this .Visible = false ; } private void showHideToolStripMenuItem_Click( object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { ShowHideForm(); } } private void newVideoDownloadToolStripMenuItem_Click( object sender, EventArgs e) { downloadList1.NewVideoDownload(); } private void toolStripScheduler_Click( object sender, EventArgs e) { downloadList1.StartScheduler(toolStripScheduler.Checked); } private void importFromTextFileToolStripMenuItem_Click( object sender, EventArgs e) { downloadList1.ImportFromTextFile(); } private void toolStripButton2_Click( object sender, EventArgs e) { downloadList1.MoveSelectionsUp(); } private void toolStripButton3_Click( object sender, EventArgs e) { downloadList1.MoveSelectionsDown(); } private void setCustomToolStripMenuItem_Click( object sender, EventArgs e) { ((SpeedLimitUIExtension)speedLimit.UIExtension).ShowSpeedLimitDialog(); } private void enableSpeedLimitToolStripMenuItem_Click( object sender, EventArgs e) { speedLimit.Parameters.Enabled = enableSpeedLimitToolStripMenuItem.Checked; } private void cntxMenuDownLimit_Opening( object sender, CancelEventArgs e) { enableSpeedLimitToolStripMenuItem.Checked = speedLimit.Parameters.Enabled; } private void selectAllToolStripMenuItem_Click( object sender, EventArgs e) { downloadList1.SelectAll(); } private void clipboardMonitoringToolStripMenuItem_Click( object sender, EventArgs e) { downloadList1.ClipboardMonitorEnabled = (clipboardMonitoringToolStripMenuItem.Checked); } private void notifyIconContextMenu_Opening( object sender, CancelEventArgs e) { clipboardMonitoringToolStripMenuItem.Checked = downloadList1.ClipboardMonitorEnabled; } private void menuBarStrip_ItemClicked( object sender, ToolStripItemClickedEventArgs e) { } private void MainForm_KeyPress( object sender, KeyPressEventArgs e) { } private void MainForm_KeyUp( object sender, KeyEventArgs e) { } private void tsbMenu_Click( object sender, EventArgs e) { menuBarStrip.Visible = !menuBarStrip.Visible; } private void MainForm_KeyDown( object sender, KeyEventArgs e) { if (e.Alt) { menuBarStrip.Visible = !menuBarStrip.Visible; } } } } |
Source at commit 1dae03ea3242 created 11 years 10 months ago. By Nathan Adams, Initial commit |
---|