2008-09-13 16:24:43 +00:00
#region Disclaimer / License
2011-05-09 19:52:28 +00:00
// Copyright (C) 2011, Kenneth Skovhede
2008-09-13 16:24:43 +00:00
// http://www.hexad.dk, opensource@hexad.dk
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
#endregion
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Data ;
using System.Drawing ;
using System.Text ;
using System.Windows.Forms ;
using Duplicati.Datamodel ;
2010-11-21 11:08:15 +00:00
using Duplicati.Library.Utility ;
2008-09-13 16:24:43 +00:00
2008-09-13 16:32:45 +00:00
namespace Duplicati.GUI
2008-09-13 16:24:43 +00:00
{
public partial class ServiceStatus : Form
{
2011-11-05 14:54:54 +00:00
private enum QuickActionType
{
None ,
Pause ,
Resume ,
Pause5Min ,
Pause10Min ,
Pause15Min ,
Pause30Min ,
Pause60Min ,
StopBackup ,
ThrottleDialog ,
QuitDuplicati
}
2008-09-13 16:24:43 +00:00
public ServiceStatus ()
{
InitializeComponent ();
2009-03-16 22:28:54 +00:00
2011-11-15 22:17:43 +00:00
if ( Library . Utility . Utility . IsClientLinux || Program . TraylessMode )
this . FormBorderStyle = System . Windows . Forms . FormBorderStyle . Sizable ;
if ( Program . TraylessMode )
{
this . StartPosition = FormStartPosition . CenterScreen ;
this . MinimizeBox = true ;
this . ShowInTaskbar = true ;
this . ShowIcon = true ;
}
2009-03-16 22:28:54 +00:00
imageList . Images . Clear ();
2009-03-30 20:17:54 +00:00
imageList . Images . Add ( DuplicatiOutputParser . OKStatus , Properties . Resources . OKStatusIcon );
imageList . Images . Add ( DuplicatiOutputParser . WarningStatus , Properties . Resources . WarningStatusIcon );
imageList . Images . Add ( DuplicatiOutputParser . ErrorStatus , Properties . Resources . ErrorStatusIcon );
imageList . Images . Add ( DuplicatiOutputParser . PartialStatus , Properties . Resources . PartialStatusIcon );
2011-10-07 18:09:15 +00:00
imageList . Images . Add ( DuplicatiOutputParser . InterruptedStatus , Properties . Resources . InterruptedStatusIcon );
2011-10-30 14:31:46 +00:00
imageList . Images . Add ( DuplicatiOutputParser . NoChangedFiles , Properties . Resources . EmptyBackupStatusIcon );
2010-11-05 06:56:07 +00:00
2011-11-05 14:54:54 +00:00
this . Text = String . Format ( Strings . ServiceStatus . DialogTitle , License . VersionNumbers . Version );
string indent = " " ;
QuickActions . Items . Clear ();
QuickActions . Items . AddRange (
new object [] {
new Library . Utility . ComboBoxItemPair < QuickActionType >( Strings . ServiceStatus . SelectQuickAction , QuickActionType . None ),
new Library . Utility . ComboBoxItemPair < QuickActionType >( Strings . ServiceStatus . QuickActionPause , QuickActionType . Pause ),
new Library . Utility . ComboBoxItemPair < QuickActionType >( indent + Strings . ServiceStatus . QuickActionPause5 , QuickActionType . Pause5Min ),
new Library . Utility . ComboBoxItemPair < QuickActionType >( indent + Strings . ServiceStatus . QuickActionPause10 , QuickActionType . Pause10Min ),
new Library . Utility . ComboBoxItemPair < QuickActionType >( indent + Strings . ServiceStatus . QuickActionPause15 , QuickActionType . Pause15Min ),
new Library . Utility . ComboBoxItemPair < QuickActionType >( indent + Strings . ServiceStatus . QuickActionPause30 , QuickActionType . Pause30Min ),
new Library . Utility . ComboBoxItemPair < QuickActionType >( indent + Strings . ServiceStatus . QuickActionPause60 , QuickActionType . Pause60Min ),
new Library . Utility . ComboBoxItemPair < QuickActionType >( Strings . ServiceStatus . QuickActionThrottle , QuickActionType . ThrottleDialog ),
new Library . Utility . ComboBoxItemPair < QuickActionType >( Strings . ServiceStatus . QuickActionExit , QuickActionType . QuitDuplicati ),
});
QuickActions . SelectedIndex = 0 ;
2008-09-13 16:24:43 +00:00
}
private void ServiceStatus_Load ( object sender , EventArgs e )
{
this . FormClosed += new FormClosedEventHandler ( ServiceStatus_FormClosed );
Program . WorkThread . StartingWork += new EventHandler ( WorkThread_StartingWork );
Program . WorkThread . CompletedWork += new EventHandler ( WorkThread_CompletedWork );
2010-11-02 19:31:34 +00:00
Program . WorkThread . WorkQueueChanged += new EventHandler ( WorkThread_WorkQueueChanged );
2008-09-13 16:24:43 +00:00
Program . Scheduler . NewSchedule += new EventHandler ( Scheduler_NewSchedule );
2011-02-16 20:11:43 +00:00
Program . Runner . ProgressEvent += new DuplicatiRunner . ProgressEventDelegate ( Runner_DuplicatiProgress );
2010-01-03 22:46:58 +00:00
Program . LiveControl . StateChanged += new EventHandler ( LiveControl_StateChanged );
2010-08-31 21:27:20 +00:00
Program . DataConnection . AfterDataConnection += new System . Data . LightDatamodel . DataConnectionEventHandler ( DataConnection_AfterDataConnection );
2008-09-13 16:24:43 +00:00
2010-01-03 22:46:58 +00:00
LiveControl_StateChanged ( null , null );
2008-09-13 16:24:43 +00:00
2010-11-02 19:31:34 +00:00
WorkThread_WorkQueueChanged ( null , null );
2008-09-13 16:24:43 +00:00
Scheduler_NewSchedule ( null , null );
BuildRecent ();
PlaceAtBottom ();
2009-03-11 20:56:01 +00:00
if ( Program . WorkThread . CurrentTask != null )
2011-11-05 14:54:54 +00:00
Program . Runner . ReinvokeLastProgressEvent ();
2009-03-11 20:56:01 +00:00
}
2010-08-31 21:27:20 +00:00
private delegate void EmptyDelegate ();
private void DataConnection_AfterDataConnection ( object sender , System . Data . LightDatamodel . DataActions action )
{
2011-11-16 19:50:54 +00:00
if ( action != System . Data . LightDatamodel . DataActions . Fetch )
{
if ( Library . Utility . Utility . IsMono )
MonoSupport . BeginInvoke ( this , new EmptyDelegate ( BuildRecent ));
else
this . BeginInvoke ( new EmptyDelegate ( BuildRecent ));
}
2010-08-31 21:27:20 +00:00
}
2010-01-03 22:46:58 +00:00
void LiveControl_StateChanged ( object sender , EventArgs e )
{
if ( InvokeRequired )
{
Invoke ( new EventHandler ( LiveControl_StateChanged ), sender , e );
return ;
}
stopBackupToolStripMenuItem . Enabled = Program . WorkThread . Active ;
2011-11-05 14:54:54 +00:00
UpdateQuickStateStop ( Program . WorkThread . Active );
2010-01-03 22:46:58 +00:00
2011-11-05 14:54:54 +00:00
SetQuickActionsPauseState ();
2010-01-03 22:46:58 +00:00
if ( Program . LiveControl . State == LiveControls . LiveControlState . Paused )
{
pauseBackupToolStripMenuItem . Checked = true ;
pauseBackupToolStripMenuItem . Text = Strings . Common . MenuResume ;
CurrentStatus . Text = Strings . ServiceStatus . StatusPaused ;
statusImage . Image = Properties . Resources . Status_pause ;
}
else
{
pauseBackupToolStripMenuItem . Checked = false ;
pauseBackupToolStripMenuItem . Text = Strings . Common . MenuPause ;
if ( Program . WorkThread . CurrentTask == null )
WorkThread_CompletedWork ( null , null );
else
WorkThread_StartingWork ( null , null );
}
}
2011-11-05 14:54:54 +00:00
/// <summary>
/// Helper function that removes the QuickState item for Pause/Resume and inserts the right one
/// </summary>
private void SetQuickActionsPauseState ()
{
int index = - 1 ;
for ( int i = 0 ; i < QuickActions . Items . Count ; i ++)
if ( QuickActions . Items [ i ] is ComboBoxItemPair < QuickActionType >)
{
QuickActionType action = (( ComboBoxItemPair < QuickActionType >) QuickActions . Items [ i ]). Value ;
if ( action == QuickActionType . Pause || action == QuickActionType . Resume )
{
//If it is already correct, return now
if ( action == QuickActionType . Resume && Program . LiveControl . State == LiveControls . LiveControlState . Paused )
return ;
if ( action == QuickActionType . Pause && Program . LiveControl . State == LiveControls . LiveControlState . Running )
return ;
index = i ;
break ;
}
}
ComboBoxItemPair < QuickActionType > newitem ;
if ( Program . LiveControl . State == LiveControls . LiveControlState . Paused )
newitem = new ComboBoxItemPair < QuickActionType >( Strings . ServiceStatus . QuickActionResume , QuickActionType . Resume );
else
newitem = new ComboBoxItemPair < QuickActionType >( Strings . ServiceStatus . QuickActionPause , QuickActionType . Pause );
QuickActions . Items . RemoveAt ( index );
QuickActions . Items . Insert ( index , newitem );
}
/// <summary>
/// Updates the QuickState combo and removes or inserts the stop backup item
/// </summary>
private void UpdateQuickStateStop ( bool enabled )
{
int index = - 1 ;
for ( int i = 0 ; i < QuickActions . Items . Count ; i ++)
if ( QuickActions . Items [ i ] is ComboBoxItemPair < QuickActionType >)
{
QuickActionType action = (( ComboBoxItemPair < QuickActionType >) QuickActions . Items [ i ]). Value ;
if ( action == QuickActionType . StopBackup )
{
index = i ;
break ;
}
}
if ( index == - 1 && enabled )
{
QuickActions . Items . Insert ( QuickActions . Items . Count - 3 , new ComboBoxItemPair < QuickActionType >( Strings . ServiceStatus . QuickActionStop , QuickActionType . StopBackup ));
}
else if ( index != - 1 && ! enabled )
{
QuickActions . Items . RemoveAt ( index );
}
}
2009-03-26 19:39:50 +00:00
void Runner_DuplicatiProgress ( Duplicati . Library . Main . DuplicatiOperation operation , DuplicatiRunner . RunnerState state , string message , string submessage , int progress , int subprogress )
2009-03-11 20:56:01 +00:00
{
if ( this . InvokeRequired )
2011-02-16 20:11:43 +00:00
this . Invoke ( new DuplicatiRunner . ProgressEventDelegate ( Runner_DuplicatiProgress ), operation , state , message , submessage , progress , subprogress );
2009-03-11 20:56:01 +00:00
else
{
WorkProgressbar . Visible = ProgressMessage . Visible = state != DuplicatiRunner . RunnerState . Stopped ;
WorkProgressbar . Style = progress < 0 ? ProgressBarStyle . Marquee : ProgressBarStyle . Blocks ;
WorkProgressbar . Value = Math . Max ( Math . Min ( WorkProgressbar . Maximum , progress ), WorkProgressbar . Minimum );
2009-03-26 19:39:50 +00:00
ProgressMessage . Text = message ;
toolTip1 . SetToolTip ( SubProgressBar , submessage );
2009-03-11 20:56:01 +00:00
SubProgressBar . Value = Math . Max ( Math . Min ( SubProgressBar . Maximum , subprogress ), SubProgressBar . Minimum );
if (! SubProgressBar . Visible && subprogress >= 0 )
ProgressMessage_TextChanged ( null , null );
SubProgressBar . Visible = subprogress >= 0 ;
toolTip1 . SetToolTip ( ProgressMessage , ProgressMessage . Text );
toolTip1 . SetToolTip ( WorkProgressbar , ProgressMessage . Text );
}
2008-09-13 16:24:43 +00:00
}
void Scheduler_NewSchedule ( object sender , EventArgs e )
{
2009-03-28 22:33:44 +00:00
try
2008-09-13 16:24:43 +00:00
{
2009-03-28 22:33:44 +00:00
if ( this . InvokeRequired )
this . Invoke ( new EventHandler ( Scheduler_NewSchedule ), sender , e );
else
2011-11-05 14:54:54 +00:00
RebuildScheduled ();
2009-03-28 22:33:44 +00:00
}
catch
2009-03-30 20:17:54 +00:00
{
//TODO: This happens occasionally when the user closes the dialog because, the form is disposed before the event is detached
//I've only seen it happen once
2008-09-13 16:24:43 +00:00
}
}
2011-11-05 14:54:54 +00:00
private void RebuildScheduled ()
{
lock ( Program . MainLock )
try
{
pendingView . BeginUpdate ();
pendingView . Items . Clear ();
foreach ( IDuplicityTask t in Program . WorkThread . CurrentTasks )
{
ListViewItem lvi = pendingView . Items . Add ( Strings . ServiceStatus . BackupImmediate );
lvi . SubItems . Add ( t . Schedule . Name == null ? "" : t . Schedule . Name );
lvi . Tag = t ; //Note: not a schedule object!
}
foreach ( Schedule s in Program . Scheduler . Schedule )
{
2011-11-07 18:34:24 +00:00
ListViewItem lvi = pendingView . Items . Add ( s . NextScheduledTime . ToString ( "g" ));
2011-11-05 14:54:54 +00:00
lvi . SubItems . Add ( s . Name );
lvi . Tag = s ;
}
}
finally
{
pendingView . EndUpdate ();
}
}
2008-09-13 16:24:43 +00:00
void ServiceStatus_FormClosed ( object sender , FormClosedEventArgs e )
{
2010-08-31 21:27:20 +00:00
Program . DataConnection . AfterDataConnection -= new System . Data . LightDatamodel . DataConnectionEventHandler ( DataConnection_AfterDataConnection );
2008-09-13 16:24:43 +00:00
Program . WorkThread . StartingWork -= new EventHandler ( WorkThread_StartingWork );
Program . WorkThread . CompletedWork -= new EventHandler ( WorkThread_CompletedWork );
2010-11-02 19:31:34 +00:00
Program . WorkThread . WorkQueueChanged -= new EventHandler ( WorkThread_WorkQueueChanged );
2008-09-13 16:24:43 +00:00
Program . Scheduler . NewSchedule -= new EventHandler ( Scheduler_NewSchedule );
2011-02-16 20:11:43 +00:00
Program . Runner . ProgressEvent -= new DuplicatiRunner . ProgressEventDelegate ( Runner_DuplicatiProgress );
2010-01-03 22:46:58 +00:00
Program . LiveControl . StateChanged -= new EventHandler ( LiveControl_StateChanged );
2008-09-13 16:24:43 +00:00
}
void WorkThread_CompletedWork ( object sender , EventArgs e )
{
if ( this . InvokeRequired )
this . Invoke ( new EventHandler ( WorkThread_CompletedWork ), sender , e );
else
{
2010-01-03 22:46:58 +00:00
if ( Program . LiveControl . State != LiveControls . LiveControlState . Paused )
{
CurrentStatus . Text = Strings . ServiceStatus . StatusWaiting ;
statusImage . Image = Properties . Resources . Status_OK ;
BuildRecent ();
}
stopBackupToolStripMenuItem . Enabled = false ;
2011-11-05 14:54:54 +00:00
UpdateQuickStateStop ( false );
2008-09-13 16:24:43 +00:00
}
}
void WorkThread_StartingWork ( object sender , EventArgs e )
{
if ( this . InvokeRequired )
this . Invoke ( new EventHandler ( WorkThread_StartingWork ), sender , e );
else
{
Schedule c = Program . WorkThread . CurrentTask . Schedule ;
2009-06-11 17:22:38 +00:00
string prefix = Program . WorkThread . CurrentTask . TaskType == DuplicityTaskType . Restore ? Strings . ServiceStatus . StatusRestore : Strings . ServiceStatus . StatusBackup ;
2008-09-13 16:24:43 +00:00
2009-06-11 17:22:38 +00:00
CurrentStatus . Text = c == null ? Strings . ServiceStatus . StatusWaiting : string . Format ( prefix , c . Name );
2009-03-16 22:28:54 +00:00
statusImage . Image = Properties . Resources . Status_Working ;
2010-11-02 19:31:34 +00:00
WorkThread_WorkQueueChanged ( sender , e );
2010-01-03 22:46:58 +00:00
stopBackupToolStripMenuItem . Enabled = true ;
2011-11-05 14:54:54 +00:00
UpdateQuickStateStop ( true );
2008-09-13 16:24:43 +00:00
}
}
2010-11-02 19:31:34 +00:00
void WorkThread_WorkQueueChanged ( object sender , EventArgs e )
2008-09-13 16:24:43 +00:00
{
if ( this . InvokeRequired )
2010-11-02 19:31:34 +00:00
this . Invoke ( new EventHandler ( WorkThread_WorkQueueChanged ), sender , e );
2008-09-13 16:24:43 +00:00
else
2011-11-05 14:54:54 +00:00
RebuildScheduled ();
2008-09-13 16:24:43 +00:00
}
private void PlaceAtBottom ()
{
this . Top = Screen . PrimaryScreen . WorkingArea . Height - this . Height ;
this . Left = Screen . PrimaryScreen . WorkingArea . Width - this . Width ;
}
private void BuildRecent ()
{
Log [] logs ;
2010-01-03 22:46:58 +00:00
lock ( Program . MainLock )
logs = Program . DataConnection . GetObjects < Log >( "EndTime > ? AND SubAction LIKE ? ORDER BY EndTime DESC" , Timeparser . ParseTimeInterval ( new Datamodel . ApplicationSettings ( Program . DataConnection ). RecentBackupDuration , DateTime . Now , true ), "Primary" );
2008-09-13 16:24:43 +00:00
2010-11-02 19:31:34 +00:00
try
2008-09-13 16:24:43 +00:00
{
2010-11-02 19:31:34 +00:00
recentBackups . BeginUpdate ();
recentBackups . Items . Clear ();
foreach ( Log l in logs )
{
2011-05-09 20:32:46 +00:00
ListViewItem lvi = new ListViewItem ( new string [] { l . EndTime . ToString ( "g" ), l . OwnerTask == null || l . OwnerTask . Schedule == null ? "" : l . OwnerTask . Schedule . Name , l . Transfersize > 0 ? l . TransferSizeString : "" });
2008-09-13 16:24:43 +00:00
2010-11-02 19:31:34 +00:00
lvi . Tag = l ;
lvi . ImageIndex = imageList . Images . ContainsKey ( l . ParsedStatus ) ? imageList . Images . IndexOfKey ( l . ParsedStatus ) : imageList . Images . IndexOfKey ( "Warning" );
recentBackups . Items . Add ( lvi );
2009-03-30 20:17:54 +00:00
2010-11-02 19:31:34 +00:00
if (! string . IsNullOrEmpty ( l . ParsedMessage ))
{
lvi . ToolTipText = l . ParsedMessage ;
}
else
2010-10-02 09:36:41 +00:00
{
2010-11-02 19:31:34 +00:00
switch ( l . ParsedStatus )
{
case DuplicatiOutputParser . OKStatus :
lvi . ToolTipText = Strings . ServiceStatus . BackupStatusOK ;
break ;
case DuplicatiOutputParser . ErrorStatus :
lvi . ToolTipText = Strings . ServiceStatus . BackupStatusError ;
break ;
case DuplicatiOutputParser . WarningStatus :
lvi . ToolTipText = Strings . ServiceStatus . BackupStatusWarning ;
break ;
case DuplicatiOutputParser . PartialStatus :
lvi . ToolTipText = Strings . ServiceStatus . BackupStatusPartial ;
break ;
}
2010-10-02 09:36:41 +00:00
}
2009-03-30 20:17:54 +00:00
}
2008-09-13 16:24:43 +00:00
}
2010-11-02 19:31:34 +00:00
finally
{
recentBackups . EndUpdate ();
}
2008-09-13 16:24:43 +00:00
}
private void recentBackups_DoubleClick ( object sender , EventArgs e )
{
if ( recentBackups . SelectedItems . Count != 1 )
return ;
Log l = recentBackups . SelectedItems [ 0 ]. Tag as Log ;
if ( l == null )
return ;
LogViewer dlg = new LogViewer ();
2010-10-02 09:36:41 +00:00
if (! string . IsNullOrEmpty ( l . ParsedMessage ))
dlg . LogText . Text = l . ParsedMessage + Environment . NewLine + Environment . NewLine ;
else
dlg . LogText . Text = "" ;
2010-01-03 22:46:58 +00:00
//TODO: Figure out if LDM still fails here
2010-10-02 09:36:41 +00:00
dlg . LogText . Text += l . Blob . StringData ;
2008-09-13 16:24:43 +00:00
dlg . ShowDialog ( this );
}
private void ServiceStatus_KeyUp ( object sender , KeyEventArgs e )
{
if ( e . KeyCode == Keys . Escape )
{
this . DialogResult = DialogResult . Cancel ;
this . Close ();
e . Handled = true ;
}
}
2009-03-11 20:56:01 +00:00
private void ProgressMessage_TextChanged ( object sender , EventArgs e )
{
int gap = ProgressMessage . Left - statusImage . Right ;
SubProgressBar . Width = Math . Max ( 0 , ( simplePanel . Width - ProgressMessage . Right ) - ( gap * 2 ));
SubProgressBar . Left = simplePanel . Width - SubProgressBar . Width ;
}
2009-04-01 08:30:14 +00:00
private void recentBackups_SelectedIndexChanged ( object sender , EventArgs e )
{
2009-04-01 13:28:04 +00:00
viewFilesToolStripMenuItem . Enabled = viewLogToolStripMenuItem . Enabled = recentBackups . SelectedItems . Count == 1 ;
2009-04-01 08:30:14 +00:00
}
private void viewFilesToolStripMenuItem_Click ( object sender , EventArgs e )
{
if ( recentBackups . SelectedItems . Count != 1 )
return ;
Log l = recentBackups . SelectedItems [ 0 ]. Tag as Log ;
if ( l == null )
return ;
2011-10-30 14:31:46 +00:00
if ( DuplicatiOutputParser . NoChangedFiles . Equals ( l . ParsedStatus , StringComparison . InvariantCultureIgnoreCase ))
{
MessageBox . Show ( this , Strings . ServiceStatus . NoFilesInBackupMessages , Application . ProductName , MessageBoxButtons . OK , MessageBoxIcon . Information );
return ;
}
2009-04-01 08:30:14 +00:00
Schedule s = l . OwnerTask . Schedule ;
2009-04-01 13:28:04 +00:00
DateTime time = l . EndTime ; //Not the exact time to use, but close enough unless there were multiple backups running at the same time
2009-04-01 08:30:14 +00:00
ListBackupFiles dlg = new ListBackupFiles ();
dlg . ShowList ( this , s , time );
}
2009-04-01 13:28:04 +00:00
private void viewLogToolStripMenuItem_Click ( object sender , EventArgs e )
{
recentBackups_DoubleClick ( sender , e );
}
2010-01-03 22:46:58 +00:00
private void pauseBackupToolStripMenuItem_Click ( object sender , EventArgs e )
{
if ( Program . LiveControl . State == LiveControls . LiveControlState . Running )
Program . LiveControl . Pause ();
else
Program . LiveControl . Resume ();
}
private void stopBackupToolStripMenuItem_Click ( object sender , EventArgs e )
{
2010-10-02 09:36:41 +00:00
Program . Runner . Stop ( CloseReason . UserClosing );
2010-01-03 22:46:58 +00:00
}
private void statusImage_Click ( object sender , EventArgs e )
{
backupTasks . Show ( Cursor . Position . X , Cursor . Position . Y );
}
private void statusImage_DoubleClick ( object sender , EventArgs e )
{
pauseBackupToolStripMenuItem_Click ( sender , e );
}
private void PauseDurationMenu_Click ( object sender , EventArgs e )
{
Program . LiveControl . Pause (( string )(( ToolStripItem ) sender ). Tag );
}
2010-12-19 17:57:40 +00:00
private void ServiceStatus_Resize ( object sender , EventArgs e )
{
ProgressMessage . MaximumSize = new Size ( WorkProgressbar . Width , ProgressMessage . MaximumSize . Height );
}
2011-02-16 20:11:43 +00:00
private void ServiceStatus_Activated ( object sender , EventArgs e )
{
Program . DisplayHelper . ResetCurrentIcon ();
}
2011-11-05 14:54:54 +00:00
private void wizardLink_LinkClicked ( object sender , LinkLabelLinkClickedEventArgs e )
{
Program . DisplayHelper . ShowWizard ();
}
private void linkLabel1_LinkClicked ( object sender , LinkLabelLinkClickedEventArgs e )
{
Program . DisplayHelper . ShowSettings ();
}
private void QuickActions_SelectedIndexChanged ( object sender , EventArgs e )
{
ComboBoxItemPair < QuickActionType > c = QuickActions . SelectedItem as ComboBoxItemPair < QuickActionType >;
if ( c != null )
{
switch ( c . Value )
{
case QuickActionType . Pause :
Program . LiveControl . Pause ();
break ;
case QuickActionType . Resume :
Program . LiveControl . Resume ();
break ;
case QuickActionType . Pause5Min :
Program . LiveControl . Pause ( "5m" );
break ;
case QuickActionType . Pause10Min :
Program . LiveControl . Pause ( "10m" );
break ;
case QuickActionType . Pause15Min :
Program . LiveControl . Pause ( "15m" );
break ;
case QuickActionType . Pause30Min :
Program . LiveControl . Pause ( "30m" );
break ;
case QuickActionType . Pause60Min :
Program . LiveControl . Pause ( "60m" );
break ;
case QuickActionType . StopBackup :
Program . Runner . Stop ( CloseReason . UserClosing );
break ;
case QuickActionType . ThrottleDialog :
new ThrottleControl (). ShowDialog ( Program . DisplayHelper );
break ;
case QuickActionType . QuitDuplicati :
Program . DisplayHelper . Quit ();
break ;
}
}
QuickActions . SelectedIndex = 0 ;
}
private void runBackupNowToolStripMenuItem_Click ( object sender , EventArgs e )
{
if ( recentBackups . SelectedItems . Count != 1 )
return ;
Log l = recentBackups . SelectedItems [ 0 ]. Tag as Log ;
if ( l == null || l . OwnerTask == null || l . OwnerTask . Schedule == null )
return ;
Program . WorkThread . AddTask ( new IncrementalBackupTask ( l . OwnerTask . Schedule ));
}
private void runBackupNowToolStripMenuItem1_Click ( object sender , EventArgs e )
{
if ( pendingView . SelectedItems . Count != 1 )
return ;
Schedule s = pendingView . SelectedItems [ 0 ]. Tag as Schedule ;
if ( s == null )
return ;
Program . WorkThread . AddTask ( new IncrementalBackupTask ( s ));
}
2011-11-15 22:17:43 +00:00
private void ServiceStatus_FormClosing ( object sender , FormClosingEventArgs e )
{
if ( Program . TraylessMode && ! Program . DisplayHelper . IsInQuit )
{
if (! Program . DisplayHelper . Quit ())
e . Cancel = true ;
}
}
2010-01-03 22:46:58 +00:00
}
2008-09-13 16:24:43 +00:00
}