private void InitializeContentIn(Control container) { _formView = container.AddControl(new ConfigStudioFormView(), fvw => { fvw.TemplateControl = this; fvw.TemplateControl = this; fvw.ApplyStyleSheetSkin(this); fvw.ID = "sfvFieldInheritance"; fvw.IdentifierDataField = "Name"; }); _dataSource = container.AddControl(new AdamDataSource(), ds => { ds.TemplateControl = this; ds.ID = "dsFieldInheritance"; ds.DataProviderType = typeof(FieldInheritanceDefinitionProvider).AssemblyQualifiedName; }); }
public static PropertyBinder AddPropertyBinder(this Control container, string targetControlId, string propertyName, Action <PropertyBinder> customizeBinder = null) { return(container.AddControl(new PropertyBinder(), binder => { binder.ID = $"bndr{targetControlId}"; binder.TargetControlID = targetControlId; binder.DataField = propertyName; customizeBinder?.Invoke(binder); })); }
/// <summary> /// Creates control at X, Y coordinates. /// </summary> /// <param name="X">X coordiante.</param> /// <param name="Y">Y coordiante.</param> private void CreateDesignControl(int x, int y) { Control control = FindDesignControl(x, y); if (null != control) { if (null != this.activeWindow) { String name = this.controlToCreateType; uint i = 0; if (false == control.CanContainControl(name)) { return; } while (null != control.FindControl(name)) { name = this.controlToCreateType + "_" + i; i++; } Control newControl = this.activeWindow.CreateControl(this.controlToCreateType, CreationFlag.NeedSaving | CreationFlag.NeedLoading | CreationFlag.SelectableInDesigner); if (null != newControl) { int cx = this.Bounds.X; int cy = this.activeWindow.TopOffset + this.Bounds.Y; for (Control pp = control; pp != null; pp = pp.Parent) { cx += pp.Bounds.X; cy += pp.Bounds.Y; } newControl.Bounds = new Rectangle(x - cx, y - cy, 95, 24); newControl.Name = name; control.AddControl(newControl); SetControl(newControl, true); } } } this.SelectControlType(null); }
private void BuildEntityList(string searchStr = null) { _entityList.Container.DisposeAllChildren(); _entityList.ResetScrollbars(); var manager = IoCManager.Resolve <IPrototypeManager>(); IEnumerable <KeyValuePair <string, EntityPrototype> > templates; if (searchStr == null) { templates = manager.EnumeratePrototypes <EntityPrototype>() .Select(p => new KeyValuePair <string, EntityPrototype>(p.ID, p)); } else { var searchStrLower = searchStr.ToLower(); templates = manager.EnumeratePrototypes <EntityPrototype>() .Where(p => p.ID.ToLower().Contains(searchStrLower)) .Select(p => new KeyValuePair <string, EntityPrototype>(p.ID, p)); } if (searchStr != null) { _clearLabel.BackgroundColor = new Color(211, 211, 211, 255); } var maxWidth = 0; Control lastControl = _entityList.Container; foreach (var newButton in templates.Select(entry => new EntitySpawnSelectButton(entry.Value, entry.Key))) { lastControl.AddControl(newButton); lastControl = newButton; newButton.FixedWidth = _entityList.Width; newButton.Alignment = ControlAlignments.Bottom; newButton.DoLayout(); newButton.Clicked += NewButtonClicked; if (newButton.ClientArea.Width > maxWidth) { maxWidth = newButton.ClientArea.Width; } } }
/// <summary> /// Create buttons in the given control. /// </summary> /// <param name="parentControl">The parent control.</param> public void CreateButtonsInControl(Control parentControl) { var y = this.theme.ControlLargeSpacing + (this.theme.ControlHeight * 2); foreach (var testWindow in this.Windows) { // create a button to go and show the window var btn = new Button(testWindow.Title) { ConfigText = testWindow.Name, Tag = testWindow.GetType().FullName, Config = { PositionY = y, PositionX = this.theme.ControlLargeSpacing } }; btn.Clicked += this.OnButtonClicked; y = y + this.theme.ControlHeight + this.theme.ControlSmallSpacing; // add the button to the window parentControl.AddControl(btn); } }