コード例 #1
0
        // --------------- Canvas Methods --------------- //

        public void CanvasMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            var image = e.Source as Image;

            if (image != null && mainWindowCanvas.CaptureMouse())
            {
                mousePosition      = e.GetPosition(mainWindowCanvas);
                canvasDraggedImage = image;
                draggedEntity      = entitiesController.FindCanvasEntityByStringId(canvasDraggedImage.Name);

                Console.WriteLine("find: " + canvasDraggedImage.Name);

                if (draggedEntity != null && !draggedEntity.Selected() && bMultiSelect == false)
                {
                    entitiesController.UnselectAll();
                    ContextMenuController.GetInstance().ClearMenu();
                }

                draggedEntity.Select();
                ContextMenuController.GetInstance().ClearMenu();
                ContextMenuController.GetInstance().SelectEntity(draggedEntity);
            }
            else
            {
                entitiesController.UnselectAll();
                ContextMenuController.GetInstance().ClearMenu();
            }

            if (canvasDraggedImage == null)
            {
                selectBoxAnchor = e.GetPosition(mainWindowCanvas);
                bIsDragging     = true;
            }
        }
コード例 #2
0
        public MainWindow()
        {
            InitializeComponent();

            entitiesController    = new EntitiesController();
            contextMenuController = new ContextMenuController(entityMenuGrid);
            canvasController      = new CanvasController(mainWindowCanvas, entitiesController, canvasScrollViewer);
            sceneController       = new SceneController(this);
            PrefabController.Init(this);
            prefabController = PrefabController.Instance;

            this.PreviewKeyDown += new KeyEventHandler(MainWindowKeyDownHandler);
            this.PreviewKeyDown += new KeyEventHandler(MainWindowDebugKey);
            this.PreviewKeyUp   += new KeyEventHandler(MainWindowKeyUpHandler);

            mainWindowCanvas.MouseLeftButtonUp   += canvasController.CanvasMouseLeftButtonUp;
            mainWindowCanvas.MouseLeftButtonDown += canvasController.CanvasMouseLeftButtonDown;
            mainWindowCanvas.MouseMove           += canvasController.CanvasMouseMove;
            mainWindowCanvas.MouseWheel          += canvasController.CanvasMouseWheel;
            mainWindowCanvas.MouseLeave          += canvasController.CanvasMouseLeave;

            Search = new SearchBar {
                SearchText = "", DataListEntities = dataListEntities, mainWindow = this
            };
            this.DataContext = Search;
        }
コード例 #3
0
        public void deleteComponent(object sender, RoutedEventArgs e)
        {
            selectedEntity.SetImage("pack://application:,,,/Src/letter-e124.png");

            var CMC = ContextMenuController.GetInstance();

            CMC.DeleteComponent(this);
        }
コード例 #4
0
        public override void _Ready()
        {
            playerResourceDisplayController = GetNode <PlayerResourceDisplayController>(playerHudPath);
            playerInventoryUiController     = GetNode <PlayerInventoryUiManager>(playerInventoryUiPath);
            pauseMenu   = GetNode <PauseMenuController>(pauseMenuPath);
            contextMenu = GetNode <ContextMenuController>(contextMenuPath);

            pauseMenu.OnMenuClosed += HandleOnChestClosed;
        }
コード例 #5
0
    public ContextMenuController CreateContextMenu(Vector3 position, IContextMenu menu, IContextMenuController parent)
    {
        Debug.Log($"adding context menu at {position}");
        ContextMenuController newContextMenu = Instantiate(m_ContextMenuPrefab);

        newContextMenu.transform.SetParent(m_ContextMenuCanvas.transform);
        newContextMenu.Init(Camera.main.WorldToScreenPoint(position), menu, parent);
        return(newContextMenu);
    }
コード例 #6
0
 protected override void EntryAction()
 {
     Debug.Log("Arrived in PlayerStateContextMenu");
     contextMenuPrefabs[0] = Resources.Load("PaintingContextMenu") as GameObject;
     contextMenuPrefabs[1] = Resources.Load("SculptureContextMenu") as GameObject;
     targetObject          = stateData.grabber.CheckHit();
     AllowMovement(false);
     targetObject          = FindRootArtwork(targetObject);
     contextMenu           = DisplayContextMenuOn(targetObject);
     contextMenuController = contextMenu.GetComponent <ContextMenuController>();
 }
コード例 #7
0
        public void Init(InventoryController inventoryController, ContextMenuController contextMenuController)
        {
            this.inventoryController   = inventoryController;
            this.contextMenuController = contextMenuController;

            contextMenuController.OnItemUsed += HandleOnItemUse;

            inventoryDragController.Init(equipmentSlotsManager, backPackSlotManager);
            equipmentSlotsManager.Init(inventoryController);
            lootChestMenuController.Init(itemInventoryTilePrefab, this.inventoryController, backPackSlotManager);
        }
コード例 #8
0
 protected override void OnContextMenuOpening(ContextMenuEventArgs e)
 {
     if (e.OriginalSource is DependencyObject originalSource && DescendantHasContextMenu(originalSource))
     {
         return;
     }
     using (EnterContextMenuVisualState())
     {
         var contextMenuItems = GetDistinctSelection <object>().OfType <IHasContextMenuController>();
         e.Handled = ContextMenuController.ShowContextMenu(contextMenuItems, GetContextMenuLocation());
     }
 }
コード例 #9
0
        private void MainWindowKeyDownHandler(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Escape)
            {
                entitiesController.UnselectAll();
            }
            else if ((e.Key == Key.Delete /* || e.Key == Key.Back*/) && FocusOnSearchBar == false)
            {
                bool mouseIsDown = Mouse.LeftButton == MouseButtonState.Pressed;

                if (!mouseIsDown && entitiesController.GetSelectedEntities() != null)
                {
                    ContextMenuController.GetInstance().ClearMenu();
                    RemoveEntitiesFromList(entitiesController.GetSelectedEntities());
                    entitiesController.DeleteSelectedEntities();
                }
            }
            else if (e.Key == Key.LeftCtrl || e.Key == Key.RightCtrl)
            {
                canvasController.bMultiSelect = true;
            }
        }
コード例 #10
0
        public void deleteComponent(object sender, RoutedEventArgs e)
        {
            var CMC = ContextMenuController.GetInstance();

            CMC.DeleteComponent(this);
        }