public void remove(Poi target) { Debug.WriteLine("remove: " + target, this.ToString()); lock (targets) { targets.Remove(target); targetsAreas.Remove(target); } }
public void add(Poi target) { Debug.WriteLine("add: " + target, this.ToString()); lock (targets) { targets.Add(target); Area tArea = createTargetArea(target); targetsAreas[target] = tArea; } }
public Point getPoiPixelCoordinates(Poi p) { double deltaLongitude = p.getLongitude() - this.area.getTopLeftLongitude(); double deltaLatitude = this.area.getTopLeftLatitude() - p.getLatitude(); int x = (int)Math.Floor(deltaLongitude / this.longitudePerPixel); int y = (int)Math.Floor(deltaLatitude / this.latitudePerPixel); return(new Point(x, y)); }
public void move(Poi target, int move) { Debug.WriteLine("move: " + target + ", move: " + move, this.ToString()); lock (targets) { int index = targets.IndexOf(target); int moveIndex = index + move; Poi tmp = targets[moveIndex]; targets[moveIndex] = target; targets[index] = tmp; } }
public void downloadPoiMedia(Poi p) { foreach (MediaFile m in p.getAllMediaFiles()) { Debug.WriteLine("downloading media file: uri: " + m.getUrl().ToString(), ToString()); try { byte[] mediaData = this.portal.download(m.getUrl()); m.setMedia(mediaData); } catch (PortalException e) { Debug.WriteLine("loadPoiMedia: portal error: " + e.Message, ToString()); } } }
/** * Loads Poi basic data: descr, lang and type from xml file */ public void loadData(Poi poi, string poiSubDir) { //Debug.WriteLine("loadData: poi sub dir: " + poiSubDir, ToString()); string descr = ""; string lang = ""; string type = ""; // load xml document XmlDocument poiXmlDoc = new XmlDocument(); string poiXmlPath = getPoiXmlPath(poiSubDir); poiXmlDoc.Load(poiXmlPath); // get descr XmlNode descrNode = poiXmlDoc.SelectSingleNode("/poi/descr"); descr = descrNode.InnerText; // get lang XmlNode langNode = poiXmlDoc.SelectSingleNode("/poi/lang"); lang = langNode.InnerText; // get type XmlNode typeNode = poiXmlDoc.SelectSingleNode("/poi/type"); type = typeNode.InnerText; // insert data into poi poi.insertData(descr, lang, type); }
public override object parse(XmlNode objNode) { // get required poi's parameters string name = objNode.SelectSingleNode("name").InnerText.Trim(); double latitude = Convert.ToDouble(objNode.SelectSingleNode("latitude").InnerText.Trim()); double longitude = Convert.ToDouble(objNode.SelectSingleNode("longitude").InnerText.Trim()); string lang = objNode.SelectSingleNode("lang").InnerText.Trim(); string type = objNode.SelectSingleNode("type").InnerText.Trim(); string descr = objNode.SelectSingleNode("descr").InnerText.Trim(); // instantiate poi Poi poi = new Poi(name, latitude, longitude, lang, type, descr); // parse media files MediaFilesXmlAdapter mediaFilesParser = new MediaFilesXmlAdapter(poi.getMediaFiles()); XmlNode mediaFilesNode = objNode.SelectSingleNode(mediaFilesParser.getXmlNodeName()); mediaFilesParser.parse(mediaFilesNode); MainDetailsXmlAdapter mainDetailsParser = new MainDetailsXmlAdapter(poi.getMainDetails()); XmlNode mainDetailsNode = objNode.SelectSingleNode(mainDetailsParser.getXmlNodeName()); mainDetailsParser.parse(mainDetailsNode); return poi; }
private void listBoxTargets_SelectedIndexChanged(object sender, EventArgs e) { int index = this.listBoxTargets.SelectedIndex; if (index < 0 || index >= this.listBoxTargets.Items.Count) return; this.selectedTargetPoi = (Poi)this.listBoxTargets.Items[index]; this.buttonPreview2.Enabled = true; this.buttonRemove.Enabled = true; if (index > 0) this.buttonUp.Enabled = true; else this.buttonUp.Enabled = false; if (index < this.listBoxTargets.Items.Count - 1) this.buttonDown.Enabled = true; else this.buttonDown.Enabled = false; }
private void listBoxPois_SelectedIndexChanged(object sender, EventArgs e) { int index = this.listBoxPois.SelectedIndex; this.selectedPoi = (Poi)this.listBoxPois.Items[index]; this.buttonPreview.Enabled = true; if (!this.listBoxTargets.Items.Contains(this.selectedPoi)) this.buttonAddTarget.Enabled = true; else this.buttonAddTarget.Enabled = false; }
// check if given poi is inside area public bool contains(Poi poi) { return(contains(poi.getLatitude(), poi.getLongitude())); }
public PoiPanel(Poi poi, MapPanel mapPanel) { this.poi = poi; this.mapPanel = mapPanel; initialize(); }
/** * Returns poi sub dir by poi and named area */ private string getPoiSubDir(Poi p, NamedArea namedArea) { string dirName = p.getName() + "_" + p.getLatitude() + "_" + p.getLongitude(); return getPoiSubDir(dirName, namedArea); }
public void preview(Poi poi) { cleanPreview(); if (poi.isMediaFree() || poi.isDataFree()) this.poiRepository.load(poi); this.currentPoi = poi; this.freeY = FREE_Y_DEFAULT; updatePreview(); this.tabControl.SelectedIndex = 1; //if (!this.Visible) this.Visible = true; }
public Point getPoiPixelCoordinates(Poi p) { double deltaLongitude = p.getLongitude() - this.area.getTopLeftLongitude(); double deltaLatitude = this.area.getTopLeftLatitude() - p.getLatitude(); int x = (int) Math.Floor(deltaLongitude / this.longitudePerPixel); int y = (int) Math.Floor(deltaLatitude / this.latitudePerPixel); return new Point(x, y); }
/** * Loads Poi media data: media files and main details. */ public void loadMedia(Poi poi, string poiSubDir) { //Debug.WriteLine("loadMedia: poi sub dir: " + poiSubDir, ToString()); // load xml document XmlDocument poiXmlDoc = new XmlDocument(); string poiXmlPath = getPoiXmlPath(poiSubDir); poiXmlDoc.Load(poiXmlPath); // get media files XmlNode mediaFilesNode = poiXmlDoc.SelectSingleNode("/poi/media_files"); if (mediaFilesNode != null) { MediaFilesXmlAdapter mfxa = new MediaFilesXmlAdapter(poi.getMediaFiles()); mfxa.parse(mediaFilesNode); } // get main details XmlNode mainDetailsNode = poiXmlDoc.SelectSingleNode("/poi/details"); if (mainDetailsNode != null) { MainDetailsXmlAdapter mdxa = new MainDetailsXmlAdapter(poi.getMainDetails()); mdxa.parse(mainDetailsNode); } string poiMediaFilesPath = getPoiMediaFilesPath(poiSubDir); if (poiMediaFilesPath != null) { loadMediaFiles(poi.getAllMediaFiles(), poiMediaFilesPath); } }
public void save(Poi poi, string poiSubDir) { Debug.WriteLine("save: poi: " + poi, ToString()); string poiXmlFilePath = createPoiXmlPath(poiSubDir); string poiMediaFilesPath = createPoiMediaFilesPath(poiSubDir); // serialize poi PoiXmlAdapter pxa = new PoiXmlAdapter(); string poiXml = pxa.serialize(poi); // save poi's xml saveXml(poiXml, poiXmlFilePath); // save poi's media saveMediaFiles(poi.getAllMediaFiles(), poiMediaFilesPath); }
private Area createTargetArea(Poi target) { double topLeftLat = target.getLatitude() + maxLatitudeToTarget; double topLeftLon = target.getLongitude() - maxLongitudeToTarget; double bottomRightLat = target.getLatitude() - maxLatitudeToTarget; double bottomRightLon = target.getLongitude() + maxLongitudeToTarget; return new Area(topLeftLat, topLeftLon, bottomRightLat, bottomRightLon); }
internal void put(Poi p, NamedArea namedArea) { if (this.pois == null) { this.pois = new List<Poi>(); } if (!p.isDataFree()) { this.poiMapperHdd.save(p, getPoiSubDir(p, namedArea)); p.free(); //if (!this.pois.Contains(p)) //{ this.pois.Add(p); //} } }
private void removeTarget(Object sender, EventArgs args) { if (this.targetToRemove != null) { this.listBoxTargets.Items.Remove(this.targetToRemove); this.targetToRemove = null; } }
// check if given poi is inside area public bool contains(Poi poi) { return contains(poi.getLatitude(), poi.getLongitude()); }
private void targetDone(Poi target) { this.targetToRemove = target; this.listBoxTargets.Invoke(new EventHandler(removeTarget)); }
public PoiDialogPanel(Poi poi) { this.poi = poi; initialize(); }
public void setTarget(Poi currentTarget) { this.target = currentTarget; }
internal void loadData(Poi poi) { if (poi.isDataFree()) this.poiMapperHdd.loadData(poi, getPoiSubDir(poi, this.currentNamedArea)); }
public void load(Poi poi) { this.poiSourceHdd.loadData(poi); this.poiSourceHdd.loadMedia(poi); }