Separeted widgets into files
This commit is contained in:
parent
18f4b191fd
commit
bc8aead471
6 changed files with 153 additions and 70 deletions
|
@ -15,11 +15,6 @@ namespace Samples
|
||||||
AddItem(CreateImageButton());
|
AddItem(CreateImageButton());
|
||||||
AddItem(CreateImageTextButton());
|
AddItem(CreateImageTextButton());
|
||||||
AddItem(CreateActionButton());
|
AddItem(CreateActionButton());
|
||||||
AddItem(CreateToggleButton());
|
|
||||||
AddItem(CreateLinkButton());
|
|
||||||
AddItem(CreateSpinButton());
|
|
||||||
AddItem(CreateSwitchButton());
|
|
||||||
AddItem(CreateColorButton());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public (string, Widget) CreateSimpleButton()
|
public (string, Widget) CreateSimpleButton()
|
||||||
|
@ -72,70 +67,5 @@ namespace Samples
|
||||||
|
|
||||||
return ("Action button:", btn);
|
return ("Action button:", btn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public (string, Widget) CreateToggleButton()
|
|
||||||
{
|
|
||||||
var btn = new ToggleButton("Toggle Me");
|
|
||||||
btn.Toggled += (sender, e) => ApplicationOutput.WriteLine(sender, "Buton Toggled");
|
|
||||||
|
|
||||||
return ("Toggle button:", btn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public (string, Widget) CreateLinkButton()
|
|
||||||
{
|
|
||||||
var btn = new LinkButton("A simple link button");
|
|
||||||
btn.Clicked += (sender, e) => ApplicationOutput.WriteLine(sender, "Link button Clicked");
|
|
||||||
|
|
||||||
return ("Link button:", btn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public (string, Widget) CreateSpinButton()
|
|
||||||
{
|
|
||||||
// Spinbutton constructor takes MinValue, MaxValue and StepValue
|
|
||||||
var btn = new SpinButton(0, 1000, 1);
|
|
||||||
|
|
||||||
// Button constructor also takes the adjustment object
|
|
||||||
// and it can be redefined any time like CurrentVal, MinVal, MaxVal, Step, PageStep, PageSize
|
|
||||||
btn.Adjustment.Configure(888, 0, 1000, 1, 100, 0);
|
|
||||||
|
|
||||||
// Default values are double, use ValueAsInt method to get Int
|
|
||||||
btn.ValueChanged += (sender, e) =>
|
|
||||||
ApplicationOutput.WriteLine(sender, $"Spin button changed: {btn.ValueAsInt}");
|
|
||||||
|
|
||||||
return ("Spin button:", btn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public (string, Widget) CreateSwitchButton()
|
|
||||||
{
|
|
||||||
var btn = new Switch();
|
|
||||||
|
|
||||||
btn.ButtonReleaseEvent += (o, args) =>
|
|
||||||
ApplicationOutput.WriteLine(o, $"Switch is now: {!btn.Active}");
|
|
||||||
|
|
||||||
return ("Switch:", btn);
|
|
||||||
}
|
|
||||||
|
|
||||||
public (string, Widget) CreateColorButton()
|
|
||||||
{
|
|
||||||
var btn = new ColorButton();
|
|
||||||
|
|
||||||
// Set RGBA color
|
|
||||||
btn.Rgba = new Gdk.RGBA()
|
|
||||||
{
|
|
||||||
Red = 0,
|
|
||||||
Green = 0,
|
|
||||||
Blue = 255,
|
|
||||||
Alpha = 0.2 // 20% translucent
|
|
||||||
};
|
|
||||||
|
|
||||||
// Or Parse hex
|
|
||||||
btn.Rgba.Parse("#729FCF");
|
|
||||||
|
|
||||||
// UseAlpha default is false
|
|
||||||
btn.UseAlpha = true;
|
|
||||||
|
|
||||||
return ("Color button:", btn);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
38
Source/Samples/Sections/Widgets/ColorButtonSection.cs
Normal file
38
Source/Samples/Sections/Widgets/ColorButtonSection.cs
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// Happy coding!!! - GtkSharp Team
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
|
||||||
|
namespace Samples
|
||||||
|
{
|
||||||
|
[Section(Name = "Color Button", Category = Category.Widgets)]
|
||||||
|
class ColorButtonSection : ListSection
|
||||||
|
{
|
||||||
|
public ColorButtonSection()
|
||||||
|
{
|
||||||
|
AddItem(CreateColorButton());
|
||||||
|
}
|
||||||
|
|
||||||
|
public (string, Widget) CreateColorButton()
|
||||||
|
{
|
||||||
|
var btn = new ColorButton();
|
||||||
|
|
||||||
|
// Set RGBA color
|
||||||
|
btn.Rgba = new Gdk.RGBA()
|
||||||
|
{
|
||||||
|
Red = 0,
|
||||||
|
Green = 0,
|
||||||
|
Blue = 255,
|
||||||
|
Alpha = 0.2 // 20% translucent
|
||||||
|
};
|
||||||
|
|
||||||
|
// Or Parse hex
|
||||||
|
btn.Rgba.Parse("#729FCF");
|
||||||
|
|
||||||
|
// UseAlpha default is false
|
||||||
|
btn.UseAlpha = true;
|
||||||
|
|
||||||
|
return ("Color button:", btn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
25
Source/Samples/Sections/Widgets/LinkButtonSection.cs
Normal file
25
Source/Samples/Sections/Widgets/LinkButtonSection.cs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// Happy coding!!! - GtkSharp Team
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
|
||||||
|
namespace Samples
|
||||||
|
{
|
||||||
|
[Section(Name = "Link Button", Category = Category.Widgets)]
|
||||||
|
class LinkButtonSection : ListSection
|
||||||
|
{
|
||||||
|
public LinkButtonSection()
|
||||||
|
{
|
||||||
|
AddItem(CreateLinkButton());
|
||||||
|
}
|
||||||
|
|
||||||
|
public (string, Widget) CreateLinkButton()
|
||||||
|
{
|
||||||
|
var btn = new LinkButton("A simple link button");
|
||||||
|
btn.Clicked += (sender, e) => ApplicationOutput.WriteLine(sender, "Link button Clicked");
|
||||||
|
|
||||||
|
return ("Link button:", btn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
Source/Samples/Sections/Widgets/SpinButtonSection.cs
Normal file
32
Source/Samples/Sections/Widgets/SpinButtonSection.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// Happy coding!!! - GtkSharp Team
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
|
||||||
|
namespace Samples
|
||||||
|
{
|
||||||
|
[Section(Name = "Spin Button", Category = Category.Widgets)]
|
||||||
|
class SpinButtonSection : ListSection
|
||||||
|
{
|
||||||
|
public SpinButtonSection()
|
||||||
|
{
|
||||||
|
AddItem(CreateSpinButton());
|
||||||
|
}
|
||||||
|
|
||||||
|
public (string, Widget) CreateSpinButton()
|
||||||
|
{
|
||||||
|
// Spinbutton constructor takes MinValue, MaxValue and StepValue
|
||||||
|
var btn = new SpinButton(0, 1000, 1);
|
||||||
|
|
||||||
|
// Button constructor also takes the adjustment object
|
||||||
|
// and it can be redefined any time like CurrentVal, MinVal, MaxVal, Step, PageStep, PageSize
|
||||||
|
btn.Adjustment.Configure(888, 0, 1000, 1, 100, 0);
|
||||||
|
|
||||||
|
// Default values are double, use ValueAsInt method to get Int
|
||||||
|
btn.ValueChanged += (sender, e) =>
|
||||||
|
ApplicationOutput.WriteLine(sender, $"Spin button changed: {btn.ValueAsInt}");
|
||||||
|
|
||||||
|
return ("Spin button:", btn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
Source/Samples/Sections/Widgets/SwitchButtonSection.cs
Normal file
26
Source/Samples/Sections/Widgets/SwitchButtonSection.cs
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// Happy coding!!! - GtkSharp Team
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
|
||||||
|
namespace Samples
|
||||||
|
{
|
||||||
|
[Section(Name = "Switch Button", Category = Category.Widgets)]
|
||||||
|
class SwitchButtonSection : ListSection
|
||||||
|
{
|
||||||
|
public SwitchButtonSection()
|
||||||
|
{
|
||||||
|
AddItem(CreateSwitchButton());
|
||||||
|
}
|
||||||
|
|
||||||
|
public (string, Widget) CreateSwitchButton()
|
||||||
|
{
|
||||||
|
var btn = new Switch();
|
||||||
|
|
||||||
|
btn.ButtonReleaseEvent += (o, args) =>
|
||||||
|
ApplicationOutput.WriteLine(o, $"Switch is now: {!btn.Active}");
|
||||||
|
|
||||||
|
return ("Switch:", btn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
32
Source/Samples/Sections/Widgets/ToggleButtonSection.cs
Normal file
32
Source/Samples/Sections/Widgets/ToggleButtonSection.cs
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
// This is free and unencumbered software released into the public domain.
|
||||||
|
// Happy coding!!! - GtkSharp Team
|
||||||
|
|
||||||
|
using Gtk;
|
||||||
|
|
||||||
|
namespace Samples
|
||||||
|
{
|
||||||
|
[Section(Name = "Toggle Button", Category = Category.Widgets)]
|
||||||
|
class ToggleButtonSection : ListSection
|
||||||
|
{
|
||||||
|
public ToggleButtonSection()
|
||||||
|
{
|
||||||
|
AddItem(CreateToggleButton());
|
||||||
|
}
|
||||||
|
|
||||||
|
public (string, Widget) CreateToggleButton()
|
||||||
|
{
|
||||||
|
var btn = new ToggleButton("Toggle Me");
|
||||||
|
btn.Toggled += (sender, e) =>
|
||||||
|
{
|
||||||
|
if (btn.Active)
|
||||||
|
btn.Label = "Untoggle Me";
|
||||||
|
else
|
||||||
|
btn.Label = "Toglle Me";
|
||||||
|
|
||||||
|
ApplicationOutput.WriteLine(sender, "Buton Toggled");
|
||||||
|
};
|
||||||
|
|
||||||
|
return ("Toggle button:", btn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue