Ejemplo n.º 1
0
        /// <summary>
        /// Middle button - for editing purposes
        /// </summary>
        /// <param name="e"></param>
        void MapMouseMiddleButtonUp(MouseButtonEventArgs e)
        {
            var stretchedPosition = e.GetPosition(_map);
            var realCoords        = _zoomer.TranslatePointBack(stretchedPosition);
            var position          = _zoomer.TranslatePoint(realCoords);

            switch (_editController.EditMode)
            {
            case EditModeType.NewPoint:
                var item = new MapDataItemVM(realCoords.X, realCoords.Y, position.X, position.Y,
                                             Properties.Resources.NewPointDefaultName,
                                             Properties.Resources.NewPointDefaultDescription);
                item.Selected += OnSelectCurrentItem;
                MapItems.Add(item);
                OnSelectCurrentItem(item, new EventArgs());
                break;

            case EditModeType.MovePoint:
                if (CurrentMapItem != null)
                {
                    CurrentMapItem.X          = position.X;
                    CurrentMapItem.Y          = position.Y;
                    CurrentMapItem.RealCoords = realCoords;
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load data from file
        /// </summary>
        private void LoadData()
        {
            var     adapter = new MapDataAdapter(DATAFILE);
            MapData data;

            try
            {
                data = adapter.Load();
            }
            catch (Exception ex)
            {
                MessageBox.Show(Properties.Resources.ErrorOnLoad + " " + ex);
                return;
            }

            foreach (var d in data.Items)
            {
                var mapItem = new MapDataItemVM(d);
                mapItem.Selected += new EventHandler <EventArgs>(OnSelectCurrentItem);
                MapItems.Add(mapItem);
            }

            // from now on, track changes
            MapItems.CollectionChanged +=
                new System.Collections.Specialized.NotifyCollectionChangedEventHandler((o, e) => { _itemCollectionChanged = true; });
        }