Files
duplicati/Duplicati/GUI/HelperControls/BackupItems.cs
T
kenneth.skovhede@gmail.com 135caf4164 All projects are now signed.
Updated to the newest version of LightDataModel.
Switched from duplicity to duplicati, this runs a bit faster.
Now supports authentication on network shares (windows only).

git-svn-id: https://duplicati.googlecode.com/svn/trunk@66 59da171f-624f-0410-aa54-27559c288bec
2009-01-15 19:42:14 +00:00

123 lines
3.7 KiB
C#

#region Disclaimer / License
// Copyright (C) 2008, Kenneth Skovhede
// 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.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using Duplicati.Datamodel;
namespace Duplicati.GUI.HelperControls
{
public partial class BackupItems : UserControl
{
private Thread m_workThread;
private Schedule m_schedule;
private string[] m_backups;
private Exception m_exception;
public event EventHandler ListLoaded;
public event EventHandler LoadError;
public BackupItems()
{
InitializeComponent();
}
public void Setup(Schedule schedule)
{
if (m_workThread != null)
{
if (m_workThread.IsAlive)
m_workThread.Abort();
m_workThread.Join(500);
}
WaitPanel.Visible = true;
statusLabel.Visible = false;
listView.Visible = false;
m_exception = null;
m_backups = null;
m_schedule = schedule;
m_workThread = new Thread(new ThreadStart(Runner));
m_workThread.Start();
}
private void Loaded(object sender, EventArgs e)
{
if (this.InvokeRequired)
this.Invoke(new EventHandler(Loaded), sender, e);
else
{
WaitPanel.Visible = false;
if (m_exception != null)
{
progressBar.Visible = false;
statusLabel.Text = "Error: " + m_exception.Message;
if (LoadError != null)
LoadError(this, null);
return;
}
try
{
listView.Visible = true;
listView.BeginUpdate();
listView.Items.Clear();
foreach (string s in m_backups)
listView.Items.Add(s);
}
finally
{
listView.EndUpdate();
listView.Visible = true;
}
if (ListLoaded != null)
ListLoaded(this, null);
}
}
public string SelectedItem { get { return listView.SelectedItems.Count == 1 ? listView.SelectedItems[0].Text : null; } }
private void Runner()
{
try
{
DuplicatiRunner r = new DuplicatiRunner();
m_backups = r.ListBackups(m_schedule);
}
catch (Exception e)
{
m_exception = e;
}
Loaded(null, null);
}
}
}