grid

Expressing 2x2 Logic Grid in Code Efficiently

不问归期 提交于 2019-11-28 01:03:29
问题 In an event handler I'm responding to the change of a value. I have access to the old value and the new value and want to do certain things depending on what the change is. Each different outcome will do some combination of actions/functions X, Y, or Z. Z accepts a parameter between -1 and 1. Order of performing these is not important. Look at the following logic grid. The old value is the leftmost column of labels, and the new value is the top row of labels: New: 0 !=0 -------- ------- Old:

Grid within a frame?

我怕爱的太早我们不能终老 提交于 2019-11-28 00:16:36
问题 Is it possible to place a grid of buttons in Tkinter inside another frame? I'm wanting to create a tic-tac-toe like game and want to use the grid feature to put gamesquares (that will be buttons). However, I'd like to have other stuff in the GUI other than just the game board so it's not ideal to just have everything in the one grid. To illustrate: O | X | X | ---------- | O | O | X | Player 2 wins! ---------- | X | O | X | The tic tac toe board is in a grid that is made up of all buttons and

How to populate LongListSelector

三世轮回 提交于 2019-11-27 23:21:02
I'm starting out with C# Windows Phone 8 development and I am trying to write an app which uses a LongListSelector. The app will show a long list of train station names. I have been looking at some of the samples online, including the MSDN PeopleHub, and PhotoHub samples but they seem very complex. I took the PeopleHub sample and hacked at it a bit until I got it to display a list of stations in a LongListSelector but I wasn't able to find out which item had been selected in the list. The SelectedItem property was just returning the app name when passed to another page and not which item had

How to create reusable WPF grid layout

*爱你&永不变心* 提交于 2019-11-27 22:46:47
I have a window with tab control and number of pages - tab items. Each tab item has same grid layout - 6 rows and 4 columns. Now, each tab item contains grid with row and column definitions, so almost half of XAML is definition of grids. How can I define this grid in one place and reuse that definition in my application? Template? User control? Besides 6x4, I have only two more grid dimensions that repeat: 8x4 and 6x6. Edit: Forgot to mention: controls in grid are different for each tab. I just want to have grid defined once in some resource so that I can reuse them on different tab pages. Now

Grid's SharedSizeGroup and * sizing

不羁的心 提交于 2019-11-27 21:50:13
I have a user control, call it UserControl, that has a grid with the following column definitions: <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" SharedSizeGroup="A"/> <ColumnDefinition Width="Auto" SharedSizeGroup="B"/> <ColumnDefinition Width="*" SharedSizeGroup="C"/> <ColumnDefinition Width="Auto" SharedSizeGroup="D"/> <ColumnDefinition MinWidth="30" Width="*" SharedSizeGroup="E"/> <ColumnDefinition MinWidth="30" Width="*" SharedSizeGroup="F"/> <ColumnDefinition Width="110" SharedSizeGroup="G"/> <ColumnDefinition MinWidth="30" Width="Auto" SharedSizeGroup="H"/> <ColumnDefinition

Finding rectangles in a 2d block grid

北战南征 提交于 2019-11-27 21:28:20
Let's say I have a grid of blocks, 7x12. We use the colors '*','%','@' and an empty cell '-'. 1 2 3 4 5 6 7 - - - - - - - 1 - - - - - - - 2 % % - - - - - 3 % % - - - - * 4 % % - - - @ % 5 @ @ @ - - @ % 6 @ @ * * * - * 7 * * * % % % % 8 % @ @ % * * % 9 % @ % % % % % 10 * * * % % @ @ 11 * * @ @ @ @ * 12 I want to find rectangles in this grid of a certain minimum size, and the biggest I can find and then smaller until no rectangles greater or equal to the minimum size can be found. In this example, consider the minimum size 1x4, 4x1, 2x2 so a 1x3 is not valid but a 2x3 is. If we want the biggest

How to plot 3D grid (cube) in Matlab

淺唱寂寞╮ 提交于 2019-11-27 19:49:48
Hi I would like to plot transparent cube-shaped grid with lines in it. Something like this: However, I managed only to draw a 2D grid: [X,Y] = meshgrid(-8:.5:8); Z = X+1; surf(X,Y,Z) I use Matlab R2009b. If it is impossible to plot this in matlab could you recommend me a software I could use. If you don't mind a few for loops, something like this will work: clf figure(1) for g = 0:.2:2 for i = 0:.2:2 plot3([g g], [0 2], [i, i]) hold on end end for g = 0:.2:2 for i = 0:.2:2 plot3([0 2], [g g], [i, i]) hold on end end for g = 0:.2:2 for i = 0:.2:2 plot3([i i], [g g], [0 2]) hold on end end You

How to programmatically access Control in WPF Grid by row and column index?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 18:44:21
Once Controls have been added to a WPF Grid, is there a way to programmatically access them by row and/or column index? Something along the lines of: var myControl = (object)MyGrid.GetChild(int row, int column); ... where GetChild is the method I wish I had! There isn't a built-in method for this, but you can easily do it by looking in the Children collection: myGrid.Children .Cast<UIElement>() .First(e => Grid.GetRow(e) == row && Grid.GetColumn(e) == column); Carlo This answer will help you int rowIndex = Grid.GetRow(myButton); RowDefinition rowDef = myGrid.RowDefinitions[rowIndex]; The

Arranging collection items in a grid

♀尐吖头ヾ 提交于 2019-11-27 18:35:35
问题 I would like to arrange items of a collection in a grid with a specific number of columns and rows (say 4x6). Each item exposes the dependency properties (integer) X and Y and should be placed in the relevant cell of the grid. Note that the collection can change during runtime which should update the grid items. I couldn't find any good solution. But maybe it is even possible without using the code-behind? Don't mind conversion or something. This stuff changes anyway. The used collection

Saving changes in SlickGrid

筅森魡賤 提交于 2019-11-27 18:24:44
HI, I'm looking at SlickGrid and I can see example on how to edit the cell, however do I save these changes. I have yet to find an example that tells me how to do this. Jim OHalloran The trick to saving the SlickGrid is to realise that the grid will update the array of data that you supplied when creating the grid as the cells are edited. The way I then save that is to include a form with a submit button and a hidden field below the grid. I trap the submit event and use the JSON plugin to serialise the array and place it in the hidden field. On the server side you'll receive a JSON string