#region Disclaimer / License
// Copyright (C) 2015, The Duplicati Team
// http://www.duplicati.com, info@duplicati.com
//
// 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.Text;
using System.Windows.Forms;
namespace Duplicati.Library.Interface
{
///
/// The interface that defines a GUI for a plugable component, such as a backend or encryption module.
/// All options are stored in a dictionary, which is persisted to the database.
/// When creating a backup, the option dictionary will be empty, when editing, it will contain the contents from the last edit.
/// The options in the dictionary are free form, and should contain the state of the userinterface.
/// When the backup is invoked, the method is invoked with the options dictionary.
/// At this point the control should setup the Duplicati options, based on the saved userinterface state.
/// This enables the user interface to be decoupled from the actual options.
///
public interface IGUIControl
{
///
/// The title of the page, shown as the wizard title or the tab caption
///
string PageTitle { get; }
///
/// The page description, shown as a helptext in the wizard or as a tooltip on a tab
///
string PageDescription { get; }
///
/// A method to retrieve a user interface control.
/// The method should keep a reference to the dictionary.
/// The control will be resized to fit in the container.
///
/// The set of settings defined by the calling application
/// A set of options, either empty or previously stored by the control
/// The control that represents the user interface
Control GetControl(IDictionary applicationSettings, IDictionary options);
///
/// Method that is called when the user leaves the form.
/// This method can be used to store data from the interface in the dictionary,
/// so the user interface can be reconstructed later.
/// Do not throw exceptions to interrupt this method as that will remove the "back" option in the wizard,
/// return false in the method instead.
///
/// The UI object created by the GetControl call
void Leave(Control control);
///
/// A method that is called when the form should be validated.
/// The method should inform the user if the validation fails.
///
/// The UI object created by the GetControl call
/// True if the data is valid, false otherwise
bool Validate(Control control);
///
/// This method sets up the Duplicati options, based on a previous setup.
/// The method should read the saved setup from , and set the appropriate .
/// If the UI represents a backend, the function should return the backend URL, otherwise the return value is ignored.
///
/// The set of settings defined by the calling application
/// A set of previously saved options for the control
/// A set of commandline options passed to Duplicati
/// The destination path if the control is for a backend, otherwise null
string GetConfiguration(IDictionary applicationSettings, IDictionary guiOptions, IDictionary commandlineOptions);
}
}