1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
| using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ComAD
{
static class Program
{
/// <summary>
/// Point d'entrée principal de l'application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
principale_ = new Principale();
gain = new Gain();
Application.Run(principale_);
}
private static Gain gain;
public static Gain gain_ { get { return gain; } set { gain = value; } }
private static Principale principale;
public static Principale principale_ { get { return principale; } set { principale = value; } }
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////
Voici une partie de ma form prinicipale ou j'ouvre ma form Gain
private void Boutonconfigurer_Click(object sender, EventArgs e)
{
Program.gain_.Show();
}
////////////////////////////////////////////////////////////////
Voici ma class static qui s'appelle Com
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
using System.Diagnostics;
using System.Timers;
using System.Drawing;
namespace ComAD
{
public static class Com
{
static byte[] c = new byte[100];
static byte[] b = new byte[100];
public static byte[] x = new byte[100];
public static int Demande;
public static System.Timers.Timer timerInterrogation;
private delegate void messagecombobox(string lstInformations);
public static void Initialisation()
{
timerInterrogation = new System.Timers.Timer();
timerInterrogation.Elapsed += new ElapsedEventHandler(timerInterrogation_Elapsed);
timerInterrogation.Interval = 1000;
timerInterrogation.Enabled = true;
}
public static void timerInterrogation_Elapsed(object sender, ElapsedEventArgs e)
{
switch (Demande)
{
case 0:
Program.gain_ .DonneeGain(Demande);
Demande = 1;
break;
case 1 :
// instructions
break;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
Voici une partie du code de de ma form (qui s'appelle Gain) ou je passe le paramètre
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 ComAD
{
public partial class Gain : Form
{
// Instructions
public double Num;
public Gain()
InitializeComponent();
// Instructions
public void DonneeGain(int Demande)
{
Num = (Com.x[7] * 256) + Com.x[8];
Program.gain_.lblGainDon1.Text= Num.ToString(); // lblGainDon1.Text est une textBox de la form Gain l'erreur se trouve à cette ligne
}
// Instructions
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////// |
Partager