Prolème form

Lhioui Messages postés 9 Date d'inscription lundi 18 avril 2005 Statut Membre Dernière intervention 20 mai 2005 - 19 mai 2005 à 16:41
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 - 20 mai 2005 à 15:37
lorsque je dessine des bitmaps par la methode graphics: voilà exactement comment j'ai fait:
publi void tabPage_MouseDown(.....................)
{
Graphics g=tabpage.createGraphics();
g.drawimage(b,e.X,e.Y);/*b est ue bitmap*/

}
le problème est lorsque j'ouvre une autre application les bitmaps s'effacent?
y'a t'-il une solution SVP
merçi

12 réponses

MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
19 mai 2005 à 16:47
Il fut overrider la méthode OnPaint, pour que tes dessins soient persistants.



protected override void OnPaint(PaintEventArgs e)

{

Graphics g = e.Graphics;

e.DrawImage(...);

...

}

Mx
0
Lhioui Messages postés 9 Date d'inscription lundi 18 avril 2005 Statut Membre Dernière intervention 20 mai 2005
19 mai 2005 à 16:49
SVP j'utilise les parametres de la souri ( e.X,e.Y) comment en faire dans OnPaint
merçi
0
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
19 mai 2005 à 16:52
La méthode OnPaint est appelée a chaque fois que la Form doit etre
raffraichie, donc tu peux toujours continuer d'utiliser ta méthode
MouseDown. Et tu forces le raffraichissement en appelant
this.Invalidate() a la fin.
Et sinon, enregistre les dans une variable tes parametres de souris, c'est pas un probleme ca.


Mx
0
cs_coq Messages postés 6349 Date d'inscription samedi 1 juin 2002 Statut Membre Dernière intervention 2 août 2014 101
19 mai 2005 à 16:59
Ah, le problème de post est résolu apparemment :-)
Par contre évite de faire du multipost comme ça à 10 min d'intervalle , si tu changes de méthode dit le dans le même sujet, ça permet d'avoir une continuité dans la discusion :-)

Cocoricoooooooo !!!!
coq
MVP Visual C#
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Lhioui Messages postés 9 Date d'inscription lundi 18 avril 2005 Statut Membre Dernière intervention 20 mai 2005
19 mai 2005 à 21:21
je vous pri MR MorpionMx donner mois un peut plus d'information en ce qui concerne this.invalidate() (ou je vais la metre)
0
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
19 mai 2005 à 21:36
this.Invalidate(),
tu peux le mettre a la fin de ton MouseDown, ou où tu le souhaite, ca
va juste forcer ton form est ses composants a se rafraichir.

Mx
0
Lhioui Messages postés 9 Date d'inscription lundi 18 avril 2005 Statut Membre Dernière intervention 20 mai 2005
19 mai 2005 à 21:50
MR MorpionMx j'ai essayé de dessiner avec la methode OnPaint j'ai fait:

protected override void OnPaint(PaintEventArgs e)
{
Graphics g=e.Graphics;
g.DrawImage(b,100,100)
.
.
.
}

mais ça pas marché
0
Lhioui Messages postés 9 Date d'inscription lundi 18 avril 2005 Statut Membre Dernière intervention 20 mai 2005
19 mai 2005 à 21:53
de plus Mr

j'aibesoin de dessiner sur la tabPage pas sur le form

merçi
0
Lhioui Messages postés 9 Date d'inscription lundi 18 avril 2005 Statut Membre Dernière intervention 20 mai 2005
19 mai 2005 à 22:17
de plusvoilà le code que je l'ai programmé (mais risque de ne pas
fonctionner car il est relié à des autre classe que j'ai crée pour
representer les différent equipement)







using System;

using System.Drawing;

using System.Collections;

using System.ComponentModel;

using System.Windows.Forms;

using System.Data;

using NetDM;

using System.Drawing.Drawing2D;







namespace NetDM

