Beispiel #1
0
        int maxDescriptionLength = 15; // <--- Used for printing out in the description box

        /* +==== Init ====+ */
        #region Init
        public MainWindow()
        {
            InitializeComponent();
            currentLayerValue = tb_layerValue.Text;
            grid_objectDescription.Visibility = Visibility.Hidden;

            xmlFileHandler = new XMLFileHandler();
            if (xmlFileHandler.Intialize(@"..\..\Resources\StoredObjects.xml"))
            {
                LoadInStoredObjects();
            }

            collectFromXmlConfig(@"..\..\Resources\XMLConfig.txt");

            mapObject = new List <Object>();
        }
Beispiel #2
0
        private void btn_loadMap_init_Click(object sender, RoutedEventArgs e)
        {
            // Configure open file dialog box
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog(); // http://msdn.microsoft.com/en-us/library/microsoft.win32.openfiledialog%28v=vs.110%29.aspx
            dlg.FileName   = "";                                                       // Default file name
            dlg.DefaultExt = ".xml";                                                   // Default file extension
            dlg.Filter     = "Config Files (.xml)|*.xml";                              // Filter files by extension

            // Show open file dialog box
            Nullable <bool> result = dlg.ShowDialog();

            // Process open file dialog box results
            if (result == true)
            {
                if (dlg.FileName != "")
                {
                    currentFilename = dlg.FileName;
                    XMLFileHandler newDocument = new XMLFileHandler();
                    newDocument.Intialize(dlg.FileName);

                    mapDetails = newDocument.getMap(xmlconfig_storageGroups[0]);
                    updateCanvas(mapDetails);

                    List <Object> objList = newDocument.get(xmlconfig_storageGroups[1]);
                    if (objList != null && objList.Count > 0)
                    {
                        foreach (Object obj in objList)
                        {
                            obj.UpdateSource();

                            // Get the position of the ellipse relative to the Canvas
                            Canvas.SetLeft(obj, obj.transform.x);
                            Canvas.SetTop(obj, obj.transform.y);
                            AddObjectToMap(obj);
                        }
                    }
                }
            }
        }
Beispiel #3
0
        private void saveToXmlFile(string filename)
        {
            if (File.Exists(filename))
            {
                File.Delete(filename);
            }

            File.Create(filename).Close();

            XMLFileHandler newDocument = new XMLFileHandler();

            newDocument.Intialize(filename);


            foreach (Object obj in map_canvas.Children)
            {
                newDocument.add(obj, "MOVEABLE");
                newDocument.save();
            }

            newDocument.add(mapDetails, "BACKGROUND");

            newDocument.save();
        }