private void miLoadMap_Click(object sender, RoutedEventArgs e) { try { OpenFileDialog ofdDialog = new OpenFileDialog(); ucPlace.m_nIndexTable = 0; ofdDialog.Filter = "XML Files (.xml)|*.xml"; if ((bool)ofdDialog.ShowDialog()) { cnvPool.Children.Clear(); PresentationDetails pdDetails = PresenetationProvider.ReadPresentation(ofdDialog.FileName); foreach (KeyValuePair<Point, ObjectDetails> pair in pdDetails.dicObject) { switch (pair.Value.poType) { case PresentationObject.POOL_TABLE: AddPlaceToCanvas("PoolTable", pair.Key); break; case PresentationObject.BAR_CHAIR: AddPlaceToCanvas("BarChair", pair.Key); break; case PresentationObject.BAR_TABLE: AddPlaceToCanvas("BarTable", pair.Key); break; default: break; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void miSaveMap_Click(object sender, RoutedEventArgs e) { SaveFileDialog sfdDialog = new SaveFileDialog(); sfdDialog.Filter = "XML Files (.xml)|*.xml"; Dictionary<Point, ObjectDetails> dic = new Dictionary<Point, ObjectDetails>(); if ((bool)sfdDialog.ShowDialog()) { foreach (ucPlace place in cnvPool.Children) { Point point = new Point(Canvas.GetLeft(place), Canvas.GetTop(place)); dic.Add(point, new ObjectDetails(place.PlaceName, place.PlaceType)); } PresenetationProvider.SavePresentation(sfdDialog.FileName, dic, ucPlace.m_nIndexTable); } }