{

///

/// Description résumée de NetDM.

///

public class NetDM : System.Windows.Forms.Form

{

Pc p=new Pc();

Serveur s=new Serveur("serveur proxy");

Switch sw=new Switch();

Hub h=new Hub();

InterconnexionLan i=new InterconnexionLan();

Mac mm=new Mac();

private Image architecture;

public bool see=false;









private System.Windows.Forms.MainMenu Menu1;

private System.Windows.Forms.MenuItem fichier;

private System.Windows.Forms.MenuItem nouveau;

private System.Windows.Forms.MenuItem ouvrir;

private System.Windows.Forms.MenuItem enregistrer;

private System.Windows.Forms.MenuItem enregistrerSous;

private System.Windows.Forms.MenuItem imprimer;

private System.Windows.Forms.MenuItem quitter;

private System.Windows.Forms.MenuItem edition;

private System.Windows.Forms.MenuItem annuler;

private System.Windows.Forms.MenuItem etablir;

private System.Windows.Forms.MenuItem couper;

private System.Windows.Forms.MenuItem copier;

private System.Windows.Forms.MenuItem coller;

private System.Windows.Forms.MenuItem supprimer;

private System.Windows.Forms.MenuItem selectionnertout;

private System.Windows.Forms.ToolBar toolBar1;

private System.Windows.Forms.ToolBarButton tbb1;

private System.Windows.Forms.ToolBarButton tbb2;

private System.Windows.Forms.ToolBarButton tbb3;

private System.Windows.Forms.ToolBarButton tbb4;

private System.Windows.Forms.ToolBarButton tbb5;

private System.Windows.Forms.ToolBarButton tbb6;

private System.Windows.Forms.ToolBarButton tbb7;

private System.Windows.Forms.ImageList imageList1;

private System.Windows.Forms.TabControl tabControl1;

private System.Windows.Forms.TabPage tabPage1;

private System.Windows.Forms.TabPage tabPage2;

private System.Windows.Forms.OpenFileDialog openFileDialog1;

private System.Windows.Forms.SaveFileDialog saveFileDialog1;

private System.Windows.Forms.Button font1;

private System.Windows.Forms.Button font2;

private System.Windows.Forms.Button font3;

private System.Windows.Forms.Button defaut;

private System.Windows.Forms.ContextMenu contextMenu1;

private System.Windows.Forms.MenuItem menuItem1;

private System.Windows.Forms.MenuItem menuItem2;

private System.Windows.Forms.MenuItem menuItem3;

private System.Windows.Forms.MenuItem menuItem5;

private System.ComponentModel.IContainer components;



public NetDM()

{

//

// Requis pour la prise en charge du Concepteur Windows Forms

//

InitializeComponent();



//

// TODO :
ajoutez le code du constructeur après l'appel à InitializeComponent

//

}



///

/// Nettoyage des ressources utilisées.

///

protected override void Dispose( bool disposing )

{

if( disposing )

{

if (components != null)

{

components.Dispose();

}

}

base.Dispose( disposing );

}



#region Code généré par le Concepteur Windows Form

///

/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas

/// le contenu de cette méthode avec l'éditeur de code.

///

private void InitializeComponent()

{

this.components = new System.ComponentModel.Container();


System.Resources.ResourceManager resources = new
System.Resources.ResourceManager(typeof(NetDM));

this.Menu1 = new System.Windows.Forms.MainMenu();

this.fichier = new System.Windows.Forms.MenuItem();

this.nouveau = new System.Windows.Forms.MenuItem();

this.ouvrir = new System.Windows.Forms.MenuItem();

this.enregistrer = new System.Windows.Forms.MenuItem();

this.enregistrerSous = new System.Windows.Forms.MenuItem();

this.imprimer = new System.Windows.Forms.MenuItem();

this.quitter = new System.Windows.Forms.MenuItem();

this.edition = new System.Windows.Forms.MenuItem();

this.annuler = new System.Windows.Forms.MenuItem();

this.etablir = new System.Windows.Forms.MenuItem();

this.couper = new System.Windows.Forms.MenuItem();

this.copier = new System.Windows.Forms.MenuItem();

this.coller = new System.Windows.Forms.MenuItem();

this.supprimer = new System.Windows.Forms.MenuItem();

this.selectionnertout = new System.Windows.Forms.MenuItem();

this.toolBar1 = new System.Windows.Forms.ToolBar();

this.tbb1 = new System.Windows.Forms.ToolBarButton();

this.tbb2 = new System.Windows.Forms.ToolBarButton();

this.tbb3 = new System.Windows.Forms.ToolBarButton();

this.tbb4 = new System.Windows.Forms.ToolBarButton();

this.tbb5 = new System.Windows.Forms.ToolBarButton();

this.tbb6 = new System.Windows.Forms.ToolBarButton();

this.tbb7 = new System.Windows.Forms.ToolBarButton();

this.imageList1 = new System.Windows.Forms.ImageList(this.components);

this.tabControl1 = new System.Windows.Forms.TabControl();

this.tabPage1 = new System.Windows.Forms.TabPage();

this.contextMenu1 = new System.Windows.Forms.ContextMenu();

this.menuItem1 = new System.Windows.Forms.MenuItem();

this.menuItem2 = new System.Windows.Forms.MenuItem();

this.menuItem3 = new System.Windows.Forms.MenuItem();

this.menuItem5 = new System.Windows.Forms.MenuItem();

this.tabPage2 = new System.Windows.Forms.TabPage();

this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();

this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();

this.font1 = new System.Windows.Forms.Button();

this.font2 = new System.Windows.Forms.Button();

this.font3 = new System.Windows.Forms.Button();

this.defaut = new System.Windows.Forms.Button();

this.tabControl1.SuspendLayout();

this.SuspendLayout();

//

// Menu1

//

this.Menu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {







this.fichier,







this.edition});

//

// fichier

//

this.fichier.Index = 0;

this.fichier.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {







this.nouveau,







this.ouvrir,








this.enregistrer,








this.enregistrerSous,







this.imprimer,







this.quitter});

this.fichier.Text = "&Fichier";

//

// nouveau

//

this.nouveau.Index = 0;

this.nouveau.Shortcut = System.Windows.Forms.Shortcut.CtrlN;

this.nouveau.Text = "&Nouveau";

//

// ouvrir

//

this.ouvrir.Index = 1;

this.ouvrir.Shortcut = System.Windows.Forms.Shortcut.CtrlO;

this.ouvrir.Text = "&Ouvrir";

this.ouvrir.Click += new System.EventHandler(this.ouvrir_Click);

//

// enregistrer

//

this.enregistrer.Index = 2;

this.enregistrer.Shortcut = System.Windows.Forms.Shortcut.CtrlE;

this.enregistrer.Text = "&Enregistrer";


this.enregistrer.Click += new
System.EventHandler(this.enregistrer_Click);

//

// enregistrerSous

//

this.enregistrerSous.Index = 3;


this.enregistrerSous.Shortcut =
System.Windows.Forms.Shortcut.CtrlShiftE;

this.enregistrerSous.Text = "&Enregistrer Sous";


this.enregistrerSous.Click += new
System.EventHandler(this.enregistrerSous_Click);

//

// imprimer

//

this.imprimer.Index = 4;

this.imprimer.Shortcut = System.Windows.Forms.Shortcut.CtrlI;

this.imprimer.Text = "&Imprimer";

//

// quitter

//

this.quitter.Index = 5;

this.quitter.Shortcut = System.Windows.Forms.Shortcut.CtrlQ;

this.quitter.Text = "&Quitter";

this.quitter.Click += new System.EventHandler(this.quitter_Click);

//

// edition

//

this.edition.Index = 1;

this.edition.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {







this.annuler,







this.etablir,







this.couper,







this.copier,







this.coller,







this.supprimer,








this.selectionnertout});

