Esempio n. 1
0
 public void delete(DeleteRoomRequest request)
 {
     try
     {
         var response = new DeleteRoomResponse();
         var bc       = new RoomComponent();
         bc.Delete(request.Id);
     }
     catch (Exception ex)
     {
         var httpError = new HttpResponseMessage()
         {
             StatusCode   = (HttpStatusCode)422,
             ReasonPhrase = ex.Message
         };
         throw new HttpResponseException(httpError);
     }
 }
Esempio n. 2
0
        void OnClicked(int posX, int posY, Gdk.Event triggerEvent, uint button)
        {
            Cairo.Point p = GetGridPosition(posX, posY, scale: false, offset: false);
            if (EnableTileEditing && hoveringComponent == null)
            {
                if (!IsInBounds(posX, posY, scale: false, offset: false))
                {
                    return;
                }
                if (button == 1)   // Left-click
                {
                    RoomLayout.SetTile(p.X, p.Y, TilesetViewer.SelectedIndex);
                    draggingTile = true;
                }
                else if (button == 3)   // Right-click
                {
                    TilesetViewer.SelectedIndex = RoomLayout.GetTile(p.X, p.Y);
                }
            }
            if (DrawRoomComponents)
            {
                if (hoveringComponent != null)
                {
                    selectedComponent = hoveringComponent;
                    hoveringComponent.Select();

                    if (button == 1)   // Left click
                    {
                        draggingObject = true;
                    }
                    else if (button == 3)   // Right click
                    {
                        Gtk.Menu menu = new Gtk.Menu();

                        foreach (Gtk.MenuItem item in selectedComponent.GetRightClickMenuItems())
                        {
                            menu.Add(item);
                        }

                        RoomComponent comp = selectedComponent;

                        if (comp.Deletable)
                        {
                            if (menu.Children.Length != 0)
                            {
                                menu.Add(new Gtk.SeparatorMenuItem());
                            }

                            var deleteButton = new Gtk.MenuItem("Delete");
                            deleteButton.Activated += (sender, args) => {
                                comp.Delete();
                            };
                            menu.Add(deleteButton);
                        }

                        menu.AttachToWidget(this, null);
                        menu.ShowAll();
                        menu.PopupAtPointer(triggerEvent);
                    }
                }
            }
            QueueDraw();
        }