grid

How to keep grid cell height and width the same

喜夏-厌秋 提交于 2019-12-01 02:23:56
问题 I need to keep the Grid cell height = width when resizing. The working code using a viewBox: <Viewbox> <Grid> <Grid.RowDefinitions> <RowDefinition Height="1*"/> <RowDefinition Height="1*"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <Label Grid.Row="0" Grid.Column="0" Background="Black" Width="{Binding RelativeSource={RelativeSource Self}, Path=ActualHeight}"></Label> <Label Grid.Row="1" Grid

Mouse position with screen scrolling in SFML

孤街浪徒 提交于 2019-12-01 01:58:06
Im trying to create a block placement with snap to grid. Everything is working, and in my head this should update the position of the mouse relative to the window each frame right? sf::Vector2i position = sf::Mouse::getPosition(window.mywindow); //get position int xSnap = (position.x / gridWidth) * gridWidth; int ySnap = (position.y / gridHeight) * gridHeight; But i also have screen scrolling using if (player.playerSprite.getPosition().x + 16 > screenDimensions.x / 2) position.x = player.playerSprite.getPosition().x + 16; else position.x = screenDimensions.x / 2; //Y if (player.playerSprite

How to obtain the state of grid cells based on a specific location on a 2D array

北城余情 提交于 2019-12-01 01:04:16
Consider a 2D grid with n rows and n columns (here 75x75). The symbols (tokens) are drawn in each cell on mouse click. The code below is used to draw grid lines and symbols within cells: class DrawCanvas extends JPanel{ @Override public void paintComponent(Graphics g){ super.paintComponent(g); setBackground(Color.WHITE); //Lines g.setColor(Color.BLACK); for(int ligne = 1; ligne < ROWS; ++ligne){ g.fillRoundRect(0, cellSize * ligne - halfGridWidth, canvasWidth - 1, gridWidth, gridWidth, gridWidth); } for(int colonne = 1; colonne < COLS; ++colonne){ g.fillRoundRect(cellSize * colonne -

ExtJs4 - What is the equivalent to the grid ColumnModel?

旧巷老猫 提交于 2019-12-01 00:48:33
问题 What is the equivalent to the ExtJs3 Ext.grid.ColumnModel in ExtJs4? What I want to do is hide a column, I did something like below in ExtJs3: grid.colModel.setHidden(1, true); 回答1: You can hide/show column using setVisible method of Ext.grid.column.Column: grid.columns[1].setVisible(false); 回答2: The other answers can be problematic if your column indexes change. Here is another solution: Set itemId on the column definition: { itemId: 'myActionColumn', xtype: 'actioncolumn', width: 50, items:

WPF Binding to Grid Column Width

怎甘沉沦 提交于 2019-12-01 00:27:24
问题 I'm attempting to bind a DependancyProperty in one of my usercontrols to the Width property of a Column in a Grid . I have code similar to this: <Grid x:Name="MyGridName"> <Grid.ColumnDefinitions> <ColumnDefinition x:Name="TitleSection" Width="100" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions>...</Grid.RowDefinitions> <GridSplitter x:Name="MyGridSplitter" Grid.Row="0" Grid.Column="0" ... /> </Grid> In a separate Usercontrol I have the following

Displaying images in grid with WPF

放肆的年华 提交于 2019-11-30 23:55:48
I'm creating an application with a store inside of it, so I need a grid view for items' icons with text. iTunes gives a good example of what I need. Any ideas? http://i55.tinypic.com/16jld3a.png You could use a ListBox that has a WrapPanel for its panel type, then use a DataTemplate that uses an Image element for the icon and a TextBlock for their caption. EG: public class MyItemType { public byte[] Icon { get; set; } public string Title { get; set; } } In window.xaml.cs: public List<MyItemType> MyItems { get; set; } public Window1() { InitializeComponent(); MyItems = new List<MyItemType>();

How can I create an enum using numbers?

余生长醉 提交于 2019-11-30 23:20:53
问题 Is it possible to make an enum using just numbers in C#? In my program I have a variable, Gain, that can only be set to 1, 2, 4, and 8. I am using a propertygrid control to display and set this value. If I were to create an enum like this... private enum GainValues {One, Two, Four, Eight} and I made my gain variable of type GainValues then the drop-down list in the propertygrid would only show the available values for the gain variable. The problem is I want the gain values to read

In WPF, how can I determine what column/row in a grid a control is in?

删除回忆录丶 提交于 2019-11-30 21:43:50
I am building a grid dynamically and putting buttons in one of the columns. When I click a button, I want to know what row of my grid it's in. How can I find this? In the Click event handler for the button you say: int row; Button btn = sender as Button; if (btn != null) { row = Grid.GetRow(btn); // And you have the row number... } else { // A nasty error occurred... } 来源: https://stackoverflow.com/questions/363100/in-wpf-how-can-i-determine-what-column-row-in-a-grid-a-control-is-in

In C#, how do you send a refresh/repaint message to a WPF grid or canvas?

吃可爱长大的小学妹 提交于 2019-11-30 21:35:13
How do you send a refresh message to a WPF grid or canvas? In other words, I have noticed while in debug mode, I can write code that sends a line to the display and then, if that line is not right, I can adjust it -- but the previous line is still there. Now, the code I am writing sends information to the display based on what the user clicks. So this must mean that the display is not refreshed each time a new set of lines and boxes and text goes to the grid or canvas in WPF. Using C# code, how do you send a refresh/repaint message to a WPF grid or canvas? DevDemon Refresh update WPF Controls

Using an ng-option dropdown in a ui-grid editableCellTemplate [ng-grid 3.x]

荒凉一梦 提交于 2019-11-30 19:34:30
I'm using ng-grid's new 3.0 release ui-grid to make a grid in my application. What i'm trying to do is make one of the editable cells in my table an ng-options dropdown that is filled with data retrieved with an angular factory. I'm trying to do this by using the editableCellTemplate feature of the ui-grid. Here is some example code: HTML: <div ui-grid="gridOptions" ui-grid-edit class="grid"></div> Controller: $scope.gridOptions = { enableSorting: true, enableFiltering: true, enableCellEditOnFocus: true, columnDefs: [ { field: 'name', sort: { direction: 'desc', priority: 1 } }, { field: