// Use this for initialization void Start() { vB = interactive.GetComponent <ViewBox>(); InvokeRepeating("MoveVBCenter", 5.0f, 1.0f); }
private void RemoveView(int uid) { foreach (Object view in ViewList) { if (view is ViewBox) { ViewBox viewType = (ViewBox)view; if (viewType.Uid == uid) { ViewList.Remove(viewType); break; } } else if (view is ViewCupboard) { ViewCupboard viewType = (ViewCupboard)view; if (viewType.Uid == uid) { ViewList.Remove(viewType); break; } } } }
public void BringToFrontView(int uid) { foreach (Object view in ViewList) { if (view is ViewBox) { ViewBox viewType = (ViewBox)view; if (viewType.Uid == uid) { viewType.BringToFront(); break; } } if (view is ViewCupboard) { ViewCupboard viewType = (ViewCupboard)view; if (viewType.Uid == uid) { viewType.RefreshView(); viewType.Show(); viewType.BringToFront(); break; } } } }
public static ViewBox CreateViewBox(int cellsLong, int cellsHigh, int cellsWide, float boxSize, float rotX, float rotY, float rotZ, string filepath, Vector3 initPos) { Vector3 middlePoint = initPos; //making the object that will be copied GameObject boxObject = Instantiate(ViewBoxPreFab.gameObject, middlePoint, Quaternion.Euler(rotX, rotY, rotZ)); ViewBox viewBox = boxObject.GetComponent <ViewBox>(); //using square scales for proper display float boxLength = boxSize; float boxHeight = boxSize; float boxWidth = boxSize; viewBox.cells = new int[] { cellsLong, cellsHigh, cellsWide }; viewBox.boxSize = new float[] { boxLength, boxHeight, boxWidth }; Vector3 boxNum = new Vector3(boxLength, boxHeight, boxWidth); viewBox.origin = new float[] { -boxLength / 2f, -boxHeight / 2f, -boxWidth / 2f }; viewBox.rotations = new float[] { rotX, rotY, rotZ }; boxObject.transform.localScale = boxNum; //could also detect if there are other view boxes and try to line them up // this is the unit cell that is copied; it gets disabled later UnitCell primeUnitCell = UnitCell.NewUnitCell(filepath, boxObject.GetComponent <ViewBox>()); for (int i = 0; i < cellsLong; i++) { for (int j = 0; j < cellsHigh; j++) { for (int k = 0; k < cellsWide; k++) { Vector3 xposVec = primeUnitCell.vecA * (float)i; Vector3 yposVec = primeUnitCell.vecB * (float)j; Vector3 zposVec = primeUnitCell.vecC * (float)k; float xpos = xposVec.x + yposVec.x + zposVec.x; float ypos = xposVec.y + yposVec.y + zposVec.y; float zpos = xposVec.z + yposVec.z + zposVec.z; Vector3 newPos = new Vector3(xpos, ypos, zpos); newPos += new Vector3(viewBox.origin[0], viewBox.origin[1], viewBox.origin[2]); GameObject iterUnitCell = Instantiate(primeUnitCell.gameObject, boxObject.transform); iterUnitCell.transform.localPosition = newPos; } } } //disables this instance but keeps all of the other ones that are corectly positioned wrt eachother primeUnitCell.gameObject.SetActive(false); return(viewBox); }
public void AddViewBox(int uidCupboard, int uid, Box box) { ViewBox viewBox = new ViewBox(uidCupboard, uid, box, this); viewBox.Dock = DockStyle.Fill; ViewList.Add(viewBox); viewBox.BringToFront(); }
/// <summary> /// Applies the required transforms to <see cref="ISvgRenderer"/>. /// </summary> /// <param name="renderer">The <see cref="ISvgRenderer"/> to be transformed.</param> protected internal override bool PushTransforms(ISvgRenderer renderer) { if (!base.PushTransforms(renderer)) { return(false); } ViewBox.AddViewBoxTransform(AspectRatio, renderer, this); return(true); }
/// <summary> /// Instantiate the View /// </summary> /// <param name="owner">The owner view</param> public PivotTableView(ViewBase owner) : base(owner) { // Read in the glade file Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.PivotTableView.glade"); // Assign the interactable objects from glade vbox1 = (VBox)builder.GetObject("vbox1"); leftbutton = (Button)builder.GetObject("leftbutton"); rightbutton = (Button)builder.GetObject("rightbutton"); storebutton = (Button)builder.GetObject("storebutton"); // Setup the ViewBoxes Ledger = new ViewBox("Ledger", this, builder); Expression = new ViewBox("Expression", this, builder); Value = new ViewBox("Value", this, builder); Row = new ViewBox("Row", this, builder); Column = new ViewBox("Column", this, builder); Pivot = new ViewBox("Pivot", this, builder); Time = new ViewBox("Time", this, builder); // Add text options to the ViewBoxes Expression.AddText("Sum"); Expression.AddText("Average"); Expression.AddText("Max"); Expression.AddText("Min"); Value.AddText("Gain"); Value.AddText("Loss"); AddOptions(Row); AddOptions(Column); AddOptions(Pivot); Time.AddText("Daily"); Time.AddText("Monthly"); Time.AddText("Yearly"); Time.AddText("MonthlyAverage"); // Subscribe the left/right buttons to the change pivot event leftbutton.Clicked += OnChangePivot; rightbutton.Clicked += OnChangePivot; // Subscribe the store button to the store data event storebutton.Clicked += OnStoreData; // Add the custom gridview (external to glade) gridview = new GridView(owner); gridview.ReadOnly = true; vbox1.Add(gridview.MainWidget); // Let the viewbase know which widget is the main widget _mainWidget = vbox1; }
public bool TouchUpInside(SKRect rect) { bool touchUpInsideButton = Touched && ViewBox.IntersectsWithInclusive(rect) && IsVisible; if (IsToggleButton && touchUpInsideButton) { IsToggled = !IsToggled; } return(touchUpInsideButton); }
void Initialize() { Element.TryMakePTable(); ViewBox.ViewBoxPreFab = ViewBoxPreFaberino; UnitCell.UnitCellPreFab = UnitCellPreFaberino; UnitCell.BoundaryPreFab = BoundaryPreFaberino; Atom.AtomPreFab = AtomPreFaberino; initPos = new Vector3(posX, posY, posZ); ViewBox.CreateViewBox(cellsLong, cellsHigh, cellsWide, boxSize, rotX, rotY, rotZ, filepathGeneral, initPos); }
protected bool Equals(CommonTileBrush other) { return(other != null && base.Equals(other) && AlignmentX == other.AlignmentX && AlignmentY == other.AlignmentY && Stretch == other.Stretch && TileMode == other.TileMode && ViewBox.Equals(other.ViewBox) && ViewBoxUnits == other.ViewBoxUnits && ViewPort.Equals(other.ViewPort) && ViewPortUnits == other.ViewPortUnits); }
public bool TouchUpInside(SKRect rect) { bool touchUpInsideButton = Touched && ViewBox.IntersectsWithInclusive(rect) && IsVisible; if (IsToggleButton && touchUpInsideButton) { IsToggled = !IsToggled; } if (touchUpInsideButton) { Handler?.Invoke(this, new EventArgs()); } return(touchUpInsideButton); }
public override int GetHashCode() { var hashCode = base.GetHashCode(); unchecked { hashCode = hashCode * -1521134295 + AlignmentX.GetHashCode(); hashCode = hashCode * -1521134295 + AlignmentY.GetHashCode(); hashCode = hashCode * -1521134295 + Stretch.GetHashCode(); hashCode = hashCode * -1521134295 + TileMode.GetHashCode(); hashCode = hashCode * -1521134295 + ViewBox.GetHashCode(); hashCode = hashCode * -1521134295 + ViewBoxUnits.GetHashCode(); hashCode = hashCode * -1521134295 + ViewPort.GetHashCode(); hashCode = hashCode * -1521134295 + ViewPortUnits.GetHashCode(); } return(hashCode); }
public MainWindow() { InitializeComponent(); ViewBox.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler(Canvas_MouseLeftButtonDown), true); _redactor = new GraphRedactor(800, 400, Canvas); _redactor.ToolPicker.AddTool(new RectangleTool()); _redactor.ToolPicker.AddTool(new ZoomTool()); _redactor.ToolPicker.AddTool(new EllipseTool()); _redactor.ToolPicker.AddTool(new PencilTool()); _redactor.ToolPicker.AddTool(new HandTool()); _redactor.ToolPicker.AddTool(new LineTool()); _redactor.ToolPicker.AddTool(new PieTool()); _redactor.ToolPicker.AddTool(new AnimateTool()); _redactor.ToolPicker.RenderTools(Tools, ToolArgs); }
private void btnServices_Click(object sender, EventArgs e) { ClearPanel(); ViewBox = new ViewBox(); ViewBox.Dock = DockStyle.Fill; ViewBox.LvServices.Width = ViewBox.Width; MainPanel.Controls.Add(ViewBox); this.WindowState = FormWindowState.Maximized; //this.Size = DefaultSize; this.StartPosition = FormStartPosition.CenterScreen; ViewBox.btnCancel.Click += LoadDashboard; ViewBox.deleteSelectedMenuItem.Click += DeleteItemFromServiceViewBox; ViewBox.addNewServiceToolStripMenuItem.Click += addNewServiceToolStripMenuItem_Click; ViewBox.editSelectedToolStripMenuItem.Click += editSelectedToolStripMenuItem_Click; ViewBox.reloadServicesToolStripMenuItem.Click += btnServices_Click; ViewBox.cancelToolStripMenuItem.Click += btnServices_Click; }
/// <summary> /// Add the ledger text options to a view box /// </summary> /// <param name="combo"></param> private static void AddOptions(ViewBox box) { List <string> options = new List <string>() { "CheckpointID", "SimulationID", "Zone", "Clock.Today", "Resource", "Activity", "ActivityType", "Reason" }; foreach (string option in options) { box.AddText(option); } }
// functions within UnitCell public static UnitCell NewUnitCell(string filepath, ViewBox parentViewBox) { //this is the order these functions should be run in, otherwise there won't be the correct things in place GameObject unitCellObject = Instantiate(UnitCellPreFab.gameObject, parentViewBox.transform); UnitCell unitCell = unitCellObject.GetComponent <UnitCell>(); string[] atomsCIF = unitCell.ReadCif(filepath); unitCell.parentViewBox = parentViewBox; unitCell.unitCellScale = unitCell.SetScaleSize(); unitCell.SetCorners(); unitCell.atomList = unitCell.MakeAtoms(atomsCIF); unitCell.SetAtomColors(); unitCell.DrawAllBoundaries(); return((unitCell));; }
public void CheckIntersection(SKRect rect) { Touched = ViewBox.IntersectsWithInclusive(rect); }
/// <summary> /// Instantiate the View /// </summary> /// <param name="owner">The owner view</param> public PivotTableView(ViewBase owner) : base(owner) { // Read in the glade file Builder builder = BuilderFromResource("ApsimNG.Resources.Glade.PivotTableView.glade"); // Assign the interactable objects from glade vbox1 = (VBox)builder.GetObject("vbox1"); leftButton = (Button)builder.GetObject("leftbutton"); rightButton = (Button)builder.GetObject("rightbutton"); storeButton = (Button)builder.GetObject("storebutton"); leftButton.Name = "left"; rightButton.Name = "right"; filterLabel = (Label)builder.GetObject("filter"); // Setup the ViewBoxes LedgerViewBox = new ViewBox("ledgerbox", this, builder) { Name = "LedgerViewBox" }; ExpressionViewBox = new ViewBox("expressionbox", this, builder) { Name = "ExpressionViewBox" }; ValueViewBox = new ViewBox("valuebox", this, builder) { Name = "ValueViewBox" }; RowViewBox = new ViewBox("rowbox", this, builder) { Name = "RowViewBox" }; ColumnViewBox = new ViewBox("columnbox", this, builder) { Name = "ColumnViewBox" }; FilterViewBox = new ViewBox("filterbox", this, builder) { Name = "FilterViewBox" }; TimeViewBox = new ViewBox("timebox", this, builder) { Name = "TimeViewBox" }; // Add text options to the ViewBoxes ExpressionViewBox.AddText("Sum"); ExpressionViewBox.AddText("Average"); ExpressionViewBox.AddText("Max"); ExpressionViewBox.AddText("Min"); ValueViewBox.AddText("Gain"); ValueViewBox.AddText("Loss"); AddOptions(RowViewBox); AddOptions(ColumnViewBox); FilterViewBox.AddText("None"); AddOptions(FilterViewBox); TimeViewBox.AddText("Daily"); TimeViewBox.AddText("Monthly"); TimeViewBox.AddText("Yearly"); // Subscribe the left/right buttons to the change pivot event leftButton.Clicked += OnInvokeUpdate; rightButton.Clicked += OnInvokeUpdate; // Subscribe the store button to the store data event storeButton.Clicked += OnStoreData; // Add the custom gridview (external to glade) Grid = new GridView(owner) { ReadOnly = true }; vbox1.Add(Grid.MainWidget); // Let the viewbase know which widget is the main widget mainWidget = vbox1; }
public TrackChangesArgs(ViewBox box) { Name = box.Name; Value = box.ID; }
public static ViewBox ParseViewBox(XmlElement node) { ViewBox box1 = null; XmlAttribute attribute1 = node.Attributes["viewBox"]; if (attribute1 != null) { string text1 = attribute1.Value.Trim(); char[] chArray1 = new char[2] { ',', ' ' }; string[] textArray1 = text1.Trim().Split(chArray1); if (textArray1.Length >= 4) { NumberFormatInfo info1 = new NumberFormatInfo(); info1.NumberDecimalSeparator = "."; try { float single1 = float.Parse(textArray1[0], info1); float single2 = float.Parse(textArray1[1], info1); float single3 = float.Parse(textArray1[2], info1); float single4 = float.Parse(textArray1[3], info1); box1 = new ViewBox(single1, single2, single3, single4); } catch (Exception) { } } } attribute1 = node.Attributes["preserveAspectRatio"]; if ((attribute1 != null) && (box1 != null)) { string text5; string text2 = attribute1.Value.Trim(); char[] chArray2 = new char[2] { ' ', ',' }; string[] textArray2 = text2.Trim().Split(chArray2); string text3 = string.Empty; string text4 = string.Empty; PreserveAspectRatio ratio1 = null; parAlign align1 = parAlign.none; parMeetOrSlice slice1 = parMeetOrSlice.meet; if (textArray2.Length >= 1) { text3 = textArray2[0].Trim(); } else if (textArray2.Length >= 2) { text4 = textArray2[1].Trim(); } if ((text3 != string.Empty) && ((text5 = text3.Trim().ToLower()) != null)) { text5 = string.IsInterned(text5); if (text5 != "xminymin") { if (text5 == "xmidymin") { align1 = parAlign.xMidYMin; } else if (text5 == "xminymid") { align1 = parAlign.xMinYMid; } else if (text5 == "xmidymid") { align1 = parAlign.xMidYMid; } else if (text5 == "xmaxymid") { align1 = parAlign.xMaxYMid; } else if (text5 == "xminymax") { align1 = parAlign.xMinYMax; } else if (text5 == "xmidymax") { align1 = parAlign.xMidYMax; } else if (text5 == "xmaxymax") { align1 = parAlign.xMaxYMax; } } else { align1 = parAlign.xMaxYMin; } } if (text4 != string.Empty) { if (text4.Trim().ToLower() == "meet") { slice1 = parMeetOrSlice.meet; } else if (text4.Trim().ToLower() == "slice") { slice1 = parMeetOrSlice.slice; } } ratio1 = new PreserveAspectRatio(align1, slice1); box1.psr = ratio1; } return(box1); }
static bool DoConvert(string glifFile, string targetGlif, string transDefFile, bool includeOriginal, int turdSize) { //1.Convert glifFile to RawSVG Stream //2.Apply target Transformations SVG //3.Use SVG File to CreateBitmap Object //4.Generate SVG File with Transformations //5.Translate Origin based on ViewBox of RawSVG //6.Generate glifFile from SVGFile. //Step#1 string rawSVG = ConvertToSVG(glifFile); if (string.IsNullOrEmpty(rawSVG)) { return(false); } //Step#2&3 string svgWithTrans = ApplyTransformations(rawSVG, transDefFile); //Step#3 Bitmap bitmap = LoadAsBitmap(svgWithTrans); { string name = new FileInfo(glifFile).Name; bitmap.Save(DebugFile("svgWithTrans", ".bmp", name), ImageFormat.Bmp); } bool targtDirection = TargetDirection(glifFile); //Step#4 string svg = PotraceWrapper.AsSVG(bitmap, Size, false, false, turdSize, false); string svg2 = PotraceWrapper.AsSVG(bitmap, Size, false, true, turdSize, false); //Step#5 ViewBox VB = ExtractViewBox(rawSVG); //Can be made part of ConvertToSVG of Step#1 string path = GetPath(svg); path = Translate(path, VB.MinX, VB.MinY, " ", " "); //Step#6 string targetGlifContent = ConvertToGilf(path, glifFile, includeOriginal); File.WriteAllText(targetGlif, targetGlifContent); if (genDebugFiles) { string name = new FileInfo(glifFile).Name; File.WriteAllText(DebugFile("rawSVG", ".svg", name), rawSVG); File.WriteAllText(DebugFile("svgWithTrans", ".svg", name), svgWithTrans); bitmap.Save(DebugFile("svgWithTrans", ".bmp", name), ImageFormat.Bmp); File.WriteAllText(DebugFile("targetSVG", ".svg", name), svg); File.WriteAllText(DebugFile("targetSVG2", ".svg", name), svg2); File.WriteAllText(DebugFile("targetglif", ".glif", name), targetGlifContent); string targetglifSVG = ConvertToSVG(DebugFile("targetglif", ".glif", name)); File.WriteAllText(DebugFile("targetglifSVG", ".svg", name), targetglifSVG); } return(true); }
internal static void ProcessSVG(string srcFile, string targetFile, string transDefFile, bool includeOriginal, int turdSize) { XmlDocument document = new XmlDocument(); XmlReaderSettings settings = new XmlReaderSettings(); settings.XmlResolver = null; settings.DtdProcessing = DtdProcessing.Ignore; Stream s = new FileStream(srcFile, FileMode.Open); XmlReader reader = XmlReader.Create(s, settings); document.Load(reader); string rules = File.ReadAllText(SVGTempalte); int cnt = 1; XmlNodeList glyphs = document.GetElementsByTagName("glyph"); foreach (XmlNode glyph in glyphs) { DateTime start = DateTime.Now; var d = glyph.Attributes["d"] == null ? "" : glyph.Attributes["d"].InnerText; if (string.IsNullOrEmpty(d)) { continue; } var name = glyph.Attributes["glyph-name"].InnerText; if (name != "Y") { continue; } name = cnt + "." + name; Console.Write(name); var d2 = RelativeToAbsolute(d); ViewBox WH = GetViewBox(d2); string absoluteSVG = rules .Replace("$width", WH.Width.ToString()) .Replace("$height", WH.Height.ToString()) .Replace("$minX", WH.MinX.ToString()) .Replace("$minY", WH.MinY.ToString()) .Replace("$path", d2); //string relativeSVG = rules.Replace("$width", WH.x.ToString()).Replace("$height", WH.y.ToString()).Replace("$path", d); //if (genDebugFiles) //{ // File.WriteAllText(DebugFile("SVG", ".svg", name), relativeSVG); // File.WriteAllText(DebugFile("SVG2", ".svg", name), absoluteSVG); //} string targetPath = DoConvert2(name, absoluteSVG, transDefFile, includeOriginal, turdSize, WH.MinX, WH.MinY); if (Size != 1) { if (glyph.Attributes["horiz-adv-x"] == null) { Debugger.Break(); } else { double horiz = Convert.ToDouble(glyph.Attributes["horiz-adv-x"].InnerText); glyph.Attributes["horiz-adv-x"].InnerText = (horiz * Size).ToString("0"); } } glyph.Attributes["d"].InnerText = targetPath; cnt++; Console.WriteLine(" -" + (DateTime.Now - start).TotalMilliseconds + "ms"); } document.Save(targetFile); }
public static void drawItem(BaseReport Base, ViewScroll parent, int offset) { int boxHeight = 110; ViewBox Box = new ViewBox(); Box.setRelativeTo(parent); Box.setWidth(parent.getWidth() - 20); Box.setHeight(boxHeight); Box.setLeft(0); Box.setTop((boxHeight + 10) * offset); Box.setColor(Color.white); parent.Components.Add(Box); string label = "[" + Base.name + " is Landed At " + Base.entity + "]"; ViewLabel BaseLabel = new ViewLabel(label); BaseLabel.setRelativeTo(Box); BaseLabel.setTop(5); BaseLabel.setLeft(5); BaseLabel.setHeight(15); BaseLabel.setPercentWidth(100); BaseLabel.setColor(Color.green); parent.Components.Add(BaseLabel); ViewLabel FuelLabel = new ViewLabel("Fuel: " + Base.fuel); FuelLabel.setRelativeTo(Box); FuelLabel.setTop(25); FuelLabel.setLeft(5); FuelLabel.setHeight(15); FuelLabel.setWidth(150); FuelLabel.setColor(Color.white); parent.Components.Add(FuelLabel); ViewLabel OreLabel = new ViewLabel("Ore: " + Base.ore); OreLabel.setRelativeTo(Box); OreLabel.setTop(45); OreLabel.setLeft(5); OreLabel.setHeight(20); OreLabel.setWidth(150); OreLabel.setColor(Color.white); parent.Components.Add(OreLabel); ViewLabel CrewLabel = new ViewLabel("Crew: " + Base.crew); CrewLabel.setRelativeTo(Box); CrewLabel.setTop(65); CrewLabel.setLeft(5); CrewLabel.setHeight(20); CrewLabel.setWidth(150); CrewLabel.setColor(Color.white); parent.Components.Add(CrewLabel); ViewLabel CrewCapacityLabel = new ViewLabel("Crew Capacity: " + Base.crewCapacity); CrewCapacityLabel.setRelativeTo(Box); CrewCapacityLabel.setTop(85); CrewCapacityLabel.setLeft(5); CrewCapacityLabel.setHeight(20); CrewCapacityLabel.setWidth(150); CrewCapacityLabel.setColor(Color.white); parent.Components.Add(CrewCapacityLabel); ViewLabel DockingPortsLabel = new ViewLabel("Docking Ports: " + Base.dockingPorts); DockingPortsLabel.setRelativeTo(Box); DockingPortsLabel.setTop(25); DockingPortsLabel.setLeft(155); DockingPortsLabel.setHeight(15); DockingPortsLabel.setWidth(150); DockingPortsLabel.setColor(Color.white); parent.Components.Add(DockingPortsLabel); ViewLabel DockedVesselsLabel = new ViewLabel("Docked Vessels: " + Base.dockedVessels); DockedVesselsLabel.setRelativeTo(Box); DockedVesselsLabel.setTop(45); DockedVesselsLabel.setLeft(155); DockedVesselsLabel.setHeight(15); DockedVesselsLabel.setWidth(150); DockedVesselsLabel.setColor(Color.white); parent.Components.Add(DockedVesselsLabel); ViewLabel ScienceLabLabel = new ViewLabel("Science Lab: " + Base.scienceLab); ScienceLabLabel.setRelativeTo(Box); ScienceLabLabel.setTop(65); ScienceLabLabel.setLeft(155); ScienceLabLabel.setHeight(15); ScienceLabLabel.setWidth(150); ScienceLabLabel.setColor(Color.white); parent.Components.Add(ScienceLabLabel); ViewLabel HasDrillLabel = new ViewLabel("Has Drill: " + Base.drill); HasDrillLabel.setRelativeTo(Box); HasDrillLabel.setTop(85); HasDrillLabel.setLeft(155); HasDrillLabel.setHeight(15); HasDrillLabel.setWidth(150); HasDrillLabel.setColor(Color.white); parent.Components.Add(HasDrillLabel); ViewLabel SCLabel = new ViewLabel("PO: " + Base.po); SCLabel.setRelativeTo(Box); SCLabel.setTop(25); SCLabel.setLeft(310); SCLabel.setHeight(15); SCLabel.setWidth(150); SCLabel.setColor(Color.white); parent.Components.Add(SCLabel); ViewLabel POLabel = new ViewLabel("SC: " + Base.sc); POLabel.setRelativeTo(Box); POLabel.setTop(45); POLabel.setLeft(310); POLabel.setHeight(15); POLabel.setWidth(150); POLabel.setColor(Color.white); parent.Components.Add(POLabel); }