private async Task <SceneObjectModel> CreateObjectModel <T>() where T : SceneElement, new() { try { var model = new SceneObjectModel(new T()); await ModelRHubClientProxy.GetInstance().CreateSceneObject(model); _objects.Add(model); if (_objects.Count == 1) { SelectedObject = model; } return(model); } catch (UserNotAuthorizedException exception) { var info = string.Format(CultureInfo.CurrentUICulture, "The user '{0}' is not authorized to create scene objects.", exception.UserName); Messenger.Default.Send <NotAuthorizedForOperationMessage>(new NotAuthorizedForOperationMessage(info)); } return(null); }
private void OnSceneObjectCreated(SceneObjectInfoModel infoModel) { SceneObjectModel model = null; switch (infoModel.SceneObjectType) { case SceneObjectType.Teapot: model = new SceneObjectModel(new Teapot() { Name = infoModel.Name }, infoModel.Id); break; case SceneObjectType.Cube: model = new SceneObjectModel(new Cube() { Name = infoModel.Name }, infoModel.Id); break; case SceneObjectType.Cylinder: model = new SceneObjectModel(new Cylinder() { Name = infoModel.Name }, infoModel.Id); break; case SceneObjectType.Disk: model = new SceneObjectModel(new Disk() { Name = infoModel.Name }, infoModel.Id); break; case SceneObjectType.Sphere: model = new SceneObjectModel(new Sphere() { Name = infoModel.Name }, infoModel.Id); break; default: break; } if (infoModel.Transformation != null) { var transformation = model.Transformation; transformation.TranslateX = infoModel.Transformation.TranslateX; transformation.TranslateY = infoModel.Transformation.TranslateY; transformation.TranslateZ = infoModel.Transformation.TranslateZ; transformation.RotateX = infoModel.Transformation.RotateX; transformation.RotateY = infoModel.Transformation.RotateY; transformation.RotateZ = infoModel.Transformation.RotateZ; transformation.ScaleX = infoModel.Transformation.ScaleX; transformation.ScaleY = infoModel.Transformation.ScaleY; transformation.ScaleZ = infoModel.Transformation.ScaleZ; } DispatcherHelper.RunAsync(() => SceneObjectModels.Add(model)); }