Basic grid and mouse events
This commit is contained in:
25
McBitFont.sln
Normal file
25
McBitFont.sln
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.4.33213.308
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "McBitFont", "McBitFont\McBitFont.csproj", "{DA4DAD15-0FF6-43B6-AD42-B521DBCA34E5}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DA4DAD15-0FF6-43B6-AD42-B521DBCA34E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{DA4DAD15-0FF6-43B6-AD42-B521DBCA34E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{DA4DAD15-0FF6-43B6-AD42-B521DBCA34E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{DA4DAD15-0FF6-43B6-AD42-B521DBCA34E5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B5570D80-5662-486E-9EEA-98EB207024D8}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
115
McBitFont/Form1.Designer.cs
generated
Normal file
115
McBitFont/Form1.Designer.cs
generated
Normal file
@@ -0,0 +1,115 @@
|
||||
namespace McBitFont {
|
||||
partial class Form1 {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
dotGrid = new DataGridView();
|
||||
button1 = new Button();
|
||||
nudX = new NumericUpDown();
|
||||
nudY = new NumericUpDown();
|
||||
((System.ComponentModel.ISupportInitialize)dotGrid).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)nudX).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)nudY).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dotGrid
|
||||
//
|
||||
dotGrid.AllowUserToAddRows = false;
|
||||
dotGrid.AllowUserToDeleteRows = false;
|
||||
dotGrid.AllowUserToResizeColumns = false;
|
||||
dotGrid.AllowUserToResizeRows = false;
|
||||
dotGrid.ClipboardCopyMode = DataGridViewClipboardCopyMode.Disable;
|
||||
dotGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
|
||||
dotGrid.ColumnHeadersVisible = false;
|
||||
dotGrid.EditMode = DataGridViewEditMode.EditProgrammatically;
|
||||
dotGrid.Location = new Point(12, 26);
|
||||
dotGrid.MultiSelect = false;
|
||||
dotGrid.Name = "dotGrid";
|
||||
dotGrid.ReadOnly = true;
|
||||
dotGrid.RowHeadersVisible = false;
|
||||
dotGrid.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.DisableResizing;
|
||||
dotGrid.RowTemplate.Height = 25;
|
||||
dotGrid.SelectionMode = DataGridViewSelectionMode.CellSelect;
|
||||
dotGrid.Size = new Size(639, 532);
|
||||
dotGrid.TabIndex = 0;
|
||||
dotGrid.TabStop = false;
|
||||
dotGrid.VirtualMode = true;
|
||||
dotGrid.CellMouseMove += dotGrid_CellMouseMove;
|
||||
dotGrid.SelectionChanged += dotGrid_SelectionChanged;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
button1.Location = new Point(668, 41);
|
||||
button1.Name = "button1";
|
||||
button1.Size = new Size(75, 23);
|
||||
button1.TabIndex = 1;
|
||||
button1.Text = "button1";
|
||||
button1.UseVisualStyleBackColor = true;
|
||||
button1.Click += button1_Click;
|
||||
//
|
||||
// nudX
|
||||
//
|
||||
nudX.Location = new Point(724, 100);
|
||||
nudX.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
nudX.Name = "nudX";
|
||||
nudX.Size = new Size(120, 23);
|
||||
nudX.TabIndex = 2;
|
||||
nudX.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
nudX.ValueChanged += nudX_ValueChanged;
|
||||
//
|
||||
// nudY
|
||||
//
|
||||
nudY.Location = new Point(724, 129);
|
||||
nudY.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
nudY.Name = "nudY";
|
||||
nudY.Size = new Size(120, 23);
|
||||
nudY.TabIndex = 3;
|
||||
nudY.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
nudY.ValueChanged += nudY_ValueChanged;
|
||||
//
|
||||
// Form1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(940, 643);
|
||||
Controls.Add(nudY);
|
||||
Controls.Add(nudX);
|
||||
Controls.Add(button1);
|
||||
Controls.Add(dotGrid);
|
||||
Name = "Form1";
|
||||
Text = "Form1";
|
||||
Load += Form1_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dotGrid).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)nudX).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)nudY).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dotGrid;
|
||||
private Button button1;
|
||||
private NumericUpDown nudX;
|
||||
private NumericUpDown nudY;
|
||||
}
|
||||
}
|
77
McBitFont/Form1.cs
Normal file
77
McBitFont/Form1.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace McBitFont {
|
||||
public partial class Form1 : Form {
|
||||
public Form1() {
|
||||
InitializeComponent();
|
||||
|
||||
// Setup the grid
|
||||
dotGrid.ColumnHeadersDefaultCellStyle.BackColor = System.Drawing.Color.FromArgb(0xff, 0, 0, 0);
|
||||
dotGrid.ColumnHeadersVisible = false;
|
||||
dotGrid.RowHeadersVisible = false;
|
||||
dotGrid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.None;
|
||||
dotGrid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.None;
|
||||
dotGrid.ColumnCount = 5;
|
||||
dotGrid.RowCount = 7;
|
||||
|
||||
dotGrid_updateCellSizes();
|
||||
}
|
||||
|
||||
private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) {
|
||||
|
||||
}
|
||||
|
||||
private void fillData() {
|
||||
|
||||
}
|
||||
|
||||
private void button1_Click(object sender, EventArgs e) {
|
||||
|
||||
}
|
||||
|
||||
private void dotGrid_CellMouseMove(object sender, DataGridViewCellMouseEventArgs e) {
|
||||
int row = e.RowIndex;
|
||||
int col = e.ColumnIndex;
|
||||
DataGridViewCell cell = dotGrid.Rows[row].Cells[col];
|
||||
|
||||
if (e.Button == MouseButtons.Left && cell.Style.BackColor != Color.Black) {
|
||||
cell.Style.BackColor = Color.Black;
|
||||
dotGrid.InvalidateCell(col, row);
|
||||
}
|
||||
if (e.Button == MouseButtons.Right && cell.Style.BackColor != Color.White) {
|
||||
cell.Style.BackColor = Color.White;
|
||||
dotGrid.InvalidateCell(col, row);
|
||||
}
|
||||
dotGrid.Update();
|
||||
|
||||
}
|
||||
|
||||
private void dotGrid_SelectionChanged(object sender, EventArgs e) {
|
||||
dotGrid.ClearSelection();
|
||||
}
|
||||
|
||||
private void dotGrid_updateCellSizes() {
|
||||
for (int i = 0; i < dotGrid.ColumnCount; i++) {
|
||||
dotGrid.Columns[i].Width = 50;
|
||||
}
|
||||
for (int i = 0; i < dotGrid.RowCount; i++) {
|
||||
dotGrid.Rows[i].Height = 50;
|
||||
}
|
||||
}
|
||||
|
||||
private void Form1_Load(object sender, EventArgs e) {
|
||||
nudX.Value = dotGrid.ColumnCount;
|
||||
nudY.Value = dotGrid.RowCount;
|
||||
}
|
||||
|
||||
private void nudX_ValueChanged(object sender, EventArgs e) {
|
||||
dotGrid.ColumnCount = (int)nudX.Value;
|
||||
dotGrid_updateCellSizes();
|
||||
}
|
||||
|
||||
private void nudY_ValueChanged(object sender, EventArgs e) {
|
||||
dotGrid.RowCount = (int)nudY.Value;
|
||||
dotGrid_updateCellSizes();
|
||||
}
|
||||
}
|
||||
}
|
60
McBitFont/Form1.resx
Normal file
60
McBitFont/Form1.resx
Normal file
@@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
11
McBitFont/McBitFont.csproj
Normal file
11
McBitFont/McBitFont.csproj
Normal file
@@ -0,0 +1,11 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net6.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
14
McBitFont/Program.cs
Normal file
14
McBitFont/Program.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace McBitFont {
|
||||
internal static class Program {
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main() {
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user