/// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (Title != null)
         {
             hashCode = hashCode * 59 + Title.GetHashCode();
         }
         if (Tooltip != null)
         {
             hashCode = hashCode * 59 + Tooltip.GetHashCode();
         }
         if (FixedWidth != null)
         {
             hashCode = hashCode * 59 + FixedWidth.GetHashCode();
         }
         if (Sortable != null)
         {
             hashCode = hashCode * 59 + Sortable.GetHashCode();
         }
         return(hashCode);
     }
 }
Example #2
0
        public TextDialog(IText text, SmallPortraitId?portraitId = null, int depth = 0) : base(DialogPositioning.Top, depth)
        {
            On <DismissMessageEvent>(_ => Close());
            On <UiLeftClickEvent>(e => { Close(); e.Propagating = false; });
            On <UiRightClickEvent>(e => { Close(); e.Propagating = false; });
            On <CloseWindowEvent>(e => Close());

            var textSection = new UiText(text);
            var padding     = new Padding(textSection, 3, 7);

            UiElement content;

            if (portraitId.HasValue)
            {
                var portrait = new FixedSize(36, 38,
                                             new ButtonFrame(new UiSpriteElement <SmallPortraitId>(portraitId.Value))
                {
                    State   = ButtonState.Pressed,
                    Padding = 0
                });
                content = new HorizontalStack(new CentreContent(portrait), padding);
            }
            else
            {
                content = padding;
            }

            var stack = new FixedWidth(320, content);

            AttachChild(new DialogFrame(stack)
            {
                Background = DialogFrameBackgroundStyle.DarkTint
            });
        }
Example #3
0
        public override void WriteXml(XmlWriter writer)
        {
            if (Queryable)
            {
                writer.WriteAttributeString("queryable", "1");
            }
            if (Cascaded > 0)
            {
                writer.WriteAttributeString("cascaded", Cascaded.ToString(NumberFormatInfo.InvariantInfo));
            }
            if (Opaque)
            {
                writer.WriteAttributeString("opaque", "1");
            }
            if (NoSubsets)
            {
                writer.WriteAttributeString("noSubsets", "1");
            }
            if (FixedWidth > 0)
            {
                writer.WriteAttributeString("fixedWidth", FixedWidth.ToString(NumberFormatInfo.InvariantInfo));
            }
            if (FixedHeight > 0)
            {
                writer.WriteAttributeString("fixedHeight", FixedHeight.ToString(NumberFormatInfo.InvariantInfo));
            }

            if (!string.IsNullOrEmpty(Name))
            {
                writer.WriteElementString("Name", Namespace, Name);
            }
            writer.WriteElementString("Title", Namespace, Title);
            if (!string.IsNullOrEmpty(Abstract))
            {
                writer.WriteElementString("Abstract", Namespace, Abstract);
            }
            WriteXmlItem("KeywordList", Namespace, writer, _keywordListField);
            WriteXmlList("CRS", Namespace, writer, _crsField);
            WriteXmlList("SRS", Namespace, writer, _srsField);
            WriteXmlItem("EX_GeographicBoundingBox", Namespace, writer, ExGeographicBoundingBox);
            WriteXmlList("BoundingBox", Namespace, writer, BoundingBox);
            WriteXmlList("Dimension", Namespace, writer, Dimension);
            WriteXmlItem("Attribution", Namespace, writer, Attribution);
            WriteXmlList("AuthorityURL", Namespace, writer, AuthorityURL);
            WriteXmlList("Identifier", Namespace, writer, Identifier);
            WriteXmlList("MetadataURL", Namespace, writer, MetadataURL);
            WriteXmlList("DataURL", Namespace, writer, DataURL);
            WriteXmlList("FeatureListURL", Namespace, writer, DataURL);
            WriteXmlList("Style", Namespace, writer, Style);
            if (MinScaleDenominator.HasValue)
            {
                writer.WriteElementString("MinScaleDenominator", Namespace, MinScaleDenominator.Value.ToString(NumberFormatInfo.InvariantInfo));
            }
            if (MaxScaleDenominator.HasValue)
            {
                writer.WriteElementString("MaxScaleDenominator", Namespace, MaxScaleDenominator.Value.ToString(NumberFormatInfo.InvariantInfo));
            }
            WriteXmlList("Layer", Namespace, writer, ChildLayers);
        }
Example #4
0
        public void GetFormattedTableTest()
        {
            var table = FixedWidth.GetFormattedTable();

            Assert.AreEqual(table[0], "| Pub Date    |                       Title | Authors                         |");
            Assert.AreEqual(table[1], "|=============================================================================|");
            Assert.AreEqual(table[2], "| 28 Nov 2008 |             Learning C# 3.0 | Jesse Liberty & Brian MacDonald |");
            Assert.AreEqual(table[3], "| 16 Sep 2013 |               Head First C# | Jennifer Greene & Andrew Ste... |");
            Assert.AreEqual(table[4], "| 27 Oct 2015 | Learn C# in One Day and ... | Jamie Chan                      |");
        }
