xartigas pushed a commit to branch master. http://git.enlightenment.org/tools/examples.git/commit/?id=9f0eebb54f26c21a860863519deca83f1989b1c5
commit 9f0eebb54f26c21a860863519deca83f1989b1c5 Author: Lukasz Oleksak <[email protected]> Date: Wed Oct 2 15:36:14 2019 +0200 Example code for Efl.Ui.* widgets Reviewers: segfaultxavi, woohyun Reviewed By: segfaultxavi Differential Revision: https://phab.enlightenment.org/D10269 --- reference/csharp/snippets/Efl.Ui.AlertPopup.cs | 17 +++++++++++++++++ reference/csharp/snippets/Efl.Ui.Bg.cs | 6 ++++++ reference/csharp/snippets/Efl.Ui.Box.cs | 9 +++++++++ reference/csharp/snippets/Efl.Ui.Button.cs | 9 +++++++++ reference/csharp/snippets/Efl.Ui.Check.cs | 12 ++++++++++++ reference/csharp/snippets/Efl.Ui.Datepicker.cs | 11 +++++++++++ reference/csharp/snippets/Efl.Ui.Image.cs | 4 ++++ reference/csharp/snippets/Efl.Ui.Popup.cs | 12 ++++++++++++ reference/csharp/snippets/Efl.Ui.Progressbar.cs | 11 +++++++++++ reference/csharp/snippets/Efl.Ui.RadioBox.cs | 14 ++++++++++++++ reference/csharp/snippets/Efl.Ui.Scroller.cs | 10 ++++++++++ reference/csharp/snippets/Efl.Ui.Slider.cs | 9 +++++++++ reference/csharp/snippets/Efl.Ui.SpinButton.cs | 13 +++++++++++++ reference/csharp/snippets/Efl.Ui.Table.cs | 10 ++++++++++ 14 files changed, 147 insertions(+) diff --git a/reference/csharp/snippets/Efl.Ui.AlertPopup.cs b/reference/csharp/snippets/Efl.Ui.AlertPopup.cs new file mode 100644 index 00000000..0621eccd --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.AlertPopup.cs @@ -0,0 +1,17 @@ +Efl.Ui.AlertPopup alertPopup = new Efl.Ui.AlertPopup(parent); + +alertPopup.SetButton(Efl.Ui.AlertPopupButton.Positive, "Accept", null); +alertPopup.SetButton(Efl.Ui.AlertPopupButton.Negative, "Reject", null); + +alertPopup.ButtonClickedEvent += (sender, args) => +{ + if (args.arg.Button_type.Equals(Efl.Ui.AlertPopupButton.Positive)) + Console.WriteLine("Positive action invoked"); + else if (args.arg.Button_type.Equals(Efl.Ui.AlertPopupButton.Negative)) + Console.WriteLine("Negative action invoked"); +}; + +alertPopup.BackwallClickedEvent += (s, e) => +{ + Console.WriteLine("Backwall clicked"); +}; diff --git a/reference/csharp/snippets/Efl.Ui.Bg.cs b/reference/csharp/snippets/Efl.Ui.Bg.cs new file mode 100644 index 00000000..380a0a16 --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Bg.cs @@ -0,0 +1,6 @@ +Efl.Ui.Bg bg = new Efl.Ui.Bg(parent); + +bg.SetColor(66, 162, 206, 255); + +bg.SetFile(image_path + "background.png"); +bg.Load(); diff --git a/reference/csharp/snippets/Efl.Ui.Box.cs b/reference/csharp/snippets/Efl.Ui.Box.cs new file mode 100644 index 00000000..48c1488c --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Box.cs @@ -0,0 +1,9 @@ +Efl.Ui.Box box = new Efl.Ui.Box(parent); + +//Creating content which we will pack into the box - it can be any widgets, for example buttons. +Efl.Ui.Button button1 = new Efl.Ui.Button(box); +Efl.Ui.Button button2 = new Efl.Ui.Button(box); + +//Packing the content to the box, one after another +box.Pack(button1); +box.Pack(button2); diff --git a/reference/csharp/snippets/Efl.Ui.Button.cs b/reference/csharp/snippets/Efl.Ui.Button.cs new file mode 100644 index 00000000..cb7162e7 --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Button.cs @@ -0,0 +1,9 @@ +Efl.Ui.Button button = new Efl.Ui.Button(parent); + +button.SetText("Test Button"); + +button.ClickedEvent += (sender, args) => +{ + Efl.Ui.Button btn = (Efl.Ui.Button)sender; + btn.SetText("Clicked"); +}; diff --git a/reference/csharp/snippets/Efl.Ui.Check.cs b/reference/csharp/snippets/Efl.Ui.Check.cs new file mode 100644 index 00000000..8d3f47ca --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Check.cs @@ -0,0 +1,12 @@ +Efl.Ui.Check check = new Efl.Ui.Check(parent); + +check.SetText("Test Check"); +check.SetSelected(true); + +check.SelectedChangedEvent += (sender, args) => +{ + if (check.Selected) + Console.WriteLine("Check is selected"); + else + Console.WriteLine("Check is not selected"); +}; diff --git a/reference/csharp/snippets/Efl.Ui.Datepicker.cs b/reference/csharp/snippets/Efl.Ui.Datepicker.cs new file mode 100644 index 00000000..4288131c --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Datepicker.cs @@ -0,0 +1,11 @@ +Efl.Ui.Datepicker datepicker = new Efl.Ui.Datepicker(parent); + +datepicker.SetDateMin(2000, 1, 1); +datepicker.SetDateMax(2030, 1, 1); +datepicker.SetDate(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day); + +datepicker.DateChangedEvent += (sender, args) => +{ + datepicker.GetDate(out int year, out int month, out int day); + Console.WriteLine("Date has been changed! Current date: " + year + "-" + month + "-" + day); +}; diff --git a/reference/csharp/snippets/Efl.Ui.Image.cs b/reference/csharp/snippets/Efl.Ui.Image.cs new file mode 100644 index 00000000..81411d89 --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Image.cs @@ -0,0 +1,4 @@ +Efl.Ui.Image image = new Efl.Ui.Image(parent); + +image.SetFile(image_path + "icon.png"); +image.Load(); diff --git a/reference/csharp/snippets/Efl.Ui.Popup.cs b/reference/csharp/snippets/Efl.Ui.Popup.cs new file mode 100644 index 00000000..ec75e006 --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Popup.cs @@ -0,0 +1,12 @@ +Efl.Ui.Popup popup = new Efl.Ui.Popup(parent); + +Efl.Ui.Button button = new Efl.Ui.Button(parent); + +button.SetText("Click to hide the popup"); + +button.ClickedEvent += (sender, args) => +{ + popup.SetVisible(false); +}; + +popup.SetContent(button); diff --git a/reference/csharp/snippets/Efl.Ui.Progressbar.cs b/reference/csharp/snippets/Efl.Ui.Progressbar.cs new file mode 100644 index 00000000..a340ae43 --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Progressbar.cs @@ -0,0 +1,11 @@ +Efl.Ui.Progressbar progressbar = new Efl.Ui.Progressbar(parent); + +// You can choose the range limits according to your needs. +// It can be percentage, but it can be also different value (e.g. number of files to be copied) +progressbar.SetRangeLimits(0.0, 100.0); + +// Setting initial progress value +progressbar.RangeValue = 0; + +// When progress is made you should modify the RangeValue: +progressbar.RangeValue = 33; diff --git a/reference/csharp/snippets/Efl.Ui.RadioBox.cs b/reference/csharp/snippets/Efl.Ui.RadioBox.cs new file mode 100644 index 00000000..e54a5bf9 --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.RadioBox.cs @@ -0,0 +1,14 @@ +Efl.Ui.RadioBox radioBox = new Efl.Ui.RadioBox(parent); + +for (int i = 1; i <= 3; i++) +{ + Efl.Ui.Radio radio = new Efl.Ui.Radio(radioBox); + radio.SetText("Choice no. " + i); + radio.SetStateValue(i); + radioBox.Pack(radio); +} + +radioBox.ValueChangedEvent += (sender, args) => +{ + System.Console.WriteLine("RadioBox value changed! Current choice value: " + args.arg); +}; diff --git a/reference/csharp/snippets/Efl.Ui.Scroller.cs b/reference/csharp/snippets/Efl.Ui.Scroller.cs new file mode 100644 index 00000000..91f30d5d --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Scroller.cs @@ -0,0 +1,10 @@ +Efl.Ui.Scroller scroller = new Efl.Ui.Scroller(parent); + +// Create a large image to put it inside the scroller +Efl.Ui.Image image = new Efl.Ui.Image(scroller); + +image.SetHintSizeMin(new Eina.Size2D(1000, 1000)); +image.SetFile(image_path + "image.png"); +image.Load(); + +scroller.SetContent(image); diff --git a/reference/csharp/snippets/Efl.Ui.Slider.cs b/reference/csharp/snippets/Efl.Ui.Slider.cs new file mode 100644 index 00000000..5205a7d2 --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Slider.cs @@ -0,0 +1,9 @@ +Efl.Ui.Slider slider = new Efl.Ui.Slider(parent); + +slider.SetRangeLimits(0, 100); +slider.SetRangeValue(50); + +slider.ChangedEvent += (sender, args) => +{ + Console.WriteLine("Current slider value is: " + slider.GetRangeValue()); +}; diff --git a/reference/csharp/snippets/Efl.Ui.SpinButton.cs b/reference/csharp/snippets/Efl.Ui.SpinButton.cs new file mode 100644 index 00000000..d253adfb --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.SpinButton.cs @@ -0,0 +1,13 @@ +Efl.Ui.SpinButton spinButton = new Efl.Ui.SpinButton(parent); + +spinButton.SetOrientation(Efl.Ui.LayoutOrientation.Vertical); + +spinButton.SetRangeLimits(0, 100); +spinButton.SetRangeStep(2); +spinButton.SetRangeValue(50); + +spinButton.ChangedEvent += (sender, args) => +{ + Efl.Ui.SpinButton spnBtn = (Efl.Ui.SpinButton)sender; + Console.WriteLine("Range value changed to: " + spnBtn.RangeValue); +}; diff --git a/reference/csharp/snippets/Efl.Ui.Table.cs b/reference/csharp/snippets/Efl.Ui.Table.cs new file mode 100644 index 00000000..ab7240fd --- /dev/null +++ b/reference/csharp/snippets/Efl.Ui.Table.cs @@ -0,0 +1,10 @@ +Efl.Ui.Table table = new Efl.Ui.Table(parent); + +table.SetTableSize(2, 2); + +Efl.Ui.Button button1 = new Efl.Ui.Button(table); +Efl.Ui.Button button2 = new Efl.Ui.Button(table); + +// The first column and row have indexes = 0. +table.PackTable(button1, 0, 0, 1, 1); +table.PackTable(button2, 1, 1, 1, 1); --
