Exemplo n.º 1
0
 void _resizetoaster(object sender, EventArgs e)
 {
     _toasterout.SetWidth(Width);
 }
Exemplo n.º 2
0
        public Virilay()
        {
            if (!File.Exists("configv2.txt"))
            {
                MessageBox.Show("You need to apply twitch settings to Configurator. Please quit the program and run it");
                Application.Exit();
            }


            _config = config.FromFile("configv2.txt");

            #region Initialize Form
            InitializeComponent();
            StartPosition = FormStartPosition.Manual;
            Text          = "Toaster";
            Application.ApplicationExit += Application_ApplicationExit;
            GotFocus       += Virilay_GotFocus;
            ClientSize      = new Size(_config.StartWidth, _lblviewercount.Location.Y + _lblviewercount.Size.Height + _lblviewercount.Height - 4);
            Location        = new Point(_config.StartX, _config.StartY);
            FormBorderStyle = FormBorderStyle.None;



            #endregion



            _toasterout = new ToasterOut(this, _config.OutputCount, _config.FontSize);
            _toasterout.SetTopToBottom(!_config.OutputGoesUp);

            ToastLine.SecondsUntilFade = _config.FadeTime;
            ToastLine.OpacityMin       = ((float)_config.Opacity) / 100.0f;
            _toasterout.SetWidth(_config.StartWidth);
            Resize          += new EventHandler(_resizetoaster);
            LocationChanged += new EventHandler(_locationchangedtoaster);
            _txtviribotsay.Focus();
            Show();

            _lt = new Executor(_config.Username, "");
            Console.SetOut(_toasterout);
            Console.SetError(_toasterout);
            Load           += Virilay_Load;
            this.Activated += Virilay_Activated; //reset opacity
            this.Click     += Virilay_Click;
            _ap             = new AdditionalParameters();
            _ap.Origin      = "";

            this.TopLevel            = true;
            this.TopMost             = true;
            _txtviribotsay.Font      = new Font("Arial", _config.FontSize);
            _lblviewercount.Font     = new Font("Arial", _config.FontSize);
            _txtviribotsay.KeyPress += new KeyPressEventHandler(this_KeyPress);
            _lblviewercount.Location = new Point(
                _txtviribotsay.Location.X,
                _txtviribotsay.Location.Y + _txtviribotsay.Size.Height + 2 //+ (int)_config.FontSize
                );

            pictureBox1.Location = new Point(
                _txtviribotsay.Right - pictureBox1.Width,
                _txtviribotsay.Location.Y + _txtviribotsay.Size.Height + 2 //+ (int)_config.FontSize
                );



            if (Directory.Exists("UserScripts\\Autoload"))
            {
                //todo:optimize
                string[] filePaths = Directory.GetFiles("UserScripts\\AutoLoad", "*.cs", SearchOption.AllDirectories);
                for (int i = 0; i < filePaths.Length; i++)
                {
                    _lt.Compile(filePaths[i].Substring("UserScripts\\".Length, filePaths[i].LastIndexOf(".cs") - "UserScripts\\".Length));
                }
            }
            if (!string.IsNullOrWhiteSpace(_config.Username))
            {
                viribot.OnMsg += _viribot_OnPrivMsg;
                Console.WriteLine(_config.Username);
                Console.WriteLine(_config.OAuth);
                viribot.Connect(_config.Username, "irc.twitch.tv", 6667, _config.Username, _config.OAuth, TimeSpan.FromSeconds(3));
            }
            else
            {
                Console.WriteLine("Not launching twitch because username or password is empty.\n(" + _config.Username + "/" + _config.OAuth + ")");
            }
            Console.SetError(viribot);
        }