Computers && Coding == Art

PC Affinity [email protected]
Menu
  • Home
  • Downloads
  • Projects
  • About Me

MagicHat Plugin

Download latest version from Github

Resource to add a graphics-based random animated hat to any form.

Shake the hat, select the winner.


This plugin was created for use with the Picket application. However, I decided to extend the usage and provide a detailed interface with multiple options. This hat can be customized and used with any Control. Please remember to give credit if using my code within your applications.


To Use

Four simple steps.

  • Create the hat object.
  • Add Entries to the list.
  • Draw the hat.
  • Shake the hat.

This example form shows nearly all options available in the interface. (Some options only available for the MagicWheel plugin.)


When initializing the Hat, any control can be used as the Parent.

// Link the hat to a form.
IRandomTool hat = new Hat(this);

// Or link the hat to a control.
IRandomTool hat = new Hat(label1);

Draw

// Use the Top Left Location and Radius.
hat.Draw(LocationX, LocationY, Radius);

// Or use the Hat's center and drawing Radius.
hat.Draw(CenterPoint, Radus);

// Refresh calls Draw using the existing location data.
hat.Refresh();

EntryList

// List of 'Entries' used for the wheel.
hat.EntryList;

// Entry type contains a UniqueID(optional), Name, and Color.
// Returns a unique ticket ID that can optionally be set in the Entry.
hat.EntryAdd(Entry);

// Remove uses an ID provided by EntryAdd.
hat.EntryRemove(UniqueID);

// Clear the EntryList.
hat.EntriesClear();

// Randomize the EntryList.
hat.ShuffleEntries();

Action

// Returns true if the hat is actively shaking.
hat.IsBusy;

// Begin the shaking animation and random list pick.
// Uses preset or default settings.
hat.Start();

// Or begin and set direction, power type, and strength.
hat.Start(animDirection, randPowerType, randStrength);

/*
'animDirection' is not used. Can be Clockwise or CoutnerClockwise.
'randPowerType' can be Infinite, Weak, Average, Strong, Super, Random, or Manual.
'randStrength' is only used if 'randPowerType' is Manual.
*/

// Manually stop the picker and cancel the random pick.
hat.Stop();

// If 'randPowerType' is Infinite, then Stop will slow the picker and still select randomly from the list.

Other

// Public function used to determine text color against the background.
hat.IsReadable(Color1, Color2);

// Brings the PictureBox control to the front of the form.
hat.BringToFront();

// Sends the PictureBox control to the back of the form.
hat.SendToBack();

// Disposes of Image and PictureBox data.
// Must create a new wheel object after this is called.
hat.Dispose();

Event Handlers

// This event is called each frame the hat is moved.
// Entry returned is the currently selected entry in the list.
ToolActionEventHandler(Entry, string[4] actionInfo)

/*
The string array provided is a 4 part array.

Example return values in quotes:
Total Hat animations. "23"
Current animation countdown. "10"
Current base speed adjustment. "0"
Spin Strength. "Random|9"
*/

// This event is called when the hat comes to a stop.
// Entry returned is the final selected Entry.
ToolStopEventHandler(Entry)

Settings

// If false, actions will return null instead of throwing an Exception.
hat.AllowExceptions = true;

// Contains all other hat settings.
hat._ToolProperties;

// See below section for all _ToolProperties settings:

_ToolProperties

hat._ToolProperties.ArrowPosition // Not used
hat._ToolProperties.ArrowImage // Not used
hat._ToolProperties.LineColor // Not used
hat._ToolProperties.LineWidth // Not used
hat._ToolProperties.ForceUniqueEntryColors
hat._ToolProperties.TextToShow // Entry Aura will override CenterColor if TextToShow is not 'none'.
hat._ToolProperties.TextColor
hat._ToolProperties.TextColorAuto
hat._ToolProperties.TextFontFamily
hat._ToolProperties.TextFontStyle
hat._ToolProperties.ShadowVisible // Not used
hat._ToolProperties.ShadowColor // Not used
hat._ToolProperties.ShadowPosition // Not used
hat._ToolProperties.ShadowLength // Not used
hat._ToolProperties.CenterVisible
hat._ToolProperties.CenterColor // Entry Aura will override CenterColor if TextToShow is not 'none'.
hat._ToolProperties.CenterSize // Not used



Please feel free to view the source code over at GitHub. Completely available. Let me know if you have any questions or concerns. And please share with your friends!



Share this:

  • Twitter
  • Facebook
  • SMS
  • Email

Like this:

Like Loading...

Leave a Reply Cancel reply

My LinkedIn Profile


'Derrick Ducote'

Tags

API ASP.NET C# Clipboard Cycler Cloudflare Coding ColorFadeCalculator ConsoleWriter DLL Downloads First FMOL Assistant FMOL Marquee FP Time Tracker Gaming Hotkey Commands HTML Learning MagicHat MagicWheel Mouse Commands NGINX Other Personal PHP Picket Projects RegistryCommands RoundedButtons Server Site Information Synology Toolkit Cleanup

Categories

  • Apps
  • Coding
  • Configurations
  • Other
  • PHP
  • Server
  • Site Information

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

PC Affinity 2023 . Powered by WordPress

%d bloggers like this: