#region Disclaimer / License // Copyright (C) 2009, 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; namespace OSGeo.MapGuide.MaestroAPI { /// [System.Xml.Serialization.XmlRootAttribute("WebLayout", Namespace="", IsNullable=false)] public class WebLayout { [System.Xml.Serialization.XmlIgnore] public static readonly string SchemaName = "WebLayout-1.0.0.xsd"; [System.Xml.Serialization.XmlIgnore] public static readonly string SchemaName1_1 = "WebLayout-1.1.0.xsd"; [System.Xml.Serialization.XmlIgnore] public static string [] ValidSchemaNames { get { return new string[] { SchemaName, SchemaName1_1 }; } } private string _xsdSchema = SchemaName; [System.Xml.Serialization.XmlAttribute("noNamespaceSchemaLocation", Namespace="http://www.w3.org/2001/XMLSchema-instance")] public string XsdSchema { get { return _xsdSchema; } set { if (Array.IndexOf(ValidSchemaNames, value) < 0) throw new System.Exception("Cannot set the schema name"); _xsdSchema = value; } } private string m_resourceId; [System.Xml.Serialization.XmlIgnore()] public string ResourceId { get { return m_resourceId; } set { m_resourceId = value; } } private ServerConnectionI m_serverConnection; /// /// Gets or sets the connection used in various operations performed on this object /// [System.Xml.Serialization.XmlIgnore()] public ServerConnectionI CurrentConnection { get { return m_serverConnection; } set { m_serverConnection = value; } } private string m_title; private MapType m_map; private string m_ping; private ToolBarType m_toolBar; private InformationPaneType m_informationPane; private ContextMenuType m_contextMenu; private TaskPaneType m_taskPane; private StatusBarType m_statusBar; private ZoomControlType m_zoomControl; private CommandTypeCollection m_commandSet; /// public string Title { get { return this.m_title; } set { this.m_title = value; } } /// public MapType Map { get { return this.m_map; } set { this.m_map = value; } } [System.Xml.Serialization.XmlElement()] public string EnablePingServer { get { if (this.XsdSchema == SchemaName1_1) { if (string.IsNullOrEmpty(m_ping)) m_ping = true.ToString(); return m_ping.ToLower(); } return null; } set { if (value != null) m_ping = value.ToLower(); else m_ping = value; } } /// public ToolBarType ToolBar { get { return this.m_toolBar; } set { this.m_toolBar = value; } } /// public InformationPaneType InformationPane { get { return this.m_informationPane; } set { this.m_informationPane = value; } } /// public ContextMenuType ContextMenu { get { return this.m_contextMenu; } set { this.m_contextMenu = value; } } /// public TaskPaneType TaskPane { get { return this.m_taskPane; } set { this.m_taskPane = value; } } /// public StatusBarType StatusBar { get { return this.m_statusBar; } set { this.m_statusBar = value; } } /// public ZoomControlType ZoomControl { get { return this.m_zoomControl; } set { this.m_zoomControl = value; } } /// [System.Xml.Serialization.XmlArrayItemAttribute("Command", IsNullable=false)] public CommandTypeCollection CommandSet { get { return this.m_commandSet; } set { this.m_commandSet = value; } } public void ConvertToVersion(System.Version version) { string xsd = "WebLayout-" + version.ToString() + ".xsd"; this.XsdSchema = xsd; //Remove the EnablePingServer element if 1.0.0 if (version == new Version(1, 0, 0)) { this.EnablePingServer = null; } } public string GetVersion() { //x.y.z = 5 characters return this.XsdSchema.Substring("WebLayout-".Length, 5); } } /// public class MapType : ResourceReferenceType { private MapViewType m_initialView; private TargetType m_hyperlinkTarget; private string m_hyperlinkTargetFrame; /// public MapViewType InitialView { get { return this.m_initialView; } set { this.m_initialView = value; } } /// public TargetType HyperlinkTarget { get { return this.m_hyperlinkTarget; } set { this.m_hyperlinkTarget = value; } } /// public string HyperlinkTargetFrame { get { return this.m_hyperlinkTargetFrame; } set { this.m_hyperlinkTargetFrame = value; } } } /// public class MapViewType { private System.Double m_centerX; private System.Double m_centerY; private System.Double m_scale; /// public System.Double CenterX { get { return this.m_centerX; } set { this.m_centerX = value; } } /// public System.Double CenterY { get { return this.m_centerY; } set { this.m_centerY = value; } } /// public System.Double Scale { get { return this.m_scale; } set { this.m_scale = value; } } } /// public class ResultColumnType { private string m_name; private string m_property; /// public string Name { get { return this.m_name; } set { this.m_name = value; } } /// public string Property { get { return this.m_property; } set { this.m_property = value; } } } /// public class ParameterPairType { private string m_key; private string m_value; /// public string Key { get { return this.m_key; } set { this.m_key = value; } } /// public string Value { get { return this.m_value; } set { this.m_value = value; } } } /// [System.Xml.Serialization.XmlIncludeAttribute(typeof(CustomCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(PrintCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(TargetedCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(SearchCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(MeasureCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(GetPrintablePageCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(InvokeURLCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(SelectWithinCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(BufferCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(ViewOptionsCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(HelpCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(InvokeScriptCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(BasicCommandType))] public abstract class CommandType { private string m_name; private string m_label; private string m_tooltip; private string m_description; private string m_imageURL; private string m_disabledImageURL; private TargetViewerType m_targetViewer; /// public string Name { get { return this.m_name; } set { this.m_name = value; } } /// public string Label { get { return this.m_label; } set { this.m_label = value; } } /// public string Tooltip { get { return this.m_tooltip; } set { this.m_tooltip = value; } } /// public string Description { get { return this.m_description; } set { this.m_description = value; } } /// public string ImageURL { get { return this.m_imageURL; } set { this.m_imageURL = value; } } /// public string DisabledImageURL { get { return this.m_disabledImageURL; } set { this.m_disabledImageURL = value; } } /// public TargetViewerType TargetViewer { get { return this.m_targetViewer; } set { this.m_targetViewer = value; } } } /// public enum TargetViewerType { /// Dwf, /// Ajax, /// All, } /// [System.Xml.Serialization.XmlIncludeAttribute(typeof(PrintCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(TargetedCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(SearchCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(MeasureCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(GetPrintablePageCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(InvokeURLCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(SelectWithinCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(BufferCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(ViewOptionsCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(HelpCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(InvokeScriptCommandType))] public abstract class CustomCommandType : CommandType { } /// public class PrintCommandType : CustomCommandType { private ResourceReferenceTypeCollection m_printLayout; /// [System.Xml.Serialization.XmlElementAttribute("PrintLayout")] public ResourceReferenceTypeCollection PrintLayout { get { return this.m_printLayout; } set { this.m_printLayout = value; } } } /// [System.Xml.Serialization.XmlIncludeAttribute(typeof(MapType))] public class ResourceReferenceType { private string m_resourceId; /// public string ResourceId { get { return this.m_resourceId; } set { this.m_resourceId = value; } } } /// [System.Xml.Serialization.XmlIncludeAttribute(typeof(SearchCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(MeasureCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(GetPrintablePageCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(InvokeURLCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(SelectWithinCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(BufferCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(ViewOptionsCommandType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(HelpCommandType))] public abstract class TargetedCommandType : CustomCommandType { private TargetType m_target; private string m_targetFrame; /// public TargetType Target { get { return this.m_target; } set { this.m_target = value; } } /// public string TargetFrame { get { return this.m_targetFrame; } set { this.m_targetFrame = value; } } } /// public enum TargetType { /// TaskPane, /// NewWindow, /// SpecifiedFrame, } /// public class SearchCommandType : TargetedCommandType { private string m_layer; private string m_prompt; private ResultColumnTypeCollection m_resultColumns; private string m_filter; private int m_matchLimit; /// public string Layer { get { return this.m_layer; } set { this.m_layer = value; } } /// public string Prompt { get { return this.m_prompt; } set { this.m_prompt = value; } } /// [System.Xml.Serialization.XmlArrayItemAttribute("Column", IsNullable=false)] public ResultColumnTypeCollection ResultColumns { get { return this.m_resultColumns; } set { this.m_resultColumns = value; } } /// public string Filter { get { return this.m_filter; } set { this.m_filter = value; } } /// public int MatchLimit { get { return this.m_matchLimit; } set { this.m_matchLimit = value; } } } /// public class MeasureCommandType : TargetedCommandType { } /// public class GetPrintablePageCommandType : TargetedCommandType { } /// public class InvokeURLCommandType : TargetedCommandType { private string m_uRL; private System.Collections.Specialized.StringCollection m_layerSet; private ParameterPairTypeCollection m_additionalParameter; private bool m_disableIfSelectionEmpty; /// public string URL { get { return this.m_uRL; } set { this.m_uRL = value; } } /// [System.Xml.Serialization.XmlArrayItemAttribute("Layer", IsNullable=false)] public System.Collections.Specialized.StringCollection LayerSet { get { return this.m_layerSet; } set { this.m_layerSet = value; } } /// [System.Xml.Serialization.XmlElementAttribute("AdditionalParameter")] public ParameterPairTypeCollection AdditionalParameter { get { return this.m_additionalParameter; } set { this.m_additionalParameter = value; } } /// public bool DisableIfSelectionEmpty { get { return this.m_disableIfSelectionEmpty; } set { this.m_disableIfSelectionEmpty = value; } } } /// public class SelectWithinCommandType : TargetedCommandType { } /// public class BufferCommandType : TargetedCommandType { } /// public class ViewOptionsCommandType : TargetedCommandType { } /// public class HelpCommandType : TargetedCommandType { private string m_uRL; /// public string URL { get { return this.m_uRL; } set { this.m_uRL = value; } } } /// public class InvokeScriptCommandType : CustomCommandType { private string m_script; /// public string Script { get { return this.m_script; } set { this.m_script = value; } } } /// public class BasicCommandType : CommandType { private BasicCommandActionType m_action; /// public BasicCommandActionType Action { get { return this.m_action; } set { this.m_action = value; } } } /// public enum BasicCommandActionType { /// Pan, /// PanUp, /// PanDown, /// PanRight, /// PanLeft, /// Zoom, /// ZoomIn, /// ZoomOut, /// ZoomRectangle, /// ZoomToSelection, /// FitToWindow, /// PreviousView, /// NextView, /// RestoreView, /// Select, /// SelectRadius, /// SelectPolygon, /// ClearSelection, /// Refresh, /// CopyMap, /// About, } /// public class TaskButtonType { private string m_name; private string m_tooltip; private string m_description; private string m_imageURL; private string m_disabledImageURL; /// public string Name { get { return this.m_name; } set { this.m_name = value; } } /// public string Tooltip { get { return this.m_tooltip; } set { this.m_tooltip = value; } } /// public string Description { get { return this.m_description; } set { this.m_description = value; } } /// public string ImageURL { get { return this.m_imageURL; } set { this.m_imageURL = value; } } /// public string DisabledImageURL { get { return this.m_disabledImageURL; } set { this.m_disabledImageURL = value; } } } /// [System.Xml.Serialization.XmlIncludeAttribute(typeof(CommandItemType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(SeparatorItemType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(FlyoutItemType))] public class UIItemType { private UIItemFunctionType m_function; /// public UIItemFunctionType Function { get { return this.m_function; } set { this.m_function = value; } } } /// public enum UIItemFunctionType { /// Separator, /// Command, /// Flyout, } /// public class CommandItemType : UIItemType { private string m_command; /// public string Command { get { return this.m_command; } set { this.m_command = value; } } } /// public class SeparatorItemType : UIItemType { } /// public class FlyoutItemType : UIItemType { private string m_label; private string m_tooltip; private string m_description; private string m_imageURL; private string m_disabledImageURL; private UIItemTypeCollection m_subItem; /// public string Label { get { return this.m_label; } set { this.m_label = value; } } /// public string Tooltip { get { return this.m_tooltip; } set { this.m_tooltip = value; } } /// public string Description { get { return this.m_description; } set { this.m_description = value; } } /// public string ImageURL { get { return this.m_imageURL; } set { this.m_imageURL = value; } } /// public string DisabledImageURL { get { return this.m_disabledImageURL; } set { this.m_disabledImageURL = value; } } /// [System.Xml.Serialization.XmlElementAttribute("SubItem")] public UIItemTypeCollection SubItem { get { return this.m_subItem; } set { this.m_subItem = value; } } } /// [System.Xml.Serialization.XmlIncludeAttribute(typeof(StatusBarType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(TaskBarType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(WebLayoutResizableControlType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(InformationPaneType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(TaskPaneType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(ZoomControlType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(ToolBarType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(ContextMenuType))] public class WebLayoutControlType { private bool m_visible; /// public bool Visible { get { return this.m_visible; } set { this.m_visible = value; } } } /// public class StatusBarType : WebLayoutControlType { } /// public class TaskBarType : WebLayoutControlType { private TaskButtonType m_home; private TaskButtonType m_forward; private TaskButtonType m_back; private TaskButtonType m_tasks; private UIItemTypeCollection m_menuButton; /// public TaskButtonType Home { get { return this.m_home; } set { this.m_home = value; } } /// public TaskButtonType Forward { get { return this.m_forward; } set { this.m_forward = value; } } /// public TaskButtonType Back { get { return this.m_back; } set { this.m_back = value; } } /// public TaskButtonType Tasks { get { return this.m_tasks; } set { this.m_tasks = value; } } /// [System.Xml.Serialization.XmlElementAttribute("MenuButton")] public UIItemTypeCollection MenuButton { get { return this.m_menuButton; } set { this.m_menuButton = value; } } } /// [System.Xml.Serialization.XmlIncludeAttribute(typeof(InformationPaneType))] [System.Xml.Serialization.XmlIncludeAttribute(typeof(TaskPaneType))] public class WebLayoutResizableControlType : WebLayoutControlType { private int m_width; /// public int Width { get { return this.m_width; } set { this.m_width = value; } } } /// public class InformationPaneType : WebLayoutResizableControlType { private bool m_legendVisible; private bool m_propertiesVisible; /// public bool LegendVisible { get { return this.m_legendVisible; } set { this.m_legendVisible = value; } } /// public bool PropertiesVisible { get { return this.m_propertiesVisible; } set { this.m_propertiesVisible = value; } } } /// public class TaskPaneType : WebLayoutResizableControlType { private TaskBarType m_taskBar; private string m_initialTask; /// public TaskBarType TaskBar { get { return this.m_taskBar; } set { this.m_taskBar = value; } } /// public string InitialTask { get { return this.m_initialTask; } set { this.m_initialTask = value; } } } /// public class ZoomControlType : WebLayoutControlType { } /// public class ToolBarType : WebLayoutControlType { private UIItemTypeCollection m_button; /// [System.Xml.Serialization.XmlElementAttribute("Button")] public UIItemTypeCollection Button { get { return this.m_button; } set { this.m_button = value; } } } /// public class ContextMenuType : WebLayoutControlType { private UIItemTypeCollection m_menuItem; /// [System.Xml.Serialization.XmlElementAttribute("MenuItem")] public UIItemTypeCollection MenuItem { get { return this.m_menuItem; } set { this.m_menuItem = value; } } } public class CommandTypeCollection : System.Collections.CollectionBase { public CommandType this[int idx] { get { return ((CommandType)(base.InnerList[idx])); } set { base.InnerList[idx] = value; } } public int Add(CommandType value) { return base.InnerList.Add(value); } } public class ResourceReferenceTypeCollection : System.Collections.CollectionBase { public ResourceReferenceType this[int idx] { get { return ((ResourceReferenceType)(base.InnerList[idx])); } set { base.InnerList[idx] = value; } } public int Add(ResourceReferenceType value) { return base.InnerList.Add(value); } } public class ResultColumnTypeCollection : System.Collections.CollectionBase { public ResultColumnType this[int idx] { get { return ((ResultColumnType)(base.InnerList[idx])); } set { base.InnerList[idx] = value; } } public int Add(ResultColumnType value) { return base.InnerList.Add(value); } } public class UIItemTypeCollection : System.Collections.CollectionBase { public UIItemType this[int idx] { get { return ((UIItemType)(base.InnerList[idx])); } set { base.InnerList[idx] = value; } } public int Add(UIItemType value) { return base.InnerList.Add(value); } public int IndexOf(UIItemType value) { return base.InnerList.IndexOf(value); } public void Insert(int index, UIItemType value) { base.InnerList.Insert(index, value); } } public class ParameterPairTypeCollection : System.Collections.CollectionBase { public ParameterPairType this[int idx] { get { return ((ParameterPairType)(base.InnerList[idx])); } set { base.InnerList[idx] = value; } } public int Add(ParameterPairType value) { return base.InnerList.Add(value); } } }