Example #5
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Family != null?Family.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ (Weight != null ? Weight.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ Italics.GetHashCode();
                hashCode = (hashCode * 397) ^ Size.GetHashCode();
                hashCode = (hashCode * 397) ^ FixedWidth.GetHashCode();
                return(hashCode);
            }
        }
        /// <summary>
        /// Returns true if AccountManagerColumn instances are equal
        /// </summary>
        /// <param name="other">Instance of AccountManagerColumn to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(AccountManagerColumn other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Title == other.Title ||
                     Title != null &&
                     Title.Equals(other.Title)
                 ) &&
                 (
                     Tooltip == other.Tooltip ||
                     Tooltip != null &&
                     Tooltip.Equals(other.Tooltip)
                 ) &&
                 (
                     FixedWidth == other.FixedWidth ||
                     FixedWidth != null &&
                     FixedWidth.Equals(other.FixedWidth)
                 ) &&
                 (
                     Sortable == other.Sortable ||
                     Sortable != null &&
                     Sortable.Equals(other.Sortable)
                 ));
        }
Example #7
0
    /// <summary>
    /// Reloads the control data.
    /// </summary>
    /// <param name="forceReload">Force the reload of the control</param>
    public override void ReloadData(bool forceReload)
    {
        if (StopProcessing)
        {
            plcPager.Visible      = false;
            ltlBeforeRows.Visible = false;
        }
        else
        {
            base.ReloadData(forceReload);
            SetPageSize(forceReload);

            // Clear filter if forced reload
            if (forceReload)
            {
                this.txtFilter.Text = "";
                this.FilterWhere    = null;
            }

            if (forceReload || (!mLoaded && !this.StopProcessing))
            {
                StringBuilder sb = new StringBuilder();

                // Prepare the order by
                string orderBy = this.OrderBy;
                if (orderBy == null)
                {
                    orderBy = this.RowItemDisplayNameColumn + " ASC";
                    // Add additional sorting by codename for equal displaynames
                    if (!String.IsNullOrEmpty(this.RowItemCodeNameColumn))
                    {
                        orderBy += ", " + this.RowItemCodeNameColumn;
                    }

                    if (this.ColumnsCount > 1)
                    {
                        orderBy += ", " + this.ColumnItemDisplayNameColumn + " ASC";
                    }
                }

                int currentPage = pagerElem.UniPager.CurrentPage;
                string where = SqlHelperClass.AddWhereCondition(this.WhereCondition, this.FilterWhere);

                bool headersOnly = false;
                bool hasData     = false;
                mTotalRows = 0;

                ArrayList columns = null;

                // Load the data
                while (true)
                {
                    // Get specific page
                    int pageItems = this.ColumnsCount * this.pagerElem.UniPager.PageSize;
                    ds = ConnectionHelper.ExecuteQuery(this.QueryName, this.QueryParameters, where, orderBy, 0, null, (currentPage - 1) * pageItems, pageItems, ref mTotalRows);

                    hasData = !DataHelper.DataSourceIsEmpty(ds);

                    // If no records found, get the records for the original dataset
                    if (!hasData && !String.IsNullOrEmpty(FilterWhere))
                    {
                        // Get only first line
                        ds          = ConnectionHelper.ExecuteQuery(this.QueryName, this.QueryParameters, this.WhereCondition, orderBy, this.ColumnsCount);
                        hasData     = !DataHelper.DataSourceIsEmpty(ds);
                        headersOnly = true;
                    }

                    // Load the list of columns
                    if (hasData)
                    {
                        if (DataLoaded != null)
                        {
                            DataLoaded(ds);
                        }

                        columns          = DataHelper.GetUniqueRows(ds.Tables[0], this.ColumnItemIDColumn);
                        ColumnOrderIndex = GetColumnIndexes(columns, ColumnsPreferedOrder);

                        // If more than current columns count found, and there is more data, get the correct data again
                        if ((columns.Count <= this.ColumnsCount) || (mTotalRows < pageItems))
                        {
                            break;
                        }
                        else
                        {
                            this.ColumnsCount = columns.Count;
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                if (hasData)
                {
                    bool manyColumns = columns.Count >= 10;

                    string imagesUrl = GetImageUrl("Design/Controls/UniMatrix/", IsLiveSite, true);

                    string firstColumnsWidth = (FirstColumnsWidth > 0) ? "width:" + this.FirstColumnsWidth + (UsePercentage ? "%;" : "px;") : "";

                    if (!headersOnly)
                    {
                        // Register the scripts
                        string script =
                            "var umImagesUrl = '" + GetImageUrl("Design/Controls/UniMatrix/", IsLiveSite, true) + "';" +
                            "function UM_ItemChanged_" + this.ClientID + "(item) {" + this.Page.ClientScript.GetCallbackEventReference(this, "item.id + ':' + (item.src.indexOf('denied.png') >= 0)", "UM_ItemSaved_" + this.ClientID, "item.id") + "; } \n" +
                            "function UM_ItemSaved_" + this.ClientID + "(rvalue, context) { var elem = document.getElementById(context); var values=rvalue.split('|'); \nif (values[0] == 'true') { elem.src = umImagesUrl + 'allowed.png'; } else { elem.src = umImagesUrl + 'denied.png'; } var contentBefore = $j(\"#contentbeforerows_" + ClientID + "\"); if(contentBefore){ contentBefore.empty().append(values[1]);}}";

                        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "UniMatrix_" + this.ClientID, ScriptHelper.GetScript(script));
                    }

                    // Render header
                    this.ltlBeforeFilter.Text = "<tr class=\"UniGridHead\" align=\"left\"><th style=\"" + firstColumnsWidth + "white-space:nowrap;\" scope=\"col\"><div class=\"UniMatrixFilter\">";

                    StringBuilder headersb = new StringBuilder();

                    headersb.Append("</div></th>");

                    string width = (FixedWidth > 0) ? "width:" + FixedWidth.ToString() + (UsePercentage ? "%;" : "px;") : "";

                    // Render matrix header
                    foreach (int index in ColumnOrderIndex)
                    {
                        DataRow dr = (DataRow)columns[index];

                        if (this.ShowHeaderRow)
                        {
                            string header = HTMLHelper.HTMLEncode(CMSContext.ResolveMacros(Convert.ToString(dr[this.ColumnItemDisplayNameColumn])));

                            headersb.Append("<th scope=\"col\" style=\"text-align: center;");
                            if (!manyColumns)
                            {
                                headersb.Append(" white-space: nowrap;");
                                header = header.Replace(" ", "&nbsp;").Replace("-", "&minus;");
                            }
                            else
                            {
                                headersb.Append(" padding: 2px 7px 2px 5px;");
                            }

                            headersb.Append(" " + width + "\"");
                            if (this.ColumnItemTooltipColumn != null)
                            {
                                headersb.Append(" title=\"", GetTooltip(dr, this.ItemTooltipColumn), "\"");
                            }

                            // Disabled mark
                            object columnValue = dr[this.ColumnItemIDColumn];
                            if (!IsColumnEditable(columnValue))
                            {
                                header += DisabledColumnMark;
                            }

                            headersb.Append(">", header, "</th>\n");
                        }
                        else
                        {
                            headersb.Append("<th scope=\"col\" style=\"text-align: center; ", width, "\">&nbsp;</td>");
                        }
                    }

                    // Set the correct number of columns
                    this.ColumnsCount = columns.Count;
                    mTotalRows        = mTotalRows / this.ColumnsCount;

                    if (!manyColumns)
                    {
                        headersb.Append("<th ", (LastColumnFullWidth ? "style=\"width:100%;\" " : ""), ">&nbsp;</th>");
                    }
                    headersb.Append("</tr>");

                    ltlAfterFilter.Text = headersb.ToString();

                    if (!headersOnly)
                    {
                        string lastId   = "";
                        int    colIndex = 0;
                        int    rowIndex = 0;

                        bool evenRow = true;

                        // Render matrix rows
                        int step = columns.Count;
                        for (int i = 0; i < ds.Tables[0].Rows.Count; i = i + step)
                        {
                            foreach (int index in ColumnOrderIndex)
                            {
                                DataRow dr = (DataRow)ds.Tables[0].Rows[i + index];

                                string id = ValidationHelper.GetString(dr[this.RowItemIDColumn], "");
                                if (id != lastId)
                                {
                                    if ((ItemsPerPage > 0) && (rowIndex++ >= this.ItemsPerPage))
                                    {
                                        break;
                                    }

                                    // New row
                                    if (lastId != "")
                                    {
                                        // Close the previous row
                                        if (!manyColumns)
                                        {
                                            sb.Append("<td style=\"white-space:nowrap;\">&nbsp;</td>");
                                        }
                                        sb.Append("</tr>");
                                    }
                                    sb.Append("<tr class=\"", (evenRow ? "EvenRow" : "OddRow"), GetAdditionalCssClass(dr), "\"><td class=\"MatrixHeader\" style=\"", firstColumnsWidth, "white-space:nowrap;\"");
                                    if (this.RowItemTooltipColumn != null)
                                    {
                                        sb.Append(" title=\"", GetTooltip(dr, this.RowItemTooltipColumn), "\"");
                                    }
                                    sb.Append(">");
                                    sb.Append(HTMLHelper.HTMLEncode(CMSContext.ResolveMacros(Convert.ToString(dr[this.RowItemDisplayNameColumn]))));

                                    // Disabled mark
                                    if (!IsRowEditable(id))
                                    {
                                        sb.Append(DisabledRowMark);
                                    }

                                    // Add global suffix if is required
                                    if ((index == 0) && (this.AddGlobalObjectSuffix) && (ValidationHelper.GetInteger(dr[this.SiteIDColumnName], 0) == 0))
                                    {
                                        sb.Append(" " + GetString("general.global"));
                                    }

                                    sb.Append("</td>\n");

                                    lastId   = id;
                                    colIndex = 0;
                                    evenRow  = !evenRow;
                                }

                                object columnValue = dr[this.ColumnItemIDColumn];

                                // Render cell
                                sb.Append("<td style=\"white-space:nowrap; text-align: center;\"><img src=\"");
                                sb.Append(imagesUrl);
                                if (!this.Enabled ||
                                    disabledColumns.Contains(colIndex) ||
                                    !IsColumnEditable(columnValue) ||
                                    !IsRowEditable(id)
                                    )
                                {
                                    // Disabled
                                    if (Convert.ToInt32(dr["Allowed"]) == 1)
                                    {
                                        sb.Append("alloweddisabled.png");
                                    }
                                    else
                                    {
                                        sb.Append("denieddisabled.png");
                                    }
                                }
                                else
                                {
                                    // Enabled
                                    if (Convert.ToInt32(dr["Allowed"]) == 1)
                                    {
                                        sb.Append("allowed.png");
                                    }
                                    else
                                    {
                                        sb.Append("denied.png");
                                    }

                                    sb.Append("\" id=\"chk:", id, ":", columnValue, "\" onclick=\"UM_ItemChanged_", this.ClientID, "(this);");
                                }

                                sb.Append("\" style=\"cursor:pointer;\" title=\"");

                                string tooltip = GetTooltip(dr, this.ItemTooltipColumn);

                                sb.Append(tooltip, "\" alt=\"", tooltip, "\" /></td>\n");

                                colIndex++;
                            }
                        }

                        // Close the latest row if present
                        if (!manyColumns)
                        {
                            sb.Append("<td>&nbsp;</td>");
                        }

                        sb.Append("</tr>");


                        int totalCols = (columns.Count + 2);
                        if (manyColumns)
                        {
                            totalCols--;
                        }

                        this.ltlPagerBefore.Text = "<tr style=\"border:0px none;\"><td style=\"border:0px none;\" colspan=\"" + totalCols + "\">";
                        this.ltlPagerAfter.Text  = "</td></tr>";
                    }
                    else
                    {
                        lblInfoAfter.Text    = this.NoRecordsMessage;
                        lblInfoAfter.Visible = true;
                    }

                    // Show filter / header
                    bool hideFilter = ((this.FilterLimit > 0) && String.IsNullOrEmpty(FilterWhere) && (mTotalRows < this.FilterLimit));
                    this.pnlFilter.Visible = !hideFilter;

                    // Show label in corner if text given and filter is hidden
                    if (hideFilter && !string.IsNullOrEmpty(this.CornerText))
                    {
                        this.ltlBeforeFilter.Text += HTMLHelper.HTMLEncode(this.CornerText);
                    }

                    if (this.ShowFilterRow && !hideFilter)
                    {
                        //this.lblFilter.ResourceString = this.ResourcePrefix + ".entersearch";
                        this.btnFilter.ResourceString = "general.search";
                    }
                    else if (!ShowHeaderRow)
                    {
                        this.plcFilter.Visible = false;
                    }
                }
                else
                {
                    pnlFilter.Visible = false;

                    // If norecords message set, hide everything and show message
                    if (!String.IsNullOrEmpty(this.NoRecordsMessage))
                    {
                        lblInfo.Text             = this.NoRecordsMessage;
                        lblInfo.Visible          = true;
                        ltlMatrix.Visible        = false;
                        ltlContentAfter.Visible  = false;
                        ltlContentBefore.Visible = false;
                    }
                }

                HasData = hasData;

                this.ltlContentBefore.Text = this.ContentBefore;
                this.ltlMatrix.Text        = sb.ToString();
                this.ltlContentAfter.Text  = this.ContentAfter;

                // Show content before rows and pager
                this.plcBeforeRows.Visible = ShowContentBeforeRows && hasData && !headersOnly;
                this.plcPager.Visible      = hasData && !headersOnly;
                if (hasData)
                {
                    // Set correct ID for direct page contol
                    this.pagerElem.DirectPageControlID = ((float)mTotalRows / pagerElem.CurrentPageSize > 20.0f) ? "txtPage" : "drpPage";
                }


                mLoaded = true;

                // Call page binding event
                if (OnPageBinding != null)
                {
                    OnPageBinding(this, null);
                }
            }
        }
    }