this.edition.Text = "&Edition";

//

// annuler

//

this.annuler.Index = 0;

this.annuler.Shortcut = System.Windows.Forms.Shortcut.CtrlZ;

this.annuler.Text = "&Annuler";

//

// etablir

//

this.etablir.Index = 1;

this.etablir.Shortcut = System.Windows.Forms.Shortcut.CtrlY;

this.etablir.Text = "&Retablir";

//

// couper

//

this.couper.Index = 2;

this.couper.Shortcut = System.Windows.Forms.Shortcut.CtrlX;

this.couper.Text = "&Couper";

//

// copier

//

this.copier.Index = 3;

this.copier.Shortcut = System.Windows.Forms.Shortcut.CtrlC;

this.copier.Text = "Co&pier";

//

// coller

//

this.coller.Index = 4;

this.coller.Shortcut = System.Windows.Forms.Shortcut.CtrlV;

this.coller.Text = "Co&ller";

//

// supprimer

//

this.supprimer.Index = 5;

this.supprimer.Shortcut = System.Windows.Forms.Shortcut.Del;

this.supprimer.Text = "S&upprimer";

//

// selectionnertout

//

this.selectionnertout.Index = 6;

this.selectionnertout.Shortcut = System.Windows.Forms.Shortcut.CtrlA;

this.selectionnertout.Text = "Selectio&nner tout";

//

// toolBar1

//

this.toolBar1.AllowDrop = true;

this.toolBar1.AutoSize = false;


this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[]
{








this.tbb1,








this.tbb2,








this.tbb3,








this.tbb4,








this.tbb5,








this.tbb6,








this.tbb7});

this.toolBar1.ButtonSize = new System.Drawing.Size(58, 49);

this.toolBar1.Cursor = System.Windows.Forms.Cursors.Help;

this.toolBar1.Dock = System.Windows.Forms.DockStyle.None;

this.toolBar1.DropDownArrows = true;

this.toolBar1.ImageList = this.imageList1;

this.toolBar1.Location = new System.Drawing.Point(8, 0);

this.toolBar1.Name = "toolBar1";

this.toolBar1.ShowToolTips = true;

this.toolBar1.Size = new System.Drawing.Size(408, 55);

this.toolBar1.TabIndex = 0;

this.toolBar1.TabStop = true;

//

// tbb1

//

this.tbb1.ImageIndex = 0;

this.tbb1.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;

this.tbb1.Text = "Serveur";

this.tbb1.ToolTipText = "inserer un serveur";

//

// tbb2

//

this.tbb2.ImageIndex = 1;

this.tbb2.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;

this.tbb2.Text = "Pc";

this.tbb2.ToolTipText = "inserer une poste de travail";

//

// tbb3

//

this.tbb3.ImageIndex = 2;

this.tbb3.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;

this.tbb3.Text = "Routeur";

this.tbb3.ToolTipText = "insrer un routeur";

//

// tbb4

//

this.tbb4.ImageIndex = 3;

this.tbb4.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;

this.tbb4.Text = "Switch";

this.tbb4.ToolTipText = "inserer un switch";

//

// tbb5

//

this.tbb5.ImageIndex = 4;

this.tbb5.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;

this.tbb5.Text = "Hub";

this.tbb5.ToolTipText = "inserer un hub";

//

// tbb6

//

this.tbb6.ImageIndex = 5;

this.tbb6.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;

this.tbb6.Text = "Wirless";

this.tbb6.ToolTipText = "inserer un point d\'accés wirless";

//

// tbb7

//

this.tbb7.ImageIndex = 6;

this.tbb7.Style = System.Windows.Forms.ToolBarButtonStyle.ToggleButton;

this.tbb7.Text = "Mac";

this.tbb7.ToolTipText = "inserer une station macintosh";

//

// imageList1

//

this.imageList1.ImageSize = new System.Drawing.Size(16, 16);


this.imageList1.ImageStream =
((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));

this.imageList1.TransparentColor = System.Drawing.Color.Transparent;

//

// tabControl1

//

this.tabControl1.AllowDrop = true;


this.tabControl1.Anchor =
((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top
| System.Windows.Forms.AnchorStyles.Bottom)

| System.Windows.Forms.AnchorStyles.Left)

| System.Windows.Forms.AnchorStyles.Right)));

this.tabControl1.Controls.Add(this.tabPage1);

this.tabControl1.Controls.Add(this.tabPage2);

this.tabControl1.HotTrack = true;

this.tabControl1.ItemSize = new System.Drawing.Size(90, 25);

this.tabControl1.Location = new System.Drawing.Point(8, 88);

this.tabControl1.Multiline = true;

this.tabControl1.Name = "tabControl1";

this.tabControl1.SelectedIndex = 0;

this.tabControl1.ShowToolTips = true;

this.tabControl1.Size = new System.Drawing.Size(1000, 424);

this.tabControl1.TabIndex = 1;

//

// tabPage1

//


this.tabPage1.AccessibleRole =
System.Windows.Forms.AccessibleRole.Graphic;

this.tabPage1.AutoScroll = true;

this.tabPage1.AutoScrollMargin = new System.Drawing.Size(5, 5);

this.tabPage1.AutoScrollMinSize = new System.Drawing.Size(992, 500);

this.tabPage1.BackColor = System.Drawing.Color.White;

this.tabPage1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

this.tabPage1.ContextMenu = this.contextMenu1;

this.tabPage1.Cursor = System.Windows.Forms.Cursors.Default;


this.tabPage1.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold |
System.Drawing.FontStyle.Underline))),
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

this.tabPage1.ForeColor = System.Drawing.Color.LightYellow;

this.tabPage1.ImeMode = System.Windows.Forms.ImeMode.NoControl;

this.tabPage1.Location = new System.Drawing.Point(4, 29);

this.tabPage1.Name = "tabPage1";

this.tabPage1.Size = new System.Drawing.Size(992, 391);

this.tabPage1.TabIndex = 0;

this.tabPage1.Text = "Architecture Du Réseau";


this.tabPage1.MouseUp += new
System.Windows.Forms.MouseEventHandler(this.tabPage1_MouseUp);


this.tabPage1.MouseDown += new
System.Windows.Forms.MouseEventHandler(this.tabPage1_MouseDown);



//

// contextMenu1

//


this.contextMenu1.MenuItems.AddRange(new
System.Windows.Forms.MenuItem[] {








this.menuItem1,








this.menuItem2,








this.menuItem3,








this.menuItem5});

this.contextMenu1.RightToLeft = System.Windows.Forms.RightToLeft.No;

//

// menuItem1

//

this.menuItem1.Index = 0;

this.menuItem1.Text = "connecter à";

//

// menuItem2

//

this.menuItem2.Index = 1;

this.menuItem2.Text = "naviguer";

//

// menuItem3

//

this.menuItem3.Index = 2;

this.menuItem3.Text = "ping";

//

// menuItem5

//

this.menuItem5.Index = 3;

this.menuItem5.Text = "Supprimer";

//

// tabPage2

//

this.tabPage2.AutoScroll = true;

this.tabPage2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;

this.tabPage2.Cursor = System.Windows.Forms.Cursors.No;


this.tabPage2.Font = new System.Drawing.Font("Microsoft Sans Serif",
8.25F, ((System.Drawing.FontStyle)((System.Drawing.FontStyle.Bold |
System.Drawing.FontStyle.Underline))),
System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));

this.tabPage2.ForeColor = System.Drawing.SystemColors.ActiveCaption;

this.tabPage2.Location = new System.Drawing.Point(4, 29);

this.tabPage2.Name = "tabPage2";

this.tabPage2.Size = new System.Drawing.Size(992, 391);

this.tabPage2.TabIndex = 1;

this.tabPage2.Text = "Informations réseaux";

//

// font1

//

this.font1.BackColor = System.Drawing.Color.LightYellow;

this.font1.Location = new System.Drawing.Point(64, 56);

this.font1.Name = "font1";

this.font1.Size = new System.Drawing.Size(56, 24);

this.font1.TabIndex = 2;

this.font1.Text = "Font1";

this.font1.Click += new System.EventHandler(this.font1_Click);

//

// font2

//

this.font2.BackColor = System.Drawing.Color.AliceBlue;

this.font2.Location = new System.Drawing.Point(120, 56);

this.font2.Name = "font2";

this.font2.Size = new System.Drawing.Size(56, 24);

this.font2.TabIndex = 3;

this.font2.Text = "Font2";

this.font2.Click += new System.EventHandler(this.font2_Click);

//

// font3

//

this.font3.BackColor = System.Drawing.Color.MintCream;

this.font3.Location = new System.Drawing.Point(176, 56);

this.font3.Name = "font3";

this.font3.Size = new System.Drawing.Size(56, 24);

this.font3.TabIndex = 4;

this.font3.Text = "Font3";

this.font3.Click += new System.EventHandler(this.font3_Click);

//

// defaut

//

this.defaut.BackColor = System.Drawing.Color.White;

this.defaut.Location = new System.Drawing.Point(8, 56);

this.defaut.Name = "defaut";

this.defaut.Size = new System.Drawing.Size(56, 24);

this.defaut.TabIndex = 5;

this.defaut.Text = "Font0";

this.defaut.Click += new System.EventHandler(this.defaut_Click);

//

// NetDM

//

this.AutoScale = false;

this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);

this.BackColor = System.Drawing.Color.Lavender;

this.ClientSize = new System.Drawing.Size(1028, 566);

this.Controls.Add(this.defaut);

this.Controls.Add(this.font3);

this.Controls.Add(this.font2);

this.Controls.Add(this.font1);

this.Controls.Add(this.tabControl1);

this.Controls.Add(this.toolBar1);

this.Menu = this.Menu1;

this.MinimumSize = new System.Drawing.Size(1000, 600);

this.Name = "NetDM";

this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

this.Text = "NetDM";

this.WindowState = System.Windows.Forms.FormWindowState.Maximized;

this.Load += new System.EventHandler(this.NetDM_Load);

this.tabControl1.ResumeLayout(false);

this.ResumeLayout(false);



}

#endregion



///

/// Point d'entrée principal de l'application.

///

[STAThread]

static void Main()

{

Application.Run(new NetDM());

}

private void NetDM_Load(object sender, System.EventArgs e)

{



}



protected override void OnPaint(PaintEventArgs e)

{



}



private void tabPage1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)

{

see=true;

Graphics g=tabPage1.CreateGraphics();

if (tbb2.Pushed==true )

{

p.posx=e.X;

p.posy=e.Y;

g.DrawImage(p.icon,p.posx,p.posy);

tbb2.Pushed=false;





}

if (tbb1.Pushed==true )

{

s.posx=e.X;

s.posy=e.Y;

g.DrawImage(s.icon,s.posx,s.posy);

tbb1.Pushed=false;

}

if (tbb3.Pushed==true )

{

i.posx=e.X;

i.posy=e.Y;

g.DrawImage(i.icon,i.posx,i.posy);

tbb3.Pushed=false;

}

if (tbb4.Pushed==true )

{

sw.posx=e.X;

sw.posy=e.Y;

g.DrawImage(sw.icon,sw.posx,sw.posy);

tbb4.Pushed=false;

}

if (tbb5.Pushed==true )

{

h.posx=e.X;

h.posy=e.Y;

g.DrawImage(h.icon,h.posx,h.posy);

tbb5.Pushed=false;

}

if (tbb7.Pushed==true )

{

mm.posx=e.X;

mm.posy=e.Y;

g.DrawImage(mm.icon,mm.posx,mm.posy);

tbb7.Pushed=false;

}



this.Invalidate();



}









private void tabPage1_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)

{



}

private void tabPage1_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)

{



}



private void ouvrir_Click(object sender, System.EventArgs e)

{


openFileDialog1.Filter = "Toutes les architectures|*NDM|Fichiers NetDM
(*NDM;*.ndm)|*NDM;*.ndm";

//string filter = openFileDialog1.Filter;

openFileDialog1.InitialDirectory = Environment.CurrentDirectory;

openFileDialog1.Title = "Charger Une Architecture";

if (openFileDialog1.ShowDialog() == DialogResult.OK)

{







architecture =
Image.FromFile(openFileDialog1.FileName);





}

}



private void quitter_Click(object sender, System.EventArgs e)

{

Close();

}



private void enregistrer_Click(object sender, System.EventArgs e)

{



}



private void enregistrerSous_Click(object sender, System.EventArgs e)

{

saveFileDialog1.Filter = "Fichiers NetDM (*NDM;*.ndm)|*NDM;*.ndm";

saveFileDialog1.InitialDirectory = Environment.CurrentDirectory;

saveFileDialog1.Title = "Enregistrer l'Architecture";

if (saveFileDialog1.ShowDialog() == DialogResult.OK)

{


string extension =
saveFileDialog1.FileName.Substring (saveFileDialog1.FileName.Length -
3, 3);

//

if (extension == "NDM")

//


architecture.Save(saveFileDialog1.FileName, ImageFormat.Bmp);

//

if (extension == "ndm")

//


architecture.Save(saveFileDialog1.FileName, ImageFormat.Jpeg);

}

}



private void font1_Click(object sender, System.EventArgs e)

{



Color couleur
= Color.LightYellow; // choix de la
couleur

Graphics g = tabPage1.CreateGraphics();


g.Clear(couleur);
// effacement du fond



}



private void font2_Click(object sender, System.EventArgs e)

{

Color couleur =
Color.AliceBlue; // choix de la
couleur

Graphics g = tabPage1.CreateGraphics();

g.Clear(couleur);

}



private void font3_Click(object sender, System.EventArgs e)

{

Color couleur =
Color.MintCream; // choix de la
couleur

Graphics g = tabPage1.CreateGraphics();

g.Clear(couleur);

}



private void defaut_Click(object sender, System.EventArgs e)

{

Color couleur
= Color.White; // choix de la
couleur

Graphics g = tabPage1.CreateGraphics();

g.Clear(couleur);

}





}

}

merçi
0
Lutinore Messages postés 3246 Date d'inscription lundi 25 avril 2005 Statut Membre Dernière intervention 27 octobre 2012 41
20 mai 2005 à 08:05
A moins de deriver ton control ( TabPage ) tu ne peux pas utiliser sa methode OnPaint donc tu utilises son evenement Paint ca revient au meme:

private void MyControl_MouseDown( object sd, MouseEventArgs args )
{
x = args.X;
y = args.Y;

myControl.Invalidate( ); // Paint
}

private void MyControl_Paint( object sd, PaintEventArgs args )
{
args.Graphics.DrawImage( bmp, x, y );
}
0
Lhioui Messages postés 9 Date d'inscription lundi 18 avril 2005 Statut Membre Dernière intervention 20 mai 2005
20 mai 2005 à 15:32
Mr [auteurdetail.aspx?ID=498040 Lutinore] ça n'a pas marché
0
MorpionMx Messages postés 3466 Date d'inscription lundi 16 octobre 2000 Statut Membre Dernière intervention 30 octobre 2008 57
20 mai 2005 à 15:37
Tu as bien pensé a t'inscrire a l'evenement Paint de ton TabPage au moins ?

Parce qu'un simple copier-coller n'est pas suffisant.



tabPage1.Paint += new PaintEventHandler(tabPage1_Paint);



puis



private void tabPage1_Paint(object sender, PaintEventArgs e)

{

e.Graphics.DrawImage( bmp, x, y );

}




Et ca marche parfaitement
Mx
0
Rejoignez-nous