コード例 #1
0
 private void editorControl_GameView_MouseUp(object sender, MouseEventArgs e)
 {
     StaticGlobalInput.HandleMouseButtons(e, false);
     _ScaleInprogress = false;
 }
コード例 #2
0
        private void editorControl_GameView_MouseDown(object sender, MouseEventArgs e)
        {
            StaticGlobalInput.HandleMouseButtons(e, true);

            var p = GetMouseVPos();

            //if (!StaticGlobalInput.IsNewLeftClick()) {
            //    return;
            //}

            // Right click should not place an object
            if (StaticGlobalInput.IsNewRightClick())
            {
                editorControl_GameView.Camera.Zoom = 1.0f;
                UpdateZoomTracker();
                return;
            }

            switch (StaticEditorMode.EditorMode)
            {
            case EditorMode.Selectmode: {
                StaticEditorMode.SelectedObject = objectsUnderCursor.OrderByDescending(actor => actor.Depth).LastOrDefault();

                break;
            }

            case EditorMode.AssetPlacement: {
                if ((StaticGlobalInput.currentMouse.LeftButton == ButtonState.Pressed))
                {
                    if (listBox_Assets.SelectedItem == null)
                    {
                        MessageBox.Show(Resources.SelectAssetError, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else if (IsValidContent(listBox_Assets.SelectedItem.ToString(), typeof(Texture2D)))
                    {
                        if (listBox_Assets.SelectedItem != null)
                        {
                            var asset = new Asset(StaticEditorMode.ContentManager, listBox_Assets.SelectedItem.ToString(), p.ToVector2());
                            StaticEditorMode.LevelInstance.Assets.Add(asset);
                            AddTreeNodeFromAsset(asset);
                            StaticEditorMode.SelectedObject = asset;
                        }
                    }
                    else
                    {
                        MessageBox.Show(string.Format(Resources.InvalidAssetType, typeof(Texture2D)), Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                break;
            }

            case EditorMode.MoveAsset: {
                if (!objectsUnderCursor.Contains(StaticEditorMode.SelectedObject))
                {
                    StaticEditorMode.SelectedObject = objectsUnderCursor.OrderByDescending(actor => actor.Depth).LastOrDefault();
                }

                break;
            }
            }
        }