Exemplo n.º 1
0
 public AtlasFile Decode(Stream file)
 {
     using (BinaryReader reader = new BinaryReader(file))
     {
         if (reader.ReadInt32() != 1)
         {
             throw new FileLoadException("Illegal atlas file: Does not start with '1'");
         }
         reader.ReadBytes(4);
         int       numEntries = reader.ReadInt32();
         AtlasFile result     = new AtlasFile();
         for (int i = 0; i < numEntries; i++)
         {
             AtlasObject item = new AtlasObject
             {
                 Container1 = IOFunctions.ReadZeroTerminatedUnicode(reader),
                 Container2 = IOFunctions.ReadZeroTerminatedUnicode(reader),
                 X1         = reader.ReadSingle(),
                 Y1         = reader.ReadSingle(),
                 X2         = reader.ReadSingle(),
                 Y2         = reader.ReadSingle(),
                 X3         = reader.ReadSingle(),
                 Y3         = reader.ReadSingle()
             };
             result.add(item);
         }
         return(result);
     }
 }
 public ToolTipRegion(AtlasObject aO)
 {
     this.name = aO.Container1;
     this.x1   = (int)aO.X1;
     this.y1   = (int)aO.Y1;
     this.x2   = (int)(aO.X1 + aO.X3);
     this.y2   = (int)(aO.Y1 + aO.Y3);
 }
Exemplo n.º 3
0
        private void removeAtlasEntry_Click(object sender, EventArgs e)
        {
            AtlasObject selectedObject = (AtlasObject)this.olv.SelectedObject;

            this.EditedFile.removeAt(this.olv.IndexOf(this.olv.SelectedObject));
            this.olv.RemoveObject(selectedObject);
            this.olv.RefreshObjects(this.EditedFile.Entries);
            this.DataChanged = true;
        }
Exemplo n.º 4
0
        private void addAtlasEntry_Click(object sender, EventArgs e)
        {
            AtlasObject newEntry = new AtlasObject {
                Container1 = "NEW_ENTRY",
                Container2 = "NEW_ENTRY"
            };

            EditedFile.add(newEntry);
            this.olv.AddObject(newEntry);
            this.DataChanged = true;
            this.olv.EnsureModelVisible(newEntry);
        }
Exemplo n.º 5
0
        private void exportTSV_Click(object sender, EventArgs e)
        {
            List <string> strings = new List <string>();

            foreach (OLVListItem item in this.olv.Items)
            {
                AtlasObject rowObject = (AtlasObject)item.RowObject;
                strings.Add(rowObject.Container1 + "\t" +
                            rowObject.Container2 + "\t" +
                            rowObject.X1.ToString() + "\t" +
                            rowObject.Y1.ToString() + "\t" +
                            rowObject.X3.ToString() + "\t" +
                            rowObject.Y3.ToString());
            }
            WriteToTSVFile(strings);
        }
 public void CreateGrid()
 {
     atlasFile.setPixelUnits(pictureBox1.Image.Height);
     grid           = new Rectangle[atlasFile.numEntries];
     toolTipRegions = new ToolTipRegion[atlasFile.numEntries];
     for (int i = 0; i < grid.Length; i++)
     {
         AtlasObject aO = atlasFile.Entries[i];
         toolTipRegions[i] = new ToolTipRegion(aO);
         grid[i]           = new Rectangle((int)aO.PX1, (int)aO.PY1, (int)aO.X3, (int)aO.Y3);
     }
     using (Graphics graphics = Graphics.FromImage(pictureBox1.Image)) {
         var pen = new Pen(Color.Red, 4f);
         graphics.DrawRectangles(pen, grid);
     }
     pictureBox1.Refresh();
     button1.Enabled = false;
     button2.Enabled = true;
     button3.Enabled = true;
     button3.Click  += Button3Click;
 }