예제 #1
0
        public override void OnLoad(string path)
        {
            this.RailPlan = RailPlan.Load(path, this.trackDict);

            this.SelectedInsertLayer = this.RailPlan.Layers.FirstOrDefault();
            this.FileChanged         = true;
        }
예제 #2
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            Guid      guid      = (Guid)value;
            RailPlan  railPlan  = (RailPlan)parameter;
            RailLayer railLayer = railPlan.Layers.FirstOrDefault(l => l.Id == guid);

            return(railLayer);
        }
예제 #3
0
파일: MainViewModel.cs 프로젝트: chcg/Rail
        public MainViewModel()
        {
            this.DefaultFileExt = "*.rail";
            this.FileFilter     = "Rail Project|*.rail|All Files|*.*";

            this.RailPlanCommand     = new DelegateCommand(OnRailPlan);
            this.PrintCommand        = new DelegateCommand(OnPrint);
            this.PrintPreviewCommand = new DelegateCommand(OnPrintPreview);

            //this.Gradients = (new double[] { 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5, 7.0, 7.5, 8.0 }).Select(d => d.ToString("F2")).ToList();

            // load track list
            DependencyObject dep = new DependencyObject();

            if (!DesignerProperties.GetIsInDesignMode(dep))
            {
                try
                {
                    string path = System.AppDomain.CurrentDomain.BaseDirectory;
                    //this.trackList = TrackList.Load(Path.Combine(path, "Tracks.xml"));
                    this.trackList = TrackList.Load();
                    this.trackDict = trackList.TrackTypes.SelectMany(t => t.Tracks).ToDictionary(t => t.Id, t => t);
                }
                catch (Exception ex)
                {
                    //if (ex.InnerException is XmlSchemaValidationException valEx)
                    //{
                    //    MessageBox.Show($"Error in File Tracks.xml\r\n{ex.Message}\r\n{valEx.Message}");
                    //}
                    //else
                    //{
                    //    MessageBox.Show("Error in File Tracks.xml\r\n{ex.Message}");
                    //}

                    Exception e       = ex;
                    string    message = $"Error in File Tracks.xml\r\n{ex.Message}";
                    while (e.InnerException != null)
                    {
                        e        = e.InnerException;
                        message += $"\r\n{e.Message}";
                    }
                    MessageBox.Show(message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    Debugger.Break();

                    throw ex;
                }
            }

            this.RailPlan = RailPlan.Create();

            Update3D();
            this.SelectedSelectionIndex = 0;
        }
예제 #4
0
 public RailPlanViewModel(RailPlan railPlan)
 {
     this.railPlan    = railPlan;
     this.PlatePoints = new ObservableCollection <PointViewModel>(railPlan.PlatePoints.Select(p => new PointViewModel(p)));
     this.Layers      = new ObservableCollection <LayerViewModel>(railPlan.Layers.Select(l => new LayerViewModel(l)));
 }
예제 #5
0
 public override void OnCreate()
 {
     this.RailPlan    = RailPlan.Create();
     this.FileChanged = true;
     this.FilePath    = null;
 }