public async void AttemptLogin() { // hide login grid LoginGrid.Visibility = Visibility.Visible; // show main grid MainGrid.Visibility = Visibility.Collapsed; // attempt to login and authenticate with OAuth _connection = await MixerConnection.ConnectViaLocalhostOAuthBrowser(ConfigurationManager.AppSettings["ClientID"], _scopes); // check that we logged in and got a connection if (_connection != null) { // get the current logged in user _user = await _connection.Users.GetCurrentUser(); // get the channel we want to connect to _channel = await _connection.Channels.GetChannel("SmiteGame"); // create a chat client so we can connect to the chat _chatClient = await ChatClient.CreateFromChannel(_connection, _channel); // attach an event handler incase we disconnect from chat _chatClient.OnDisconnectOccurred += ChatClient_OnDisconnectOccurred; // try and connect + authenticate with the chat client (will fail if banned from chat etc...) if (await _chatClient.Connect() && await _chatClient.Authenticate()) { // set logged in user on ui ChannelUserTextBlock.Text = _user.username; // set stream title on ui StreamTitleTextBox.Text = _channel.name; // set game title on ui GameTitleTextBlock.Text = _channel.type.name; // set connection status on ui ConnectionStatus.Text = "Connected"; // set stream online status on ui StreamStatus.Text = _channel.online.ToString(); // set taskbar hover text to show we're connected MainIcon.ToolTipText = "Smite Mixer Idler (Connected)"; // set the icon to the coloured version MainIcon.Icon = Properties.Resources.lumbridgeAvatar; // show a notification to the user saying we connected and authenticated successfully MainIcon.ShowBalloonTip("Smite Mixer Idler", "Successfully connected to chat.", Properties.Resources.lumbridgeAvatar, true); // hide the login grid LoginGrid.Visibility = Visibility.Collapsed; // show the main grid MainGrid.Visibility = Visibility.Visible; } } }
private void UpdateMainIconPosition() { if (ImageMainIcon.Visibility == Visibility.Visible) { if (LabelMainInstruction.Visibility == Visibility.Visible) { ImageMainIcon.SetValue(Grid.RowProperty, 0); if (MainIcon >= TaskDialogIcon.SecuritySuccess && MainIcon <= TaskDialogIcon.SecurityShieldGray && MainIcon != TaskDialogIcon.SecurityShield) { ImageMainIcon.SetValue(Grid.RowSpanProperty, 1); BorderGradient.Visibility = Visibility.Visible; LabelMainInstruction.Foreground = MainIcon == TaskDialogIcon.SecurityWarning ? Brushes.Black : Brushes.White; switch (MainIcon) { case TaskDialogIcon.SecuritySuccess: case TaskDialogIcon.SecurityQuestion: case TaskDialogIcon.SecurityWarning: case TaskDialogIcon.SecurityError: case TaskDialogIcon.SecurityShieldBlue: case TaskDialogIcon.SecurityShieldGray: BorderGradient.Background = Resources["Gradient" + MainIcon.ToString()] as Brush; break; default: BorderGradient.Background = Resources["GradientNormal"] as Brush; break; } } else { ImageMainIcon.SetValue(Grid.RowSpanProperty, 2); BorderGradient.Visibility = Visibility.Collapsed; //LabelMainInstruction.Background = Brushes.Transparent; LabelMainInstruction.Foreground = new SolidColorBrush(Color.FromRgb(0, 0x33, 0x99)); } } else if (LabelExpandedInfo.Visibility == Visibility.Visible) { ImageMainIcon.SetValue(Grid.RowProperty, 1); ImageMainIcon.SetValue(Grid.RowSpanProperty, 2); } else { ImageMainIcon.SetValue(Grid.RowProperty, 1); ImageMainIcon.SetValue(Grid.RowSpanProperty, 1); } } }