コード例 #1
0
        public AreaViewModel(FootprintEditorViewModel parent, FTPT.Area area)
        {
            mParent = parent;
            mArea = area;
            mAreaTypeAttributes = new AreaTypeAttributes(mArea);
            mSurfaceTypeAttributes = new SurfaceTypeAttributes(mArea);
            mSurfaceAttributes = new SurfaceAttributes(mArea);
            mIntersectionAttributes = new IntersectionAttributes(mArea);

            mPoints = new ObservableCollection<PointViewModel>();
            foreach (FTPT.PolygonPoint pt in area.ClosedPolygon)
            {
                Add(new PointViewModel(this, pt));
            }
            SelectedPoint = Points.FirstOrDefault();
            mDeletePointCommand = new UserCommand<AreaViewModel>(x => x != null && x.SelectedPoint != null && x.Points.Contains(x.SelectedPoint), x => x.Remove(x.SelectedPoint));

            mAddPointCommand = new UserCommand<AreaViewModel>(x => x != null && true, x => x.Add());
        }
コード例 #2
0
 public PointViewModel(AreaViewModel area, FTPT.PolygonPoint point)
 {
     mArea = area;
     mPoint = point;
     mArea.PropertyChanged += mArea_PropertyChanged;
 }
コード例 #3
0
        public FootprintEditorViewModel(GenericRCOLResource rcol)
        {
            mRcol           = rcol;
            mFootprint      = rcol.ChunkEntries[0].RCOLBlock as FTPT;
            mFootprintAreas = new ObservableCollection <AreaViewModel>(mFootprint.FootprintAreas.Select(x => new AreaViewModel(this, x)));
            mSlotAreas      = new ObservableCollection <AreaViewModel>(mFootprint.SlotAreas.Select(x => new AreaViewModel(this, x)));

            AddSlotCommand    = new UserCommand <FootprintEditorViewModel>(x => x != null, x => x.AddSlotArea());
            CloneSlotCommand  = new UserCommand <FootprintEditorViewModel>(x => x != null && x.CheckSlotArea(), x => x.CopySlotArea());
            DeleteSlotCommand = new UserCommand <FootprintEditorViewModel>(x => x != null && x.CheckSlotArea(), x => x.DeleteArea());


            AddFootprintCommand    = new UserCommand <FootprintEditorViewModel>(x => x != null, x => x.AddFootprintArea());
            CloneFootprintCommand  = new UserCommand <FootprintEditorViewModel>(x => x != null && x.CheckFootprintArea(), x => x.CopyFootprintArea());
            DeleteFootprintCommand = new UserCommand <FootprintEditorViewModel>(x => x != null && x.CheckFootprintArea(), x => x.DeleteArea());


            CommitCommand = new UserCommand <FootprintEditorViewModel>(x => true, y =>
            {
                mIsSaving = true;
                Application.Current.Shutdown();
            });
            CancelCommand = new UserCommand <FootprintEditorViewModel>(x => true, y =>
            {
                mIsSaving = false;
                Application.Current.Shutdown();
            });


            SetBackgroundImageCommand = new UserCommand <FootprintEditorViewModel>(
                x => true,
                y =>
            {
                var d = new OpenFileDialog {
                    CheckFileExists = true, Multiselect = false
                };
                if (d.ShowDialog() == true)
                {
                    BackgroundImagePath = d.FileName;
                }
            }
                );
            ClearBackgroundImageCommand = new UserCommand <FootprintEditorViewModel>(
                x => x != null && !String.IsNullOrEmpty(x.BackgroundImagePath),
                y => y.BackgroundImagePath = null
                );
            SetReferenceMeshCommand = new UserCommand <FootprintEditorViewModel>(
                x => true,
                y =>
            {
                var d = new OpenFileDialog {
                    CheckFileExists = true, Multiselect = false
                };
                if (d.ShowDialog() == true)
                {
                    ReferenceMesh = d.FileName;
                }
            }
                );
            ClearReferenceMeshCommand = new UserCommand <FootprintEditorViewModel>(
                x => x != null && !String.IsNullOrEmpty(x.ReferenceMesh),
                y => y.ReferenceMesh = null
                );
            SelectedFootprint = FootprintAreas.FirstOrDefault();
            if (SelectedArea == null)
            {
                SelectedSlot = SlotAreas.FirstOrDefault();
            }
        }