A feedback form in a few lines.
A rating, a range slider and a token edit, all reporting through OnChange. The same API in Delphi, C++ Builder and C#.
dotnet add package esegece.sgcEditors.WinForms
C++ Builder and C# versions
uses
SysUtils, Classes, Controls, Forms, StdCtrls,
sgcEditors_Types, sgcEditors_VCL_Value, sgcEditors_VCL_Token;
type
TFeedbackForm = class(TComponent)
public
Stars: TsgcVCLRating;
Budget: TsgcVCLRangeSlider;
Tags: TsgcVCLTokenEdit;
Summary: TLabel;
procedure EditorChange(Sender: TObject);
end;
procedure TFeedbackForm.EditorChange(Sender: TObject);
begin
// OnChange fires for every new value: clicked, dragged or typed
Summary.Caption := Format('%.1f stars, budget %.0f to %.0f, %d tags',
[Stars.Value, Budget.Value, Budget.EndValue, Tags.Tokens.Count]);
end;
function CreateFeedbackForm(aForm: TForm): TFeedbackForm;
begin
Result := TFeedbackForm.Create(aForm);
Result.Stars := TsgcVCLRating.Create(aForm);
Result.Stars.Parent := aForm;
Result.Stars.SetBounds(16, 16, 200, 32);
Result.Stars.Glyph := ergHeart;
Result.Stars.Precision := erpHalf;
Result.Stars.Value := 3.5;
Result.Stars.OnChange := Result.EditorChange;
Result.Budget := TsgcVCLRangeSlider.Create(aForm);
Result.Budget.Parent := aForm;
Result.Budget.SetBounds(16, 60, 320, 48);
Result.Budget.Max := 500;
Result.Budget.Step := 10;
Result.Budget.RangeMode := True;
Result.Budget.Value := 80;
Result.Budget.EndValue := 240;
Result.Budget.ShowLabels := True;
Result.Budget.OnChange := Result.EditorChange;
Result.Tags := TsgcVCLTokenEdit.Create(aForm);
Result.Tags.Parent := aForm;
Result.Tags.SetBounds(16, 120, 320, 64);
Result.Tags.TextHint := 'Add a tag';
Result.Tags.AutoCompleteItems.CommaText := 'Breakfast,Parking,Pool';
Result.Tags.AddToken('Breakfast');
Result.Tags.OnChange := Result.EditorChange;
Result.Summary := TLabel.Create(aForm);
Result.Summary.Parent := aForm;
Result.Summary.SetBounds(16, 196, 320, 20);
Result.EditorChange(nil);
end;