Exemplo n.º 1
0
        public Console(StandardConverter tempConverter,
                       NoFocusTrackBar trackBar)
        {
            _fahrenheitPainter = new PanelPainter();
            _celsiusPainter    = new PanelPainter();
            _kelvinPainter     = new PanelPainter();

            _tempConverter = tempConverter;
            _trackBar      = trackBar;

            InitializeComponent();
            InitAndDisplayTrackBar();
            InitialiseScaleLabels();
            CreateLabelToolTips();
        }
Exemplo n.º 2
0
        internal static void Main()
        {
            //For UI thread exceptions
            Application.ThreadException += GlobalExceptionHandler;

            //Force all Windows Forms errors to go through our handler
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            //For non-UI thread exceptions
            AppDomain.CurrentDomain.UnhandledException += GlobalExceptionHandler;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var tempConverter   = new StandardConverter();
            var noFocusTrackBar = new NoFocusTrackBar(new Scale <int>(minimum: -220, maximum: 220, scaleBy: 5));

            Application.Run(new Console(tempConverter, noFocusTrackBar));
        }
Exemplo n.º 3
0
        void MTrackBar(object sender, EventArgs e)
        {
            NoFocusTrackBar trackbar = sender as NoFocusTrackBar;
            string          id1      = trackbar.Name.Substring(9, 1);                //is it x or y?
            int             id2      = Convert.ToInt32(trackbar.Name.Substring(10)); //what index?

            //Console.WriteLine(id1 + " " + id2);
            if (id1 == "X") //x-value trackbar
            {
                if ((tabPage3.Controls["checkBox" + (id2)] as CheckBox).Checked)
                {
                    (tabPage3.Controls["mTrackBarY" + (id2)] as NoFocusTrackBar).Value = trackbar.Value;
                    (tabPage3.Controls["mValueY" + (id2)] as NumericUpDown).Value      = trackbar.Value / (1000m);
                }
                (tabPage3.Controls["mValueX" + (id2)] as NumericUpDown).Value = trackbar.Value / (1000m);
            }
            else
            {
                (tabPage3.Controls["mValueY" + (id2)] as NumericUpDown).Value = trackbar.Value / (1000m);
            }
        }
Exemplo n.º 4
0
        private void dynamicComponent()
        {
            int currentDeep = 12;

            label    = new Label[bc.Length];
            trackBar = new NoFocusTrackBar[bc.Length];
            for (int i = 0; i < bc.Length; i++)
            {
                trackBar[i]             = new NoFocusTrackBar();
                trackBar[i].Location    = new Point(96, currentDeep);
                trackBar[i].Size        = new Size(565, 45);
                trackBar[i].Scroll     += new EventHandler(trackBar_Scroll);
                trackBar[i].LargeChange = 5;
                trackBar[i].Name        = i.ToString();
                trackBar[i].SendToBack();

                label[i]           = new Label();
                label[i].AutoSize  = true;
                label[i].Location  = new Point(10, currentDeep + 9);
                label[i].Size      = new Size(20, 13);
                label[i].ForeColor = Color.White;
                label[i].Text      = "Monitor " + i;
                label[i].BringToFront();

                Controls.Add(trackBar[i]);
                Controls.Add(label[i]);

                currentDeep += trackBar[i].Height;
            }
            for (int i = 0; i < bc.Length; i++)
            {
                updateTrackBar(trackBar[i], bc[i].getBrightnessStat());
            }
            ClientSize = new Size(trackBar[0].Location.X + trackBar[0].Width + 6, trackBar[trackBar.Length - 1].Location.Y + trackBar[trackBar.Length - 1].Height - 3);
            Location   = new Point((Screen.PrimaryScreen.WorkingArea.Width - Width), (Screen.PrimaryScreen.WorkingArea.Height - Height));

            // Check Startup with Windows
            if (System.Reflection.Assembly.GetEntryAssembly().Location == Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\Brightness Controller.exe")
            {
                addStartupToolStripMenuItem.Enabled = false;
                addStartupToolStripMenuItem.Text    = "Windows Startup (On)";
            }
            else
            {
                addStartupToolStripMenuItem.Text = "Windows Startup (Off)";
            }

            // Delete Old Update File
            TryAgain : try
            {
                string OldExeLocation = System.Reflection.Assembly.GetEntryAssembly().Location + ".old";
                if (File.Exists(OldExeLocation))
                {
                    File.Delete(OldExeLocation);
                }
            }
            catch (Exception)
            {
                goto TryAgain;
            }

            // Check Update
            Updater();
        }