public NativeDesignControl(DesignView designView) : base(designView) { ClientSize = new Size(10, 10); if (!GameEngine.IsInError) { swapChainId = GameEngine.GetObjectTypeId("SwapChain"); SurfaceId = GameEngine.CreateObject(swapChainId, this.Handle, IntPtr.Size); SizePropId = GameEngine.GetObjectPropertyId(swapChainId, "Size"); GameEngine.SetObjectProperty(swapChainId, SurfaceId, SizePropId, ClientSize); BkgColorPropId = GameEngine.GetObjectPropertyId(swapChainId, "BkgColor"); GameEngine.SetObjectProperty(swapChainId, SurfaceId, BkgColorPropId, BackColor); } if (s_marqueePen == null) { s_marqueePen = new Pen(Color.FromArgb(30, 30, 30), 2); s_marqueePen.DashPattern = new float[] { 3, 3 }; } m_renderState = new RenderState(); m_renderState.RenderFlag = GlobalRenderFlags.Solid | GlobalRenderFlags.Textured | GlobalRenderFlags.Lit | GlobalRenderFlags.Shadows; m_renderState.WireFrameColor = Color.DarkBlue; m_renderState.SelectionColor = Color.FromArgb(66, 255, 161); BackColor = SystemColors.ControlDark; m_renderState.Changed += (sender, e) => Invalidate(); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.MouseMove"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param> protected override void OnMouseMove(MouseEventArgs e) { if (DesignView.Context != null) { Size dragBoxSize = SystemInformation.DragSize; CurrentMousePoint = new Point(e.X, e.Y); int dx = CurrentMousePoint.X - FirstMousePoint.X; int dy = CurrentMousePoint.Y - FirstMousePoint.Y; if (!m_dragOverThreshold) { if (Math.Abs(dx) > dragBoxSize.Width || Math.Abs(dy) > dragBoxSize.Height) { m_dragOverThreshold = true; if (m_mouseDownAction == MouseDownAction.Manipulating) { DesignView.Manipulator.OnBeginDrag(); } } } if (m_mouseDownAction == MouseDownAction.Picking) { Invalidate(); } else if (m_mouseDownAction == MouseDownAction.ControllingCamera) { CameraController.MouseMove(this, e); } else if (m_mouseDownAction == MouseDownAction.Manipulating) { if (m_dragOverThreshold) { DesignView.Manipulator.OnDragging(this, e.Location); DesignView.Tick(); if (m_propEditor == null) { m_propEditor = Globals.MEFContainer.GetExportedValue <PropertyEditor>(); } m_propEditor.PropertyGrid.RefreshProperties(); } } else if (DesignView.Manipulator != null) { bool picked = DesignView.Manipulator.Pick(this, e.Location); this.Cursor = picked ? Cursors.SizeAll : Cursors.Default; DesignView.InvalidateViews(); } else if (this.Cursor != Cursors.Default) { this.Cursor = Cursors.Default; } } if (m_dragOverThreshold) { m_hitIndex = -1; } base.OnMouseMove(e); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.MouseDown"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param> protected override void OnMouseDown(MouseEventArgs e) { // reject additional mouse clicks until current is done. if (m_mouseDownAction != MouseDownAction.None) { return; } Focus(); FirstMousePoint = CurrentMousePoint = new Point(e.X, e.Y); m_dragOverThreshold = false; if (DesignView.Context != null) { bool handled = CameraController.MouseDown(this, e); if (handled) { m_mouseDownAction = MouseDownAction.ControllingCamera; } else if (e.Button == MouseButtons.Left) {// either regular pick or manipulator pick. if (DesignView.Manipulator != null && DesignView.Manipulator.Pick(this, e.Location)) { m_mouseDownAction = MouseDownAction.Manipulating; } else { m_mouseDownAction = MouseDownAction.Picking; } } } DesignView.InvalidateViews(); base.OnMouseDown(e); }
public NativeDesignControl(DesignView designView, GUILayer.EditorSceneManager sceneManager, GUILayer.ObjectSet selection) : base(designView, sceneManager, selection) { if (s_marqueePen == null) { s_marqueePen = new Pen(Color.FromArgb(30, 30, 30), 2); s_marqueePen.DashPattern = new float[] { 3, 3 }; } m_renderState = new RenderState(); m_renderState.RenderFlag = GlobalRenderFlags.Solid | GlobalRenderFlags.Textured | GlobalRenderFlags.Lit | GlobalRenderFlags.Shadows; m_renderState.WireFrameColor = Color.DarkBlue; m_renderState.SelectionColor = Color.FromArgb(66, 255, 161); BackColor = SystemColors.ControlDark; m_renderState.OnChanged += (sender, e) => Invalidate(); base.AddRenderCallback(RenderExtras); }
/// <summary> /// Raises the <see cref="E:System.Windows.Forms.Control.MouseUp"></see> event. /// </summary> /// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"></see> that contains the event data.</param> protected override void OnMouseUp(MouseEventArgs e) { if (m_mouseDownAction == MouseDownAction.Picking) { HandlePick(e); } else if (m_mouseDownAction == MouseDownAction.ControllingCamera) { CameraController.MouseUp(this, e); } else if (m_mouseDownAction == MouseDownAction.Manipulating) { DesignView.Manipulator.OnEndDrag(this, e.Location); } else if (e.Button == MouseButtons.Right) { IEnumerable <IContextMenuCommandProvider> contextMenuCommandProviders = Globals.MEFContainer.GetExportedValues <IContextMenuCommandProvider>(); Point clientPoint = new Point(e.X, e.Y); Point screenPoint = PointToScreen(clientPoint); object target = this; IList <object> pickList = Pick(e); if (pickList.Count > 0) { Path <object> pickedObj = (Path <object>)pickList[0]; target = pickedObj.Last; } IEnumerable <object> commands = contextMenuCommandProviders.GetCommands(DesignView.Context, target); ICommandService commandService = Globals.MEFContainer.GetExportedValue <ICommandService>(); commandService.RunContextMenu(commands, screenPoint); } m_mouseDownAction = MouseDownAction.None; DesignView.InvalidateViews(); base.OnMouseUp(e); }
/// <summary> /// Constructor</summary> public DesignViewControl(DesignView designView) { DesignView = designView; this.Camera.SetPerspective((float)(Math.PI / 4), 1.0f, 0.1f, designView.CameraFarZ); }
private void RenderExtras(DesignView designView, Sce.Atf.Rendering.Camera camera) { bool renderSelected = RenderState.DisplayBound == DisplayFlagModes.Selection || RenderState.DisplayCaption == DisplayFlagModes.Selection || RenderState.DisplayPivot == DisplayFlagModes.Selection; if (renderSelected) { var selection = DesignView.Context.As<ISelectionContext>().Selection; IEnumerable<DomNode> rootDomNodes = DomNode.GetRoots(selection.AsIEnumerable<DomNode>()); RenderProperties(rootDomNodes, RenderState.DisplayCaption == DisplayFlagModes.Selection, RenderState.DisplayBound == DisplayFlagModes.Selection, RenderState.DisplayPivot == DisplayFlagModes.Selection); } if (RenderState.GridMode == RenderState.GridModes.Enabled) { var game = designView.Context.As<IGame>(); GridRenderer gridRender = game.Grid.Cast<GridRenderer>(); gridRender.Render(camera); } RenderProperties(Items, RenderState.DisplayCaption == DisplayFlagModes.Always, RenderState.DisplayBound == DisplayFlagModes.Always, RenderState.DisplayPivot == DisplayFlagModes.Always); GameEngine.DrawText2D(m_pendingCaption, Util3D.CaptionFont, 1, 1, Color.White); }
private void RenderCallback(DesignView designView, Sce.Atf.Rendering.Camera camera) {}