private void Button_Click_3(object sender, RoutedEventArgs e)
        {
            Window2 fr2 = new Window2();

            fr2.Show();
            Hide();
        }
Beispiel #2
0
        private void BtnAddToFeat_Click(object sender, RoutedEventArgs e)
        {
            Window2 fWin = new Window2();

            fWin.Owner = this;
            fWin.Show();
        }
Beispiel #3
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Hide();
            Window2 Готово = new Window2();

            Готово.Show();
            Close();
        }
        // user login button
        private void first_Click(object sender, RoutedEventArgs e)
        {
            //validate data from user-input
            if (username.Text.Length == 0)
            {
                errormessage.Text = "Enter an username.";
                username.Focus();
            }
            else if (pd.Password.Length == 0)
            {
                errormessage1.Text = "Enter an password.";
                pd.Focus();
            }
            //   MessageBox.Show(password.ToString());
            dc = new DataClasses1DataContext();
            Table tb = new Table();


            //fetching value from database
            var q1 = from a in dc.logins where a.type == firstname.Text && a.username == username.Text && a.password == pd.Password.ToString() select a;

            foreach (var b in q1)
            {
                if (b.type == "Admin" && b.username == username.Text && b.password == pd.Password.ToString())
                {
                    MessageBox.Show("Welcome " + username.Text);
                    string  value = username.Text;
                    Window3 w2    = new Window3();
                    w2.fetch(value.ToString());
                    w2.Show();
                    this.Close();
                }
                else if (b.type == "Manager" && b.username == username.Text && b.password == pd.Password.ToString())
                {
                    //MessageBox.Show("Welcome Manager");
                    MessageBox.Show("Welcome " + username.Text);
                    string     value = username.Text;
                    MainWindow w2    = new MainWindow();
                    w2.fetch(value.ToString());
                    w2.Show();
                    this.Close();
                }
                else if (b.type == "Employee" && b.username == username.Text && b.password == pd.Password.ToString())
                {
                    MessageBox.Show("Welcome " + username.Text);
                    string  value = username.Text;
                    Window2 w2    = new Window2();
                    w2.fetch(value.ToString());
                    w2.Show();
                    this.Close();
                }
            }
        }
 /// <summary>
 /// Timer_Tick метод осуществляющий тик и проверку окончания тайминга
 /// Так же идет вызов разблокировки, закрытие существующей формы и вызов формы windows1,
 /// когда конечный пользователь не нарушил условия тайминга
 /// </summary>
 /// <param name="sender"></param> переменная для связки таймера
 /// <param name="e"></param> параметр не содержит данных
 private void Timer_Tick(object sender, EventArgs e)
 {
     if (--TickCounter <= 0)
     {
         var timer = (DispatcherTimer)sender;
         timer.Stop();
         Unlock();
         Window2 window2 = new Window2();
         window2.Show();
         this.Close();
     }
 }
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     win2.Show();
     this.Hide();
 }
        //start listening for donations, open status window
        public void LaunchWindow(object sender, RoutedEventArgs e)
        {
            if (!Directory.Exists("output"))
            {
                DirectoryInfo di = Directory.CreateDirectory("output");
            }
            string         url = "https://www.twitchalerts.com/api/v1.0/user?access_token=" + AccessToken.Password;
            HttpWebRequest request;

            request        = (HttpWebRequest)WebRequest.Create(url);
            request.Method = "GET";
            window2.Show();
            string         url2 = "https://api.twitch.tv/kraken/channel";
            HttpWebRequest request2;

            request2        = (HttpWebRequest)WebRequest.Create(url2);
            request2.Method = "GET";
            request2.Headers["Client-ID"]     = "9tztppkgkayamw5135n4uo216fwvoy";
            request2.Headers["Authorization"] = "OAuth " + TwitchAccessToken.Password;
            try
            {
                WebResponse  resp               = request.GetResponse();
                Stream       dataStream         = resp.GetResponseStream();
                StreamReader reader             = new StreamReader(dataStream);
                string       responseFromServer = reader.ReadToEnd();
                dataStream.Close();
                string json = responseFromServer;
                User   user = JsonConvert.DeserializeObject <User>(json);
                my_username = user.GetTwitch().getName();
                my_user_id  = user.GetTwitch().GetId();
                WebResponse  resp2               = request2.GetResponse();
                Stream       dataStream2         = resp2.GetResponseStream();
                StreamReader reader2             = new StreamReader(dataStream2);
                string       responseFromServer2 = reader2.ReadToEnd();
                dataStream2.Close();
                string     json2      = responseFromServer2;
                TwitchUser twitchuser = JsonConvert.DeserializeObject <TwitchUser>(json2);

                //set up timer for streamlabs donation checker
                void updateWindow(object source, ElapsedEventArgs ev)
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        UpdateDonations(user.GetTwitch().GetId());
                    });
                }
                UpdateDonations(user.GetTwitch().GetId());
                System.Timers.Timer myTimer = new System.Timers.Timer();
                myTimer.Elapsed += new ElapsedEventHandler(updateWindow);
                myTimer.Interval = 10000;
                myTimer.Enabled  = true;
                List <string> bidwarOptions = new List <string>();
                foreach (object child in TextBoxes.Children)
                {
                    var textbox = (TextBox)child;
                    if (textbox.Text != "")
                    {
                        bidwarOptions.Add(textbox.Text);
                    }
                }

                //set up IRC listener for subs, resubs, and corrections
                void doIRC()
                {
                    IRCConfig conf = new IRCConfig();

                    conf.name     = my_username;
                    conf.nick     = my_username;
                    conf.port     = 6667;
                    conf.channel  = "#" + my_username;
                    conf.server   = "irc.chat.twitch.tv";
                    conf.password = "******" + TwitchAccessToken.Password;
                    conf.joined   = false;


                    IRCBot bot = new IRCBot(conf);

                    using (bot)
                    {
                        System.Diagnostics.Debug.WriteLine("connecting");
                        bot.Connect();
                        bot.IRCWork(user.GetTwitch().GetId(), bidwarOptions);
                    }
                }
                Thread irc = new Thread(new ThreadStart(doIRC));
                irc.Start();

                //websocket listener for bits

                /*WebSocket websocket = new WebSocket("wss://pubsub-edge.twitch.tv");
                 * websocket.Opened += new EventHandler(websocket_Opened);
                 * websocket.Error += new EventHandler<SuperSocket.ClientEngine.ErrorEventArgs>(websocket_Error);
                 * websocket.Closed += new EventHandler(websocket_Closed);
                 * websocket.MessageReceived += new EventHandler<WebSocket4Net.MessageReceivedEventArgs>(websocket_MessageReceived);
                 * websocket.Open();
                 * openListener();
                 * JavaScriptSerializer serializer = new JavaScriptSerializer();
                 * var listen = false;
                 * System.Timers.Timer pingTimer = new System.Timers.Timer();
                 * pingTimer.Elapsed += new ElapsedEventHandler(sendPing);
                 * pingTimer.Interval = 240000;
                 * pingTimer.Enabled = true;
                 * void websocket_Opened(object sender2, EventArgs e2)
                 * {
                 *  Application.Current.Dispatcher.Invoke((Action)delegate {
                 *      var tblock2 = new TextBlock();
                 *      tblock2.Text = "Established connection to bits service";
                 *      tblock2.TextWrapping = System.Windows.TextWrapping.Wrap;
                 *      window2.Logs.Children.Add(tblock2);
                 *  });
                 * }
                 * void websocket_Error(object sender2, SuperSocket.ClientEngine.ErrorEventArgs e2)
                 * {
                 *  Application.Current.Dispatcher.Invoke((Action)delegate {
                 *      var tblock3 = new TextBlock();
                 *      tblock3.Text = "Bits service error: " + e2.Exception.Message;
                 *      tblock3.TextWrapping = System.Windows.TextWrapping.Wrap;
                 *      window2.Logs.Children.Add(tblock3);
                 *  });
                 * }
                 * void websocket_Closed(object sender2, EventArgs e2)
                 * {
                 *  Application.Current.Dispatcher.Invoke((Action)delegate {
                 *      var tblock4 = new TextBlock();
                 *      tblock4.Text = "Closed bits service";
                 *      tblock4.TextWrapping = System.Windows.TextWrapping.Wrap;
                 *      window2.Logs.Children.Add(tblock4);
                 *  });
                 * }
                 * void websocket_MessageReceived(object sender2, MessageReceivedEventArgs e2)
                 * {
                 *  SocketMessage baseMessage = JsonConvert.DeserializeObject<SocketMessage>(e2.Message);
                 *  var output = "";
                 *  if (baseMessage.getType() == "PONG")
                 *  {
                 *      output = "pong";
                 *  }
                 *  else if (baseMessage.getType() == "RECONNECT")
                 *  {
                 *      websocket.Close();
                 *      websocket.Open();
                 *      output = "Reconnecting due to server restart";
                 *  }
                 *  if (baseMessage.getType() == "MESSAGE")
                 *  {
                 *      var container = JsonConvert.DeserializeObject<CheerMessageContainer>(e2.Message);
                 *      CheerMessageData data = container.getData();
                 *      try
                 *      {
                 *          if (data.getTopic() == "channel-bits-events-v1." + twitchuser.getId().ToString())
                 *          {
                 *              CheerContainer thisCheer = JsonConvert.DeserializeObject<CheerContainer>(data.getMessage());
                 *              saveCheer(thisCheer, user.GetTwitch().GetId());
                 *          }
                 *      }
                 *      catch(Exception eee)
                 *      {
                 *          output = e2.Message;
                 *      }
                 *  }
                 *  else
                 *  {
                 *      output = e2.Message;
                 *  }
                 *  Application.Current.Dispatcher.Invoke((Action)delegate {
                 *      var tblock5 = new TextBlock();
                 *      tblock5.Text = "Message from bits service: " + e2.Message;
                 *      tblock5.TextWrapping = System.Windows.TextWrapping.Wrap;
                 *      window2.Logs.Children.Add(tblock5);
                 *  });
                 * }
                 * void sendPing(object source, ElapsedEventArgs ev)
                 * {
                 *  var ping = new { type = "PING" };
                 *  websocket.Send(serializer.Serialize(ping));
                 * }
                 * async void openListener()
                 * {
                 *  await Task.Delay(TimeSpan.FromSeconds(7));
                 *  var ts = new string[1];
                 *  ts[0] = "channel-bits-events-v1." + twitchuser.getId().ToString();
                 *  var listener = new { type = "LISTEN", data = new { topics = ts, auth_token = TwitchAccessToken.Password } };
                 *  websocket.Send(serializer.Serialize(listener));
                 * }*/
            }
            catch (Exception ee)
            {
                System.Diagnostics.Debug.WriteLine(ee.Message);
                MessageBox.Show("Could not connect to StreamLabs. Try re-entering your access token. The server may also be down.");
            }
        }
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            Window2 window2 = new Window2();

            window2.Show();
        }