public static bool AddParsedSubObjectReplacement(IListControl ctl, object obj)
        {
            if (obj is FixedListItem)
            {
                switch (((FixedListItem)obj).Position)
                {
                case FixedListItemPosition.First:
                    ctl.FixedItemsFirst.Add(obj);
                    break;

                case FixedListItemPosition.Last:
                    ctl.FixedItemsLast.Add(obj);
                    break;

                default:
                    throw new InvalidOperationException("Invalid FixedListItem position.");
                }
                return(true);
            }
            else if (obj is ListItem)
            {
                ctl.Items.Add((ListItem)obj);
                return(true);
            }
            else
            {
                return(false);
            }
        }
		public static bool AddParsedSubObjectReplacement(IListControl ctl, object obj)
		{
			if (obj is FixedListItem) 
			{
				switch (((FixedListItem) obj).Position)
				{
					case FixedListItemPosition.First:
						ctl.FixedItemsFirst.Add(obj);
						break;
					case FixedListItemPosition.Last:
						ctl.FixedItemsLast.Add(obj);
						break;
					default:
						throw new InvalidOperationException("Invalid FixedListItem position.");
				}
				return true;
			}
			else if (obj is ListItem) 
			{
				ctl.Items.Add((ListItem) obj);
				return true;
			}
			else
				return false;
		}
Example #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        int entityTypeValue = 0;

        Int32.TryParse(Request.QueryString["EntityType"], out entityTypeValue);
        if (Enum.IsDefined(typeof(EntityType), entityTypeValue))
        {
            _selectedEntityType = (EntityType)entityTypeValue;
            _entityTypeDefined  = true;
        }

        if (_entityTypeDefined)
        {
            // load list control for given entity.
            Control controlToAdd = Page.LoadControl("~/Controls/List" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + "Instances.ascx");
            _lister = controlToAdd as IListControl;
            if (_lister != null)
            {
                phListControls.Controls.Add(controlToAdd);
            }
            phListArea.Visible = false;

            // load search control
            controlToAdd = Page.LoadControl("~/Controls/Search" + GeneralUtils.EntityTypeToEntityName(_selectedEntityType) + ".ascx");
            _searcher    = controlToAdd as ISearchControl;
            if (_searcher != null)
            {
                _searcher.AllowSingleEntitySearches = false;
                _searcher.AllowMultiEntitySearches  = true;
                _searcher.SearchClicked            += new EventHandler(searcher_SearchClicked);
                phSearchControls.Controls.Add(controlToAdd);
                phSearchArea.Visible = true;
            }

            bool?showSearchArea = (bool?)ViewState["showSearchArea"];
            if (showSearchArea.HasValue)
            {
                // stored in viewstate, show the correct area.
                phSearchArea.Visible = showSearchArea.Value;
                phListArea.Visible   = !showSearchArea.Value;
            }
        }

        if (!Page.IsPostBack)
        {
            if (_entityTypeDefined)
            {
                this.Title        += _selectedEntityType.ToString() + " instances";
                lblEntityName.Text = GeneralUtils.EntityTypeToEntityName(_selectedEntityType);
            }

            // check for user info
            if (SessionHelper.GetUserID() == string.Empty)
            {
                Response.Redirect("Login.aspx");
            }
        }
    }
        /// <summary>
        /// Construcst the SelectorControlBinder with the Selector Control.
        /// </summary>
        /// <param name="listControl"></param>
        public HabaneroSelectorControlBinder(TControlType listControl)
        {
            _controlAdaptorFactory = new WinFormsControlAdaptorFactory();
            ControlBinders         = new List <HabaneroControlBinder <TBo> >();

            _lstControl      = _controlAdaptorFactory.GetHabaneroControl(listControl) as IListControl;
            _selectorManager = CreateBoColSelector(ListControl);
            _selectorManager.BusinessObjectSelected += OnBusinessObjectSelected;
        }
