2017-01-16 20:59:50 +01:00
|
|
|
|
/* Copyright (c) Citrix Systems, Inc.
|
2013-06-24 13:41:48 +02:00
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms,
|
|
|
|
|
* with or without modification, are permitted provided
|
|
|
|
|
* that the following conditions are met:
|
|
|
|
|
*
|
|
|
|
|
* * Redistributions of source code must retain the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer.
|
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
|
* copyright notice, this list of conditions and the
|
|
|
|
|
* following disclaimer in the documentation and/or other
|
|
|
|
|
* materials provided with the distribution.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
|
|
|
|
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
|
|
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
|
|
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
|
|
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
|
|
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
using System.Windows.Forms.Design;
|
|
|
|
|
using XenAdmin.Network;
|
|
|
|
|
|
2018-03-09 00:55:50 +01:00
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
namespace XenAdmin.Controls
|
|
|
|
|
{
|
|
|
|
|
public delegate void XenTabPageStatusChanged(XenTabPage sender);
|
|
|
|
|
|
|
|
|
|
[Designer(typeof(ParentControlDesigner))]
|
|
|
|
|
public partial class XenTabPage : UserControl
|
|
|
|
|
{
|
|
|
|
|
public IXenConnection Connection;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Set this value to true to grey the step out in the wizard progress and mark it to be skipped
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool DisableStep;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets a value describing whether it is the first time the page is loaded after
|
|
|
|
|
/// a change in a previous page affecting this one has taken place. Default value is True.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool IsFirstLoad { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets a value describing whether there are pending changes in the page.
|
|
|
|
|
/// Default value is True (so the page takes in the default values of the controls)
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected bool IsDirty { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Does the page use IsDirty?
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected virtual bool ImplementsIsDirty()
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public XenTabPage()
|
|
|
|
|
{
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
IsFirstLoad = true;
|
|
|
|
|
IsDirty = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Action<XenTabPage> WizardContentUpdater { protected get; set; }
|
|
|
|
|
public Func<XenTabPage, bool> NextPagePrecheck { protected get; set; }
|
|
|
|
|
|
|
|
|
|
protected override bool ScaleChildren
|
|
|
|
|
{
|
|
|
|
|
get { return false; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[EditorBrowsable(EditorBrowsableState.Always)]
|
|
|
|
|
[Browsable(true)]
|
|
|
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
|
|
|
|
[Bindable(true)]
|
|
|
|
|
public override string Text
|
|
|
|
|
{
|
|
|
|
|
get { return base.Text; }
|
|
|
|
|
set { base.Text = value; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual string PageTitle
|
|
|
|
|
{
|
|
|
|
|
get { return null; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Note that most derived classes override the getter to return a fixed string
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual string HelpID { get { return ""; } }
|
|
|
|
|
|
|
|
|
|
public virtual string NextText(bool isLastPage)
|
|
|
|
|
{
|
|
|
|
|
return isLastPage ? Messages.FINISH : Messages.WIZARD_BUTTON_NEXT;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual List<KeyValuePair<string, string>> PageSummary { get { return new List<KeyValuePair<string, string>>(); } }
|
|
|
|
|
|
|
|
|
|
public virtual bool EnableNext()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual bool EnablePrevious()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual bool EnableCancel()
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 01:31:46 +01:00
|
|
|
|
public void PageLoaded(PageLoadedDirection direction)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
if (direction == PageLoadedDirection.Forward && IsFirstLoad)
|
|
|
|
|
{
|
|
|
|
|
if (ImplementsIsDirty())
|
|
|
|
|
IsDirty = true;
|
|
|
|
|
|
|
|
|
|
PopulatePage();
|
|
|
|
|
IsFirstLoad = false;
|
|
|
|
|
}
|
2018-03-09 01:31:46 +01:00
|
|
|
|
|
|
|
|
|
PageLoadedCore(direction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void PageLoadedCore(PageLoadedDirection direction)
|
|
|
|
|
{
|
2013-06-24 13:41:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 00:55:50 +01:00
|
|
|
|
public void PageLeave(PageLoadedDirection direction, ref bool cancel)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
2018-03-09 00:55:50 +01:00
|
|
|
|
PageLeaveCore(direction, ref cancel);
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
if (direction == PageLoadedDirection.Forward && !cancel)
|
|
|
|
|
{
|
|
|
|
|
if (ImplementsIsDirty() && IsDirty && WizardContentUpdater != null)
|
|
|
|
|
{
|
|
|
|
|
WizardContentUpdater.Invoke(this);//notify the wizard that the page contents have been updated
|
|
|
|
|
IsDirty = false; //reset edited state
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (NextPagePrecheck != null)
|
|
|
|
|
cancel = !NextPagePrecheck.Invoke(this);
|
|
|
|
|
|
|
|
|
|
if (!cancel && WizardContentUpdater != null)
|
|
|
|
|
WizardContentUpdater.Invoke(this);//notify the wizard that the page contents have been updated
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-09 00:55:50 +01:00
|
|
|
|
protected virtual void PageLeaveCore(PageLoadedDirection direction, ref bool cancel)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-24 13:41:48 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Called when the wizard's Cancel button is hit while on this page
|
|
|
|
|
/// </summary>
|
2018-12-20 13:33:26 +01:00
|
|
|
|
public virtual void PageCancelled(ref bool cancel)
|
2013-06-24 13:41:48 +02:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fired when the page is ready (or not) for the user to advance to the next page).
|
|
|
|
|
/// Currently not implemented by all pages.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public event XenTabPageStatusChanged StatusChanged;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Not always overriden in derived classes
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual void PopulatePage() { }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Check whether this step needs to be disabled. Not always overriden in derived classes
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual void CheckPageDisabled() { }
|
2016-12-08 15:47:58 +01:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Select a control on the page. Not always overriden in derived classes
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual void SelectDefaultControl() { }
|
2013-06-24 13:41:48 +02:00
|
|
|
|
|
|
|
|
|
protected void OnPageUpdated()
|
|
|
|
|
{
|
|
|
|
|
if (StatusChanged != null)
|
|
|
|
|
StatusChanged(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum PageLoadedDirection
|
|
|
|
|
{
|
|
|
|
|
Forward,
|
|
|
|
|
Back
|
|
|
|
|
}
|
|
|
|
|
}
|