Treceți la conținutul principal

simple draw cs

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 SimpleDraw
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            //At this point, GraphicsImage is null. This will assign it a value of a new image that is the size of the DrawingPanel
            GraphicsImage = new Bitmap(DrawingPanel.Width, DrawingPanel.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            //Fills the image we just created with white
            Graphics.FromImage(GraphicsImage).Clear(Color.White);
        }

        private void ClearButton_Click(object sender, EventArgs e)
        {
            //Fills the image with white
            Graphics.FromImage(GraphicsImage).Clear(Color.White);
            //Draw the GraphicsImage onto the DrawingPanel
            DrawingPanel.CreateGraphics().DrawImageUnscaled(GraphicsImage, new Point(0, 0));
        }

        /*The graphics object we use will draw on this image. This image will
        then be drawn on the drawing surface (DrawingPanel). If we drew directly
        on the DrawingPanel, there would be no way to save what we drew.
        */
        private Bitmap GraphicsImage;

        private void DrawingPanel_MouseMove(object sender, MouseEventArgs e)
        {
            //This sub fires whenever the mouse is moved over the DrawingPanel control
            if (e.Button == MouseButtons.Left) //See if the left mouse button is held down
            {
                //Draw a circle on the canvas
                System.Drawing.Graphics DrawingGraphics = Graphics.FromImage(GraphicsImage);
                if (AACheckBox.Checked)
                {
                    //AntiAliasing is to be used
                    DrawingGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                }
                switch (ShapeComboBox.SelectedIndex)
                {
                    case 0: //draw a filled circle
                        DrawingGraphics.FillEllipse(new SolidBrush(ColorButton.BackColor), new Rectangle(Convert.ToInt32(e.X - numericUpDown1.Value / 2), Convert.ToInt32(e.Y - numericUpDown1.Value / 2), Convert.ToInt32(numericUpDown1.Value), Convert.ToInt32(numericUpDown1.Value)));
                        break;
                    case 1: //draw an open circle
                        DrawingGraphics.DrawEllipse(new Pen(ColorButton.BackColor), new Rectangle(Convert.ToInt32(e.X - numericUpDown1.Value / 2), Convert.ToInt32(e.Y - numericUpDown1.Value / 2), Convert.ToInt32(numericUpDown1.Value), Convert.ToInt32(numericUpDown1.Value)));
                        break;
                    case 2: //draw a filled square
                        DrawingGraphics.FillRectangle(new SolidBrush(ColorButton.BackColor), new Rectangle(Convert.ToInt32(e.X - numericUpDown1.Value / 2), Convert.ToInt32(e.Y - numericUpDown1.Value / 2), Convert.ToInt32(numericUpDown1.Value), Convert.ToInt32(numericUpDown1.Value)));
                        break;
                    case 3: //draw an open square
                        DrawingGraphics.DrawRectangle(new Pen(ColorButton.BackColor), new Rectangle(Convert.ToInt32(e.X - numericUpDown1.Value / 2), Convert.ToInt32(e.Y - numericUpDown1.Value / 2), Convert.ToInt32(numericUpDown1.Value), Convert.ToInt32(numericUpDown1.Value)));
                        break;
                }
                //Draw the GraphicsImage onto the DrawingPanel
                DrawingPanel.CreateGraphics().DrawImageUnscaled(GraphicsImage, new Point(0, 0));
            }
        }

        private void DrawingPanel_MouseDown(object sender, MouseEventArgs e)
        {
            //This sub fires whenever the mouse is clicked on the DrawingPanel control. This makes it so a single click will draw as well
            if (e.Button == MouseButtons.Left) //See if the left mouse button is held down
            {
                //Draw a circle on the canvas
                System.Drawing.Graphics DrawingGraphics = Graphics.FromImage(GraphicsImage);
                if (AACheckBox.Checked)
                {
                    //AntiAliasing is to be used
                    DrawingGraphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
                }
                switch (ShapeComboBox.SelectedIndex)
                {
                    case 0: //draw a filled circle
                        DrawingGraphics.FillEllipse(new SolidBrush(ColorButton.BackColor), new Rectangle(Convert.ToInt32(e.X - numericUpDown1.Value / 2), Convert.ToInt32(e.Y - numericUpDown1.Value / 2), Convert.ToInt32(numericUpDown1.Value), Convert.ToInt32(numericUpDown1.Value)));
                        break;
                    case 1: //draw an open circle
                        DrawingGraphics.DrawEllipse(new Pen(ColorButton.BackColor), new Rectangle(Convert.ToInt32(e.X - numericUpDown1.Value / 2), Convert.ToInt32(e.Y - numericUpDown1.Value / 2), Convert.ToInt32(numericUpDown1.Value), Convert.ToInt32(numericUpDown1.Value)));
                        break;
                    case 2: //draw a filled square
                        DrawingGraphics.FillRectangle(new SolidBrush(ColorButton.BackColor), new Rectangle(Convert.ToInt32(e.X - numericUpDown1.Value / 2), Convert.ToInt32(e.Y - numericUpDown1.Value / 2), Convert.ToInt32(numericUpDown1.Value), Convert.ToInt32(numericUpDown1.Value)));
                        break;
                    case 3: //draw an open square
                        DrawingGraphics.DrawRectangle(new Pen(ColorButton.BackColor), new Rectangle(Convert.ToInt32(e.X - numericUpDown1.Value / 2), Convert.ToInt32(e.Y - numericUpDown1.Value / 2), Convert.ToInt32(numericUpDown1.Value), Convert.ToInt32(numericUpDown1.Value)));
                        break;
                }
                //Draw the GraphicsImage onto the DrawingPanel
                DrawingPanel.CreateGraphics().DrawImageUnscaled(GraphicsImage, new Point(0, 0));
            }
        }

        private void DrawingPanel_Paint(object sender, PaintEventArgs e)
        {
            /*Draw the GraphicsImage onto the DrawingPanel. In this, instead
             * of using DrawingPanel.CreateGraphics(), we can use e.Graphics instead.
             * It will return the graphics used to paint DrawingPanel. This will do the 
             * same as DrawingPanel.CreateGraphics(), but i thought i should point
             * this out */
            e.Graphics.DrawImageUnscaled(GraphicsImage, new Point(0, 0));
        }

        private void saveFileDialog1_FileOk(object sender, CancelEventArgs e)
        {
            //this event fires when the user clicks Save on the save dialog. It will save the image
            GraphicsImage.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Shows the save dialog
            saveFileDialog1.ShowDialog();
        }

        private void ColorButton_Click(object sender, EventArgs e)
        {
            //Shows the choose color dialog
            colorDialog1.ShowDialog();
            /*Set's the ColorButton's backcolor to the color chosen by
             * the user. When painting on the image, you will notice we
             * refer to this property to get the color to paint with. */
            ColorButton.BackColor = colorDialog1.Color;
        }
    }
}

Comentarii

Postări populare de pe acest blog

program principal cpp

#include "clasa.h" #include <stdio.h> #include <conio.h> #include <stdlib.h> #include <string.h> #define DELAY 9000000 void delay() { for(long i=0;i<DELAY;i++); } //constructor cu initializare de la tastatura BigInt::BigInt() {char x; signed char t[400]; int i; printf("\nNumarul cu semn "); do s=getche(); while((s!='+')&&(s!='-')); n=0; do {x=getche(); t[n]=x-'0'; n++; } while((x>='0')&&(x<='9')); n--; for(i=0;i<n;i++) nr[i]=t[n-i-1]; } //constructor cu initializare prin parametri BigInt::BigInt(char semn,signed char numar[],int dim) {int i; s=semn; n=dim; for(i=0;i<n;i++) nr[i]=numar[n-i-1]; } //transform un int negativ in pozitiv int BigInt::Pozitiv(int x) {int a,vb; a=0; vb=0; while(vb==0) if((x+a)==0) vb=1; else a=a+1; x=a; return x; } //constructor dintr-un nr int obisnuit BigInt::BigInt(int x) {int i; if(x>=0) s='+'…

NUMERE PRIME ALGORITM C++

// NUMERE PRIME ALGORITM C++//  reediting from scratch //on this page is just the study for a next algoritm for generating the parime nr series like Fibonnaci or ....if possibile
BPN = 2 POW 74207281 -1

odd impar
even par

!!! any even number is a sum of two even numbers or two odd numbers or two prime numbers
!!! any odd number is a sum of a odd number and a even numbers
!!!  prime numbers can not be a sum of two prime numbers but will be a sum of a prime number and an even number 
!!! any prime numbers will be odd too but not all odd number are primes
!!! all the numbers formed by same digit  1,3,7,9 are not prime numbers except 11


0, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 
37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 
79, 83, 89, 97

1 = 1 + 0+ 0              0
2 = 1 + 1+ 0              1
3 = 2 + 1+ 0              1

small numbers 

5 = 3 + 2+ 0              2
7 = 5 + 2 + 0              2
11 = 7 + 3 + 1            4
13 = 11+2 + 0            2
17 = 13 + 3 + 1 4
19 = 17 + 2+ 0 2
23 = 19 + 3 + 1 4
29 = 23 + 5 + …

o aplicatie php localitati romania

//APLICATIA SE REFERA LA BAZA DE DATE SIRUTA

//dragtable.js


/* dragtable v1.0 June 26, 2008 Dan Vanderkam, http://danvk.org/dragtable/ http://code.google.com/p/dragtable/ \Bsortabledraggable\B Instructions: - Download this file - Add <script src="dragtable.js"></script> to your HTML. - Add class="draggable" to any table you might like to reorder. - Drag the headers around to reorder them. This is code was based on: - Stuart Langridge's SortTable (kryogenix.org/code/browser/sorttable) - Mike Hall's draggable class (http://www.brainjar.com/dhtml/drag/) - A discussion of permuting table columns on comp.lang.javascript Licensed under the MIT license. */ // Here's the notice from Mike Hall's draggable script: //***************************************************************************** // Do not remove this notice. // // Copyright 2001 by Mike Hall. // See http…