Example #5
0
        public virtual void DrawItemImage(IListControl parent, ListControlDrawItemEventArgs e)
        {
            if (e.Image == null)
            {
                return;
            }
            Size size = e.Image.Size;

            e.Graphics.DrawImage(e.Image, e.Bounds.Left + e.Offset, e.Bounds.Top + (e.Bounds.Height - size.Height) / 2,
                                 size.Width, size.Height);
            e.Offset += size.Width + parent.Padding.Left;
        }
Example #6
0
        public virtual SizeF MeasureItem(IListControl parent, Graphics g, ImageComboItem item)
        {
            TextFormatFlags flags  = GetFlags(parent, item.Text);
            SizeF           sizeF1 = TextRenderer.MeasureText(g, item.Text, parent.Font, parent.ClientSize, flags);
            SizeF           sizeF2 = item.Image != null ? item.Image.Size : SizeF.Empty;

            if (sizeF1.Height < (double)parent.DefaultItemHeight)
            {
                sizeF1.Height = parent.DefaultItemHeight;
            }
            return(new SizeF(Math.Max(sizeF1.Width, sizeF2.Width),
                             Math.Max(Math.Max(sizeF1.Height, sizeF2.Height), parent.DefaultItemHeight)));
        }
Example #7
0
 public virtual void DrawItemBackground(IListControl parent, ListControlDrawItemEventArgs e)
 {
     using (
         Brush brush =
             new SolidBrush(!EnumExtensions.HasFlag(e.State, DrawItemState.HotLight) ||
                            EnumExtensions.HasFlag(e.State, DrawItemState.Selected) || !AllowHotTrack
                 ? (!parent.Enabled || EnumExtensions.HasFlag(e.State, DrawItemState.Selected)
                     ? (!parent.Enabled ||
                        !parent.IsDroppedDown && parent.HideSelection &&
                        (!EnumExtensions.HasFlag(e.State, DrawItemState.Focus) && parent.FullRowSelect)
                         ? SystemColors.Control
                         : parent.HighlightBackColor)
                     : parent.BackColor)
                 : parent.HotTrackColor))
         e.Graphics.FillRectangle(brush, e.Bounds);
 }
Example #8
0
        public virtual void DrawItemText(IListControl parent, ListControlDrawItemEventArgs e)
        {
            int             num       = Math.Max(2, parent.Padding.Right);
            int             width     = e.Bounds.Width - (e.Offset + num);
            TextFormatFlags flags     = GetFlags(parent, e.Item.Text);
            var             rectangle = new Rectangle(e.Bounds.X + e.Offset, e.Bounds.Y,
                                                      TextRenderer.MeasureText(e.Graphics, e.Item.Text, e.Font, new Size(width, e.Bounds.Height)).Width + num,
                                                      e.Bounds.Height);

            if (rectangle.Width > width)
            {
                rectangle.Width = width;
            }
            Color foreColor;

            if (EnumExtensions.HasFlag(e.State, DrawItemState.Selected))
            {
                Color color;
                if (!parent.IsDroppedDown && parent.HideSelection &&
                    !EnumExtensions.HasFlag(e.State, DrawItemState.Focus))
                {
                    color     = SystemColors.Control;
                    foreColor = parent.ForeColor;
                }
                else
                {
                    color     = parent.HighlightBackColor;
                    foreColor = parent.HighlightForeColor;
                }
                if (!parent.FullRowSelect)
                {
                    using (Brush brush = new SolidBrush(color))
                        e.Graphics.FillRectangle(brush, rectangle);
                }
            }
            else
            {
                foreColor = parent.Enabled ? parent.ForeColor : SystemColors.GrayText;
            }
            TextRenderer.DrawText(e.Graphics, e.Item.Text, e.Font, rectangle, foreColor, flags);
            if (!EnumExtensions.HasFlag(e.State, DrawItemState.Focus) ||
                EnumExtensions.HasFlag(e.State, DrawItemState.NoFocusRect))
            {
                return;
            }
            ControlPaint.DrawFocusRectangle(e.Graphics, parent.FullRowSelect ? e.Bounds : rectangle);
        }
		public static void InsertFixedItems(IListControl ctl)
		{
			int i = 0;
			int prevIndex = (ctl is DropDownList ? ((DropDownList) ctl).SelectedIndex : -1);
			foreach (FixedListItem li in ctl.FixedItemsFirst)
			{
				ListItem newItem = new ListItem(li.Text, li.Value);
				newItem.Selected = false;
				ctl.Items.Insert(i++, newItem);
			}

			foreach (FixedListItem li in ctl.FixedItemsLast)
			{
				ListItem newItem = new ListItem(li.Text,  li.Value);
				newItem.Selected = false;
				ctl.Items.Add(newItem);
			}

			if (ctl is DropDownList)
				((DropDownList) ctl).SelectedIndex = prevIndex + i;
		}
Example #10
0
        protected virtual TextFormatFlags GetFlags(IListControl parent, string text)
        {
            TextFormatFlags textFormatFlags1 = TextFormatFlags.NoPrefix | TextFormatFlags.VerticalCenter |
                                               TextFormatFlags.WordEllipsis;
            TextFormatFlags textFormatFlags2;

            if (!parent.WordWrap)
            {
                if (text.IndexOfAny(new char[2]
                {
                    '\n',
                    '\r'
                }) == -1)
                {
                    textFormatFlags2 = textFormatFlags1 | TextFormatFlags.SingleLine;
                    goto label_4;
                }
            }
            textFormatFlags2 = textFormatFlags1 | TextFormatFlags.WordBreak;
label_4:
            return(textFormatFlags2);
        }
Example #11
0
        private Control GetEditControl(PropertyInfo property, ModulePropertyAttribute attribute)
        {
            string name = property.Name;

            if (PropertyValues.ContainsKey(name))
            {
                attribute.DefaultValue = PropertyValues[name];
            }

            PortalControl editControl = attribute.GetEditControl(property.PropertyType);

            editControl.ID = name;
            string value = Context.Request.Form[name];

            if (value != null)
            {
                ITextControl textControl = editControl as ITextControl;
                if (textControl != null)
                {
                    textControl.Text = value;
                    return(editControl);
                }

                IListControl listControl = editControl as IListControl;
                if (listControl != null)
                {
                    ListItem item = listControl.Items.FindByValue(value);
                    if (item != null)
                    {
                        item.Selected = true;
                    }
                    return(editControl);
                }
            }

            return(editControl);
        }
        public static void InsertFixedItems(IListControl ctl)
        {
            int i         = 0;
            int prevIndex = (ctl is DropDownList ? ((DropDownList)ctl).SelectedIndex : -1);

            foreach (FixedListItem li in ctl.FixedItemsFirst)
            {
                ListItem newItem = new ListItem(li.Text, li.Value);
                newItem.Selected = false;
                ctl.Items.Insert(i++, newItem);
            }

            foreach (FixedListItem li in ctl.FixedItemsLast)
            {
                ListItem newItem = new ListItem(li.Text, li.Value);
                newItem.Selected = false;
                ctl.Items.Add(newItem);
            }

            if (ctl is DropDownList)
            {
                ((DropDownList)ctl).SelectedIndex = prevIndex + i;
            }
        }
Example #13
0
 protected ListControl(Generator g, Type type, bool initialize = true)
     : base(g, type, initialize)
 {
     handler = (IListControl)base.Handler;
 }
 internal /*public*/ ListDataHelper(IListControl parent, StateBag parentViewState)
 {
     _parent = parent;
     _parentViewState = parentViewState;
 }
Example #15
0
 internal /*public*/ ListDataHelper(IListControl parent, StateBag parentViewState)
 {
     _parent          = parent;
     _parentViewState = parentViewState;
 }
Example #16
0
 public virtual void Bind(IListControl parent)
 {
 }
			public NormalizeControlNames(IListControl ctl)
				: this((Control) ctl) { }
 public NormalizeControlNames(IListControl ctl)
     : this((Control)ctl)
 {
 }