class FillCategoryComboBox
{
public static void Fill(ComboBox combo)
{
combo.Items.Add("Пункт 2"); //Не добавляет пункт.
MessageBox.Show("Класс вызван"); //Выводит сообщение, т.е. класс вызывается.
}
}
FillCategoryComboBox.Fill(categoryComboBox);
foreach(DriveInfo drive in allDrivers)
вы их перезаписываете.using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace joke1
{
class Program
{
static int port = 8005;
static string address = "127.0.0.1";
static void Main(string[] args)
{
DriveInfo[] allDrivers = DriveInfo.GetDrives();
var dataDrivers = new List<string[]>();
foreach(DriveInfo drive in allDrivers)
{
string[] dataDrive = new string[6];
dataDrive[0] = drive.Name + " ";
dataDrive[1] = drive.DriveType.ToString() + " ";
dataDrive[2] = drive.DriveFormat + " ";
long totalSize1 = drive.TotalSize >> 30;
long freeSpace1 = drive.AvailableFreeSpace >> 30;
dataDrive[3] = Convert.ToInt32(totalSize1).ToString() + "gb" + " ";
dataDrive[4] = Convert.ToInt32(freeSpace1).ToString() + "gb" + " ";
dataDrive[5] = drive.RootDirectory.ToString() + " ";
dataDrivers.Add(dataDrive);
}
try
{
IPEndPoint ipPoint = new IPEndPoint(IPAddress.Parse(address), port);
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
socket.Connect(ipPoint);
foreach(var driveInfo in dataDrivers)
{
byte[][] data = new byte[6][];
for(int i = 0; i < 6; i++)
{
data[i] = Encoding.Unicode.GetBytes(driveInfo[i]);
socket.Send(data[i]);
}
}
Console.WriteLine("Данные отправлены");
Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
Console.ReadKey();
}
}
}
}
private void button1_Click(object sender, EventArgs e)
{
var fields = this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance).Where(w => w.FieldType == typeof(CheckBox))
.Select(s => ((CheckBox)s.GetValue(this)).Name + "=" + ((CheckBox)s.GetValue(this)).Checked)
.ToList();
var fileContent = string.Join(",", fields);
File.AppendAllText("config.txt", fileContent);
}
private void Form1_Load(object sender, EventArgs e)
{
if(!File.Exists("config.txt")) return;
var fileContent = File.ReadAllText("config.txt");
var fieldsValues = fileContent.Split(',');
var fields = this.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance).Where(w => w.FieldType == typeof(CheckBox)).ToList();
foreach(var field in fieldsValues)
{
var data = field.Split('=');
var name = data[0];
var value = bool.Parse(data[1]);
var fieldObj = fields.FirstOrDefault(f => f.Name == name);
if(fieldObj != null)
{
var checkBox = (CheckBox)fieldObj.GetValue(this);
checkBox.Checked = value;
}
}
}
if (UserPassCheckField.Text == UserPassField.Text)
{
SQLiteCommand cmd = new SQLiteCommand("INSERT INTO accounts (Login, Password) VALUES ('"+UserLoginField.Text+"', '"+UserPassField.Text+"')", sqlCon);
cmd.ExecuteNonQuery();
}
ffmpeg -r 6/1 -i img%03d.png -c:v libx264 -vf "fps=30,format=yuv420p" out.mp4
class MyClass
{
public MyClass(Action method, Guid id, params object[] param)
{
Method = method;
Params = param;
Id = id;
}
public Action Method;
public object[] Params;
public Guid Id;
}
class Sender
{
public void Main()
{
Receiver.AddMethod(new MyClass(() => SomeMethod("dfsdf"),new Guid(), "dfsdf"));
}
public void SomeMethod(string str)
{
//...
}
}
class Receiver
{
private static Dictionary<string, MyClass> Methods = new Dictionary<string, MyClass>();
public static void AddMethod(MyClass myClass)
{
//Тут надо некий уникальный идентификатор полученного метода
//Псевдокод: Methods.Add(myClass.Id, myClass);
}
}