private void InitializeWorkspace() { DataContext = new CWorkspace(); CWorkspace.Instance.DockingManager = dockManager; foreach (var tool in CWorkspace.Instance.Tools) { if (!tool.CanBeInvisible || tool.IsAlwaysHidden) { continue; } System.Windows.Controls.MenuItem toolMenu = new System.Windows.Controls.MenuItem(); toolMenu.Header = tool.Name; toolMenu.IsCheckable = true; toolMenu.DataContext = tool; Binding isCheckedBinding = new Binding(); isCheckedBinding.Path = new PropertyPath("IsVisible"); isCheckedBinding.Mode = BindingMode.TwoWay; toolMenu.SetBinding(System.Windows.Controls.MenuItem.IsCheckedProperty, isCheckedBinding); ToolsMenu.Items.Add(toolMenu); } }
protected override void OnSelectedChanged(bool bNewValue) { CWorkspace workspace = CWorkspace.Instance; if (bNewValue) { workspace.SetSelectedObject(new CEditableObject(EntityId)); } else { if (workspace.SelectedEditableObject == EntityId) { workspace.SetSelectedObject(null); } } }
public static void MakeComponentRoot(SEntityComponentId id, bool bDispatch = true) { void Command() { CSceneComponent newRoot = id.GetComponent <CSceneComponent>(); if (newRoot == null) { return; } CSceneComponent oldRoot = newRoot.Owner.RootComponent; if (oldRoot == null) { return; } SEntityComponentId oldId = new SEntityComponentId(oldRoot); void Do() { CSceneComponent component = id.GetComponent <CSceneComponent>(); if (component != null) { CEntity owner = component.Owner; owner.SetRootComponent(component); } } void Redo() { CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { Do(); Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => { CWorkspace space = CWorkspace.Instance; space.SetSelectedObject(space.SelectedEditableObject, true); })); }); } void Undo() { CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { CSceneComponent component = oldId.GetComponent <CSceneComponent>(); if (component != null) { CEntity owner = component.Owner; owner.SetRootComponent(component); Application.Current.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (Action)(() => { CWorkspace space = CWorkspace.Instance; space.SetSelectedObject(space.SelectedEditableObject, true); })); } }); } Do(); CUndoItem item = new CRelayUndoItem(Undo, Redo); UndoRedoUtility.Record(item); } if (bDispatch) { CEngine.Instance.Dispatch(EEngineUpdatePriority.BeginFrame, () => { Command(); }); } else { Command(); } }