Skip to content

DanieleCarrozzino/Poll

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Poll2 Library

Overview

The Poll2 library is a versatile tool designed to simplify the creation and management of polls within your applications. It provides an easy-to-use Poll object that encapsulates the entire poll structure, making it straightforward to integrate polls into your user interfaces.

Features

  • Flexible Design: The Poll class extends StackPanel, offering a customizable layout for displaying poll questions, answers, and progress.

  • Rich Visuals: Enhance your polls with rich visuals, including icons for poll questions and multiple selection options.

  • User-Friendly Interface: The library offers an intuitive interface for users to interact with polls, providing a seamless experience in selecting answers.

  • Dynamic Progress Tracking: Automatically tracks and displays the progress of selected answers, making it easy to gauge the popularity of each option.

Usage

Getting Started

  • Instantiate Poll: Create an instance of the Poll class by providing a list of answers and a question string.
var pollAnswers = new List<(string, int)> { ("Option A", 1), ("Option B", 2), ("Option C", 3) };
var pollQuestion = "Which option do you prefer?";
var poll = new Poll2.Poll(pollAnswers, pollQuestion);
  • Integration: Add the Poll instance to your application's UI as needed.
yourUiElement.Children.Add(poll);
  • Handle Click Events: Attach a callback function to handle user click events.
poll.ClickAction += (text, id, selected) =>
{
    // Handle the click event, e.g., store user responses.
    Console.WriteLine($"User selected option {id}: {text}, Selected: {selected}");
};
  • External Selection: Optionally, you can programmatically select answers externally using the selectAnswer method.
// Select the answer with id 2 for user with id 123
poll.selectAnswer(2, 123, true);

Example

Here's a simple example demonstrating how to create a poll:

var pollAnswers = new List<(string, int)> { ("Yes", 1), ("No", 2), ("Undecided", 3) };
var pollQuestion = "Do you enjoy coding?";
var poll = new Poll2.Poll(pollAnswers, pollQuestion);

// Add the poll to your UI element
yourUiElement.Children.Add(poll);

// Handle click events
poll.ClickAction += (text, id, selected) =>
{
    Console.WriteLine($"User selected option {id}: {text}, Selected: {selected}");
};

Acknowledgments

boh

About

wpf Poll structure

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages