public static TableObject ImportFromXML(string DocumentTitle)
        {
            try
            {
                XDocument doc = XDocument.Load($@".\Maps\{DocumentTitle}.xml");

                string       _tableTitle       = doc.Root.Element("Title").Attribute("name").Value;
                int          _rowCount         = int.Parse(doc.Root.Element("TableDimensions").Attribute("rowCount").Value);
                int          _colCount         = int.Parse(doc.Root.Element("TableDimensions").Attribute("colCount").Value);
                int          _animationSpeed   = int.Parse(doc.Root.Element("Variables").Attribute("animation_speed").Value);
                double       _uncertaintyLevel = double.Parse(doc.Root.Element("Variables").Attribute("uncertainty_level").Value);
                BackPathType _back_path_type   = (doc.Root.Element("Variables").Attribute("back_path_type").Value == "Shortest") ? BackPathType.Shortest : BackPathType.Reversed;

                List <RectangleParams> _rectangleParamsList = doc.Descendants("Rectangle")
                                                              .Select(r => new RectangleParams()
                {
                    X    = int.Parse(r.Attribute("x").Value),
                    Y    = int.Parse(r.Attribute("y").Value),
                    Type = FindType(r.Attribute("type").Value)
                }).ToList();

                return(new TableObject(_tableTitle, _rowCount, _colCount, _animationSpeed, _uncertaintyLevel, _back_path_type, _rectangleParamsList));
            }
            catch (Exception ex) { MessageBox.Show(ex.Message); return(null); }
        }
Beispiel #2
0
        private void RadioButton_Checked(object sender, RoutedEventArgs e)
        {
            switch ((sender as RadioButton).Name)
            {
            case "StartPoint": { ModeChanged?.Invoke(null, new ModeEventArgs()
                    {
                        Mode = ModePoint.StartPoint
                    }); }
                    break;

            case "BlockPoint": { ModeChanged?.Invoke(null, new ModeEventArgs()
                    {
                        Mode = ModePoint.BlockPoint
                    }); }
                    break;

            case "EndPoint": { ModeChanged?.Invoke(null, new ModeEventArgs()
                    {
                        Mode = ModePoint.EndPoint
                    }); }
                    break;

            case "Shortest": { BackPathType = BackPathType.Shortest; }
            break;

            case "Reversed": { BackPathType = BackPathType.Reversed; }
            break;
            }
        }
Beispiel #3
0
        private void MapOpen_Click(object sender, RoutedEventArgs e)
        {
            tableObj = MapExporterImporter.ImportFromXML((sender as MenuItem).Name);
            if (tableObj != null)
            {
                txtName.Text           = tableObj.TableTitle;
                txtRows.Text           = tableObj.RowCount.ToString();
                txtCols.Text           = tableObj.ColCount.ToString();
                txtAnimationSpeed.Text = tableObj.AnimationSpeed.ToString();
                slider.Value           = tableObj.UncertaintyLevel;
                Shortest.IsChecked     = (tableObj.BackPathType == BackPathType.Shortest) ? true : false;
                Reversed.IsChecked     = (tableObj.BackPathType == BackPathType.Reversed) ? true : false;
                BackPathType           = tableObj.BackPathType;

                btnCreate_Click(null, null);
            }
        }
Beispiel #4
0
 public TableObject(string _TableTitle, int _RowCount, int _ColCount, int _AnimationSpeed, double _UncertaintyLevel, BackPathType _BackPathType, List <RectangleParams> _RectangleParamsList)
 {
     this.TableTitle          = _TableTitle;
     this.RowCount            = _RowCount;
     this.ColCount            = _ColCount;
     this.AnimationSpeed      = _AnimationSpeed;
     this.UncertaintyLevel    = _UncertaintyLevel;
     this.BackPathType        = _BackPathType;
     this.RectangleParamsList = _RectangleParamsList;
 }