Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #region Directives
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Drawing.Text;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- #endregion
- #region Browse
- /* Copyright & Contact
- * --------------------------------------------------------------------------------<
- * Tool Name : Switch Button *
- * From Project : Creators Eye *
- * Project Lang : C# *
- * Creator : Yassine Abbani *
- * Facebook : https://www.facebook.com/YassineAbbani.user *
- * Pastebin : https://pastebin.com/u/Yassine_Abbani *
- * Youtube : https://www.youtube.com/channel/UCqvOCRs3HWbPH4yuZuTx8mw *
- * Version : 1.0 Beta *
- * Color : Multi-Color *
- * Style : Lolipop *
- *>--------------------------------------------------------------------------------<
- */
- /* Features
- * ------------------------
- * Creators Eye Lolipop Switch is a custom toggle control similar to Bunifu switch. The difference is that it has a sliding circle inside the component that performs the switching. It can be themed with color customization to fit the look and feel of your other controls.
- * Creators Eye Lolipop Switch can be added at design time using drag and drop and at runtime
- * Possible customizations:
- * Ability to change on and off colors*/
- /* history
- * ------------------------
- * 1.0 (24 Feb 2018):
- * Custom Properties
- * Set the color of Ce Lolipop switch when ON using OnColor property
- * Set the color of Ce Lolipop switch when on OFF status using OffColor property
- */
- #endregion
- #region Browse
- /* Copyright & Contact
- * --------------------------------------------------------------------------------<
- * Tool Name : Card *
- * From Project : Creator Eye *
- * Project Lang : C# *
- * Creator : Yassine Abbani *
- * Facebook : https://www.facebook.com/YassineAbbani.user *
- * Pastebin : https://pastebin.com/u/Yassine_Abbani *
- * Youtube : https://www.youtube.com/channel/UCqvOCRs3HWbPH4yuZuTx8mw *
- * Version : 1.0 Beta *
- * Color : Dark Theme *
- * Style : Smal *
- *>--------------------------------------------------------------------------------<
- */
- /* Features
- * ------------------------
- * We Was Converting rbg color to Html color
- * Creators Eye Cards is a custom control that arranges your info or controls inside a beautiful panel. It makes your dashboard presentation more organized and aligned.
- */
- /* history
- * ------------------------
- * 1.0 (24 Feb 2018):
- *
- * Custom Properties
- * Ability to add image to the left side of the card using property
- * Ability to change the color of the card image using Color property
- */
- #endregion
- #region Andriod Switch
- public class Ce_AndriodSwitch : CheckBox
- {
- #region Variables
- Timer AnimationTimer = new Timer { Interval = 1 };
- GraphicsPath RoundedRectangle;
- string EllipseBG = "#508ef5";
- string EllipseBorder = "#3b73d1";
- Color EllipseBackColor;
- Color EllipseBorderBackColor;
- Color EnabledUnCheckedColor = ColorTranslator.FromHtml("#bcbfc4");
- Color EnabledUnCheckedEllipseBorderColor = ColorTranslator.FromHtml("#a9acb0");
- Color DisabledEllipseBackColor = ColorTranslator.FromHtml("#c3c4c6");
- Color DisabledEllipseBorderBackColor = ColorTranslator.FromHtml("#90949a");
- int PointAnimationNum = 4;
- #endregion
- #region Properties
- [Category("Appearance")]
- public string EllipseColor
- {
- get { return EllipseBG; }
- set
- {
- EllipseBG = value;
- Invalidate();
- }
- }
- [Category("Appearance")]
- public string EllipseBorderColor
- {
- get { return EllipseBorder; }
- set
- {
- EllipseBorder = value;
- Invalidate();
- }
- }
- #endregion
- #region Events
- protected override void OnHandleCreated(EventArgs e)
- {
- base.OnHandleCreated(e);
- AnimationTimer.Start();
- }
- protected override void OnResize(EventArgs e)
- {
- Height = 19; Width = 47;
- RoundedRectangle = new GraphicsPath();
- int radius = 10;
- RoundedRectangle.AddArc(11, 4, radius - 1, radius, 180, 90);
- RoundedRectangle.AddArc(Width - 21, 4, radius - 1, radius, -90, 90);
- RoundedRectangle.AddArc(Width - 21, Height - 15, radius - 1, radius, 0, 90);
- RoundedRectangle.AddArc(11, Height - 15, radius - 1, radius, 90, 90);
- RoundedRectangle.CloseAllFigures();
- Invalidate();
- }
- #endregion
- public Ce_AndriodSwitch()
- {
- Height = 19; Width = 47; DoubleBuffered = true;
- AnimationTimer.Tick += new EventHandler(AnimationTick);
- }
- protected override void OnPaint(PaintEventArgs pevent)
- {
- var G = pevent.Graphics;
- G.SmoothingMode = SmoothingMode.AntiAlias;
- G.Clear(Parent.BackColor);
- EllipseBackColor = ColorTranslator.FromHtml(EllipseBG);
- EllipseBorderBackColor = ColorTranslator.FromHtml(EllipseBorder);
- G.FillPath(new SolidBrush(Color.FromArgb(115, Enabled ? Checked ? EllipseBackColor : EnabledUnCheckedColor : EnabledUnCheckedColor)), RoundedRectangle);
- G.DrawPath(new Pen(Color.FromArgb(50, Enabled ? Checked ? EllipseBackColor : EnabledUnCheckedColor : EnabledUnCheckedColor)), RoundedRectangle);
- G.FillEllipse(new SolidBrush(Enabled ? Checked ? EllipseBackColor : Color.White : DisabledEllipseBackColor), PointAnimationNum, 0, 18, 18);
- G.DrawEllipse(new Pen(Enabled ? Checked ? EllipseBorderBackColor : EnabledUnCheckedEllipseBorderColor : DisabledEllipseBorderBackColor), PointAnimationNum, 0, 18, 18);
- }
- void AnimationTick(object sender, EventArgs e)
- {
- if (Checked)
- {
- if (PointAnimationNum < 24)
- {
- PointAnimationNum += 1;
- this.Invalidate();
- }
- }
- else if (PointAnimationNum > 4)
- {
- PointAnimationNum -= 1;
- this.Invalidate();
- }
- }
- }
- #endregion
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement