如何在检查器中排列图表上的点 [英] How to arrangement of points on the chart in checker
本文介绍了如何在检查器中排列图表上的点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在棋盘上制作一个图表(如屏幕截图所示),但我想不出一个算法的构造。
//第一个点的位置
double x如何更改我的算法以便构建它? = FirstStationX;
double y = FirstStationY;
double x1 = 0,y1 = 0;
//按钮分离内嵌
double spacingX = InlineStations *(InlineSpacing - 1);
//按钮分隔横线
double spacingY = CrosslineStations *(CrosslineSpacing - 1);
//沿着X轴循环块(按钮)的数量
for(int i = 0; i {
if(i> 0)x = x1 + spacingX + InlineSeparation;
//沿着Y轴的块数(按钮)循环
for(int j = 0; j< CrosslineButtons; j ++)
{
if(j> 0)
{
y = y1 + spacingY + CrosslineSeparation;
}
//沿着X轴按钮中的点数循环
for(int k = 0; k {
if (k == 0)x1 = x;
else x1 = x1 + InlineSpacing;
//沿着Y轴循环按钮中的点数
for(int h = 0; h {
if(h == 0 )y1 = y;
else y1 = y1 + CrosslineSpacing;
listPointsButtonStation.Add(new ObservablePoint(x1,y1));
}
}
}
}
解决方案使用System;解决方案尝试类似这样的代码
使用System.Collections.Generic;
使用System.ComponentModel;
使用System.Data;
使用System.Drawing;
使用System.Linq;
使用System.Text;
使用System.Windows.Forms;
namespace WindowsFormsApplication26
{
public partial class Form1:Form
{
const string IMAGE_FILENAME = @c:\temp\image1.jpg ;
const int NUMBER_OF_CHART_COLUMNS = 8;
const int NUMBER_OF_CHART_ROWS = 8;
const int MAIN_PANEL_TOP = 20;
const int MAIN_PANEL_LEFT = 20;
const int MAIN_PANEL_WIDTH = 1000;
const int MAIN_PANEl_HEIGHT = 1000;
const int CHART_LEFT = 20;
const int CHART_TOP = 20;
const int CHART_WIDTH = 100;
const int CHART_HEIGHT = 100;
const int CHART_SPACE = 10;
列表< MyChart>图表=新列表< MyChart>();
public Form1()
{
InitializeComponent();
面板mainPanel =新面板();
mainPanel.Left = MAIN_PANEL_LEFT;
mainPanel.Top = MAIN_PANEL_TOP;
mainPanel.Height = MAIN_PANEl_HEIGHT;
mainPanel.Width = MAIN_PANEL_WIDTH;
this.Controls.Add(mainPanel);
$ b $ for(int row = 0; row< NUMBER_OF_CHART_ROWS; row ++)
{
for(int col = 0; col< NUMBER_OF_CHART_COLUMNS; col ++)
{
MyChart newChart = new MyChart();
newChart.row = row;
newChart.col = col;
newChart.Width = CHART_WIDTH;
newChart.Height = CHART_HEIGHT;
newChart.Left = col *(CHART_WIDTH + CHART_SPACE);
newChart.Top = row *(CHART_HEIGHT + CHART_SPACE);
newChart.Image = Image.FromFile(IMAGE_FILENAME);
mainPanel.Controls.Add(newChart);
charts.Add(newChart);
$ b public class MyChart:PictureBox
{
public int row {get;组; }
public int col {get;组; }
}
}
I'm trying to make a chart in checkerboard (as pictured in the screenshot), but I can not think of an algorithm for its construction. How can I change my algorithm so that I can build it?
// location for the first point
double x = FirstStationX;
double y = FirstStationY;
double x1 = 0, y1 = 0;
// button separation inline
double spacingX = InlineStations * (InlineSpacing - 1);
// button separation crossline
double spacingY = CrosslineStations * (CrosslineSpacing - 1);
// Cycle by number of blocks (buttons) along the X axis
for (int i = 0; i < InlineButtons; i++)
{
if (i > 0) x = x1 + spacingX + InlineSeparation;
// Cycle by number of blocks (buttons) along the Y axis
for(int j = 0; j < CrosslineButtons; j++)
{
if (j > 0)
{
y = y1 + spacingY + CrosslineSeparation;
}
// Cycle by number of point in buttons along the X axis
for(int k = 0; k < InlineStations; k++)
{
if (k == 0) x1 = x;
else x1 = x1 + InlineSpacing;
// Cycle by number of point in buttons along the Y axis
for(int h = 0; h < CrosslineStations; h++)
{
if (h == 0) y1 = y;
else y1 = y1 + CrosslineSpacing;
listPointsButtonStation.Add(new ObservablePoint(x1, y1));
}
}
}
}
解决方案
Try code like this
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication26
{
public partial class Form1 : Form
{
const string IMAGE_FILENAME = @"c:\temp\image1.jpg";
const int NUMBER_OF_CHART_COLUMNS = 8;
const int NUMBER_OF_CHART_ROWS = 8;
const int MAIN_PANEL_TOP = 20;
const int MAIN_PANEL_LEFT = 20;
const int MAIN_PANEL_WIDTH = 1000;
const int MAIN_PANEl_HEIGHT = 1000;
const int CHART_LEFT = 20;
const int CHART_TOP = 20;
const int CHART_WIDTH = 100;
const int CHART_HEIGHT = 100;
const int CHART_SPACE = 10;
List<MyChart> charts = new List<MyChart>();
public Form1()
{
InitializeComponent();
Panel mainPanel = new Panel();
mainPanel.Left = MAIN_PANEL_LEFT;
mainPanel.Top = MAIN_PANEL_TOP;
mainPanel.Height = MAIN_PANEl_HEIGHT;
mainPanel.Width = MAIN_PANEL_WIDTH;
this.Controls.Add(mainPanel);
for(int row = 0; row < NUMBER_OF_CHART_ROWS; row++)
{
for (int col = 0; col < NUMBER_OF_CHART_COLUMNS; col++)
{
MyChart newChart = new MyChart();
newChart.row = row;
newChart.col = col;
newChart.Width = CHART_WIDTH;
newChart.Height = CHART_HEIGHT;
newChart.Left = col * (CHART_WIDTH + CHART_SPACE);
newChart.Top = row * (CHART_HEIGHT + CHART_SPACE);
newChart.Image = Image.FromFile(IMAGE_FILENAME);
mainPanel.Controls.Add(newChart);
charts.Add(newChart);
}
}
}
}
public class MyChart : PictureBox
{
public int row { get; set; }
public int col { get; set; }
}
}
这篇关于如何在检查器中排列图表上的点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文