/// <summary>
 /// Initializes a new instance of the <see cref="EhfaStructureType" /> class.
 /// </summary>
 /// <param name="other">The other structure type.</param>
 /// <param name="dataPlacement">The data placement mode.</param>
 private EhfaStructureType(EhfaStructureType other, DataPlacement dataPlacement)
 {
     Items         = other.Items;
     DataPlacement = dataPlacement;
     ItemName      = other.ItemName;
     Dictionary    = other.Dictionary;
 }
        public virtual IHtmlString Tooltip(string title, DataPlacement placement, bool isHtml = false)
        {
            var placementStr = string.Empty;

            switch (placement)
            {
            case DataPlacement.right:
                placementStr = "data-placement=\"right\"";
                break;

            case DataPlacement.bottom:
                placementStr = "data-placement=\"bottom\"";
                break;

            case DataPlacement.left:
                placementStr = "data-placement=\"left\"";
                break;

            default:
                break;
            }
            var result = $"data-toggle=\"tooltip\" {(isHtml ? "data-html=\"true\"" : string.Empty)} {placementStr} title={title}";

            return(new HtmlString(result));
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="EhfaPrimitiveType" /> class.
 /// </summary>
 /// <param name="itemName">The item name.</param>
 /// <param name="itemNumber">The item number.</param>
 /// <param name="placement">The data placement mode.</param>
 /// <param name="enumItems">The list of items in the enumeration.</param>
 public EhfaPrimitiveType(String itemName, Int32 itemNumber, DataPlacement placement, IReadOnlyList <String> enumItems)
 {
     ItemType      = ItemType.Enum;
     ItemName      = itemName;
     ItemNumber    = itemNumber;
     DataPlacement = placement;
     EnumItems     = enumItems;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="EhfaPrimitiveType" /> class.
 /// </summary>
 /// <param name="itemName">The item name.</param>
 /// <param name="itemNumber">The item number.</param>
 /// <param name="itemType">The item type.</param>
 /// <param name="placement">The data placement mode.</param>
 public EhfaPrimitiveType(String itemName, Int32 itemNumber, ItemType itemType, DataPlacement placement)
 {
     ItemType      = itemType;
     ItemName      = itemName;
     ItemNumber    = itemNumber;
     DataPlacement = placement;
     EnumItems     = null;
 }
        /// <summary>
        /// Parses the item definitions.
        /// </summary>
        /// <param name="definitions">The item definitions.</param>
        private void ParseItemDefinitions(String definitions)
        {
            Items = new OrderedDictionary();

            Int32 index = 0;

            while (index < definitions.Length)
            {
                Int32         itemNumber = GetItemNumber(definitions, ref index);
                DataPlacement placement  = GetDataPlacement(definitions, ref index);
                ItemType      itemType   = GetItemType(definitions, ref index);

                List <String>   enumItems      = null;
                IEhfaObjectType ehfaObjectType = null;

                if (itemType == ItemType.Enum)
                {
                    enumItems = GetEnumItems(definitions, ref index);
                }

                if (itemType == ItemType.PreviouslyDefined)
                {
                    ehfaObjectType = GetPreviouslyDefinedObjectType(definitions, placement, ref index);
                }

                if (itemType == ItemType.FollowedDefined)
                {
                    ehfaObjectType = GetFollowingDefinedObjectType(definitions, ref index);
                }

                String itemName = GetItemName(definitions, ref index);

                if (ehfaObjectType == null)
                {
                    if (itemType == ItemType.Enum)
                    {
                        ehfaObjectType = new EhfaPrimitiveType(itemName, itemNumber, placement, enumItems);
                    }
                    else
                    {
                        ehfaObjectType = new EhfaPrimitiveType(itemName, itemNumber, itemType, placement);
                    }
                }

                Items.Add(itemName, ehfaObjectType);
            }
        }
        /// <summary>
        /// Returns the data placement mode.
        /// </summary>
        /// <param name="definition">The item definitions.</param>
        /// <param name="index">The zero-based index of the placement within the definition.</param>
        /// <returns>The data placement mode.</returns>
        private DataPlacement GetDataPlacement(String definition, ref Int32 index)
        {
            DataPlacement placement = DataPlacement.Internal;

            if (definition[index] == 'p')
            {
                placement = DataPlacement.ExternalDynamicSize;
                index++;
            }
            else if (definition[index] == '*')
            {
                placement = DataPlacement.ExternalFixedSize;
                index++;
            }

            return(placement);
        }
        /// <summary>
        /// Gets the type of a structure that was previously defined.
        /// </summary>
        /// <param name="definitions">The item definitions.</param>
        /// <param name="index">The zero-based index of the type within the definition.</param>
        /// <param name="placement">The data placement mode.</param>
        /// <returns>The structure type.</returns>
        private IEhfaObjectType GetPreviouslyDefinedObjectType(String definitions, DataPlacement placement, ref Int32 index)
        {
            if (Dictionary == null)
            {
                return(null);
            }

            Int32  endIndex = definitions.IndexOf(',', index);
            String typeName = definitions.Substring(index, endIndex - index);

            index = endIndex + 1;

            if (!Dictionary.ContainsKey(typeName))
            {
                return(null);
            }

            return(new EhfaStructureType(Dictionary[typeName], placement));
        }
Exemple #8
0
 public static MvcHtmlString PersianFromToDatePickerItem(this HtmlHelper htmlHelper, DataPlacement datePickerPlacement = DataPlacement.Bottom)
 {
     return(htmlHelper.PersianFromToDatePickerItem(null, null, false, datePickerPlacement));
 }
Exemple #9
0
        public static MvcHtmlString PersianFromToDatePickerItem(this HtmlHelper htmlHelper, string fromId, string toId, bool hasTime, DataPlacement datePickerPlacement = DataPlacement.Bottom)
        {
            fromId = fromId ?? Guid.NewGuid().ToString();
            toId   = toId ?? Guid.NewGuid().ToString();
            var groupid = Guid.NewGuid();
            var div     = new TagBuilder("div");

            div.AddCssClass("row");

            div.InnerHtml = $@"<div class='col-xs-6'>
                                    <div class='input-group'>
                                        <div class='input-group-addon' data-MdDateTimePicker='true' data-trigger='click' data-targetselector='#{toId}' data-groupid='group1' data-todate='true' data-enabletimepicker='{hasTime.ToString().ToLower()}' data-placement='{datePickerPlacement.ToString().ToLower()}'>
                                            <span class='glyphicon glyphicon-calendar'></span>
                                        </div>
                                        <input style='text-align: center;' type='text' class='form-control' id='{toId}' placeholder='تا تاریخ' data-MdDateTimePicker='true' data-Trigger='focus' data-targetselector='#{toId}' data-enabletimepicker='{hasTime.ToString().ToLower()}' data-groupid='{groupid}' data-todate='true'  data-placement='{datePickerPlacement.ToString().ToLower()}' />
                                    </div>
                                </div>
                                <div class='col-xs-6'>
                                    <div class='input-group'>
                                        <div class='input-group-addon' data-MdDateTimePicker='true' data-trigger='click' data-targetselector='#{fromId}' data-groupid='{groupid}' data-fromdate='true' data-enabletimepicker='{hasTime.ToString().ToLower()}' data-placement='{datePickerPlacement.ToString().ToLower()}'>
                                            <span class='glyphicon glyphicon-calendar'></span>
                                        </div>
                                        <input style='text-align: center;' type='text' class='form-control' id='{fromId}' placeholder='از تاریخ' data-MdDateTimePicker='true' data-Trigger='focus' data-targetselector='#{fromId}' data-groupid='{groupid}' data-fromdate='true' data-enabletimepicker='{hasTime.ToString().ToLower()}' data-placement='{datePickerPlacement.ToString().ToLower()}' />
                                    </div>
                                </div>";

            return(MvcHtmlString.Create(div.ToString()));
        }
Exemple #10
0
 public static MvcHtmlString PersianDatePickerItem(this HtmlHelper htmlHelper, bool hasTime, DataPlacement datePickerPlacement = DataPlacement.Bottom)
 {
     return(htmlHelper.PersianDatePickerItem(null, hasTime, datePickerPlacement));
 }