我正在开发一个在抽搐流中发送消息时会更改文本的应用程序。
我的应用程序有3种形式,startup.cs,overlay.cs和options.cs Startup.cs是首先启动的表单,当您单击按钮时,将启动overlay.cs并隐藏启动。 在抽搐流上发送消息时,overlay.cs会将标签的文本更改为消息。 Overlay.cs在标签下方有2个按钮,分别是quit(符合您的期望)和options,这将启动options.cs。 在options.cs中,有一个NumberUpDown控件,该控件将用于控制overlay.cs的宽度。当我尝试通过options.cs修改overlay.cs的宽度时,什么也没发生。有什么建议?
startup.cs
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;
using System.Threading;
namespace twitch_chat_overlay
{
public partial class startup : Form
{
public startup()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
// button to launch overlay
overlay form = new overlay();
form.Visible = true;
Visible = false;
}
private void button2_Click(object sender, EventArgs e)
{
// exit button
Environment.Exit(0);
}
}
}
overlay.cs
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;
using System.Threading;
using System.Media;
using System.Runtime.CompilerServices;
namespace twitch_chat_overlay
{
public partial class overlay : Form
{
public overlay()
{
InitializeComponent();
}
private void overlay_Load(object sender, EventArgs e)
{
TopMost = true;
ActiveForm.TopMost = true;
Location = new Point(785, 0);
// location: 785, size: 350 X
Thread thread = new Thread(start);
thread.Start();
// Console.WriteLine(mainForm.username);
}
public void recMsg(string user, string msg)
{
// setting label
if (InvokeRequired)
{
this.Invoke(new Action(() => recMsg(user, msg)));
return;
}
label1.Text = user + ": " + msg;
}
private void button1_Click(object sender, EventArgs e)
{
Environment.Exit(0);
}
private void button2_Click(object sender, EventArgs e)
{
options form = new options();
form.Show(this);
}
}
}
options.cs
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;
using System.Media;
namespace twitch_chat_overlay
{
public partial class options : Form
{
public options()
{
InitializeComponent();
}
private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
overlay Overlay = new overlay();
Overlay.Width = Convert.ToInt32(numericUpDown1.Value);
Overlay.Location = new Point((1920 - Convert.ToInt32(numericUpDown1.Value)) / 2);
}
}
}