internal CommodityView(Vector2 position, Alignment positionAlignment, SettlementView settlementView, string imageTextureName1, string imageTextureName2, string name) : base(name) { Size = new PointI(100, 30); PositionAlignment = positionAlignment; Position = position.ToPointI(); SettlementView = settlementView; var pairs = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("textureName1", $"Icons_1.{imageTextureName1}"), new KeyValuePair <string, string>("textureName2", $"Icons_1.{imageTextureName2}") }; Controls = ControlCreator.CreateFromSpecification( @" image1 : Image { TextureNormal: '%textureName1%' Size: [30;30] } image2 : Image { TextureNormal: '%textureName2%' Size: [20;20] }", pairs); Controls.SetOwner(this); }
internal CitizenView(string name, Vector2 position, Alignment positionAlignment, SettlementView settlementView, string textureAtlas) : base(name) { Size = new PointI(100, 30); PositionAlignment = positionAlignment; Position = position.ToPointI(); SettlementView = settlementView; var kvps = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("position1", $"{Convert.ToInt32(position.X + Bounds.X)};{Convert.ToInt32(position.Y + Bounds.Y)}"), new KeyValuePair <string, string>("position2", $"{Convert.ToInt32(position.X + Bounds.X + 20)};{Convert.ToInt32(position.Y + Bounds.Y)}"), new KeyValuePair <string, string>("position3", $"{Convert.ToInt32(position.X + Bounds.X)};{Convert.ToInt32(position.Y + Bounds.Y + 30)}"), new KeyValuePair <string, string>("position4", $"{Convert.ToInt32(position.X + Bounds.X + 20)};{Convert.ToInt32(position.Y + Bounds.Y + 30)}"), new KeyValuePair <string, string>("textureName1", $"{textureAtlas}.Citizen_{settlementView.Settlement.Race.Name}_Farmer"), new KeyValuePair <string, string>("textureName2", $"{textureAtlas}.Citizen_{settlementView.Settlement.Race.Name}_Worker"), new KeyValuePair <string, string>("textureName3", $"{textureAtlas}.Citizen_{settlementView.Settlement.Race.Name}_Rebel") }; var spec = ResourceReader.ReadResource("PhoenixGamePresentation.Views.SettlementViewComposite.CitizenViewControls.txt", Assembly.GetExecutingAssembly()); Controls = ControlCreator.CreateFromSpecification(spec, kvps); Controls.SetOwner(this); }
public void DoNavigation(int userControlCode, Dictionary <string, int> additionalParameters = null) { this.controlPanel.Controls.Clear(); UserControl currenUserControl = ControlCreator.CreateUserControl(userControlCode, additionalParameters, this.DoNavigation, parkingSystem); this.controlPanel.Controls.Add(currenUserControl); }
/// <inheritdoc/> public override void CreateControlsForModule() { var result = ApplicationBase.Current.ModuleAnalyser.SortProperties(uiModule.ModuleItemType); UIElement previousControl = null; foreach (var item in result) { if (item.Value.PropertyAttributes.FirstOrDefault(x => x.GetType() == typeof(UIIgnoreAttribute)) != null) { continue; } var uiParamsAttr = item.Value.PropertyAttributes.FirstOrDefault(x => x.GetType() == typeof(UIParamsAttribute)); if ((uiParamsAttr != null && !(uiParamsAttr as UIParamsAttribute).ReadOnlyMode) || uiParamsAttr == null) { mainContent.Children.Add(ControlCreator.CreateEditableControl(item, ref previousControl, uiModule)); } else { mainContent.Children.Add(ControlCreator.CreateDetailControl(item, ref previousControl)); } } FillPredefinedValues(); }
internal HudView(WorldView worldView, StackViews stackViews, InputHandler input) { var x = worldView.Camera.GetViewport.Right; var y = 0; var width = 1920 - x; var height = 1020; Area = new Rectangle(x, y, width, height); // 1680,0,240,1020 var pairs = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("position1", "0;0"), new KeyValuePair <string, string>("size1", $"{width};{height}"), new KeyValuePair <string, string>("size2", $"{width - 20};{Convert.ToInt32(height * 0.15f)}"), // 15% of parent new KeyValuePair <string, string>("size3", $"{width - 20};{Convert.ToInt32(height * 0.20f)}"), // 20% of parent new KeyValuePair <string, string>("size4", $"{width - 20};{Convert.ToInt32(height * 0.30f)}") // 30% of parent }; var spec = ResourceReader.ReadResource("PhoenixGamePresentation.Views.HudViewControls.txt", Assembly.GetExecutingAssembly()); Controls = ControlCreator.CreateFromSpecification(spec, pairs); Controls.SetOwner(this); WorldView = worldView; StackViews = stackViews; worldView.CellGrid.NewCellSeen += NewCellSeen; SetupViewport(x, y, width, height + Controls["frmHudView.btnEndTurn"].Height); // 1680,0,240,1020 + 56 : btnEndTurn.Height = 56 Input = input; }
public MainFrame(SettlementView settlementView, Vector2 topLeftPosition, string textureAtlas) : base("MainFrame") { Size = new PointI(556, 741); Position = topLeftPosition.ToPointI(); SettlementView = settlementView; var pairs = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("textureName1", $"{textureAtlas}.frame_main"), new KeyValuePair <string, string>("textureName2", $"{textureAtlas}.frame_big_heading"), new KeyValuePair <string, string>("textureName3", $"{textureAtlas}.frame2_whole"), new KeyValuePair <string, string>("textureName4", $"{textureAtlas}.frame_bottom"), new KeyValuePair <string, string>("position1", $"{Convert.ToInt32(topLeftPosition.X)};{Convert.ToInt32(topLeftPosition.Y)}"), new KeyValuePair <string, string>("size1", $"{Size.X};{Size.Y}"), new KeyValuePair <string, string>("textureNormal1", $"{textureAtlas}.close_button_n"), new KeyValuePair <string, string>("textureActive1", $"{textureAtlas}.close_button_a"), new KeyValuePair <string, string>("textureHover1", $"{textureAtlas}.close_button_h"), }; var spec = File.ReadAllText(@".\Views\SettlementViewComposite\MainFrameControls.txt"); Controls = ControlCreator.CreateFromSpecification(spec, pairs); Controls.SetOwner(this); Controls["frmMain.frmPopulation"].AddControl(new CitizenView("citizenView", new Vector2(90.0f, 135.0f), Alignment.TopLeft, settlementView, "Citizens")); Controls["frmMain.frmResources"].AddControl(new FoodView("foodView", new Vector2(130.0f, 0.0f), Alignment.TopLeft, settlementView, "Bread", "Corn"), Alignment.TopLeft, Alignment.TopLeft, new PointI(130, 20)); Controls["frmMain.frmResources"].AddControl(new ProductionView("productionView", new Vector2(130.0f, 0.0f), Alignment.TopLeft, settlementView, "Anvil", "Pickaxe"), Alignment.TopLeft, Alignment.TopLeft, new PointI(130, 50)); }
public AddDeviceControl(List <Device> deviceList, DeviceManager manager) { devices = deviceList; this.manager = manager; creator = new DeviceCreator(manager, deviceList); ctrCreator = new ControlCreator(manager); Initializer(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes this instance. /// </summary> /// ------------------------------------------------------------------------------------ protected virtual void Initialize() { if (m_fShownBefore) { return; } // Create a FwSplitContainer with two draft views. Control draftView = ControlCreator.Create(this, m_rightView.Tag); draftView.Dock = DockStyle.Fill; m_draftView = draftView as IRootSite; if (draftView is ISelectableView) { ((ISelectableView)draftView).BaseInfoBarCaption = m_baseInfoBarCaption; } // Create a draft view of Scripture in the project. m_rightView.Panel2.Controls.Add(draftView); // Create a view for the list of renderings for the selected key term m_gridControl = CreateGridControl(m_mainWnd); m_gridControl.Dock = DockStyle.Fill; if (m_gridControl is ISelectableView) { ((ISelectableView)m_gridControl).BaseInfoBarCaption = m_baseInfoBarCaption; } if (m_gridControl is IChecksViewWrapperView) { ((IChecksViewWrapperView)m_gridControl).Persistence = m_persistence; } m_rightView.Panel1.Controls.Add(m_gridControl); // Create a key terms control (containing the tool strip and tree). // Subscribe to events so that the enabled status of the tool strip buttons can be updated. m_treeContainer = CreateCheckControl(); m_treeContainer.Dock = DockStyle.Left; if (m_treeContainer is IChecksViewWrapperView) { ((IChecksViewWrapperView)m_treeContainer).Persistence = m_persistence; } Controls.Add(m_treeContainer); m_dockExtender = new DockExtender(this); m_floaty = m_dockExtender.Attach(m_treeContainer, m_treeContainer.ToolStrip, true, m_persistence); m_floaty.DockOnInside = false; // outside m_floaty.HideHandle = false; m_floaty.AllowedDocking = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right; m_floaty.ShowCloseButton = false; m_treeContainer.Floaty = m_floaty; m_fShownBefore = true; }
public MetricsPanel() { var spec = ResourceReader.ReadResource("PhoenixGamePresentation.MetricsPanelControls.txt", Assembly.GetExecutingAssembly()); Controls = ControlCreator.CreateFromSpecification(spec); Controls.SetOwner(this); SetupViewport(0, 1060, 1920, 20); }
private void OnInsertControl(ControlCreator controlCreator) { if (controlCreator == null || selectedWidget == null) { return; } SelectedWidgetLayout = _designerControlCreatorService.InsertControlSnippet(controlCreator, SelectedWidgetLayout, LayoutCaretPosition); }
public string InsertControlSnippet(ControlCreator controlCreator, string layoutDefinition, int currentPosition) { var control = controlCreator.Create(_namingService); var content = layoutDefinition.Insert(currentPosition, control.Control); var stylePosition = FindStylePosition(content); return(content.Insert(stylePosition, control.Style)); }
Label CreateEndLabel(string text, int row) { Label label = ControlCreator.CreateLabel(text, DockStyle.Left); panel.Controls.Add(label, 0, row); maxRow = row; endSign = label; return(label); }
public ATimer(int interval, ControlCreator c, int control_id) { this.timer = new Timer(); this.timer.Tick += new EventHandler(OnTimedEvent); // Set the Interval to 1 seconds. this.timer.Interval = interval; this.timer.Enabled = false; this.c = c; this.control_id = control_id; this.running = false; }
Button CreateButton(string textID, int row, int index) { Button btn = ControlCreator.CreateButton("Add", DockStyle.Right); btn.Click += btn_Click; panel.Controls.Add(btn, 0, row); maxRow = row; return(btn); }
void AddTextBox(int row, string name, string text) { TextBox textBox = ControlCreator.CreateTextBox(text, name); textBox.TextChanged += textBox_TextChanged; panel.Controls.Add(textBox, 1, row); textBoxes.Add(textBox); maxRow = row; }
public override void Create() { base.Create(); btnRemove = ControlCreator.CreateButton("Remove", DockStyle.Left); btnRemove.Click += btnRemove_Click; maxRow++; table.Controls.Add(btnRemove, 1, maxRow); EndCreate(); }
void AddComboBox(int row, List <string> items) { string[] names = GetNames(items); cboMaterials = ControlCreator.CreateComboBox(names, names[0], false); panel.Controls.Add(cboMaterials, 1, row); maxRow = row; cboMaterials.SelectedIndexChanged += cboMaterials_SelectedIndexChanged; }
public void EndCreate() { if (endLabel != null) { table.Controls.Remove(endLabel); } maxRow += 2; endLabel = ControlCreator.CreateLabel("", DockStyle.None); table.Controls.Add(endLabel, 0, maxRow); maxRow++; }
public override void Create() { descLabel = ControlCreator.CreateLabel(desc, DockStyle.Left); table.Controls.Add(descLabel, 0, maxRow); cbo = ControlCreator.CreateComboBox(options, selected, true); cbo.SelectedIndexChanged += cbo_SelectedIndexChanged; table.Controls.Add(cbo, 1, maxRow); maxRow++; base.Create(); }
void AddLabel(string name, int row) { DockStyle dock = DockStyle.Right; if (name.Length > 2) { dock = DockStyle.Left; } Label label = ControlCreator.CreateLabel(name, dock); desc.Add(label); table.Controls.Add(label, 0, row); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Creates the control in column. /// </summary> /// <param name="cell">The cell that will host the control we create.</param> /// ------------------------------------------------------------------------------------ private void CreateHostedControl(DataGridViewControlCell cell) { if (cell.ControlCreateInfo == null || (ControlCreator == null && !(cell.ControlCreateInfo.ClientControlInfo is FixedControlCreateInfo))) { return; } IRootSiteGroup group = cell.ControlCreateInfo.Group; Control c; if (cell.ControlCreateInfo.ClientControlInfo is FixedControlCreateInfo) { // We know how to deal with this! c = ((FixedControlCreateInfo)cell.ControlCreateInfo.ClientControlInfo).Control; } else { c = ControlCreator.Create(this, cell.ControlCreateInfo.ClientControlInfo); } if (c is RootSite) { RootSite rs = c as RootSite; rs.Cache = m_cache; rs.StyleSheet = m_StyleSheet; } if (group != null && c is IRootSiteSlave) { IRootSiteSlave slave = c as IRootSiteSlave; group.AddToSyncGroup(slave); if (cell.ControlCreateInfo.IsScrollingController) { group.ScrollingController = slave; } } if (c is ISelectableView) { ((ISelectableView)c).BaseInfoBarCaption = m_baseInfoBarCaption; } cell.ControlCreateInfo.Control = c; OnHostedControlCreated(c); }
/// <inheritdoc/> public override void CreateControlsForModule() { var result = ApplicationBase.Current.ModuleAnalyser.SortProperties(uiModule.ModuleItemType); UIElement previousControl = null; foreach (var item in result) { if (item.Value.PropertyAttributes.FirstOrDefault(x => x.GetType() == typeof(UIIgnoreAttribute)) != null) { continue; } mainContent.Children.Add(ControlCreator.CreateDetailControl(item, ref previousControl)); } FillPredefinedValues(); }
public LevelContentViewModel() { dialogManager = new DialogManager(); controlCreator = new ControlCreator(); additionMgElem = null; deletionMgElem = null; cleansingMgElems = null; fillingGrid = null; grid = null; mgElemsStack = null; imagesSelect = new List <MgElemControl>(); AddMgElem = new Command(OnAddMgElemExecute); RemoveMgElem = new Command(OnRemoveMgElemExecute); FillAllVoids = new Command(OnFillAllVoidsExecute); ClearField = new Command(OnClearFieldExecute); BindStackPanel = new Command <StackPanel>(OnBindStackPanelExecute); BindGrid = new Command <Grid>(OnBindGridExecute); }
internal SecondaryFrame(SettlementView settlementView, Vector2 topLeftPosition, string textureAtlas) : base("SecondaryFrame") { _gameConfigCache = CallContext <GameConfigCache> .GetData("GameConfigCache"); Size = new PointI(556, 741); Position = topLeftPosition.ToPointI(); SettlementView = settlementView; var pairs = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("textureName1", $"{textureAtlas}.frame_main"), new KeyValuePair <string, string>("textureName2", $"{textureAtlas}.frame2_whole"), new KeyValuePair <string, string>("textureName3", $"{textureAtlas}.frame_bottom"), new KeyValuePair <string, string>("position1", $"{Convert.ToInt32(topLeftPosition.X)};{Convert.ToInt32(topLeftPosition.Y)}"), new KeyValuePair <string, string>("size1", $"{Size.X};{Size.Y}") }; var spec = ResourceReader.ReadResource("PhoenixGamePresentation.Views.SettlementViewComposite.SecondaryFrameControls.txt", Assembly.GetExecutingAssembly()); Controls = ControlCreator.CreateFromSpecification(spec, pairs); var buildingsView = new BuildingsView("buildingsView", settlementView, textureAtlas); var frmBuildings = Controls["frmSecondary.frmBuildings"]; frmBuildings.AddControl(buildingsView, Alignment.TopCenter); var slots10 = new DynamicSlots("slots20", $"{textureAtlas}.slot", new PointI(515, 65), 5, 2, 10.0f); var frmUnits = Controls["frmSecondary.frmUnits"]; frmUnits.AddControl(slots10, Alignment.TopLeft, Alignment.TopLeft, new PointI(0, 5)); CreateUnitLabels(slots10); var slots5 = new DynamicSlots("slots2", $"{textureAtlas}.slot", new PointI(515, 65), 5, 1, 10.0f); var frmOther = Controls["frmSecondary.frmOther"]; frmOther.AddControl(slots5, Alignment.TopLeft, Alignment.TopLeft, new PointI(0, 5)); CreateOtherLabels(slots5); }
public ControlsCreator(ControlCreator <ControlType> creator) : this(creator, true) { }
public ControlsCreator(ControlCreator <ControlType> creator, bool showInDesigner) { this.creator = creator; this.showInDesigner = showInDesigner; }
public virtual void Create() { string name = PropertyHelper.GetTypeName(obj.ObjectType); ConstructorInfo[] ctors = AssemblyManager.GetType(obj.ObjectType).GetConstructors(); ConstructorInfo info = null; if (obj.Parameters != null) { for (int i = 0; i < ctors.Length; i++) { if (ctors[i].GetParameters().Length == obj.Parameters.Length) { info = ctors[i]; } } } else { if (ctors.Length > 1) { int max = 0; for (int i = 0; i < ctors.Length; i++) { if (ctors[i].GetParameters().Length > max) { info = ctors[i]; max = info.GetParameters().Length; } } obj.Parameters = new object[max]; } else { info = ctors[0]; obj.Parameters = new object[info.GetParameters().Length]; } } ParameterInfo[] param = info.GetParameters(); for (int i = 0; i < param.Length; i++) { string paramName = PropertyHelper.GetName(param[i].Name); Type t = param[i].ParameterType; if (t == typeof(bool)) { table.Controls.Add(ControlCreator.CreateLabel(paramName, DockStyle.Left), 0, maxRow); bool val = false; try { if (obj.Parameters[i] != null) { val = (bool)obj.Parameters[i]; } else { obj.Parameters[i] = val; } } catch { } ctrls.Add(new ModCheckBox("", val, i, table, maxRow, paramName)); maxRow++; } else if (t == typeof(string)) { table.Controls.Add(ControlCreator.CreateLabel(paramName, DockStyle.Left), 0, maxRow); string val = ""; try { if (obj.Parameters[i] != null) { val = (string)obj.Parameters[i]; } else { obj.Parameters[i] = val; } } catch { } if (paramName.Contains("Filepath")) { ModTextBox <string> txt = new ModTextBox <string>( val, "", i, table, maxRow, new string[] { ".xnb" }, true); ctrls.Add(txt); } else { ModTextBox <string> txt = new ModTextBox <string>( val, i, table, maxRow); ctrls.Add(txt); } maxRow++; } else if (t == typeof(Int32)) { table.Controls.Add(ControlCreator.CreateLabel(paramName, DockStyle.Left), 0, maxRow); int val = 0; try { if (obj.Parameters[i] != null) { val = (int)obj.Parameters[i]; } else { obj.Parameters[i] = val; } } catch { } ctrls.Add(new ModTextBox <int>( val, i, table, maxRow)); maxRow++; } else if (t == typeof(Single)) { table.Controls.Add(ControlCreator.CreateLabel(paramName, DockStyle.Left), 0, maxRow); float val = 0.0f; try { if (obj.Parameters[i] != null) { val = (float)obj.Parameters[i]; } else { obj.Parameters[i] = val; } } catch { } ctrls.Add(new ModTextBox <float>( val, i, table, maxRow)); maxRow++; } else if (t == typeof(Vector2)) { Vector2 vec = Vector2.Zero; try { if (obj.Parameters[i] != null) { vec = (Vector2)obj.Parameters[i]; } else { obj.Parameters[i] = vec; } } catch { } float[] array = new float[] { vec.X, vec.Y }; string[] names = new string[] { "X", "Y" }; GroupedTextBox <float> group = new GroupedTextBox <float>( paramName, "", array, names, i, table, maxRow); ctrls.Add(group); maxRow = group.MaxRow; } else if (t == typeof(Vector3)) { Vector3 vec = Vector3.Zero; try { if (obj.Parameters[i] != null) { vec = (Vector3)obj.Parameters[i]; } else { obj.Parameters[i] = vec; } } catch { } float[] array = new float[] { vec.X, vec.Y, vec.Z }; string[] names = new string[] { "X", "Y", "Z" }; GroupedTextBox <float> group = new GroupedTextBox <float>( paramName, "", array, names, i, table, maxRow); ctrls.Add(group); maxRow = group.MaxRow; } else if (t == typeof(Vector4)) { Vector4 vec = Vector4.Zero; try { if (obj.Parameters[i] != null) { vec = (Vector4)obj.Parameters[i]; } else { obj.Parameters[i] = vec; } } catch { } float[] array = new float[] { vec.X, vec.Y, vec.Z, vec.W }; string[] names = new string[] { "X", "Y", "Z", "W" }; GroupedTextBox <float> group = new GroupedTextBox <float>( paramName, "", array, names, i, table, maxRow); ctrls.Add(group); maxRow = group.MaxRow; } else if (t == typeof(Microsoft.Xna.Framework.Color)) { Microsoft.Xna.Framework.Color col = Microsoft.Xna.Framework.Color.White; try { if (obj.Parameters[i] != null) { col = (Microsoft.Xna.Framework.Color)obj.Parameters[i]; } else { obj.Parameters[i] = col; } } catch { } byte[] array = new byte[] { col.R, col.G, col.B, col.A }; string[] names = new string[] { "R", "G", "B", "A" }; GroupedTextBox <byte> group = new GroupedTextBox <byte>( paramName, "", array, names, i, table, maxRow); ctrls.Add(group); maxRow = group.MaxRow; } else if (t == typeof(Microsoft.Xna.Framework.Rectangle)) { Microsoft.Xna.Framework.Rectangle rect = Microsoft.Xna.Framework.Rectangle.Empty; try { if (obj.Parameters[i] != null) { rect = (Microsoft.Xna.Framework.Rectangle)obj.Parameters[i]; } else { obj.Parameters[i] = rect; } } catch { } int[] array = new int[] { rect.X, rect.Y, rect.Width, rect.Height }; string[] names = new string[] { "X", "Y", "Width", "Height" }; GroupedTextBox <int> group = new GroupedTextBox <int>( paramName, "", array, names, i, table, maxRow); ctrls.Add(group); maxRow = group.MaxRow; } } }