public void ChangeSelectedFile(Object sender, ChangeFileEventArgs e) { var x = fileView.FindItemWithText(e.filename); ChangeFileEventArgs.currentDaxId = e.daxId; ChangeFileEventArgs.targetPlace = e.place; x.Selected = true; x.Focused = true; }
public void mouseClickOnMap(object sender, MouseEventArgs e) { var panel = tab.SelectedTab.Controls["mapPanel"]; var pictureBox = panel.Controls["map"] as PictureBox; var mousePos = new Point(e.X, e.Y); // Cursor.Position; var offset = getPictureBoxOffset(pictureBox); float x = mousePos.X - offset.X; float y = mousePos.Y - offset.Y; x /= ((float)offset.Width / FullMapWidth); y /= ((float)offset.Height / FullMapHeight); int row = (int)((y - GutterSize) / (RoomSize)); int col = (int)((x - GutterSize) / (RoomSize)); EventHandler <ChangeFileEventArgs> handler = ChangeSelectedFile; // Event will be null if there are no subscribers if (handler != null) { ChangeFileEventArgs ev = new ChangeFileEventArgs(); ev.daxId = -1; var mapRecord = _goldBoxFile.GetMaps()[tab.SelectedIndex]; foreach (var w in mapRecord.Walls) { if (w.Row == row && w.Column == col) { ev.place = String.Format("event {0}", w.Event & 127); } } var diskNumber = Convert.ToInt32(Path.GetFileName(_goldBoxFile.FileName).Replace("GEO", "").Replace(".DAX", "")); ev.filename = String.Format("ECL{0}.DAX", diskNumber); // choose an ecl we hope corresponds to this map // first choose the ecl with the same id as the map, if such an ecl block exists if (_goldBoxFile._daxEclFile.eclDumps.Find(ecldump => ecldump._blockId == mapRecord.DaxId) != null) { ev.daxId = mapRecord.DaxId; } // have any of the ecls referenced this map in code? if so, pick one of those if (_goldBoxFile.referencedByEcl.Count > 0) { // do we not have a valid ecl block yet? if not, default to the first ecl block that references this map id if (ev.daxId == -1) { ev.daxId = _goldBoxFile.referencedByEcl[0]; } // see if there's an ecl with the same number of events, that will be the most likely candidate foreach (var id in _goldBoxFile.referencedByEcl) { var eclBlk = _goldBoxFile._daxEclFile.eclDumps.Find(ecldump => ecldump._blockId == id); // find the ecl block which matches id if (eclBlk != null) { if ((_goldBoxFile.highestEvent[mapRecord.DaxId] == eclBlk.eventCount || (_goldBoxFile.highestEvent[mapRecord.DaxId] & 31) == eclBlk.eventCount) && eclBlk.eventCount > 0) { ev.daxId = id; } } } } // if we still haven't found an ecl, just go with the first one in the ecl file for this disk if (ev.daxId == -1) { ev.daxId = _goldBoxFile._daxEclFile.eclDumps[0]._blockId; } // Use the () operator to raise the event. if (ev.place != null) { handler(this, ev); } } }
public void mouseClickOnMap(object sender, MouseEventArgs e) { var panel = tab.SelectedTab.Controls["mapPanel"]; var pictureBox = panel.Controls["map"] as PictureBox; var mousePos = new Point(e.X, e.Y); // Cursor.Position; var offset = getPictureBoxOffset(pictureBox); float x = mousePos.X - offset.X; float y = mousePos.Y - offset.Y; x /= ((float)offset.Width / FullMapWidth); y /= ((float) offset.Height / FullMapHeight); int row = (int)((y - GutterSize) / (RoomSize)); int col = (int) ((x - GutterSize) / (RoomSize)); EventHandler<ChangeFileEventArgs> handler = ChangeSelectedFile; // Event will be null if there are no subscribers if (handler != null) { ChangeFileEventArgs ev = new ChangeFileEventArgs(); ev.daxId = -1; var mapRecord = _goldBoxFile.GetMaps()[tab.SelectedIndex]; foreach (var w in mapRecord.Walls) { if (w.Row == row && w.Column == col) ev.place = String.Format("event {0}", w.Event & 127); } var diskNumber = Convert.ToInt32(Path.GetFileName(_goldBoxFile.FileName).Replace("GEO", "").Replace(".DAX", "")); ev.filename = String.Format("ECL{0}.DAX", diskNumber); // choose an ecl we hope corresponds to this map // first choose the ecl with the same id as the map, if such an ecl block exists if (_goldBoxFile._daxEclFile.eclDumps.Find(ecldump => ecldump._blockId == mapRecord.DaxId) != null) { ev.daxId = mapRecord.DaxId; } // have any of the ecls referenced this map in code? if so, pick one of those if (_goldBoxFile.referencedByEcl.Count > 0) { // do we not have a valid ecl block yet? if not, default to the first ecl block that references this map id if (ev.daxId == -1) ev.daxId = _goldBoxFile.referencedByEcl[0]; // see if there's an ecl with the same number of events, that will be the most likely candidate foreach (var id in _goldBoxFile.referencedByEcl) { var eclBlk = _goldBoxFile._daxEclFile.eclDumps.Find(ecldump => ecldump._blockId == id); // find the ecl block which matches id if ( eclBlk != null) { if ((_goldBoxFile.highestEvent[mapRecord.DaxId] == eclBlk.eventCount || (_goldBoxFile.highestEvent[mapRecord.DaxId] & 31) == eclBlk.eventCount) && eclBlk.eventCount > 0) { ev.daxId = id; } } } } // if we still haven't found an ecl, just go with the first one in the ecl file for this disk if (ev.daxId == -1) ev.daxId = _goldBoxFile._daxEclFile.eclDumps[0]._blockId; // Use the () operator to raise the event. if (ev.place!= null) handler(this, ev); } }