public StagedGraphic StageGraphic(string filePath, string id) { var definition = File.ReadAllLines(filePath).Where(l => l.Length > 0) .Where(l => l.ToLower().StartsWith("graphic") && l.Contains($"id={id}")) .FirstOrDefault(); if (definition.Length == 0) { return(new StagedGraphic()); } var work = definition.Split(';'); GraphicType type = GraphicType.None; for (int i = 0; i < work.Length; i++) { var pair = work[i].Split('='); if (pair[0].Trim().ToLower() == "graphic") { type = ParseType(pair[1].Trim().ToLower()); break; } } if (type == GraphicType.None) { return(new StagedGraphic()); } var stagedGraphic = new StagedGraphic(id, filePath, type); return(stagedGraphic); }
private static Vector2 ExtractBounds(Graphic graphic, GraphicType type) { int vWidth; int vHeight; IntRange vBounds; try { vBounds = Def_Extensions.CropVertical((graphic.MatEast.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight); } catch (Exception ex) { throw new Exception("CombatExtended :: CropVertical error while cropping Textures/" + graphic.path + "_east", ex); } //Plants only care for verts //This is assuming PLANTS TAKE UP A FULL TILE!! // TODO : Refactor if (type == GraphicType.Plant) { return(new Vector2( 1f, (float)(vBounds.max - vBounds.min) / (float)vHeight)); } int hWidth; int hHeight; IntRange hBounds; try { hBounds = Def_Extensions.CropHorizontal((graphic.MatSouth.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight); } catch (Exception ex) { throw new Exception("CombatExtended :: CropHorizontal error while cropping Textures/" + graphic.path + "_south", ex); } return(new Vector2( (float)(hBounds.max - hBounds.min) / (float)hWidth, (float)(vBounds.max - vBounds.min) / (float)vHeight)); }
public void Draw(SpriteBatch spritebatch, int angle, Color tint, Vector2 position, GraphicType gtype) { int gidx = (int)gtype; int closesta=int.MaxValue; FramePair current; int i, j = 0; if (pairs == null || pairs.Length < 1) return; current = pairs[0]; for (i = 0; i < pairs.Length; ++i) { if (Math.Max(pairs[i].deg, angle) - Math.Min(pairs[i].deg, angle) < closesta) { closesta = Math.Max(pairs[i].deg, angle) - Math.Min(pairs[i].deg, angle); current = pairs[i]; j = i; if (closesta == 0) break; } } System.Diagnostics.Trace.WriteLine(j); parts[gidx].invertHorizontal = current.flip; parts[gidx].gotoAndStop(current.frame); // TODO(xoorath): don't hard code 128*128 parts[gidx].Draw(spritebatch, new Rectangle((int)position.X, (int)position.Y, 128, 128), tint, 0.0f); if (SnakeManager.Instance().DFont != null) spritebatch.DrawString(SnakeManager.Instance().DFont, j.ToString() + " : " + angle.ToString(), position, Color.White); }
public void ShouldInsertGraphicTypeWhenDBContextIsValid() { furniture = CreateGraphicType(); _spacePlanningUnitOfWork.GraphicTypeRepository.Add(furniture); _spacePlanningUnitOfWork.Save(); Assert.IsTrue(_spacePlanningUnitOfWork.GraphicTypeRepository.GetById(furniture.GraphicTypeId) != null); }
private void SetInitialValues() { initialRectValues = new TransformAnimationRecord() { Position = rectTransform.anchoredPosition, Scale = rectTransform.localScale, RotationEuler = rectTransform.rotation.eulerAngles, Pivot = rectTransform.pivot, AnchorMin = rectTransform.anchorMin, AnchorMax = rectTransform.anchorMax }; if (graphic) { if (graphic is Image) { graphicType = GraphicType.Image; img = GetComponent <Image>(); } else if (graphic is Text) { graphicType = GraphicType.Text; txt = GetComponent <Text>(); } initialGraphicValues = new GraphicAnimationRecord() { Color = graphic.color, Sprite = (graphicType == GraphicType.Image) ? img.sprite : null, Text = (graphicType == GraphicType.Text) ? txt.text : "", }; } }
public SnakeNode(SnakeNode a_Follow, SegmentType a_SegmentType, GraphicType a_GraphicType, Vector2 a_Translation) { m_Follow = a_Follow; SegmentType = a_SegmentType; m_GraphicType = a_GraphicType; Position = Vector2.Zero + a_Translation; }
public static Vector2 BoundMap(Graphic graphic, GraphicType type) { if (!boundMap.ContainsKey(graphic.path)) { boundMap[graphic.path] = ExtractBounds(graphic, type); } return(boundMap[graphic.path]); }
GraphicInfo GraphicInfoFromType(GraphicType type) { var info = new GraphicInfo { Width = 16, Height = 16, GraphicFormat = GraphicFormat.Palette5Bit }; switch (type) { case GraphicType.Tileset1: case GraphicType.Tileset2: case GraphicType.Tileset3: case GraphicType.Tileset4: case GraphicType.Tileset5: case GraphicType.Tileset6: case GraphicType.Tileset7: case GraphicType.Tileset8: info.Alpha = true; break; case GraphicType.Player: info.Width = 16; info.Height = 32; info.Alpha = true; break; case GraphicType.Portrait: info.Width = 32; info.Height = 32; break; case GraphicType.Item: info.Width = 16; info.Height = 16; break; case GraphicType.Layout: info.Width = 320; info.Height = 163; info.GraphicFormat = GraphicFormat.Palette3Bit; info.PaletteOffset = 24; info.Alpha = true; break; case GraphicType.LabBackground: info.Width = 144; info.Height = 20; info.GraphicFormat = GraphicFormat.Palette4Bit; info.PaletteOffset = 0; info.Alpha = false; break; // TODO } return(info); }
public static Vector2 BoundMap(Graphic graphic, GraphicType type) { if (!boundMap.ContainsKey(graphic.path)) { try { boundMap[graphic.path] = ExtractBounds(graphic, type); } catch (Exception e) { throw new Exception("BoundMap(,)", e); } } return(boundMap[graphic.path]); }
public SlotItemAlbumDetailTextureInfo(GraphicType graphicType, int graphicSlotItemId, Vector3 scale, Vector3 offset, bool needPixelPerfect) { mGraphicSlotItemMstId = graphicSlotItemId; mGraphicType = graphicType; mWidth = -1; mHeight = -1; mVector3_Offset = offset; mVector3_Scale = scale; mNeedPixelPerfect = needPixelPerfect; }
public static Vector2 BoundMap(Graphic graphic, GraphicType type, Graphic headGraphic, Vector2 headOffset) { string path = graphic.path + (headGraphic == null ? "" : "+" + headGraphic.path); if (!boundMap.ContainsKey(path)) { boundMap[path] = ExtractBounds(graphic, type, headGraphic, headOffset); } return(boundMap[path]); }
public SlotItemAlbumDetailTextureInfo(GraphicType graphicType, int graphicSlotItemId, Vector3 scale, Vector3 offset, int width, int height) { mGraphicSlotItemMstId = graphicSlotItemId; mGraphicType = graphicType; mWidth = width; mHeight = height; mVector3_Offset = offset; mVector3_Scale = scale; mNeedPixelPerfect = false; }
public void SetDiagrammValues(float[,] values) { quadsCount = new Vector2(values.GetLength(0), values.GetLength(1)); diagramm = new Mesh[values.GetLength(0), values.GetLength(1)]; diagrammValues = values; type = GraphicType.Diagramm; CreateDiagramm(); Invalidate(); }
public string LoadList(string stSql) { try { tBoxGridX.Text = ""; tBoxGridY.Text = ""; tBoxMaxX.Text = ""; tBoxMaxY.Text = ""; tBoxMinX.Text = ""; tBoxMinY.Text = ""; using (var reader = new ReaderAdo(ConnectionString, stSql)) { while (reader.Read()) { switch (reader.GetString("GraficType")) { case "График": _graphicType = GraphicType.Graphic; break; case "График0": _graphicType = GraphicType.Graphic0; break; case "Диаграмма": _graphicType = GraphicType.Diagram; break; } string uS = "(" + reader.GetString("UnitsX2") + ")"; if (uS == "()") { uS = ""; } chart1.ChartAreas[0].AxisX.Title = reader.GetString("NameX2") + uS; uS = "(" + reader.GetString("UnitsX1") + ")"; if (uS == "()") { uS = ""; } chart1.ChartAreas[0].AxisY.Title = reader.GetString("NameX1") + uS; chart1.Titles[0].Text = reader.GetString("Code"); //_graphicId = int.Parse(reader.GetString("GraficId")); _dim = reader.GetInt("Dimension"); chart1.Legends[0].Enabled = _dim >= 3; } } return(""); } catch (Exception exception) { Error = new ErrorCommand("Траблы с LoadParams", exception); return(ErrorMessage); } }
/// <summary> /// Constructs a new instance of the <see cref="BaseGraphic" /> class /// with properties filed from XML /// </summary> /// <param name="type">Type of the graphic</param> /// <param name="xml">XML to read properties from</param> public BaseGraphic(GraphicType type, XmlNode xml) { if (xml == null) { throw new ArgumentNullException(nameof(xml)); } Type = type; ID = xml.Attributes["id"].Value; }
public static Vector2 BoundMap(Graphic graphic, GraphicType type, Graphic headGraphic, Vector2 headOffset) { string path = graphic.path + (headGraphic == null ? "" : "+" + headGraphic.path); if (!boundMap.ContainsKey(path)) { try { boundMap[path] = ExtractBounds(graphic, type, headGraphic, headOffset); } catch (Exception e) { throw new Exception("BoundMap(,,,)", e); } } return(boundMap[path]); }
private GraphicType CreateGraphicType() { furniture = new GraphicType() { GraphicTypeId = Guid.NewGuid(), Name = "furniture", Description = "Group of furniture" }; return(furniture); }
public void ShouldUpdateGraphicTypeWhenDBContextIsValid() { furniture = CreateGraphicType(); string graphicName = "New GraphicName"; _spacePlanningUnitOfWork.GraphicTypeRepository.Add(furniture); _spacePlanningUnitOfWork.Save(); this.furniture = _spacePlanningUnitOfWork.GraphicTypeRepository.GetById(furniture.GraphicTypeId); this.furniture.Name = graphicName; _spacePlanningUnitOfWork.Save(); Assert.AreEqual(graphicName, _spacePlanningUnitOfWork.GraphicTypeRepository.GetById(furniture.GraphicTypeId).Name); }
void LoadGraphics(GraphicType type) { if (!graphics.ContainsKey(type)) { graphics.Add(type, new List <Graphic>()); var reader = new GraphicReader(); var info = GraphicInfoFromType(type); var graphicList = graphics[type]; void LoadGraphic(IDataReader graphicDataReader, byte maskColor = 0) { graphicDataReader.Position = 0; int end = graphicDataReader.Size - info.DataSize; while (graphicDataReader.Position <= end) { var graphic = new Graphic(); reader.ReadGraphic(graphic, graphicDataReader, info, maskColor); graphicList.Add(graphic); } } var allFiles = new SortedDictionary <int, IDataReader>(); foreach (var graphicFile in graphicFiles[type]) { var containerFile = gameData.Files[graphicFile.File]; if (graphicFile.SubFiles == null) { foreach (var file in containerFile.Files) { allFiles[graphicFile.FileIndexOffset + file.Key] = file.Value; } } else { foreach (var file in graphicFile.SubFiles) { allFiles[graphicFile.FileIndexOffset + file] = containerFile.Files[file]; } } } foreach (var file in allFiles) { LoadGraphic(file.Value, (byte)(type switch { GraphicType.Portrait => 25, GraphicType.LabBackground => 9, // 9 is the sky color index _ => 0 }));
private void CreateElementUser() { Element chairElement; GraphicType graphicType = new GraphicType() { GraphicTypeId = Guid.NewGuid(), Name = "Straight", Description = "Straight" }; Graphic graphic = new Graphic() { GraphicId = Guid.NewGuid(), Height = 100, Width = 200, GraphicTypeId = graphicType.GraphicTypeId, Name = "Straight", Description = "Group of Straight" }; graphic.GraphicType = graphicType; _spacePlanningUnitOfWork.Save(); _spacePlanningUnitOfWork.GraphicRepository.Add(graphic); _spacePlanningUnitOfWork.Save(); ElementType chairs = new ElementType { ElementTypeId = Guid.NewGuid(), Name = "chairs", Description = "chairs" }; chairElement = new Element() { ElementId = Guid.NewGuid(), GraphicId = graphic.GraphicId, ElementTypeId = chairs.ElementTypeId, Description = "computer Chair", Label = "tx chair" }; chairElement.ElementType = chairs; _spacePlanningUnitOfWork.ElementypeRepository.Add(chairs); _spacePlanningUnitOfWork.Save(); User user = new User() { Username = "******", Password = "******", UserId = Guid.NewGuid() }; _spacePlanningUnitOfWork.UserRepository.Add(user); _spacePlanningUnitOfWork.Save(); ownerUser = new ElementUser() { ElementId = chairElement.ElementId, UserId = user.UserId, Element = chairElement, User = user }; }
void LoadGraphics(GraphicType type) { if (!graphics.ContainsKey(type)) { graphics.Add(type, new List <Graphic>()); var reader = new GraphicReader(); var info = GraphicInfoFromType(type); var graphicList = graphics[type]; void LoadGraphic(IDataReader graphicDataReader) { graphicDataReader.Position = 0; int end = graphicDataReader.Size - info.DataSize; while (graphicDataReader.Position <= end) { var graphic = new Graphic(); reader.ReadGraphic(graphic, graphicDataReader, info); graphicList.Add(graphic); } } var allFiles = new SortedDictionary <int, IDataReader>(); foreach (var graphicFile in graphicFiles[type]) { var containerFile = gameData.Files[graphicFile.File]; if (graphicFile.SubFiles == null) { foreach (var file in containerFile.Files) { allFiles[graphicFile.FileIndexOffset + file.Key] = file.Value; } } else { foreach (var file in graphicFile.SubFiles) { allFiles[graphicFile.FileIndexOffset + file] = containerFile.Files[file]; } } } foreach (var file in allFiles) { LoadGraphic(file.Value); } } }
void Awake() { if (GetComponent <SpriteRenderer>() != null) { graphicRenderer = GetComponent <SpriteRenderer>(); defaultSprite = ((SpriteRenderer)graphicRenderer).sprite; graphicType = GraphicType.SPRITERENDERER; } else if (GetComponent <Image>() != null) { graphicRenderer = GetComponent <Image>(); defaultSprite = ((Image)graphicRenderer).sprite; graphicType = GraphicType.IMAGE; } }
/// <summary> /// Определяет график, необходимый к отображению /// </summary> /// <param name="e">An object that contains the navigation data.</param> public void OnFragmentNavigation(FirstFloor.ModernUI.Windows.Navigation.FragmentNavigationEventArgs e) { try { graphicType = (GraphicType)int.Parse(e.Fragment); if (graphicType == GraphicType.Followers) PrintGraphicFollowers(); else if (graphicType == GraphicType.Following) PrintGraphicFollowing(); else PrintGraphicMedia(); } catch(Exception exc) { Client.Pages.MainPage.ShowMessage(ApiServer.ErrorMessageForClient); } }
private static Vector2 ExtractBounds(Graphic graphic, GraphicType type, Graphic headGraphic, Vector2 headOffset) { int vWidth; int vHeight; IntRange vBounds; try { vBounds = Def_Extensions.CropVertical((graphic.MatEast.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight); } catch (Exception ex) { throw new Exception("CombatExtended :: CropVertical error while cropping Textures/" + graphic.path + "_east", ex); } int hWidth; int hHeight; IntRange hBounds; try { hBounds = Def_Extensions.CropHorizontal((graphic.MatSouth.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight); } catch (Exception ex) { throw new Exception("CombatExtended :: CropHorizontal error while cropping Textures/" + graphic.path + "_south", ex); } int vWidthHead; int vHeightHead; IntRange vBoundsHead; try { vBoundsHead = Def_Extensions.CropVertical((headGraphic.MatEast.mainTexture as Texture2D).GetColorSafe(out vWidthHead, out vHeightHead), vWidthHead, vHeightHead); } catch (Exception ex) { throw new Exception("CombatExtended :: CropVertical error while cropping Textures/" + headGraphic.path + "_east", ex); } vBoundsHead.min -= (int)(headOffset.y * (float)vHeightHead); vBoundsHead.max -= (int)(headOffset.y * (float)vHeightHead); vBounds.min = Math.Min(vBounds.min, (int)((float)vBoundsHead.min * (float)vHeight / (float)vHeightHead)); vBounds.max = Math.Max(vBounds.max, (int)((float)vBoundsHead.max * (float)vHeight / (float)vHeightHead)); int hWidthHead; int hHeightHead; IntRange hBoundsHead; try { hBoundsHead = Def_Extensions.CropHorizontal((headGraphic.MatSouth.mainTexture as Texture2D).GetColorSafe(out hWidthHead, out hHeightHead), hWidthHead, hHeightHead); } catch (Exception ex) { throw new Exception("CombatExtended :: CropHorizontal error while cropping Textures/" + headGraphic.path + "_south", ex); } hBoundsHead.min += (int)(headOffset.x * (float)hWidthHead); hBoundsHead.max += (int)(headOffset.x * (float)hWidthHead); hBounds.max = Math.Max(hBounds.max, (int)((float)hBoundsHead.max * (float)hWidth / (float)hWidthHead)); hBounds.min = Math.Min(hBounds.min, (int)((float)hBoundsHead.min * (float)hWidth / (float)hWidthHead)); return(new Vector2( (float)(hBounds.max - hBounds.min) / (float)hWidth, (float)(vBounds.max - vBounds.min) / (float)vHeight)); }
private Texture LoadTexture(GraphicType graphicType, int graphicShipId) { switch (graphicType) { case GraphicType.Card: return(SingletonMonoBehaviour <ResourceManager> .Instance.ShipTexture.Load(mGraphicShipId, 3)); case GraphicType.ShipNormal: return(SingletonMonoBehaviour <ResourceManager> .Instance.ShipTexture.Load(mGraphicShipId, 9)); case GraphicType.ShipTaiha: return(SingletonMonoBehaviour <ResourceManager> .Instance.ShipTexture.Load(mGraphicShipId, 10)); default: return(null); } }
private void CreateGeometryAndExtentForTrackOrRoute(GeometryData data, GraphicType typeOfGraphic) { var builder = new PolylineBuilder(new SpatialReference(4326)); foreach (var wayPoint in data.Points) { builder.AddPoint(new MapPoint((double)wayPoint.lon, (double)wayPoint.lat)); } var esriGeometry = builder.ToGeometry(); data.Extent = esriGeometry.Extent; var geometry = new BikeTouringGISGraphic(esriGeometry, typeOfGraphic); geometry.Attributes["name"] = data.Name; geometry.Attributes["filename"] = data.FileName; data.Geometry = geometry; }
private void CreateDesktop() { GraphicType graphicType = new GraphicType() { GraphicTypeId = Guid.NewGuid(), Name = "Straight", Description = "Straight" }; desktop = new Graphic() { GraphicId = Guid.NewGuid(), Height = 100, Width = 200, GraphicTypeId = graphicType.GraphicTypeId, Name = "Straight", Description = "Group of Straight" }; desktop.GraphicType = graphicType; }
private Texture LoadTexture(GraphicType graphicType, int graphicShipId) { switch (graphicType) { case GraphicType.First: return(SingletonMonoBehaviour <ResourceManager> .Instance.SlotItemTexture.Load(mGraphicSlotItemMstId, 1)); case GraphicType.Second: return(SingletonMonoBehaviour <ResourceManager> .Instance.SlotItemTexture.Load(mGraphicSlotItemMstId, 2)); case GraphicType.Third: return(SingletonMonoBehaviour <ResourceManager> .Instance.SlotItemTexture.Load(mGraphicSlotItemMstId, 3)); case GraphicType.Fourth: return(SingletonMonoBehaviour <ResourceManager> .Instance.SlotItemTexture.Load(mGraphicSlotItemMstId, 4)); default: return(null); } }
public static void FillTwoColumnMatrix(this double[][] matrix, GraphicType graphicType, double decreaseCoeff, double increaseCoeff) { var rows = matrix.Length; var columns = matrix[0].Length; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { if (j == 0) { matrix[i][j] = i + 1; } else { matrix[i][j] = (i + 1) * ((i + j) % 2 == 0 ? decreaseCoeff : increaseCoeff); } } } }
/// <summary> /// Loads a new graphics from a wad /// </summary> /// <param name="lumpName"></param> /// <param name="file"></param> public Graphic(WadFile file, string lumpName) { lump = file[lumpName]; using (MemoryStream stream = lump.RawStream()) { // Move to png marker stream.ReadByte(); bool png = IsPng(stream); bool jfif = false; if (!png) { stream.Position = 4; for (int i = 0; i < 2; i++) { stream.ReadByte(); } jfif = IsJfif(stream); } if (png) { Type = GraphicType.Png; } else if (jfif) { Type = GraphicType.Jpeg; } else { Type = GraphicType.DoomPatch; doomImage = new DoomGraphic(lump, file.Pallete(0)); } } }
private static Vector2 ExtractBounds(Graphic graphic, GraphicType type) { int vWidth; int vHeight; var vBounds = Def_Extensions.CropVertical((graphic.MatSide.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight); //Plants only care for verts //This is assuming PLANTS TAKE UP A FULL TILE!! // TODO : Refactor if (type == GraphicType.Plant) { return(new Vector2( 1f, (float)(vBounds.max - vBounds.min) / (float)vHeight)); } int hWidth; int hHeight; var hBounds = Def_Extensions.CropHorizontal((graphic.MatFront.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight); return(new Vector2( (float)(hBounds.max - hBounds.min) / (float)hWidth, (float)(vBounds.max - vBounds.min) / (float)vHeight)); }
private static Vector2 ExtractBounds(Graphic graphic, GraphicType type, Graphic headGraphic, Vector2 headOffset) { int vWidth; int vHeight; var vBounds = Def_Extensions.CropVertical((graphic.MatSide.mainTexture as Texture2D).GetColorSafe(out vWidth, out vHeight), vWidth, vHeight); int hWidth; int hHeight; var hBounds = Def_Extensions.CropHorizontal((graphic.MatFront.mainTexture as Texture2D).GetColorSafe(out hWidth, out hHeight), hWidth, hHeight); int vWidthHead; int vHeightHead; var vTexHead = headGraphic.MatSide.mainTexture as Texture2D; var vBoundsHead = Def_Extensions.CropVertical(vTexHead.GetColorSafe(out vWidthHead, out vHeightHead), vWidthHead, vHeightHead); vBoundsHead.min += (int)(headOffset.y * (float)vHeightHead); vBoundsHead.max += (int)(headOffset.y * (float)vHeightHead); vBounds.max = Math.Max(vBounds.max, (int)((float)vBoundsHead.max * (float)vHeight / (float)vHeightHead)); vBounds.min = Math.Min(vBounds.min, (int)((float)vBoundsHead.min * (float)vHeight / (float)vHeightHead)); int hWidthHead; int hHeightHead; var hTexHead = headGraphic.MatFront.mainTexture as Texture2D; var hBoundsHead = Def_Extensions.CropVertical(hTexHead.GetColorSafe(out hWidthHead, out hHeightHead), hWidthHead, hHeightHead); hBoundsHead.min += (int)(headOffset.x * (float)hWidthHead); hBoundsHead.max += (int)(headOffset.x * (float)hWidthHead); hBounds.max = Math.Max(hBounds.max, (int)((float)hBoundsHead.max * (float)hWidth / (float)hWidthHead)); hBounds.min = Math.Min(hBounds.min, (int)((float)hBoundsHead.min * (float)hWidth / (float)hWidthHead)); return(new Vector2( (float)(hBounds.max - hBounds.min) / (float)hWidth, (float)(vBounds.max - vBounds.min) / (float)vHeight)); }