Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/chanos-dev/tour.net

.net farmework48 winforms tour uiux
https://github.com/chanos-dev/tour.net

csharp netframework48 tutorial winforms

Last synced: about 1 month ago
JSON representation

.net farmework48 winforms tour uiux

Awesome Lists containing this project

README

        

# tour.net
A simple library to easily implement tutorial functionality in WinForms.

Developed using .NET Framework 4.8.

## Preview
![sample](https://github.com/chanos-dev/tour.net/blob/main/sample.gif?raw=true)

## Usage
```csharp
public partial class MainForm : Form
{
private ITutorial _tutorial;

public MainForm()
{
InitializeComponent();
}

private void MainForm_Load(object sender, EventArgs e)
{
InitializeTutorial();
}

private void InitializeTutorial()
{
var tutorial = new Tutorial(this)
.SetTutorialConfig(config =>
{
config.TooltipColor = Color.LightBlue;
})
.AddStep(new HighlightForm(button1), new DefaultTooltipForm("Step 1", "click the button1.", ETooltipPosition.Right))
.AddStep(new HighlightForm(button2), new DefaultTooltipForm("Step 2", "click the button2.", ETooltipPosition.Right))
.AddStep(new HighlightForm(checkBox1), new DefaultTooltipForm("Step 3", "check the checkBox1.", ETooltipPosition.Top))
.AddStep(new HighlightForm(radioButton1), new DefaultTooltipForm("Step 4", "click the radioButton1.", ETooltipPosition.Bottom))
.AddStep(new HighlightForm(radioButton2), new DefaultTooltipForm("Step 5", "click the radioButton2.", ETooltipPosition.Left))
.AddStep(new HighlightForm(radioButton3), new DefaultTooltipForm("Step 6", "click the radioButton3.", ETooltipPosition.Right));

_tutorial = tutorial.Build();
}

private void button3_Click(object sender, EventArgs e)
{
_tutorial.Start();
}
}
```

- The constructor of Tutorial takes the Form where the tutorial will be executed as a parameter.
- You can add tutorial steps using the AddStep method.
- HighlightForm: Specifies the Control to be highlighted.
- DefaultTooltipForm: Provides a default Tooltip design where you can specify the title and content.
- Finally, call the Build method to create an ITutorial interface to start the tutorial.
- Start the tutorial using the Start method of the ITutorial interface.

> The SetTutorialConfig method works when using DefaultTooltipForm.

## Custom Tooltip
In addition to the provided DefaultTooltipForm, you can create a custom Tooltip design by implementing your own form.

```csharp
public class TooltipForm : Form
{
public TooltipForm()
{
ShowInTaskbar = false;
}

///
/// Adds an event handler for the Exit button click event.
///
/// The event handler to add.
public virtual void AddExitEvent(EventHandler exitEvent) { }

///
/// Adds an event handler for the Next button click event.
///
/// The event handler to add.
public virtual void AddNextEvent(EventHandler nextEvent) { }

///
/// Adds an event handler for the Previous button click event.
///
/// The event handler to add.
public virtual void AddPrevEvent(EventHandler prevEvent) { }

///
/// Removes an event handler for the Exit button click event.
///
/// The event handler to remove.
public virtual void RemoveExitEvent(EventHandler exitEvent) { }

///
/// Removes an event handler for the Next button click event.
///
/// The event handler to remove.
public virtual void RemoveNextEvent(EventHandler nextEvent) { }

///
/// Removes an event handler for the Previous button click event.
///
/// The event handler to remove.
public virtual void RemovePrevEvent(EventHandler prevEvent) { }

///
/// Sets the step information for the tooltip, such as the current step index and the total number of steps.
///
/// The current step index.
/// The total number of steps.
public virtual void SetStepInfo(int stepIndex, int totalStepsCount) { }

///
/// Moves the tooltip to the specified location based on the provided bounds of the highlighted control.
///
/// The bounds of the control to highlight.
public virtual void MoveTooltip(Rectangle highlightControlBounds)
{
Location = new Point(highlightControlBounds.X, highlightControlBounds.Y);
}
}
```
When designing a custom Tooltip, the following implementations are required:

- Inherit from the TooltipForm class.
- Use the [Add/Remove]NextEvent, [Add/Remove]PrevEvent, [Add/Remove]ExitEvent methods to connect button events.
- (Optional) Specify the current Tooltip step index using the SetStepInfo method.
- Implement the MoveTooltip method to set the Tooltip's location.
- By default, the Tooltip is positioned at (0, 0) of the highlighted Control.

> To prevent the TooltipForm from closing, settings like FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; may be necessary.

## TODO
- Automatic Tooltip position adjustment (when the Tooltip goes outside the bounds of the Form).