/* i-net software provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This programming example assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. i-net software support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. © i-net software 1998-2013 */ using System; using System.Web; using System.Text; using System.Security.Policy; namespace Inet.Viewer.Data { /// /// Kind of a link (hyperlink, subreport, sorting) /// public enum LinkType { /// /// Link to a subreport /// SubreportOnDemand = 0, /// /// Link to a URL /// Hyperlink = 1, /// /// Interactive Sorting /// InteractiveSorting = 2, /// /// No link, only a tooltip (internal link type) /// ToolTip = -1, } /// /// This class represents the interactive features like Hyperlinks, Subreports on demand, or drilldown. /// It contains the information about the rectangle with position and the meta information. /// internal class PageClip { private int x, y, width, height; private string tabName; // for links equals url.toExternalForm() private string toolTip; /// /// The hyperlink URL /// public Uri Url { get; private set; } /// /// The sub-report URL /// public string SubReportURL { get; private set; } /// /// The link type /// public LinkType LinkType { get; private set; } /// /// Base constructor /// /// the x position of the clip /// the y position of the clip /// the width of the clip /// the height of the clip private PageClip(int x, int y, int width, int height) { this.x = x; this.y = y; this.width = width; this.height = height; } /// /// Creates an element with a hyperlink. /// /// the x position of the clip /// the y position of the clip /// the width of the clip /// the height of the clip /// The linktype /// the url /// the tooltip public PageClip(int x, int y, int width, int height, LinkType type, Uri url, string toolTip) : this(x, y, width, height) { this.LinkType = type; this.Url = url; if (toolTip == null) { try { this.toolTip = HttpUtility.UrlDecode(url.ToString(), Encoding.UTF8).ToLower(); } catch (Exception) { // Than it will not be decoded, which should never happen this.toolTip = url.OriginalString; } } else { this.toolTip = toolTip; } } /// /// Creates an element with an on-demand subreport. /// /// the x position of the clip /// the y position of the clip /// /// /// /// the width of the clip /// the height of the clip public PageClip(int x, int y, int width, int height, LinkType type, string url, string subreport) : this(x, y, width, height) { this.LinkType = type; this.SubReportURL = url; toolTip = tabName = subreport; } /// /// Creates an element with a tool tip. /// /// the x position of the clip /// the y position of the clip /// the width of the clip /// the height of the clip /// public PageClip(int x, int y, int width, int height, string toolTip) : this(x, y, width, height) { this.toolTip = toolTip; this.LinkType = Data.LinkType.ToolTip; } /// /// Checks whether the point is within this Page clip /// x coordiante of the point /// y coordiante of the point /// true if the point is in within the clip public virtual bool Contains(int x, int y) { return (x >= this.x) && ((x - this.x) < this.width) && (y >= this.y) && ((y - this.y) < this.height); } /// /// Gets the tool tip. /// public string ToolTip { get { return toolTip; } set { toolTip = value; } } /// /// Compares this instance with the specified instance and /// returns true if both have the same locations and dimensions. /// /// the other pageclip /// true if both have the same locations and dimensions, otherwise false public bool EqualLocation(PageClip other) { return x == other.x && y == other.y && width == other.width && height == other.height; } } }