我创建了一个包含3个滑块和2个radiobuttons的项目,radiobuttons在我要编辑的光标,Main或光标边框之间切换。
每次滑块更改值时,它会将其设置为变量并保存,因此3为主,3为边框,当我更改单选按钮时,我希望滑块根据哪个单选按钮转到各自的值检查..
代码应该正常但只有R工作..如果我删除设置R滑块值的代码,那么蓝色滑块工作..反之亦然,有谁知道为什么会发生这种情况?这是代码。
sliderR.Value = borderrgb.R; sliderG.Value = borderrgb.G; SliderB.Value = borderrgb.B;
这行代码应该有用......
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.IO;
using Newtonsoft.Json;
namespace Terraria_Cursor_Editor_V2
{
public partial class Form1 : Form
{
int R;
int G;
int B;
int R1;
int G1;
int B1;
Color mainrgb;
Color borderrgb;
bool changed = false;
public Form1()
{
InitializeComponent();
dynamic json = JsonConvert.DeserializeObject<Data>(File.ReadAllText(
System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
+ "/My Games/Terraria/config.json"));
var value = json.MouseColorR;
sliderR.Value = value;
value = json.MouseColorG;
sliderG.Value = value;
value = json.MouseColorB;
sliderG.Value = value;
value = json.ThickMouseEdges;
if (value == true)
{
nsOnOffBox1.Checked = true;
}
else
{
nsOnOffBox1.Checked = false;
}
UpdateRGB();
R = sliderR.Value; G = sliderG.Value; B = SliderB.Value;
mainrgb = Color.FromArgb(R, G, B);
mpanel.BackColor = mainrgb;
}
public void mainRGB()
{
if (rbMain.Checked == true)
{
R1 = R;
G1 = G;
B1 = B;
}
else
{
borderrgb = Color.FromArgb(R, G, B);
}
pnl();
}
public void pnl()
{
mpanel.BackColor = mainrgb;
bpanel.BackColor = borderrgb;
rbMain.MainColor = mainrgb;
rbBorder.MainColor = borderrgb;
rval.Value1 = sliderR.Value.ToString();
gval.Value1 = sliderG.Value.ToString();
bval.Value1 = SliderB.Value.ToString();
cbLabel.val1Color = mainrgb;
cbLabel.val2Color = borderrgb;
}
public void UpdateRGB()
{
}
private void sliderG_Scroll(object sender)
{
G = sliderG.Value;
mainRGB();
}
private void SliderB_Scroll(object sender)
{
B = SliderB.Value;
mainRGB();
}
private void sliderR_Scroll(object sender)
{
R = sliderR.Value;
mainRGB();
}
private void rbMain_CheckedChanged(object sender)
{
if (rbMain.Checked)
{
sliderR.Value = R1;
sliderG.Value = G1;
SliderB.Value = B1;
}
else
{
sliderR.Value = borderrgb.R;
sliderG.Value = borderrgb.G;
SliderB.Value = borderrgb.B;
}
}
private void rbBorder_CheckedChanged(object sender)
{
}
}
}