Click here to Skip to main content
15,888,330 members
Home / Discussions / C#
   

C#

 
AnswerRe: coding for a software which is gonna run on a server Pin
Pete O'Hanlon6-Apr-10 3:35
mvePete O'Hanlon6-Apr-10 3:35 
AnswerRe: coding for a software which is gonna run on a server Pin
PIEBALDconsult6-Apr-10 4:34
mvePIEBALDconsult6-Apr-10 4:34 
GeneralRe: coding for a software which is gonna run on a server Pin
mrkeivan6-Apr-10 7:25
mrkeivan6-Apr-10 7:25 
GeneralRe: coding for a software which is gonna run on a server Pin
PIEBALDconsult6-Apr-10 9:13
mvePIEBALDconsult6-Apr-10 9:13 
QuestionHow i can create dvdplayer in directshow? Pin
Nematjon Rahmanov6-Apr-10 1:44
Nematjon Rahmanov6-Apr-10 1:44 
QuestionPanel array [modified] Pin
peropata6-Apr-10 1:36
peropata6-Apr-10 1:36 
AnswerRe: Panel array Pin
WillemM6-Apr-10 4:49
WillemM6-Apr-10 4:49 
GeneralRe: Panel array [modified] Pin
peropata6-Apr-10 7:39
peropata6-Apr-10 7:39 
Here is my code:
Class for drawing different shapes (selected by iSelectShape):
public class ShapeDrawing
    {
        private int iSelectShape = 1;

        public int SelectShape
        {
            get { return iSelectShape; }
            set { iSelectShape = value; }
        }

        public void DrawShape(Graphics g)
        {
            Rectangle r = new Rectangle(new Point(0, 0), new Size(100, 100));
            
            switch (iSelectShape)
            {
                case 1:
                    g.DrawEllipse(Pens.Black , r);
                    break;
                case 2:
                    g.DrawRectangle(Pens.Black, r);
                    break;
            }
        }
    }


Custom panel class:

public class MyCustomPanel : Panel
{
    public ShapeDrawing Drawing { get; set; }

    protected override void OnPaint(PaintEventArgs e)
    {
        // Draw the image here using e.Graphics
        if (Drawing != null)
            Drawing.DrawShape(e.Graphics);
    }
}


And main form with one panel:
public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            ShapeDrawing shape1 = new ShapeDrawing();
            myPanel.Drawing = shape1;
            shape1.SelectShape = 2;
        }

        private void myPanel_Paint(object sender, PaintEventArgs e)
        {

        }

    }


and InitializeComponent
private void InitializeComponent()
        {
            this.myPanel = new Dynamic_controls_panel.MyCustomPanel();
            this.SuspendLayout();
            // 
            // myPanel
            // 
            this.myPanel.BackColor = System.Drawing.Color.White;
            this.myPanel.Drawing = null;
            this.myPanel.Location = new System.Drawing.Point(0, 0);
            this.myPanel.Name = "myPanel";
            this.myPanel.Size = new System.Drawing.Size(301, 331);
            this.myPanel.TabIndex = 0;
            this.myPanel.Paint += new System.Windows.Forms.PaintEventHandler(this.myPanel_Paint);
            // 
            // Form1
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(416, 459);
            this.Controls.Add(this.myPanel);
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);

        }

        #endregion

        private MyCustomPanel myPanel;


Now I want to add number of panels with shape drawings dynamically with click on the button and select shape wich shall be drawn on each panel. Form will also contain remove button, so I can remove any selected panel ...
modified on Wednesday, April 7, 2010 1:05 AM

QuestionHow to get DataGridView Checkbox Checked or not ! [modified] Pin
Sr...Frank6-Apr-10 1:16
Sr...Frank6-Apr-10 1:16 
AnswerRe: How to get DataGridView Checkbox Checked or not ! Pin
Eddy Vluggen6-Apr-10 3:41
professionalEddy Vluggen6-Apr-10 3:41 
GeneralRe: How to get DataGridView Checkbox Checked or not ! Pin
Sr...Frank6-Apr-10 4:22
Sr...Frank6-Apr-10 4:22 
GeneralRe: How to get DataGridView Checkbox Checked or not ! Pin
Eddy Vluggen6-Apr-10 4:59
professionalEddy Vluggen6-Apr-10 4:59 
AnswerRe: How to get DataGridView Checkbox Checked or not ! Pin
carlecomm7-Apr-10 2:37
carlecomm7-Apr-10 2:37 
GeneralRe: How to get DataGridView Checkbox Checked or not ! Pin
Ashrafuddin7-Jun-11 19:15
Ashrafuddin7-Jun-11 19:15 
Questionkeeping sql connection open Pin
teknolog1236-Apr-10 0:31
teknolog1236-Apr-10 0:31 
AnswerRe: keeping sql connection open Pin
Pete O'Hanlon6-Apr-10 1:10
mvePete O'Hanlon6-Apr-10 1:10 
GeneralRe: keeping sql connection open Pin
teknolog1236-Apr-10 1:56
teknolog1236-Apr-10 1:56 
GeneralRe: keeping sql connection open Pin
Not Active6-Apr-10 2:31
mentorNot Active6-Apr-10 2:31 
GeneralRe: keeping sql connection open Pin
Pete O'Hanlon6-Apr-10 3:22
mvePete O'Hanlon6-Apr-10 3:22 
AnswerRe: keeping sql connection open Pin
PIEBALDconsult6-Apr-10 4:35
mvePIEBALDconsult6-Apr-10 4:35 
QuestionSending Large Files in C# using TCP Client/Server [modified] Pin
EvanSaunders5-Apr-10 23:43
EvanSaunders5-Apr-10 23:43 
AnswerRe: Sending Large Files in C# using TCP Client/Server Pin
Garth J Lancaster6-Apr-10 0:43
professionalGarth J Lancaster6-Apr-10 0:43 
GeneralRe: Sending Large Files in C# using TCP Client/Server Pin
EvanSaunders6-Apr-10 1:26
EvanSaunders6-Apr-10 1:26 
AnswerRe: Sending Large Files in C# using TCP Client/Server Pin
Garth J Lancaster6-Apr-10 0:55
professionalGarth J Lancaster6-Apr-10 0:55 
GeneralRe: Sending Large Files in C# using TCP Client/Server Pin
EvanSaunders6-Apr-10 1:43
EvanSaunders6-Apr-10 1:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.