using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace eTagTech.HelloWorld
{
public partial class Form1 : Form
{
static ID id = new ID();
class ID
{
private String id = null;
// automatic properties
public String Form1
{
get
{
return id;
}
set
{
id = value;
}
}
}
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
Form1.id.Form1 = textBox1.Text;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
}
}
Ho creato una variabile di istanza : static ID id = new ID();
di cui qui faccio il set : Form1.id.Form1 = textBox1.Text;
Ora vorrei capire come recuperare il valore inserito da tastiera nel main:
using eTagTech.SDK;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using eTagTech.HelloWorld;
namespace eTagTech.HelloWorld
{
static class Program
{
/// <summary>
/// Punto di ingresso principale dell'applicazione.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
// Form1 form = new Form1();
.
List<string> TAG_LIST = new List<string>() { "001E3C", "001E3A", "001E45", "001E3F", "001E43" };
Server.Instance.Start();
Server.Instance.StationEventHandler += Instance_StationEventHandler;
Server.Instance.ResultEventHandler += Instance_ResultEventHandler;
}
static void Instance_StationEventHandler(object sender, SDK.Event.StationEventArgs e)
{
Console.WriteLine("Comunicazione con box");
string msg = string.Format("[{0:yy-MM-dd HH:mm:ss:ff}] Station ID:{1}, IP:{2}, Shop Code:{3}, Online:{4}", DateTime.Now, e.StationID, e.IP, e.Shop, e.Online);
Logger.LogHelper.Debug(msg);
Console.WriteLine(msg);
}
static void Instance_ResultEventHandler(object sender, SDK.Event.ResultEventArgs e)
{
foreach (var result in e.ResultList)
{
Console.WriteLine(string.Format("--TagID:{0} Status:{1} ServiceCode:{2} Power:{3}({4}) RSSI:{5} Temperature:{6}",
result.TagID, result.TagStatus, result.BatchCode, result.PowerLevel, result.PowerValue, result.Signal, result.Temperature));
//Program.v.Voltaggio = result.PowerValue;
}
}
}
}