/// <summary> /// Group the specified uiElements. /// </summary> /// <param name="elements">User interface elements.</param> protected override void Group(List <LayoutElementInfo> elements) { ElementsGroup.Clear(); if (Layout.GridConstraint == GridConstraints.Flexible) { GroupFlexible(elements); } else if (Layout.GridConstraint == GridConstraints.FixedRowCount) { GroupByRows(elements); } else if (Layout.GridConstraint == GridConstraints.FixedColumnCount) { GroupByColumns(elements); } if (!Layout.TopToBottom) { ElementsGroup.Reverse(); } if (Layout.RightToLeft) { ElementsGroup.ForEach(ReverseList); } }
private void RecalculateTitlePaths() { for (int i = 0; i < TileElements.Length; i += 6) { VertexPosTexNormal[] quadElements = TileElements.Skip(i).Take(6).ToArray(); int[] pattern = { quadElements[0].Taken, (quadElements[1].Taken == 0? quadElements[4].Taken: quadElements[1].Taken), (quadElements[2].Taken == 0 ? quadElements[3].Taken : quadElements[2].Taken), quadElements[5].Taken }; TileElement stg1 = TileSheetData.TileElements.Where(x => x.Groups.Any(y => y.Pattern.SequenceEqual(pattern))).FirstOrDefault(); if (stg1 != null) { ElementsGroup texture2Put = stg1.Groups.Where(x => x.Pattern.SequenceEqual(pattern)).FirstOrDefault(); if (texture2Put != null) { int value; using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider()) { byte[] randomNumber = new byte[4];//4 for int32 rng.GetBytes(randomNumber); value = BitConverter.ToInt32(randomNumber, 0); } int indexRand = new Random(value).Next((texture2Put.Positions.Count <= 1 ? 1 : texture2Put.Positions.Count)); float uvX = (float)texture2Put.Positions[indexRand].X / (ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Width); float uvY = (float)texture2Put.Positions[indexRand].Y / (ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Height); float uvX2 = ((float)texture2Put.Positions[indexRand].X / (float)ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Width) + ((float)TileSheetData.TileElementWeight / ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Width); float uvY2 = ((float)texture2Put.Positions[indexRand].Y / (float)ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Height) - ((float)TileSheetData.TileElementHeight / ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Height); VertexPosTexNormal temp = TileElements[i]; temp.texCoord = new Vector2(uvX, uvY); TileElements[i] = temp; temp = TileElements[i + 1]; temp.texCoord = new Vector2(uvX, uvY2); TileElements[i + 1] = temp; temp = TileElements[i + 2]; temp.texCoord = new Vector2(uvX2, uvY); TileElements[i + 2] = temp; temp = TileElements[i + 3]; temp.texCoord = new Vector2(uvX2, uvY); TileElements[i + 3] = temp; temp = TileElements[i + 4]; temp.texCoord = new Vector2(uvX, uvY2); TileElements[i + 4] = temp; temp = TileElements[i + 5]; temp.texCoord = new Vector2(uvX2, uvY2); TileElements[i + 5] = temp; } } } }
/// <summary> /// Group elements. /// </summary> protected override void Group() { ElementsGroup.Clear(); var row = new List <LayoutElementInfo>(); ElementsGroup.Add(row); if (!Layout.FlexSettings.Wrap) { row.AddRange(Elements); return; } var base_size = Layout.MainAxisSize; var size = base_size; var spacing = Layout.IsHorizontal ? Layout.Spacing.x : Layout.Spacing.y; for (int i = 0; i < Elements.Count; i++) { if (row.Count == 0) { size -= Elements[i].AxisSize; row.Add(Elements[i]); continue; } var element_size = Elements[i].AxisSize + spacing; if (size >= element_size) { size -= element_size; row.Add(Elements[i]); } else { size = base_size - Elements[i].AxisSize; row = new List <LayoutElementInfo>(); ElementsGroup.Add(row); row.Add(Elements[i]); } } if (!Layout.TopToBottom) { ElementsGroup.Reverse(); } if (Layout.RightToLeft) { ElementsGroup.ForEach(ReverseList); } }
private static void CreateTouchElement(ElementsGroup Group, Vector3 Position, Vector3 Size, int ScreenIndex, int[] SoundIndices, TrainManager.CommandEntry[] CommandEntries) { Vertex t0 = new Vertex(Size.X, Size.Y, -Size.Z); Vertex t1 = new Vertex(Size.X, -Size.Y, -Size.Z); Vertex t2 = new Vertex(-Size.X, -Size.Y, -Size.Z); Vertex t3 = new Vertex(-Size.X, Size.Y, -Size.Z); Vertex t4 = new Vertex(Size.X, Size.Y, Size.Z); Vertex t5 = new Vertex(Size.X, -Size.Y, Size.Z); Vertex t6 = new Vertex(-Size.X, -Size.Y, Size.Z); Vertex t7 = new Vertex(-Size.X, Size.Y, Size.Z); StaticObject Object = new StaticObject(Program.CurrentHost); Object.Mesh.Vertices = new VertexTemplate[] { t0, t1, t2, t3, t4, t5, t6, t7 }; Object.Mesh.Faces = new MeshFace[] { new MeshFace(new int[] { 0, 1, 2, 3 }), new MeshFace(new int[] { 0, 4, 5, 1 }), new MeshFace(new int[] { 0, 3, 7, 4 }), new MeshFace(new int[] { 6, 5, 4, 7 }), new MeshFace(new int[] { 6, 7, 3, 2 }), new MeshFace(new int[] { 6, 2, 1, 5 }) }; Object.Mesh.Materials = new MeshMaterial[1]; Object.Mesh.Materials[0].Flags = 0; Object.Mesh.Materials[0].Color = Color32.White; Object.Mesh.Materials[0].TransparentColor = Color24.Blue; Object.Mesh.Materials[0].DaytimeTexture = null; Object.Mesh.Materials[0].NighttimeTexture = null; Object.Dynamic = true; if (Group.TouchElements == null) { Group.TouchElements = new TouchElement[0]; } int n = Group.TouchElements.Length; Array.Resize(ref Group.TouchElements, n + 1); Group.TouchElements[n] = new TouchElement { Element = new AnimatedObject(Program.CurrentHost), JumpScreenIndex = ScreenIndex, SoundIndices = SoundIndices, ControlIndices = new int[CommandEntries.Length] }; Group.TouchElements[n].Element.States = new [] { new ObjectState() }; Group.TouchElements[n].Element.States[0].Translation = Matrix4D.CreateTranslation(Position.X, Position.Y, -Position.Z); Group.TouchElements[n].Element.States[0].Prototype = Object; Group.TouchElements[n].Element.CurrentState = 0; Group.TouchElements[n].Element.internalObject = new ObjectState { Prototype = Object }; Program.CurrentHost.CreateDynamicObject(ref Group.TouchElements[n].Element.internalObject); int m = Interface.CurrentControls.Length; Array.Resize(ref Interface.CurrentControls, m + CommandEntries.Length); for (int i = 0; i < CommandEntries.Length; i++) { Interface.CurrentControls[m + i].Command = CommandEntries[i].Command; Interface.CurrentControls[m + i].Method = Interface.ControlMethod.Touch; Interface.CurrentControls[m + i].Option = CommandEntries[i].Option; Group.TouchElements[n].ControlIndices[i] = m + i; } }
public void LoadMapData(int terrainWidth, int terrainHeight, float terrainZ, int r) { ElementsGroup element = TileSheetData.TileElements.Where(x => x.Groups.Any(z => z.Name == "Default")).FirstOrDefault().Groups.Where(y => y.Name == "Default").FirstOrDefault(); int TableIterator = 0; for (int x = 0; x < terrainWidth; x += 1) { for (int y = 0; y < terrainHeight; y += 1) { int value; using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider()) { byte[] randomNumber = new byte[4];//4 for int32 rng.GetBytes(randomNumber); value = BitConverter.ToInt32(randomNumber, 0); } int indexRand = new Random(value).Next(element.Positions.Count); float uvX = (float)element.Positions[indexRand].X / (float)ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Width; float uvY = (float)element.Positions[indexRand].Y / (float)ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Height; float uvX2 = ((float)element.Positions[indexRand].X / (float)ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Width) + ((float)TileSheetData.TileElementWeight / (float)ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Width); float uvY2 = ((float)element.Positions[indexRand].Y / (float)ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Height) + ((float)TileSheetData.TileElementHeight / (float)ContentContainer.GetObjectFromContainer <Texture2D>(TileSheetData.Name).Height); VertexPosTexNormal _temp = new VertexPosTexNormal(new Vector3(x, terrainZ, y) * r, new Vector2(uvX, uvY), new Vector3(0, 1, 0)); TileElements[TableIterator] = (_temp); TableIterator++; _temp = new VertexPosTexNormal(new Vector3(x, terrainZ, y + 1) * r, new Vector2(uvX, uvY2), new Vector3(0, 1, 0)); TileElements[TableIterator] = (_temp); TableIterator++; _temp = new VertexPosTexNormal(new Vector3(x + 1, terrainZ, y) * r, new Vector2(uvX2, uvY), new Vector3(0, 1, 0)); TileElements[TableIterator] = (_temp); TableIterator++; _temp = new VertexPosTexNormal(new Vector3(x + 1, terrainZ, y) * r, new Vector2(uvX2, uvY), new Vector3(0, 1, 0)); TileElements[TableIterator] = (_temp); TableIterator++; _temp = new VertexPosTexNormal(new Vector3(x, terrainZ, y + 1) * r, new Vector2(uvX, uvY2), new Vector3(0, 1, 0)); TileElements[TableIterator] = (_temp); TableIterator++; _temp = new VertexPosTexNormal(new Vector3(x + 1, terrainZ, y + 1) * r, new Vector2(uvX2, uvY2), new Vector3(0, 1, 0)); TileElements[TableIterator] = (_temp); TableIterator++; } } }
public IEnumerable <ElementsGroup> GetSettings() { var items = new List <Element>(); var username = new TextItem("username", "Username"); var password = new PasswordItem("password", "Password"); var loginButton = new ButtonItem("loginButton", "Login"); var logoutButton = new ButtonItem("logoutButton", "Logout"); switch (showLabel) { case Label.ShowNothing: items.Add(username); items.Add(password); items.Add(loginButton); break; case Label.ShowLoginOk: var label = new LabelItem("label", "You are now logged in!"); items.Add(logoutButton); items.Add(label); break; case Label.ShowLoginFailed: label = new LabelItem("label", "Login failed"); items.Add(username); items.Add(password); items.Add(loginButton); items.Add(label); break; case Label.ShowLogoutOk: label = new LabelItem("label", "You have logged out"); items.Add(username); items.Add(password); items.Add(loginButton); items.Add(label); break; default: throw new ArgumentOutOfRangeException(); } var settings = new ElementsGroup("settings", "", items.ToArray()); return(new[] { settings, }); }
public IEnumerable <ElementsGroup> GetSettings() { // get Fresh settings each time _settings = _settingsRepo.Get(); var items = new List <Element>(); var note = new TextItem("notelabel1", "Note:") { Value = "Capture One doesn't update until you exit the field." }; var tip = new TextItem("tiplabel1", "Tip:") { Value = "Please click or tab off before pressing save or test." }; items.Add(note); items.Add(tip); var downloadButton = new ButtonItem("downloadButton", "Download Hugin"); items.Add(downloadButton); var pathToProcessExe = new TextItem("pathToHuginBin", "Hugin Bin Path") { Value = _settings.HuginBinPath, InformativeText = $"This needs to be the bin folder in your Hugin installation. E.g. {_settings.HuginBinPath}" }; items.Add(pathToProcessExe); var testButton = new ButtonItem("testBinPath", "Test (Hugin will open if valid)"); items.Add(testButton); var saveButton = new ButtonItem("saveBinPath", "Save"); items.Add(saveButton); var settings = new ElementsGroup("settings", "Configure Hugin", items.ToArray()); return(new[] { settings, }); }
void InsertToBlock(int block_index, LayoutElementInfo element) { for (int i = ElementsGroup.Count; i <= block_index; i++) { ElementsGroup.Add(new List <LayoutElementInfo>()); } var row = ElementsGroup[block_index]; row.Add(element); BlocksSizes[block_index] += element.AxisSize; if (row.Count > 1) { var spacing = Layout.IsHorizontal ? Layout.Spacing.x : Layout.Spacing.y; BlocksSizes[block_index] += spacing; } }
/// <summary> /// Group the specified elements. /// </summary> protected override void Group() { ElementsGroup.Clear(); if (Elements.Count == 0) { return; } if (Layout.IsHorizontal) { GroupHorizontal(ElementsGroup); } else { GroupVertical(ElementsGroup); } var rows = ElementsGroup.Count; var columns = EasyLayoutUtilites.MaxCount(ElementsGroup); if ((Layout.CompactConstraint == CompactConstraints.MaxRowCount) && (rows > Layout.ConstraintCount)) { ElementsGroup.Clear(); GroupByRows(); } else if ((Layout.CompactConstraint == CompactConstraints.MaxColumnCount) && (columns > Layout.ConstraintCount)) { ElementsGroup.Clear(); GroupByColumns(); } if (!Layout.TopToBottom) { ElementsGroup.Reverse(); } if (Layout.RightToLeft) { ElementsGroup.ForEach(ReverseList); } }
public IEnumerable <ElementsGroup> GetSettings() { var items = new List <Element>(); var openSettingsButton = new ButtonItem("openSettings", "Open Configurator"); items.Add(openSettingsButton); var pathToProcessExe = new TextItem("pathToProcessExe", "Post Process Program Path") { Value = PostProcessProgramPath, InformativeText = "Copy and paste this path into process recipes so that it runs once Capture One has finished processing the image." }; items.Add(pathToProcessExe); var settings = new ElementsGroup("settings", "", items.ToArray()); return(new[] { settings, }); }
/// <summary> /// Group elements. /// </summary> /// <param name="elements">Elements.</param> protected override void Group(List <LayoutElementInfo> elements) { ElementsGroup.Clear(); var blocks = GetBlockSizes(elements); InitBlockSizes(blocks); for (int i = 0; i < elements.Count; i++) { InsertToBlock(NextBlockIndex(), elements[i]); } if (!Layout.TopToBottom) { ElementsGroup.Reverse(); } if (Layout.RightToLeft) { ElementsGroup.ForEach(ReverseList); } }