From bc15a68df6b3cccd7fa6d5b7532ef27f156efdcb Mon Sep 17 00:00:00 2001 From: Sharique Ahmed Farooqui <112452+sharique@users.noreply.github.com> Date: Sat, 13 Dec 2025 12:37:32 +0000 Subject: [PATCH 1/3] Update to .NET 10.0 and fix ColorButton deprecation warnings --- ColorManager/ColorManager.csproj | 2 +- ColorManager/MainWindow.cs | 226 +++++++++++++++---------------- ColorManager/MyForm.cs | 94 ++++++++----- 3 files changed, 171 insertions(+), 151 deletions(-) diff --git a/ColorManager/ColorManager.csproj b/ColorManager/ColorManager.csproj index 54c778e..ad2ec99 100644 --- a/ColorManager/ColorManager.csproj +++ b/ColorManager/ColorManager.csproj @@ -2,7 +2,7 @@ Exe - net8.0 + net10.0 disable disable ColorManager diff --git a/ColorManager/MainWindow.cs b/ColorManager/MainWindow.cs index f2b7c1a..016e163 100644 --- a/ColorManager/MainWindow.cs +++ b/ColorManager/MainWindow.cs @@ -122,8 +122,8 @@ protected virtual void OnCbtnClick (object sender, System.EventArgs e) protected virtual void OnColorbutton1ColorSet (object sender, System.EventArgs e) { //Red - double a = colorbutton1.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton1.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -135,8 +135,8 @@ protected virtual void OnColorbutton1ColorSet (object sender, System.EventArgs e else hax1 = l1; //Green - double b = colorbutton1.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton1.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -148,8 +148,8 @@ protected virtual void OnColorbutton1ColorSet (object sender, System.EventArgs e else hax2 = l2; //blue - double c = colorbutton1.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton1.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -193,8 +193,8 @@ protected virtual void OnColorbutton1ColorSet (object sender, System.EventArgs e protected virtual void OnColorbutton2ColorSet (object sender, System.EventArgs e) { //Red - double a = colorbutton2.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton2.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -206,8 +206,8 @@ protected virtual void OnColorbutton2ColorSet (object sender, System.EventArgs e else hax1 = l1; //Green - double b = colorbutton2.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton2.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); @@ -221,8 +221,8 @@ protected virtual void OnColorbutton2ColorSet (object sender, System.EventArgs e hax2 = l2; //blue - double c = colorbutton2.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton2.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); @@ -260,8 +260,8 @@ protected virtual void OnColorbutton2ColorSet (object sender, System.EventArgs e protected virtual void OnColorbutton3ColorSet (object sender, System.EventArgs e) { - double a = colorbutton3.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton3.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -273,8 +273,8 @@ protected virtual void OnColorbutton3ColorSet (object sender, System.EventArgs e else hax1 = l1; //Green - double b = colorbutton3.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton3.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); @@ -288,8 +288,8 @@ protected virtual void OnColorbutton3ColorSet (object sender, System.EventArgs e hax2 = l2; //blue - double c = colorbutton3.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton3.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); @@ -332,8 +332,8 @@ protected virtual void OnColorbutton3ColorSet (object sender, System.EventArgs e protected virtual void OnColorbutton4ColorSet (object sender, System.EventArgs e) { //Red - double a = colorbutton4.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton4.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -345,8 +345,8 @@ protected virtual void OnColorbutton4ColorSet (object sender, System.EventArgs e else hax1 = l1; //Green - double b = colorbutton4.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton4.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -359,8 +359,8 @@ protected virtual void OnColorbutton4ColorSet (object sender, System.EventArgs e hax2 = l2; //blue - double c = colorbutton4.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton4.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -401,8 +401,8 @@ protected virtual void OnColorbutton4ColorSet (object sender, System.EventArgs e protected virtual void OnColorbutton5ColorSet (object sender, System.EventArgs e) { //Red - double a = colorbutton5.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton5.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -414,8 +414,8 @@ protected virtual void OnColorbutton5ColorSet (object sender, System.EventArgs e else hax1 = l1; //Green - double b = colorbutton5.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton5.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -427,8 +427,8 @@ protected virtual void OnColorbutton5ColorSet (object sender, System.EventArgs e else hax2 = l2; //blue - double c = colorbutton5.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton5.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -464,8 +464,8 @@ protected virtual void OnColorbutton5ColorSet (object sender, System.EventArgs e protected virtual void OnColorbutton6ColorSet (object sender, System.EventArgs e) { //Red - double a = colorbutton6.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton6.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -477,8 +477,8 @@ protected virtual void OnColorbutton6ColorSet (object sender, System.EventArgs e else hax1 = l1; //Green - double b = colorbutton6.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton6.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); @@ -492,8 +492,8 @@ protected virtual void OnColorbutton6ColorSet (object sender, System.EventArgs e hax2 = l2; //blue - double c = colorbutton6.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton6.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); @@ -535,8 +535,8 @@ protected virtual void OnColorbutton6ColorSet (object sender, System.EventArgs e protected virtual void OnColorbutton7ColorSet (object sender, System.EventArgs e) { //Red - double a = colorbutton7.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton7.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -547,8 +547,8 @@ protected virtual void OnColorbutton7ColorSet (object sender, System.EventArgs e else hax1 = l1; //Green - double b = colorbutton7.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton7.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -559,8 +559,8 @@ protected virtual void OnColorbutton7ColorSet (object sender, System.EventArgs e else hax2 = l2; //blue - double c = colorbutton7.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton7.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -600,8 +600,8 @@ protected virtual void OnColorbutton7ColorSet (object sender, System.EventArgs e protected virtual void OnColorbutton8ColorSet (object sender, System.EventArgs e) { //Red - double a = colorbutton8.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton8.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -612,8 +612,8 @@ protected virtual void OnColorbutton8ColorSet (object sender, System.EventArgs e else hax1 = l1; //Green - double b = colorbutton8.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton8.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -625,9 +625,9 @@ protected virtual void OnColorbutton8ColorSet (object sender, System.EventArgs e else hax2 = l2; //blue - //string bl = colorbutton1.Color.Blue.ToString(); - double c = colorbutton8.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + //string bl = colorbutton1.Rgba.Blue * 255.ToString(); + double c = colorbutton8.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -668,8 +668,8 @@ protected virtual void OnColorbutton8ColorSet (object sender, System.EventArgs e protected virtual void OnColorbutton9ColorSet (object sender, System.EventArgs e) { //Red - double a = colorbutton9.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton9.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -681,8 +681,8 @@ protected virtual void OnColorbutton9ColorSet (object sender, System.EventArgs e else hax1 = l1; //Green - double b = colorbutton9.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton9.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -695,8 +695,8 @@ protected virtual void OnColorbutton9ColorSet (object sender, System.EventArgs e hax2 = l2; //blue - double c = colorbutton9.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton9.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -736,8 +736,8 @@ protected virtual void OnColorbutton9ColorSet (object sender, System.EventArgs e protected virtual void OnColorbutton10ColorSet (object sender, System.EventArgs e) { //Red - double a = colorbutton10.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton10.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -749,8 +749,8 @@ protected virtual void OnColorbutton10ColorSet (object sender, System.EventArgs else hax1 = l1; //Green - double b = colorbutton10.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton10.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -762,8 +762,8 @@ protected virtual void OnColorbutton10ColorSet (object sender, System.EventArgs else hax2 = l2; //blue - double c = colorbutton10.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton10.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -804,8 +804,8 @@ protected virtual void OnColorbutton11ColorSet (object sender, System.EventArgs { //entry3.Text = "Button2"; //Red - double a = colorbutton11.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton11.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -817,8 +817,8 @@ protected virtual void OnColorbutton11ColorSet (object sender, System.EventArgs else hax1 = l1; //Green - double b = colorbutton11.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton11.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -831,8 +831,8 @@ protected virtual void OnColorbutton11ColorSet (object sender, System.EventArgs hax2 = l2; //blue - double c = colorbutton11.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton11.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -872,8 +872,8 @@ protected virtual void OnColorbutton12ColorSet (object sender, System.EventArgs { //Red - double a = colorbutton12.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton12.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -885,8 +885,8 @@ protected virtual void OnColorbutton12ColorSet (object sender, System.EventArgs else hax1 = l1; //Green - double b = colorbutton12.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton12.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -898,8 +898,8 @@ protected virtual void OnColorbutton12ColorSet (object sender, System.EventArgs else hax2 = l2; //blue - double c = colorbutton12.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton12.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -940,8 +940,8 @@ protected virtual void OnColorbutton13ColorSet (object sender, System.EventArgs { //Red - double a = colorbutton13.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton13.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -953,8 +953,8 @@ protected virtual void OnColorbutton13ColorSet (object sender, System.EventArgs else hax1 = l1; //Green - double b = colorbutton13.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton13.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -966,8 +966,8 @@ protected virtual void OnColorbutton13ColorSet (object sender, System.EventArgs else hax2 = l2; //blue - double c = colorbutton13.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton13.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -1008,8 +1008,8 @@ protected virtual void OnColorbutton14ColorSet (object sender, System.EventArgs { // entry3.Text = "Button2"; //Red - double a = colorbutton14.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton14.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -1021,8 +1021,8 @@ protected virtual void OnColorbutton14ColorSet (object sender, System.EventArgs else hax1 = l1; //Green - double b = colorbutton14.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton14.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -1035,8 +1035,8 @@ protected virtual void OnColorbutton14ColorSet (object sender, System.EventArgs hax2 = l2; //blue - double c = colorbutton14.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton14.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); @@ -1079,8 +1079,8 @@ protected virtual void OnColorbutton15ColorSet (object sender, System.EventArgs { // entry3.Text = "Button2"; //Red - double a = colorbutton15.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton15.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -1092,8 +1092,8 @@ protected virtual void OnColorbutton15ColorSet (object sender, System.EventArgs else hax1 = l1; //Green - double b = colorbutton15.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton15.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -1106,8 +1106,8 @@ protected virtual void OnColorbutton15ColorSet (object sender, System.EventArgs hax2 = l2; //blue - double c = colorbutton15.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton15.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -1148,8 +1148,8 @@ protected virtual void OnColorbutton16ColorSet (object sender, System.EventArgs { // entry3.Text = "Button2"; //Red - double a = colorbutton16.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = colorbutton16.Rgba.Red * 255; + int mod1 = (int)a; string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -1161,8 +1161,8 @@ protected virtual void OnColorbutton16ColorSet (object sender, System.EventArgs else hax1 = l1; //Green - double b = colorbutton16.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = colorbutton16.Rgba.Green * 255; + int mod2 = (int)b; string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -1174,8 +1174,8 @@ protected virtual void OnColorbutton16ColorSet (object sender, System.EventArgs else hax2 = l2; //blue - double c = colorbutton16.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = colorbutton16.Rgba.Blue * 255; + int mod3 = (int)c; string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -1222,22 +1222,22 @@ protected virtual void btn_Click (object sender, System.EventArgs e) } protected virtual void Cmb_Changed (object sender, System.EventArgs e) { - colorbutton1.Color = new Gdk.Color (255, 255, 255); - colorbutton2.Color = new Gdk.Color (255, 255, 255); - colorbutton3.Color = new Gdk.Color (255, 255, 255); - colorbutton4.Color = new Gdk.Color (255, 255, 255); - colorbutton5.Color = new Gdk.Color (255, 255, 255); - colorbutton6.Color = new Gdk.Color (255, 255, 255); - colorbutton7.Color = new Gdk.Color (255, 255, 255); - colorbutton8.Color = new Gdk.Color (255, 255, 255); - colorbutton9.Color = new Gdk.Color (255, 255, 255); - colorbutton10.Color = new Gdk.Color (255, 255, 255); - colorbutton11.Color = new Gdk.Color (255, 255, 255); - colorbutton12.Color = new Gdk.Color (255, 255, 255); - colorbutton13.Color = new Gdk.Color (255, 255, 255); - colorbutton14.Color = new Gdk.Color (255, 255, 255); - colorbutton15.Color = new Gdk.Color (255, 255, 255); - colorbutton16.Color = new Gdk.Color (255, 255, 255); + colorbutton1.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton2.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton3.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton4.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton5.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton6.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton7.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton8.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton9.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton10.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton11.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton12.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton13.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton14.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton15.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + colorbutton16.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; XmlDocument xdoc = new XmlDocument (); diff --git a/ColorManager/MyForm.cs b/ColorManager/MyForm.cs index 696d97d..fde6cd5 100644 --- a/ColorManager/MyForm.cs +++ b/ColorManager/MyForm.cs @@ -45,40 +45,60 @@ protected void LoadPalette (string name) tbClr.Text=""; int cnt = elem.Count (); - if (cnt >= 1) - clrBtn1.Color = GetColor(elem.ElementAt (0).Attribute ("COLOR").Value.ToString ()); - if (cnt >= 2) - clrBtn2.Color = GetColor (elem.ElementAt (1).Attribute ("COLOR").Value.ToString ()); - if (cnt >= 3) - clrBtn3.Color = GetColor (elem.ElementAt (2).Attribute ("COLOR").Value.ToString ()); - if (cnt >= 4) - clrBtn4.Color = GetColor (elem.ElementAt (3).Attribute ("COLOR").Value.ToString ()); - if (cnt >= 5) - clrBtn5.Color = GetColor (elem.ElementAt (4).Attribute ("COLOR").Value.ToString ()); - if (cnt >= 6) - clrBtn6.Color = GetColor (elem.ElementAt (5).Attribute ("COLOR").Value.ToString ()); - if (cnt >= 7) - clrBtn7.Color = GetColor (elem.ElementAt (6).Attribute ("COLOR").Value.ToString ()); - if (cnt >= 8) - clrBtn8.Color = GetColor (elem.ElementAt (7).Attribute ("COLOR").Value.ToString ()); - if (cnt >= 9) - clrBtn9.Color = GetColor (elem.ElementAt (8).Attribute ("COLOR").Value.ToString ()); - if (cnt >= 10) - clrBtn10.Color = GetColor (elem.ElementAt (9).Attribute ("COLOR").Value.ToString ()); + if (cnt >= 1) { + Gdk.Color c = GetColor(elem.ElementAt (0).Attribute ("COLOR").Value.ToString ()); + clrBtn1.Rgba = new Gdk.RGBA { Red = c.Red / 65535.0, Green = c.Green / 65535.0, Blue = c.Blue / 65535.0, Alpha = 1 }; + } + if (cnt >= 2) { + Gdk.Color c = GetColor (elem.ElementAt (1).Attribute ("COLOR").Value.ToString ()); + clrBtn2.Rgba = new Gdk.RGBA { Red = c.Red / 65535.0, Green = c.Green / 65535.0, Blue = c.Blue / 65535.0, Alpha = 1 }; + } + if (cnt >= 3) { + Gdk.Color c = GetColor (elem.ElementAt (2).Attribute ("COLOR").Value.ToString ()); + clrBtn3.Rgba = new Gdk.RGBA { Red = c.Red / 65535.0, Green = c.Green / 65535.0, Blue = c.Blue / 65535.0, Alpha = 1 }; + } + if (cnt >= 4) { + Gdk.Color c = GetColor (elem.ElementAt (3).Attribute ("COLOR").Value.ToString ()); + clrBtn4.Rgba = new Gdk.RGBA { Red = c.Red / 65535.0, Green = c.Green / 65535.0, Blue = c.Blue / 65535.0, Alpha = 1 }; + } + if (cnt >= 5) { + Gdk.Color c = GetColor (elem.ElementAt (4).Attribute ("COLOR").Value.ToString ()); + clrBtn5.Rgba = new Gdk.RGBA { Red = c.Red / 65535.0, Green = c.Green / 65535.0, Blue = c.Blue / 65535.0, Alpha = 1 }; + } + if (cnt >= 6) { + Gdk.Color c = GetColor (elem.ElementAt (5).Attribute ("COLOR").Value.ToString ()); + clrBtn6.Rgba = new Gdk.RGBA { Red = c.Red / 65535.0, Green = c.Green / 65535.0, Blue = c.Blue / 65535.0, Alpha = 1 }; + } + if (cnt >= 7) { + Gdk.Color c = GetColor (elem.ElementAt (6).Attribute ("COLOR").Value.ToString ()); + clrBtn7.Rgba = new Gdk.RGBA { Red = c.Red / 65535.0, Green = c.Green / 65535.0, Blue = c.Blue / 65535.0, Alpha = 1 }; + } + if (cnt >= 8) { + Gdk.Color c = GetColor (elem.ElementAt (7).Attribute ("COLOR").Value.ToString ()); + clrBtn8.Rgba = new Gdk.RGBA { Red = c.Red / 65535.0, Green = c.Green / 65535.0, Blue = c.Blue / 65535.0, Alpha = 1 }; + } + if (cnt >= 9) { + Gdk.Color c = GetColor (elem.ElementAt (8).Attribute ("COLOR").Value.ToString ()); + clrBtn9.Rgba = new Gdk.RGBA { Red = c.Red / 65535.0, Green = c.Green / 65535.0, Blue = c.Blue / 65535.0, Alpha = 1 }; + } + if (cnt >= 10) { + Gdk.Color c = GetColor (elem.ElementAt (9).Attribute ("COLOR").Value.ToString ()); + clrBtn10.Rgba = new Gdk.RGBA { Red = c.Red / 65535.0, Green = c.Green / 65535.0, Blue = c.Blue / 65535.0, Alpha = 1 }; + } } protected void ClearClrBtns () { - clrBtn1.Color = new Gdk.Color (255, 255, 255); - clrBtn2.Color = new Gdk.Color (255, 255, 255); - clrBtn3.Color = new Gdk.Color (255, 255, 255); - clrBtn4.Color = new Gdk.Color (255, 255, 255); - clrBtn5.Color = new Gdk.Color (255, 255, 255); - clrBtn6.Color = new Gdk.Color (255, 255, 255); - clrBtn7.Color = new Gdk.Color (255, 255, 255); - clrBtn8.Color = new Gdk.Color (255, 255, 255); - clrBtn9.Color = new Gdk.Color (255, 255, 255); - clrBtn10.Color = new Gdk.Color (255, 255, 255); + clrBtn1.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + clrBtn2.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + clrBtn3.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + clrBtn4.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + clrBtn5.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + clrBtn6.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + clrBtn7.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + clrBtn8.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + clrBtn9.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; + clrBtn10.Rgba = new Gdk.RGBA { Red = 1, Green = 1, Blue = 1, Alpha = 1 }; } protected Gdk.Color GetColor (string clr1) @@ -101,8 +121,8 @@ protected Gdk.Color GetColor (string clr1) protected string GetColorCode (Gtk.ColorButton clrbtn) { //Red - double a = clrbtn.Color.Red; - int mod1 = Convert.ToInt32 (a / 257); + double a = clrbtn.Rgba.Red * 255; + int mod1 = (int)a; //string red = mod1.ToString (); string l1 = Convert.ToString (mod1, 16).ToUpper (); @@ -114,8 +134,8 @@ protected string GetColorCode (Gtk.ColorButton clrbtn) else hax1 = l1; //Green - double b = clrbtn.Color.Green; - int mod2 = Convert.ToInt32 (b / 257); + double b = clrbtn.Rgba.Green * 255; + int mod2 = (int)b; //string green = mod2.ToString (); string l2 = Convert.ToString (mod2, 16).ToUpper (); @@ -127,8 +147,8 @@ protected string GetColorCode (Gtk.ColorButton clrbtn) else hax2 = l2; //blue - double c = clrbtn.Color.Blue; - int mod3 = Convert.ToInt32 (c / 257); + double c = clrbtn.Rgba.Blue * 255; + int mod3 = (int)c; //string blue = mod3.ToString (); string l3 = Convert.ToString (mod3, 16).ToUpper (); @@ -170,7 +190,7 @@ protected void updateColor (string pltname, Gtk.ColorButton btn, int no) e1.Attribute ("COLOR").Value = clrCode; //else // e1.Add ("Color",new XAttribute ("COLOR", clrCode)); - } catch (Exception ex) { + } catch (Exception) { XElement plelem = mgr.GetPalette (pltname).Single (); XElement e = new XElement ("Color", new XAttribute ("COLOR", clrCode)); plelem.Add (e); From 293c2314810fb91130a5c2c8eaac57819d817459 Mon Sep 17 00:00:00 2001 From: Sharique Ahmed Farooqui <112452+sharique@users.noreply.github.com> Date: Sat, 13 Dec 2025 13:08:44 +0000 Subject: [PATCH 2/3] Upgrade UI to GTK 3: Remove deprecated UIManager/Action menus, update ColorButton to Rgba, fix constructors --- ColorManager/MainWindow.cs | 32 +++---- ColorManager/gtk-gui/ColorManager.MyForm.cs | 53 ++---------- ColorManager/gtk-gui/MainWindow.cs | 95 ++------------------- ColorManager/gtk-gui/gui.stetic | 2 +- 4 files changed, 35 insertions(+), 147 deletions(-) diff --git a/ColorManager/MainWindow.cs b/ColorManager/MainWindow.cs index 016e163..b93f1d7 100644 --- a/ColorManager/MainWindow.cs +++ b/ColorManager/MainWindow.cs @@ -1260,7 +1260,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b1 = clr1.Substring (5, 2); int ib1 = Int32.Parse (b1, NumberStyles.HexNumber); - colorbutton1.Color = new Gdk.Color ((byte)ir1, (byte)ig1, (byte)ib1); + colorbutton1.Rgba = new Gdk.RGBA { Red = ir1 / 255.0, Green = ig1 / 255.0, Blue = ib1 / 255.0, Alpha = 1 }; cnt--; } else @@ -1280,7 +1280,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b2 = clr2.Substring (5, 2); int ib2 = Int32.Parse (b2, NumberStyles.HexNumber); - colorbutton2.Color = new Gdk.Color ((byte)ir2, (byte)ig2, (byte)ib2); + colorbutton2.Rgba = new Gdk.RGBA { Red = ir2 / 255.0, Green = ig2 / 255.0, Blue = ib2 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1299,7 +1299,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b3 = clr3.Substring (5, 2); int ib3 = Int32.Parse (b3, NumberStyles.HexNumber); - colorbutton3.Color = new Gdk.Color ((byte)ir3, (byte)ig3, (byte)ib3); + colorbutton3.Rgba = new Gdk.RGBA { Red = ir3 / 255.0, Green = ig3 / 255.0, Blue = ib3 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1317,7 +1317,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b4 = clr4.Substring (5, 2); int ib4 = Int32.Parse (b4, NumberStyles.HexNumber); - colorbutton4.Color = new Gdk.Color ((byte)ir4, (byte)ig4, (byte)ib4); + colorbutton4.Rgba = new Gdk.RGBA { Red = ir4 / 255.0, Green = ig4 / 255.0, Blue = ib4 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1336,7 +1336,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b5 = clr5.Substring (5, 2); int ib5 = Int32.Parse (b5, NumberStyles.HexNumber); - colorbutton5.Color = new Gdk.Color ((byte)ir5, (byte)ig5, (byte)ib5); + colorbutton5.Rgba = new Gdk.RGBA { Red = ir5 / 255.0, Green = ig5 / 255.0, Blue = ib5 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1354,7 +1354,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b6 = clr6.Substring (5, 2); int ib6 = Int32.Parse (b6, NumberStyles.HexNumber); - colorbutton6.Color = new Gdk.Color ((byte)ir6, (byte)ig6, (byte)ib6); + colorbutton6.Rgba = new Gdk.RGBA { Red = ir6 / 255.0, Green = ig6 / 255.0, Blue = ib6 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1372,7 +1372,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b7 = clr7.Substring (5, 2); int ib7 = Int32.Parse (b7, NumberStyles.HexNumber); - colorbutton7.Color = new Gdk.Color ((byte)ir7, (byte)ig7, (byte)ib7); + colorbutton7.Rgba = new Gdk.RGBA { Red = ir7 / 255.0, Green = ig7 / 255.0, Blue = ib7 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1389,7 +1389,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b8 = clr8.Substring (5, 2); int ib8 = Int32.Parse (b8, NumberStyles.HexNumber); - colorbutton8.Color = new Gdk.Color ((byte)ir8, (byte)ig8, (byte)ib8); + colorbutton8.Rgba = new Gdk.RGBA { Red = ir8 / 255.0, Green = ig8 / 255.0, Blue = ib8 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1406,7 +1406,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b9 = clr9.Substring (5, 2); int ib9 = Int32.Parse (b9, NumberStyles.HexNumber); - colorbutton9.Color = new Gdk.Color ((byte)ir9, (byte)ig9, (byte)ib9); + colorbutton9.Rgba = new Gdk.RGBA { Red = ir9 / 255.0, Green = ig9 / 255.0, Blue = ib9 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1423,7 +1423,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b10 = clr10.Substring (5, 2); int ib10 = Int32.Parse (b10, NumberStyles.HexNumber); - colorbutton10.Color = new Gdk.Color ((byte)ir10, (byte)ig10, (byte)ib10); + colorbutton10.Rgba = new Gdk.RGBA { Red = ir10 / 255.0, Green = ig10 / 255.0, Blue = ib10 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1440,7 +1440,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b11 = clr11.Substring (5, 2); int ib11 = Int32.Parse (b11, NumberStyles.HexNumber); - colorbutton11.Color = new Gdk.Color ((byte)ir11, (byte)ig11, (byte)ib11); + colorbutton11.Rgba = new Gdk.RGBA { Red = ir11 / 255.0, Green = ig11 / 255.0, Blue = ib11 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1457,7 +1457,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b12 = clr12.Substring (5, 2); int ib12 = Int32.Parse (b12, NumberStyles.HexNumber); - colorbutton12.Color = new Gdk.Color ((byte)ir12, (byte)ig12, (byte)ib12); + colorbutton12.Rgba = new Gdk.RGBA { Red = ir12 / 255.0, Green = ig12 / 255.0, Blue = ib12 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1474,7 +1474,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b13 = clr13.Substring (5, 2); int ib13 = Int32.Parse (b13, NumberStyles.HexNumber); - colorbutton13.Color = new Gdk.Color ((byte)ir13, (byte)ig13, (byte)ib13); + colorbutton13.Rgba = new Gdk.RGBA { Red = ir13 / 255.0, Green = ig13 / 255.0, Blue = ib13 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1491,7 +1491,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b14 = clr14.Substring (5, 2); int ib14 = Int32.Parse (b14, NumberStyles.HexNumber); - colorbutton14.Color = new Gdk.Color ((byte)ir14, (byte)ig14, (byte)ib14); + colorbutton14.Rgba = new Gdk.RGBA { Red = ir14 / 255.0, Green = ig14 / 255.0, Blue = ib14 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1508,7 +1508,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b15 = clr15.Substring (5, 2); int ib15 = Int32.Parse (b15, NumberStyles.HexNumber); - colorbutton15.Color = new Gdk.Color ((byte)ir15, (byte)ig15, (byte)ib15); + colorbutton15.Rgba = new Gdk.RGBA { Red = ir15 / 255.0, Green = ig15 / 255.0, Blue = ib15 / 255.0, Alpha = 1 }; cnt--; } else return; @@ -1525,7 +1525,7 @@ protected virtual void Cmb_Changed (object sender, System.EventArgs e) string b16 = clr16.Substring (5, 2); int ib16 = Int32.Parse (b16, NumberStyles.HexNumber); - colorbutton16.Color = new Gdk.Color ((byte)ir16, (byte)ig16, (byte)ib16); + colorbutton16.Rgba = new Gdk.RGBA { Red = ir16 / 255.0, Green = ig16 / 255.0, Blue = ib16 / 255.0, Alpha = 1 }; cnt--; } else return; diff --git a/ColorManager/gtk-gui/ColorManager.MyForm.cs b/ColorManager/gtk-gui/ColorManager.MyForm.cs index f384b27..dadb92e 100644 --- a/ColorManager/gtk-gui/ColorManager.MyForm.cs +++ b/ColorManager/gtk-gui/ColorManager.MyForm.cs @@ -4,18 +4,8 @@ namespace ColorManager { internal partial class MyForm { - private global::Gtk.UIManager UIManager; - - private global::Gtk.Action FileAction; - - private global::Gtk.Action quitAction; - - private global::Gtk.Action HelpAction; - private global::Gtk.VBox vbox1; - private global::Gtk.MenuBar menubar1; - private global::Gtk.HBox hbox1; private global::Gtk.Label label1; @@ -68,39 +58,15 @@ protected virtual void Build () { global::Stetic.Gui.Initialize (this); // Widget ColorManager.MyForm - this.UIManager = new global::Gtk.UIManager (); - global::Gtk.ActionGroup w1 = new global::Gtk.ActionGroup ("Default"); - this.FileAction = new global::Gtk.Action ("FileAction", "_File", null, null); - this.FileAction.ShortLabel = "_File"; - w1.Add (this.FileAction, null); - this.quitAction = new global::Gtk.Action ("quitAction", "_Quit", null, "gtk-quit"); - this.quitAction.ShortLabel = "_Quit"; - w1.Add (this.quitAction, null); - this.HelpAction = new global::Gtk.Action ("HelpAction", "_Help", null, null); - this.HelpAction.ShortLabel = "_Help"; - w1.Add (this.HelpAction, null); - this.UIManager.InsertActionGroup (w1, 0); - this.AddAccelGroup (this.UIManager.AccelGroup); this.Name = "ColorManager.MyForm"; this.Title = "Color Manager"; this.WindowPosition = ((global::Gtk.WindowPosition)(4)); // Container child ColorManager.MyForm.Gtk.Container+ContainerChild - this.vbox1 = new global::Gtk.VBox (); + this.vbox1 = new global::Gtk.VBox (false, 6); this.vbox1.Name = "vbox1"; - this.vbox1.Spacing = 6; - // Container child vbox1.Gtk.Box+BoxChild - this.UIManager.AddUiFromString (""); - this.menubar1 = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menubar1"))); - this.menubar1.Name = "menubar1"; - this.vbox1.Add (this.menubar1); - global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.menubar1])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; // Container child vbox1.Gtk.Box+BoxChild - this.hbox1 = new global::Gtk.HBox (); + this.hbox1 = new global::Gtk.HBox (false, 6); this.hbox1.Name = "hbox1"; - this.hbox1.Spacing = 6; // Container child hbox1.Gtk.Box+BoxChild this.label1 = new global::Gtk.Label (); this.label1.Name = "label1"; @@ -148,13 +114,12 @@ protected virtual void Build () w8.Fill = false; this.vbox1.Add (this.hbox1); global::Gtk.Box.BoxChild w9 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox1])); - w9.Position = 1; + w9.Position = 0; w9.Expand = false; w9.Fill = false; // Container child vbox1.Gtk.Box+BoxChild - this.hbox2 = new global::Gtk.HBox (); + this.hbox2 = new global::Gtk.HBox (false, 6); this.hbox2.Name = "hbox2"; - this.hbox2.Spacing = 6; // Container child hbox2.Gtk.Box+BoxChild this.label2 = new global::Gtk.Label (); this.label2.Name = "label2"; @@ -186,7 +151,7 @@ protected virtual void Build () w12.Fill = false; this.vbox1.Add (this.hbox2); global::Gtk.Box.BoxChild w13 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox2])); - w13.Position = 2; + w13.Position = 1; w13.Expand = false; w13.Fill = false; // Container child vbox1.Gtk.Box+BoxChild @@ -333,16 +298,16 @@ protected virtual void Build () w25.YOptions = ((global::Gtk.AttachOptions)(4)); this.vbox1.Add (this.table1); global::Gtk.Box.BoxChild w26 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.table1])); - w26.Position = 3; + w26.Position = 2; w26.Expand = false; w26.Fill = false; // Container child vbox1.Gtk.Box+BoxChild this.colorselection1 = new global::Gtk.ColorSelection (); this.colorselection1.Name = "colorselection1"; - this.colorselection1.HasOpacityControl = true; + this.colorselection1.HasOpacityControl = false; this.vbox1.Add (this.colorselection1); global::Gtk.Box.BoxChild w27 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.colorselection1])); - w27.Position = 4; + w27.Position = 3; // Container child vbox1.Gtk.Box+BoxChild this.lblDebug = new global::Gtk.Label (); this.lblDebug.Name = "lblDebug"; @@ -350,7 +315,7 @@ protected virtual void Build () this.lblDebug.SingleLineMode = true; this.vbox1.Add (this.lblDebug); global::Gtk.Box.BoxChild w28 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.lblDebug])); - w28.Position = 5; + w28.Position = 4; w28.Expand = false; w28.Fill = false; this.Add (this.vbox1); diff --git a/ColorManager/gtk-gui/MainWindow.cs b/ColorManager/gtk-gui/MainWindow.cs index 3182edc..332db75 100644 --- a/ColorManager/gtk-gui/MainWindow.cs +++ b/ColorManager/gtk-gui/MainWindow.cs @@ -3,34 +3,8 @@ public partial class MainWindow { - private global::Gtk.UIManager UIManager; - - private global::Gtk.Action Help; - - private global::Gtk.Action AboutUs; - - private global::Gtk.Action help; - - private global::Gtk.Action colorPicker; - - private global::Gtk.Action selectColor; - - private global::Gtk.Action quit; - - private global::Gtk.Action File; - - private global::Gtk.Action quit1; - - private global::Gtk.Action Help1; - - private global::Gtk.Action Help2; - - private global::Gtk.Action selectColor1; - private global::Gtk.VBox vbox1; - private global::Gtk.MenuBar menubar1; - private global::Gtk.HBox hbox1; private global::Gtk.ComboBoxText comboboxentry1; @@ -101,64 +75,17 @@ protected virtual void Build () { global::Stetic.Gui.Initialize (this); // Widget MainWindow - this.UIManager = new global::Gtk.UIManager (); - global::Gtk.ActionGroup w1 = new global::Gtk.ActionGroup ("Default"); - this.Help = new global::Gtk.Action ("Help", "Help", null, null); - this.Help.ShortLabel = "Help"; - w1.Add (this.Help, null); - this.AboutUs = new global::Gtk.Action ("AboutUs", "About us", null, null); - this.AboutUs.ShortLabel = "About us"; - w1.Add (this.AboutUs, null); - this.help = new global::Gtk.Action ("help", "About us", null, "gtk-help"); - this.help.ShortLabel = "_Help"; - w1.Add (this.help, null); - this.colorPicker = new global::Gtk.Action ("colorPicker", null, null, "gtk-color-picker"); - w1.Add (this.colorPicker, null); - this.selectColor = new global::Gtk.Action ("selectColor", "_Color", null, "gtk-select-color"); - this.selectColor.ShortLabel = "_Color"; - w1.Add (this.selectColor, null); - this.quit = new global::Gtk.Action ("quit", "_Quit", null, "gtk-quit"); - this.quit.ShortLabel = "_Quit"; - w1.Add (this.quit, null); - this.File = new global::Gtk.Action ("File", " File", null, null); - this.File.ShortLabel = " File"; - w1.Add (this.File, null); - this.quit1 = new global::Gtk.Action ("quit1", "_Quit", null, "gtk-quit"); - this.quit1.ShortLabel = "_Quit"; - w1.Add (this.quit1, null); - this.Help1 = new global::Gtk.Action ("Help1", "Help", null, null); - this.Help1.ShortLabel = "Help"; - w1.Add (this.Help1, null); - this.Help2 = new global::Gtk.Action ("Help2", "Help", null, null); - this.Help2.ShortLabel = "Help"; - w1.Add (this.Help2, null); - this.selectColor1 = new global::Gtk.Action ("selectColor1", "About Us", null, "gtk-dialog-info"); - this.selectColor1.ShortLabel = "About Us"; - w1.Add (this.selectColor1, null); - this.UIManager.InsertActionGroup (w1, 0); - this.AddAccelGroup (this.UIManager.AccelGroup); this.Name = "MainWindow"; this.Title = "ColorPicker"; this.Icon = global::Stetic.IconLoader.LoadIcon (this, "gtk-select-color", global::Gtk.IconSize.Menu); this.WindowPosition = ((global::Gtk.WindowPosition)(4)); this.DefaultWidth = 13; // Container child MainWindow.Gtk.Container+ContainerChild - this.vbox1 = new global::Gtk.VBox (); - this.vbox1.Name = "vbox1"; - this.vbox1.Spacing = 6; - // Container child vbox1.Gtk.Box+BoxChild - this.UIManager.AddUiFromString (""); - this.menubar1 = ((global::Gtk.MenuBar)(this.UIManager.GetWidget ("/menubar1"))); - this.menubar1.Name = "menubar1"; - this.vbox1.Add (this.menubar1); - global::Gtk.Box.BoxChild w2 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.menubar1])); - w2.Position = 0; - w2.Expand = false; - w2.Fill = false; + this.vbox1 = new global::Gtk.VBox (false, 6); + this.vbox1.Name = "vbox1"; // Container child vbox1.Gtk.Box+BoxChild - this.hbox1 = new global::Gtk.HBox (); + this.hbox1 = new global::Gtk.HBox (false, 6); this.hbox1.Name = "hbox1"; - this.hbox1.Spacing = 6; // Container child hbox1.Gtk.Box+BoxChild this.comboboxentry1 = new global::Gtk.ComboBoxText (); this.comboboxentry1.Name = "comboboxentry1"; @@ -211,13 +138,12 @@ protected virtual void Build () w9.Fill = false; this.vbox1.Add (this.hbox1); global::Gtk.Box.BoxChild w10 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox1])); - w10.Position = 1; + w10.Position = 0; w10.Expand = false; w10.Fill = false; // Container child vbox1.Gtk.Box+BoxChild - this.hbox2 = new global::Gtk.HBox (); + this.hbox2 = new global::Gtk.HBox (false, 6); this.hbox2.Name = "hbox2"; - this.hbox2.Spacing = 6; // Container child hbox2.Gtk.Box+BoxChild this.lblPaletteName = new global::Gtk.Label (); this.lblPaletteName.Name = "lblPaletteName"; @@ -273,7 +199,7 @@ protected virtual void Build () w15.Fill = false; this.vbox1.Add (this.hbox2); global::Gtk.Box.BoxChild w16 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.hbox2])); - w16.Position = 2; + w16.Position = 1; w16.Expand = false; w16.Fill = false; // Container child vbox1.Gtk.Box+BoxChild @@ -523,16 +449,16 @@ protected virtual void Build () w36.YOptions = ((global::Gtk.AttachOptions)(4)); this.vbox1.Add (this.table1); global::Gtk.Box.BoxChild w37 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.table1])); - w37.Position = 3; + w37.Position = 2; w37.Expand = false; w37.Fill = false; // Container child vbox1.Gtk.Box+BoxChild this.colorselection1 = new global::Gtk.ColorSelection (); this.colorselection1.Name = "colorselection1"; - this.colorselection1.HasOpacityControl = true; + this.colorselection1.HasOpacityControl = false; this.vbox1.Add (this.colorselection1); global::Gtk.Box.BoxChild w38 = ((global::Gtk.Box.BoxChild)(this.vbox1 [this.colorselection1])); - w38.Position = 4; + w38.Position = 3; this.Add (this.vbox1); if ((this.Child != null)) { this.Child.ShowAll (); @@ -542,9 +468,6 @@ protected virtual void Build () this.hbox2.Hide (); this.Show (); this.DeleteEvent += new global::Gtk.DeleteEventHandler (this.OnDeleteEvent); - this.quit.Activated += new global::System.EventHandler (this.OnQuitActionActivated); - this.quit1.Activated += new global::System.EventHandler (this.QuitClicked); - this.selectColor1.Activated += new global::System.EventHandler (this.AboutusClicked); this.comboboxentry1.Changed += new global::System.EventHandler (this.Cmb_Changed); this.btnNew.Clicked += new global::System.EventHandler (this.OnBtnNewClicked); this.button2.Clicked += new global::System.EventHandler (this.onBtnEditClicked); diff --git a/ColorManager/gtk-gui/gui.stetic b/ColorManager/gtk-gui/gui.stetic index 2178dd6..ff49c87 100644 --- a/ColorManager/gtk-gui/gui.stetic +++ b/ColorManager/gtk-gui/gui.stetic @@ -2,7 +2,7 @@ .. - 2.12 + 3.0 From 5cd5c672c9710901b146730d842249356e3b0859 Mon Sep 17 00:00:00 2001 From: Sharique Ahmed Farooqui <112452+sharique@users.noreply.github.com> Date: Sun, 14 Dec 2025 11:06:19 +0000 Subject: [PATCH 3/3] Fixing menu issue. --- ColorManager/MainWindow.cs | 24 +++++++++++++++++++++ ColorManager/MyForm.cs | 22 +++++++++++++++++++ ColorManager/gtk-gui/ColorManager.MyForm.cs | 12 +++++------ ColorManager/gtk-gui/MainWindow.cs | 12 +++++------ 4 files changed, 58 insertions(+), 12 deletions(-) diff --git a/ColorManager/MainWindow.cs b/ColorManager/MainWindow.cs index b93f1d7..b1f7549 100644 --- a/ColorManager/MainWindow.cs +++ b/ColorManager/MainWindow.cs @@ -15,6 +15,30 @@ public MainWindow () : base(Gtk.WindowType.Toplevel) } protected void FormLoad () { + // Create menu + var menubar = new Gtk.MenuBar(); + var fileMenu = new Gtk.Menu(); + var quitItem = new Gtk.MenuItem("_Quit"); + quitItem.Activated += QuitClicked; + fileMenu.Append(quitItem); + + var fileMenuItem = new Gtk.MenuItem("File"); + fileMenuItem.Submenu = fileMenu; + + var helpMenu = new Gtk.Menu(); + var aboutItem = new Gtk.MenuItem("About Us"); + // aboutItem.Activated += handler if needed + helpMenu.Append(aboutItem); + + var helpMenuItem = new Gtk.MenuItem("Help"); + helpMenuItem.Submenu = helpMenu; + + menubar.Append(fileMenuItem); + menubar.Append(helpMenuItem); + + vbox1.PackStart(menubar, false, false, 0); + vbox1.ReorderChild(menubar, 0); + //comboboxentry1.Clear(); XmlDocument xdoc = new XmlDocument (); xdoc.Load ("colors.xml"); diff --git a/ColorManager/MyForm.cs b/ColorManager/MyForm.cs index fde6cd5..a33ba46 100644 --- a/ColorManager/MyForm.cs +++ b/ColorManager/MyForm.cs @@ -20,6 +20,28 @@ public MyForm () : base(Gtk.WindowType.Toplevel) public void BuildForm () { + // Create menu + var menubar = new Gtk.MenuBar(); + var fileMenu = new Gtk.Menu(); + var quitItem = new Gtk.MenuItem("_Quit"); + quitItem.Activated += (sender, e) => Gtk.Application.Quit(); + fileMenu.Append(quitItem); + + var fileMenuItem = new Gtk.MenuItem("File"); + fileMenuItem.Submenu = fileMenu; + + var helpMenu = new Gtk.Menu(); + // No items for Help? + + var helpMenuItem = new Gtk.MenuItem("Help"); + helpMenuItem.Submenu = helpMenu; + + menubar.Append(fileMenuItem); + menubar.Append(helpMenuItem); + + vbox1.PackStart(menubar, false, false, 0); + vbox1.ReorderChild(menubar, 0); + LoadList (); } diff --git a/ColorManager/gtk-gui/ColorManager.MyForm.cs b/ColorManager/gtk-gui/ColorManager.MyForm.cs index dadb92e..593ce3c 100644 --- a/ColorManager/gtk-gui/ColorManager.MyForm.cs +++ b/ColorManager/gtk-gui/ColorManager.MyForm.cs @@ -4,9 +4,9 @@ namespace ColorManager { internal partial class MyForm { - private global::Gtk.VBox vbox1; + private global::Gtk.Box vbox1; - private global::Gtk.HBox hbox1; + private global::Gtk.Box hbox1; private global::Gtk.Label label1; @@ -16,7 +16,7 @@ internal partial class MyForm private global::Gtk.Button btnDelete; - private global::Gtk.HBox hbox2; + private global::Gtk.Box hbox2; private global::Gtk.Label label2; @@ -62,10 +62,10 @@ protected virtual void Build () this.Title = "Color Manager"; this.WindowPosition = ((global::Gtk.WindowPosition)(4)); // Container child ColorManager.MyForm.Gtk.Container+ContainerChild - this.vbox1 = new global::Gtk.VBox (false, 6); + this.vbox1 = new global::Gtk.Box (Gtk.Orientation.Vertical, 6); this.vbox1.Name = "vbox1"; // Container child vbox1.Gtk.Box+BoxChild - this.hbox1 = new global::Gtk.HBox (false, 6); + this.hbox1 = new global::Gtk.Box (Gtk.Orientation.Horizontal, 6); this.hbox1.Name = "hbox1"; // Container child hbox1.Gtk.Box+BoxChild this.label1 = new global::Gtk.Label (); @@ -118,7 +118,7 @@ protected virtual void Build () w9.Expand = false; w9.Fill = false; // Container child vbox1.Gtk.Box+BoxChild - this.hbox2 = new global::Gtk.HBox (false, 6); + this.hbox2 = new global::Gtk.Box (Gtk.Orientation.Horizontal, 6); this.hbox2.Name = "hbox2"; // Container child hbox2.Gtk.Box+BoxChild this.label2 = new global::Gtk.Label (); diff --git a/ColorManager/gtk-gui/MainWindow.cs b/ColorManager/gtk-gui/MainWindow.cs index 332db75..da15cc6 100644 --- a/ColorManager/gtk-gui/MainWindow.cs +++ b/ColorManager/gtk-gui/MainWindow.cs @@ -3,9 +3,9 @@ public partial class MainWindow { - private global::Gtk.VBox vbox1; + private global::Gtk.Box vbox1; - private global::Gtk.HBox hbox1; + private global::Gtk.Box hbox1; private global::Gtk.ComboBoxText comboboxentry1; @@ -15,7 +15,7 @@ public partial class MainWindow private global::Gtk.Button btnDelete; - private global::Gtk.HBox hbox2; + private global::Gtk.Box hbox2; private global::Gtk.Label lblPaletteName; @@ -81,10 +81,10 @@ protected virtual void Build () this.WindowPosition = ((global::Gtk.WindowPosition)(4)); this.DefaultWidth = 13; // Container child MainWindow.Gtk.Container+ContainerChild - this.vbox1 = new global::Gtk.VBox (false, 6); + this.vbox1 = new global::Gtk.Box (Gtk.Orientation.Vertical, 6); this.vbox1.Name = "vbox1"; // Container child vbox1.Gtk.Box+BoxChild - this.hbox1 = new global::Gtk.HBox (false, 6); + this.hbox1 = new global::Gtk.Box (Gtk.Orientation.Horizontal, 6); this.hbox1.Name = "hbox1"; // Container child hbox1.Gtk.Box+BoxChild this.comboboxentry1 = new global::Gtk.ComboBoxText (); @@ -142,7 +142,7 @@ protected virtual void Build () w10.Expand = false; w10.Fill = false; // Container child vbox1.Gtk.Box+BoxChild - this.hbox2 = new global::Gtk.HBox (false, 6); + this.hbox2 = new global::Gtk.Box (Gtk.Orientation.Horizontal, 6); this.hbox2.Name = "hbox2"; // Container child hbox2.Gtk.Box+BoxChild this.lblPaletteName = new global::Gtk.Label ();