Click here to Skip to main content
15,886,791 members
Articles / Programming Languages / C#

Dividing Up A Rectangle Based on Pairs of Points using C#

Rate me:
Please Sign up or sign in to vote.
5.00/5 (1 vote)
18 Feb 2013CPOL4 min read 12.2K   212   4  
This article describes how to break up a rectangle into smaller parts based on user defined co-ordinates.
namespace SliceRectangleSample
{
  partial class MainForm
  {
    /// <summary>
    /// Required designer variable.
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    #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()
    {
      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
      this.previewSplitContainer = new System.Windows.Forms.SplitContainer();
      this.menuStrip = new System.Windows.Forms.MenuStrip();
      this.fileToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
      this.openToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
      this.saveAsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
      this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripSeparator();
      this.exitToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
      this.splitContainer = new System.Windows.Forms.SplitContainer();
      this.tabControl = new System.Windows.Forms.TabControl();
      this.segmentsTabPage = new System.Windows.Forms.TabPage();
      this.segmentsTextBox = new System.Windows.Forms.TextBox();
      this.pointsTabPage = new System.Windows.Forms.TabPage();
      this.pointsTextBox = new System.Windows.Forms.TextBox();
      this.rectanglesTabPage = new System.Windows.Forms.TabPage();
      this.rectanglesTextBox = new System.Windows.Forms.TextBox();
      this.toolStripMenuItem2 = new System.Windows.Forms.ToolStripSeparator();
      this.aboutToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
      ((System.ComponentModel.ISupportInitialize)(this.previewSplitContainer)).BeginInit();
      this.previewSplitContainer.SuspendLayout();
      this.menuStrip.SuspendLayout();
      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
      this.splitContainer.Panel1.SuspendLayout();
      this.splitContainer.Panel2.SuspendLayout();
      this.splitContainer.SuspendLayout();
      this.tabControl.SuspendLayout();
      this.segmentsTabPage.SuspendLayout();
      this.pointsTabPage.SuspendLayout();
      this.rectanglesTabPage.SuspendLayout();
      this.SuspendLayout();
      // 
      // previewSplitContainer
      // 
      this.previewSplitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
      this.previewSplitContainer.Location = new System.Drawing.Point(0, 0);
      this.previewSplitContainer.Name = "previewSplitContainer";
      // 
      // previewSplitContainer.Panel1
      // 
      this.previewSplitContainer.Panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.previewSplitContainer1_Panel1_Paint);
      // 
      // previewSplitContainer.Panel2
      // 
      this.previewSplitContainer.Panel2.Paint += new System.Windows.Forms.PaintEventHandler(this.previewSplitContainer1_Panel2_Paint);
      this.previewSplitContainer.Size = new System.Drawing.Size(598, 296);
      this.previewSplitContainer.SplitterDistance = 296;
      this.previewSplitContainer.TabIndex = 0;
      // 
      // menuStrip
      // 
      this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.fileToolStripMenuItem});
      this.menuStrip.Location = new System.Drawing.Point(0, 0);
      this.menuStrip.Name = "menuStrip";
      this.menuStrip.Size = new System.Drawing.Size(598, 24);
      this.menuStrip.TabIndex = 1;
      this.menuStrip.Text = "menuStrip1";
      // 
      // fileToolStripMenuItem
      // 
      this.fileToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
            this.openToolStripMenuItem,
            this.saveAsToolStripMenuItem,
            this.toolStripMenuItem2,
            this.aboutToolStripMenuItem,
            this.toolStripMenuItem1,
            this.exitToolStripMenuItem});
      this.fileToolStripMenuItem.Name = "fileToolStripMenuItem";
      this.fileToolStripMenuItem.Size = new System.Drawing.Size(37, 20);
      this.fileToolStripMenuItem.Text = "&File";
      // 
      // openToolStripMenuItem
      // 
      this.openToolStripMenuItem.Name = "openToolStripMenuItem";
      this.openToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.O)));
      this.openToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
      this.openToolStripMenuItem.Text = "&Open...";
      this.openToolStripMenuItem.Click += new System.EventHandler(this.openToolStripMenuItem_Click);
      // 
      // saveAsToolStripMenuItem
      // 
      this.saveAsToolStripMenuItem.Name = "saveAsToolStripMenuItem";
      this.saveAsToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
      this.saveAsToolStripMenuItem.Text = "Save &As...";
      this.saveAsToolStripMenuItem.Click += new System.EventHandler(this.saveAsToolStripMenuItem_Click);
      // 
      // toolStripMenuItem1
      // 
      this.toolStripMenuItem1.Name = "toolStripMenuItem1";
      this.toolStripMenuItem1.Size = new System.Drawing.Size(152, 6);
      // 
      // exitToolStripMenuItem
      // 
      this.exitToolStripMenuItem.Name = "exitToolStripMenuItem";
      this.exitToolStripMenuItem.ShortcutKeys = ((System.Windows.Forms.Keys)((System.Windows.Forms.Keys.Alt | System.Windows.Forms.Keys.F4)));
      this.exitToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
      this.exitToolStripMenuItem.Text = "E&xit";
      this.exitToolStripMenuItem.Click += new System.EventHandler(this.exitToolStripMenuItem_Click);
      // 
      // splitContainer
      // 
      this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
      this.splitContainer.Location = new System.Drawing.Point(0, 24);
      this.splitContainer.Name = "splitContainer";
      this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
      // 
      // splitContainer.Panel1
      // 
      this.splitContainer.Panel1.Controls.Add(this.previewSplitContainer);
      // 
      // splitContainer.Panel2
      // 
      this.splitContainer.Panel2.Controls.Add(this.tabControl);
      this.splitContainer.Size = new System.Drawing.Size(598, 504);
      this.splitContainer.SplitterDistance = 296;
      this.splitContainer.TabIndex = 2;
      // 
      // tabControl
      // 
      this.tabControl.Controls.Add(this.segmentsTabPage);
      this.tabControl.Controls.Add(this.pointsTabPage);
      this.tabControl.Controls.Add(this.rectanglesTabPage);
      this.tabControl.Dock = System.Windows.Forms.DockStyle.Fill;
      this.tabControl.Location = new System.Drawing.Point(0, 0);
      this.tabControl.Name = "tabControl";
      this.tabControl.SelectedIndex = 0;
      this.tabControl.Size = new System.Drawing.Size(598, 204);
      this.tabControl.TabIndex = 0;
      // 
      // segmentsTabPage
      // 
      this.segmentsTabPage.Controls.Add(this.segmentsTextBox);
      this.segmentsTabPage.Location = new System.Drawing.Point(4, 22);
      this.segmentsTabPage.Name = "segmentsTabPage";
      this.segmentsTabPage.Padding = new System.Windows.Forms.Padding(9);
      this.segmentsTabPage.Size = new System.Drawing.Size(590, 178);
      this.segmentsTabPage.TabIndex = 0;
      this.segmentsTabPage.Text = "Segments";
      this.segmentsTabPage.UseVisualStyleBackColor = true;
      // 
      // segmentsTextBox
      // 
      this.segmentsTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
      this.segmentsTextBox.Location = new System.Drawing.Point(9, 9);
      this.segmentsTextBox.Multiline = true;
      this.segmentsTextBox.Name = "segmentsTextBox";
      this.segmentsTextBox.ReadOnly = true;
      this.segmentsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
      this.segmentsTextBox.Size = new System.Drawing.Size(572, 160);
      this.segmentsTextBox.TabIndex = 0;
      this.segmentsTextBox.WordWrap = false;
      // 
      // pointsTabPage
      // 
      this.pointsTabPage.Controls.Add(this.pointsTextBox);
      this.pointsTabPage.Location = new System.Drawing.Point(4, 22);
      this.pointsTabPage.Name = "pointsTabPage";
      this.pointsTabPage.Padding = new System.Windows.Forms.Padding(9);
      this.pointsTabPage.Size = new System.Drawing.Size(590, 178);
      this.pointsTabPage.TabIndex = 1;
      this.pointsTabPage.Text = "Points";
      this.pointsTabPage.UseVisualStyleBackColor = true;
      // 
      // pointsTextBox
      // 
      this.pointsTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
      this.pointsTextBox.Location = new System.Drawing.Point(9, 9);
      this.pointsTextBox.Multiline = true;
      this.pointsTextBox.Name = "pointsTextBox";
      this.pointsTextBox.ReadOnly = true;
      this.pointsTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
      this.pointsTextBox.Size = new System.Drawing.Size(572, 160);
      this.pointsTextBox.TabIndex = 1;
      this.pointsTextBox.WordWrap = false;
      // 
      // rectanglesTabPage
      // 
      this.rectanglesTabPage.Controls.Add(this.rectanglesTextBox);
      this.rectanglesTabPage.Location = new System.Drawing.Point(4, 22);
      this.rectanglesTabPage.Name = "rectanglesTabPage";
      this.rectanglesTabPage.Padding = new System.Windows.Forms.Padding(9);
      this.rectanglesTabPage.Size = new System.Drawing.Size(590, 178);
      this.rectanglesTabPage.TabIndex = 2;
      this.rectanglesTabPage.Text = "Rectangles";
      this.rectanglesTabPage.UseVisualStyleBackColor = true;
      // 
      // rectanglesTextBox
      // 
      this.rectanglesTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
      this.rectanglesTextBox.Location = new System.Drawing.Point(9, 9);
      this.rectanglesTextBox.Multiline = true;
      this.rectanglesTextBox.Name = "rectanglesTextBox";
      this.rectanglesTextBox.ReadOnly = true;
      this.rectanglesTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
      this.rectanglesTextBox.Size = new System.Drawing.Size(572, 160);
      this.rectanglesTextBox.TabIndex = 2;
      this.rectanglesTextBox.WordWrap = false;
      // 
      // toolStripMenuItem2
      // 
      this.toolStripMenuItem2.Name = "toolStripMenuItem2";
      this.toolStripMenuItem2.Size = new System.Drawing.Size(152, 6);
      // 
      // aboutToolStripMenuItem
      // 
      this.aboutToolStripMenuItem.Name = "aboutToolStripMenuItem";
      this.aboutToolStripMenuItem.Size = new System.Drawing.Size(155, 22);
      this.aboutToolStripMenuItem.Text = "A&bout...";
      this.aboutToolStripMenuItem.Click += new System.EventHandler(this.aboutToolStripMenuItem_Click);
      // 
      // MainForm
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(598, 528);
      this.Controls.Add(this.splitContainer);
      this.Controls.Add(this.menuStrip);
      this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
      this.MainMenuStrip = this.menuStrip;
      this.Name = "MainForm";
      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
      this.Text = "cyotek.com Slice Rectangle Sample";
      ((System.ComponentModel.ISupportInitialize)(this.previewSplitContainer)).EndInit();
      this.previewSplitContainer.ResumeLayout(false);
      this.menuStrip.ResumeLayout(false);
      this.menuStrip.PerformLayout();
      this.splitContainer.Panel1.ResumeLayout(false);
      this.splitContainer.Panel2.ResumeLayout(false);
      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
      this.splitContainer.ResumeLayout(false);
      this.tabControl.ResumeLayout(false);
      this.segmentsTabPage.ResumeLayout(false);
      this.segmentsTabPage.PerformLayout();
      this.pointsTabPage.ResumeLayout(false);
      this.pointsTabPage.PerformLayout();
      this.rectanglesTabPage.ResumeLayout(false);
      this.rectanglesTabPage.PerformLayout();
      this.ResumeLayout(false);
      this.PerformLayout();

    }

    #endregion

    private System.Windows.Forms.SplitContainer previewSplitContainer;
    private System.Windows.Forms.MenuStrip menuStrip;
    private System.Windows.Forms.ToolStripMenuItem fileToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem exitToolStripMenuItem;
    private System.Windows.Forms.SplitContainer splitContainer;
    private System.Windows.Forms.TabControl tabControl;
    private System.Windows.Forms.TabPage segmentsTabPage;
    private System.Windows.Forms.TextBox segmentsTextBox;
    private System.Windows.Forms.TabPage pointsTabPage;
    private System.Windows.Forms.TabPage rectanglesTabPage;
    private System.Windows.Forms.TextBox pointsTextBox;
    private System.Windows.Forms.TextBox rectanglesTextBox;
    private System.Windows.Forms.ToolStripMenuItem openToolStripMenuItem;
    private System.Windows.Forms.ToolStripMenuItem saveAsToolStripMenuItem;
    private System.Windows.Forms.ToolStripSeparator toolStripMenuItem1;
    private System.Windows.Forms.ToolStripSeparator toolStripMenuItem2;
    private System.Windows.Forms.ToolStripMenuItem aboutToolStripMenuItem;
  }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions