Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace batteryMonitor_v2
- {
- public partial class Form1 : Form
- {
- int fadeTime = 500;
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- ShowIcon = true;
- this.Left = Screen.PrimaryScreen.Bounds.Width - (this.Width + 10); //Awkward read-only bastard
- this.Top = -(this.Height);
- }
- private void fadeOut_Tick(object sender, EventArgs e)
- {
- if (fadeTime != 0)
- {
- fadeTime--;
- }
- else
- {
- fadeOut.Stop();
- outScroll.Start();
- fadeTime = 500;
- }
- }
- private void setGUI(string bottomLine, Color textColour)
- {
- label2.Text = bottomLine;
- label2.SetBounds(((this.Width / 2) - (label2.Width / 2)), label2.Location.Y, label2.Width, label2.Height);
- foreach(Label L in this.Controls)
- {
- ((Label)L).ForeColor = textColour;
- }
- this.Show();
- inScroll.Start();
- }
- private void monitorPower_Tick(object sender, EventArgs e)
- {
- PowerLineStatus isCharging = SystemInformation.PowerStatus.PowerLineStatus;
- string tempPower = SystemInformation.PowerStatus.BatteryLifePercent.ToString("P0");
- string getPower = tempPower.Replace("%", "");
- if(fadeOut.Enabled == false && this.Top <= -(this.Height))
- {
- if (Convert.ToInt16(getPower) <= 15 && isCharging != PowerLineStatus.Online)
- {
- setGUI("Your battery needs charging!", Color.IndianRed);
- }
- if (Convert.ToInt16(getPower) >= 100 && isCharging == PowerLineStatus.Online)
- {
- setGUI("Your battery is fully charged!", Color.ForestGreen);
- }
- }
- }
- private void inScroll_Tick(object sender, EventArgs e)
- {
- if (this.Top != 10)
- {
- this.Top++;
- }
- else
- {
- fadeOut.Start();
- inScroll.Stop();
- }
- }
- private void outScroll_Tick(object sender, EventArgs e)
- {
- if (this.Top != -(this.Height))
- {
- this.Top--;
- }
- else
- {
- outScroll.Stop();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment