示例#1
0
        private void ProcessBlock(ContainerGlobals globals, XmlNode valueNode, IFieldControl fieldControl, string fullPropertyName)
        {
            int maxDepth = globals.MaxDepth;

            IBlockControl blockControl = fieldControl as IBlockControl;

            if (valueNode.Attributes["maxelements"] != null)
            {
                blockControl.MaxBlockCount = Convert.ToInt32(valueNode.Attributes["maxelements"].Value);
            }
            else
            {
                blockControl.MaxBlockCount = -1;
            }
            // At this point, we need to recurse and create the sub control for this block.
            // Step 1: Locate the proper struct in the document and construct it's full path.
            string  structName = valueNode.Attributes["struct"].InnerText;
            XmlNode structNode = tagDefinition.SelectSingleNode("//struct[@name='" + structName + "']");

            Controls.BlockContainer fieldControlContainer = new Controls.BlockContainer();
            fieldControlContainer.Globals = new ContainerGlobals(globals, structNode, maxDepth);
            InitContainer(fieldControlContainer);
            fieldControlContainer.ContainerName     = StringOps.CapitalizeWords(fieldControl.Title);
            fieldControlContainer.FooterText        = "End of '" + fieldControlContainer.ContainerName + "' Block";
            fieldControlContainer.BoundPropertyName = fullPropertyName;
            //fieldControlContainer.Block.BlockChanged += new BlockChangedHandler();

            // add the IBlockControl
            fieldControlContainer.AddField(fieldControl);

            containers.Peek().AddFieldContainer(fieldControlContainer);

            // Step 3: Wire up the BlockChanged event for databinding.
            blockControl.Initialize();
        }
示例#2
0
        public static bool IsShowInList(IFieldControl control, Tk5ListDetailConfig listDetail,
                                        FieldKind kind, IPageStyle style, bool isInTable)
        {
            if (control == null)
            {
                return(false);
            }
            if ((control.DefaultShow & PageStyle.List) != PageStyle.List ||
                kind != FieldKind.Data)
            {
                return(false);
            }

            if (isInTable)
            {
                var ctrl = control.GetControl(style);
                if (ctrl == ControlType.Hidden)
                {
                    return(false);
                }
                if (listDetail != null && listDetail.Search == FieldSearchMethod.Only)
                {
                    return(false);
                }
            }

            return(true);
        }
        /// <summary>
        /// Gets all the controls being hosted by the group box
        /// </summary>
        private List <Control> GetChildControls(Panel currentPanel)
        {
            List <Control> controls = new List <Control>();

            if (this.field != null && this.field is OptionField)
            {
                return(controls);
            }
            else if (this.field != null)
            {
                String[] names = ((GroupField)this.Field).ChildFieldNames.Split(new char[] { ',' });

                foreach (Control pageControl in currentPanel.Controls)
                {
                    IFieldControl fieldControl = pageControl as IFieldControl;

                    if (fieldControl != null)
                    {
                        foreach (String name in names)
                        {
                            if (fieldControl.Field.Name == name)
                            {
                                controls.Add(pageControl);
                            }
                        }
                    }
                }
            }
            childControls = controls;
            return(controls);
        }
        protected override void CreateChildControls()
        {
            Control child = this.Page.LoadControl("~/Controls/FieldControl/" + this.ControlType.ToString() + ".ascx");

            child.ID = "EasyOne2007";
            if (this.IsAdminManage)
            {
                this.Visible = RolePermissions.AccessCheckFieldPermission(OperateCode.ContentFieldInput, DataConverter.CLng(HttpContext.Current.Request.QueryString["ModelId"]), this.FieldName);
            }
            else
            {
                this.Visible = UserPermissions.AccessCheck(OperateCode.ContentFieldInput, DataConverter.CLng(HttpContext.Current.Request.QueryString["ModelId"]), this.FieldName);
            }
            this.m_FieldControl               = (IFieldControl)child;
            this.m_FieldControl.Settings      = this.Settings;
            this.m_FieldControl.EnableNull    = this.EnableNull;
            this.m_FieldControl.FieldAlias    = this.FieldAlias;
            this.m_FieldControl.FieldLevel    = this.FieldLevel;
            this.m_FieldControl.FieldName     = this.FieldName;
            this.m_FieldControl.Tips          = this.Tips;
            this.m_FieldControl.Description   = this.Description;
            this.m_FieldControl.ControlType   = this.ControlType;
            this.m_FieldControl.IsAdminManage = this.IsAdminManage;
            this.m_FieldControl.InitFieldControl();
            this.Controls.Add(child);
        }
        //protected string GetData(IRelationView view)
        //{
        //    if (!(view?.Controls?.Any()).GetValueOrDefault())
        //    {
        //        throw new ArgumentNullException(nameof(view.Controls));
        //    }

        //    if (view.RelationType == null)
        //    {
        //        throw new ArgumentNullException(nameof(view.RelationType));
        //    }

        //    var select = view.Controls.OfType<IFieldControl>().Select(x => GetData((dynamic)x));
        //    var from = view.RelationType.Code;
        //    var innerJoins = view.Controls.OfType<FieldControl>().Where(x => x.Field.EntityType != view.EntityType).Select(x => x.Field.EntityType).Distinct();
        //    var where = new List<string>();

        //    return $"SELECT {string.Join(", ", select)} FROM {from} {string.Join(" ", innerJoins.Select(x => $"INNER JOIN {x.Code} ON {x.Code}.id = {view.EntityType.Code}.id"))}";
        //}

        protected string GetData(IFieldControl control)
        {
            if (control == null)
            {
                throw new ArgumentNullException(nameof(control));
            }

            return(GetData((dynamic)control.Field));
        }
示例#6
0
 public void AddField(IFieldControl field)
 {
     if (field is IBlockControl)
     {
         SetBlockControl(field as IBlockControl);
     }
     else if (fieldPanel != null)
     {
         FieldPanel.AddField(field);
     }
 }
示例#7
0
        public static void AddWatcher([NotNull] IFieldControl field, [NotNull] string value, [NotNull] string caption, [NotNull] string fileType, [NotNull] Action <string> edited)
        {
            Assert.ArgumentNotNull(field, nameof(field));
            Assert.ArgumentNotNull(value, nameof(value));
            Assert.ArgumentNotNull(caption, nameof(caption));
            Assert.ArgumentNotNull(fileType, nameof(fileType));
            Assert.ArgumentNotNull(edited, nameof(edited));

            var watcher = AppHost.Files.EditText(value, caption, fileType, edited);

            Watchers.Add(new Tuple <IFieldControl, FileSystemWatcher>(field, watcher.Item2));
        }
示例#8
0
        public SimpleFieldControl(IFieldControl control, IPageStyle style)
        {
            fStyle     = style.Style;
            Order      = control.GetOrder(style);
            SrcControl = control.GetControl(style);
            var customCtrl = control.GetCustomControl(style);

            if (customCtrl != null)
            {
                CustomControl     = customCtrl.Item1;
                CustomControlData = customCtrl.Item2;
            }
        }
示例#9
0
        /// <summary>
        /// Set the position of the control tracker's "handlebars"
        /// </summary>
        private void SetRectangles()
        {
            if (isResizeSelect)
            {
                // do the cast once up top to avoid doing it (potentially) several times below
                IFieldControl control = ((IFieldControl)currentControl);

                int xLeft   = baseRect.X - Square.Width;
                int yTop    = baseRect.Y - Square.Height;
                int xRight  = baseRect.X + baseRect.Width + 1;
                int yBottom = baseRect.Y + baseRect.Height + 1;
                int xMiddle = baseRect.X + (baseRect.Width / 2) - (Square.Width / 2);
                int yMiddle = baseRect.Y + (baseRect.Height / 2) - (Square.Height / 2);

                if (control.Field is Epi.Fields.MultilineTextField ||
                    control.Field is Epi.Fields.ImageField ||
                    control.Field is Epi.Fields.GridField ||
                    control.Field is Epi.Fields.GroupField ||
                    control.Field is Epi.Fields.RelatedViewField ||
                    control.Field is Epi.Fields.CommandButtonField ||
                    control.Field is Epi.Fields.LabelField)
                {
                    //TopLeft
                    SmallRect[0] = new Rectangle(new Point(xLeft, yTop), Square);
                    //TopRight
                    SmallRect[1] = new Rectangle(new Point(xRight, yTop), Square);
                    //BottomLeft
                    SmallRect[2] = new Rectangle(new Point(xLeft, yBottom), Square);
                    //BottomRight
                    SmallRect[3] = new Rectangle(new Point(xRight, yBottom), Square);
                    //TopMiddle
                    SmallRect[4] = new Rectangle(new Point(xMiddle, yTop), Square);
                    //BottomMiddle
                    SmallRect[5] = new Rectangle(new Point(xMiddle, yBottom), Square);
                }

                //LeftMiddle
                SmallRect[6] = new Rectangle(new Point(xLeft, yMiddle), Square);
                //RightMiddle
                SmallRect[7] = new Rectangle(new Point(xRight, yMiddle), Square);
            }

            int side   = Square.Width;
            int width  = currentControl.Width + side + 1;
            int height = currentControl.Height + side + 1;

            FenceRect   = new Rectangle(side / 2, side / 2, width, height);
            ControlRect = new Rectangle(new Point(0, 0), this.Bounds.Size);
        }
示例#10
0
        public static void Reuse([NotNull] string fieldType, [NotNull] IFieldControl control)
        {
            Assert.ArgumentNotNull(fieldType, nameof(fieldType));
            Assert.ArgumentNotNull(control, nameof(control));

            List <IFieldControl> controls;

            if (!fieldControls.TryGetValue(fieldType, out controls))
            {
                controls = new List <IFieldControl>();
                fieldControls[fieldType] = controls;
            }

            controls.Add(control);

            control.GetControl().IsEnabled = true;
        }
示例#11
0
        public static void RemoveWatcher([NotNull] IFieldControl field)
        {
            Assert.ArgumentNotNull(field, nameof(field));

            for (var i = Watchers.Count - 1; i >= 0; i--)
            {
                var tuple = Watchers[i];
                if (tuple.Item1 != field)
                {
                    continue;
                }

                tuple.Item2.EnableRaisingEvents = false;
                tuple.Item2.Dispose();

                Watchers.Remove(tuple);
            }
        }
示例#12
0
        public virtual string GetHtmlControl(IFieldControl field)
        {
            if (field == null)
                return string.Empty;

            var html = string.Empty;

            switch (field.Control)
            {
                case "TextBox":
                    html = string.Format("<input type=\"text\" id=\"{0}\" name=\"{0}\" class=\"form-control\"", field.Code);
                    if (!string.IsNullOrEmpty(field.Value))
                        html += string.Format(" value=\"{0}\"", field.Value);
                    if (field.IsRequired)
                        html += " required";
                    html += ">";
                    break;
                case "DropDownList":
                    break;
            }

            return html;
        }
示例#13
0
        protected override void CreateChildControls()
        {
            string virtualPath = this.ControlPath + this.ControlType.ToString() + ".ascx";

            if (!string.IsNullOrEmpty(this.LoadControlId))
            {
                virtualPath = this.ControlPath + this.LoadControlId + ".ascx";
            }

            System.Web.UI.Control control = this.Page.LoadControl(virtualPath);
            control.ID                    = "singoocmsctr";
            this.fieldControl             = (IFieldControl)control;
            this.fieldControl.ControlType = this.ControlType;
            this.fieldControl.Description = this.Description;
            this.fieldControl.EnableNull  = this.EnableNull;
            this.fieldControl.FieldAlias  = this.FieldAlias;
            this.fieldControl.FieldName   = this.FieldName;
            this.fieldControl.Settings    = this.Settings;
            this.fieldControl.Tips        = this.Tips;
            this.fieldControl.ContentID   = this.ContentID;
            this.fieldControl.DataLength  = this.DataLength;
            this.Controls.Add(control);
        }
示例#14
0
        /// <summary>
        /// Refreshes a control that has already been rendered
        /// </summary>
        /// <param name="control">The control to refresh</param>
        /// <param name="canvasSize">The size of the canvas</param>
        /// <returns>A list of controls</returns>
        public List <Control> RefreshControl(IFieldControl control, Size canvasSize)
        {
            List <Control> controls;

            if (control.Field is GroupField)
            {
                controls = new List <Control>();
                controls = GetFieldControls(control.Field, canvasSize);
            }
            else
            {
                controls = GetFieldControls(control.Field, canvasSize);
            }
            if (control is DragableLabel)
            {
                if (((DragableLabel)control).LabelFor != null)
                {
                    ((DragableLabel)control).LabelFor.Dispose();
                }
            }
            ((Control)control).Dispose();
            return(controls);
        }
 /// <summary>
 /// The event handler
 /// </summary>
 /// <param name="control">A field control</param>
 public FieldControlEventArgs(IFieldControl control)
 {
     this.control = control;
 }
示例#16
0
 /// <summary>
 /// The event handler
 /// </summary>
 /// <param name="control">A field control</param>
 public FieldControlEventArgs(IFieldControl control)
 {
     this.control = control;
 }
示例#17
0
        internal void RegisterControlInternal(IDataBoundControlInterface dataBoundControl, IDynamicDataSource dataSource, IMetaTable table, bool setSelectionFromUrl, bool isPostBack)
        {
            // Set the auto field generator (for controls that support it - GridView and DetailsView)
            IFieldControl fieldControl = dataBoundControl as IFieldControl;

            if (fieldControl != null)
            {
                fieldControl.FieldsGenerator = new DefaultAutoFieldGenerator(table);
            }
            var linqDataSource   = dataSource as LinqDataSource;
            var entityDataSource = dataSource as EntityDataSource;

            // If the context type is not set, we need to set it
            if (dataSource.ContextType == null)
            {
                dataSource.ContextType = table.DataContextType;

                // If it's a LinqDataSurce, register for ContextCreating so the context gets created using the correct ctor
                // Ideally, this would work with other datasource, but we just don't have the right abstraction
                if (linqDataSource != null)
                {
                    linqDataSource.ContextCreating += delegate(object sender, LinqDataSourceContextEventArgs e) {
                        e.ObjectInstance = table.CreateContext();
                    };
                }

                if (entityDataSource != null)
                {
                    entityDataSource.ContextCreating += delegate(object sender, EntityDataSourceContextCreatingEventArgs e) {
                        e.Context = (ObjectContext)table.CreateContext();
                    };
                }
            }

            // If the datasource doesn't have an EntitySetName (aka TableName), set it from the meta table
            if (String.IsNullOrEmpty(dataSource.EntitySetName))
            {
                dataSource.EntitySetName = table.DataContextPropertyName;
            }

            // If there is no Where clause, turn on auto generate
            if (String.IsNullOrEmpty(dataSource.Where))
            {
                dataSource.AutoGenerateWhereClause = true;
            }

            // If it's a LinqDataSource and the flag is set, pre load the foreign keys
            if (AutoLoadForeignKeys && linqDataSource != null)
            {
                linqDataSource.LoadWithForeignKeys(table.EntityType);
            }

            if (!isPostBack)
            {
                if (table.HasPrimaryKey)
                {
                    dataBoundControl.DataKeyNames = table.PrimaryKeyNames;

                    // Set the virtual selection from the URL if needed
                    var dataKeySelector = dataBoundControl as IPersistedSelector;
                    if (dataKeySelector != null && setSelectionFromUrl)
                    {
                        DataKey dataKey = table.GetDataKeyFromRoute();
                        if (dataKey != null)
                        {
                            dataKeySelector.DataKey = dataKey;
                        }
                    }
                }
            }
        }
 public void AddField(IFieldControl field)
 {
     Controls.Add(field as Control);
 }