private void ShowDialogControl(string key) { showDialog = false; int num = 0; if (int.TryParse(key, out num) == false) { return; } switch (num) { case 1: DialogContent = new UserControls.DrawControl(); DialogContent.DataContext = drawmodel; DialogTitle = "Main"; break; case 2: DialogContent = new UserControls.CameraControl(); dialogContent.DataContext = cameraVM; DialogTitle = "Camera Control"; break; case 3: DialogContent = new UserControls.GraphicProperties(); DialogContent.DataContext = graphicPropertyvm; graphicPropertyvm.Update(); DialogTitle = "Thuộc tính"; break; case 4: DialogContent = new UserControls.Animation(); DialogContent.DataContext = animationVM; animationVM.Update(); DialogTitle = "Animation"; break; case 5: DialogContent = new UserControls.Texture(); DialogContent.DataContext = textureVM; textureVM.Update(); DialogTitle = "Texture"; break; case 6: DialogContent = new UserControls.Lighting(); DialogContent.DataContext = lightingVM; lightingVM.Update(); DialogTitle = "Lighting"; break; } if (dialogContent != null) { ShowDialog = true; } }
public MainWindowViewModel() { listObject = new ObservableCollection <Graphic3D>(); cameraVM = new CameraControlViewModel(this); graphicPropertyvm = new GraphicPropertyVM(this); animationVM = new AnimationViewModel(this); textureVM = new TextureViewModel(this); lightingVM = new LightingViewModel(this); showDialog = true; DialogContent = new UserControls.DrawControl(); drawmodel = new DrawViewModel(this); DialogContent.DataContext = drawmodel; DialogTitle = "Main"; ShowDialogCommand = new RelayCommand <string>( (i) => true, (i) => ShowDialogControl(i)); HideDialogCommand = new RelayCommand( (i) => { ShowDialog = false; SeletedGraphic = null; }); RegisterFormCommand = new RelayCommand <MainWindow>( (w) => w != null, (w) => { mainWindow = w; mainWindow.OpenGLControl.OpenGLDraw += OpenGLControl_OpenGLDraw; mainWindow.OpenGLControl.OpenGLInitialized += OpenGLControl_OpenGLInitialized; mainWindow.OpenGLControl.MouseMove += OpenGLControl_MouseMove; mainWindow.OpenGLControl.MouseLeave += OpenGLControl_MouseLeave; mainWindow.OpenGLControl.MouseLeftButtonUp += OpenGLControl_MouseLeftButtonUp; mainWindow.OpenGLControl.MouseEnter += OpenGLControl_MouseEnter; mainWindow.OpenGLControl.MouseWheel += OpenGLControl_MouseWheel; }); }