نمایش نتایج 1 تا 4 از 4

نام تاپیک: پاک شدن picturebox پس از کشیدن دایره

  1. #1

    پاک شدن picturebox پس از کشیدن دایره

    با عرض سلام خدمت استادان عزیز

    من یه مشکل دارم هر کس بتونه مشکلمو حل کنه ازش خیلی ممنون می شم

    من یک usercontrol‌ نوشتم که توش یه دایره و چند آبجکت گرافیکی دیگر کشیده ام مشکل من اینجاست که وقتی که این user control‌ رو روی یه فرم میارمش و فرم رو دراگ اند دراپ می کنم تمام اجزایی که روی picture box کشیدم پاک میشه . یا بهتر بگم وقتی یک فرم دیگه میاد روی پیکچر باکس هر چی زیر فرم باشه پاک میشه
    من برنامه ام رو به صورت زیر نوشتم

    public void draw circl()

    {
    Bitmap buffer = new Bitmap(1024,678);
    using (Graphic content=Graphid.drawImage(buffer))
    {
    content.FillEllipse(.....);
    this.picturebox1.CreateGraphics().drawImage(buffer );
    buffer1.dispose();
    }
    }


    از تمام شما دوستان فعال ممنونم

  2. #2

    نقل قول: پاک شدن پیکچر باکس پس از کشیدن دایره

    حالا که از bitmap استفاده کردی تمام اشکال را روی اون بکش و بعد به پیکچرباکس انتساب بده.

    public void drawcircl()
    {
    Bitmap buffer = new Bitmap(1024, 678);
    using (Graphics g = Graphics.FromImage(buffer))
    {
    g.FillEllipse(Brushes.Blue, new RectangleF(0, 0, buffer.Width, buffer.Height));
    this.pictureBox1.Image = buffer;
    }
    }

  3. #3

    نقل قول: پاک شدن پیکچر باکس پس از کشیدن دایره

    متوجه شدم باید در رویداد OnPaint کار ترسیم رو دوباره انجام بدید.
    مشکل شما رو اینجوری گفته:http://msdn.microsoft.com/en-us/libr...l.onpaint.aspx

    The following code example enables the user to drag an image or image file onto the form, and have it be displayed at the point on which it is dropped. The OnPaint method is overridden to repaint the image each time the form is painted; otherwise the image would only persist until the next repainting.





    private Image picture;
    private Point pictureLocation;

    public Form1()
    {
    // Enable drag-and-drop operations and
    // add handlers for DragEnter and DragDrop.
    this.AllowDrop = true;
    this.DragDrop += new DragEventHandler(this.Form1_DragDrop);
    this.DragEnter += new DragEventHandler(this.Form1_DragEnter);
    }

    protected override void OnPaint(PaintEventArgs e)
    {
    // If there is an image and it has a location,
    // paint it when the Form is repainted.
    base.OnPaint(e);
    if(this.picture != null && this.pictureLocation != Point.Empty)
    {
    e.Graphics.DrawImage(this.picture, this.pictureLocation);
    }
    }

    private void Form1_DragDrop(object sender, DragEventArgs e)
    {
    // Handle FileDrop data.
    if(e.Data.GetDataPresent(DataFormats.FileDrop) )
    {
    // Assign the file names to a string array, in
    // case the user has selected multiple files.
    string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
    try
    {
    // Assign the first image to the picture variable.
    this.picture = Image.FromFile(files[0]);
    // Set the picture location equal to the drop point.
    this.pictureLocation = this.PointToClient(new Point(e.X, e.Y) );
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.Message);
    return;
    }
    }

    // Handle Bitmap data.
    if(e.Data.GetDataPresent(DataFormats.Bitmap) )
    {
    try
    {
    // Create an Image and assign it to the picture variable.
    this.picture = (Image)e.Data.GetData(DataFormats.Bitmap);
    // Set the picture location equal to the drop point.
    this.pictureLocation = this.PointToClient(new Point(e.X, e.Y) );
    }
    catch(Exception ex)
    {
    MessageBox.Show(ex.Message);
    return;
    }
    }
    // Force the form to be redrawn with the image.
    this.Invalidate();
    }

    private void Form1_DragEnter(object sender, DragEventArgs e)
    {
    // If the data is a file or a bitmap, display the copy cursor.
    if (e.Data.GetDataPresent(DataFormats.Bitmap) ||
    e.Data.GetDataPresent(DataFormats.FileDrop) )
    {
    e.Effect = DragDropEffects.Copy;
    }
    else
    {
    e.Effect = DragDropEffects.None;
    }
    }

  4. #4

    نقل قول: پاک شدن پیکچر باکس پس از کشیدن دایره

    تشکر از دوستان عزیز مشکل حل شد ممنون

تاپیک های مشابه

  1. پاک شدن اطلاعات پس از بازگشت به صفحه قبل
    نوشته شده توسط elahe1364 در بخش ASP.NET Web Forms
    پاسخ: 25
    آخرین پست: جمعه 04 بهمن 1387, 15:08 عصر
  2. باز شدن منو پس از لود فرم
    نوشته شده توسط انگوران در بخش Access
    پاسخ: 21
    آخرین پست: چهارشنبه 13 دی 1385, 11:34 صبح
  3. غیرفعال شدن برنامه پس از اجرا
    نوشته شده توسط FirstLine در بخش برنامه نویسی در Delphi
    پاسخ: 4
    آخرین پست: پنج شنبه 04 خرداد 1385, 00:44 صبح
  4. پاک شدن برنامه پس از گذشت یک زمان مشخص
    نوشته شده توسط babak869 در بخش برنامه نویسی در Delphi
    پاسخ: 26
    آخرین پست: جمعه 23 دی 1384, 23:00 عصر

قوانین ایجاد تاپیک در تالار

  • شما نمی توانید تاپیک جدید ایجاد کنید
  • شما نمی توانید به تاپیک ها پاسخ دهید
  • شما نمی توانید ضمیمه ارسال کنید
  • شما نمی توانید پاسخ هایتان را ویرایش کنید
  •