コード例 #1
0
		private void openStream(string channelName)
		{
			if (OnStreamOpen != null)
			{
				var args = new StreamOpenEventArgs {ChannelName = channelName.Trim()};
				OnStreamOpen(this, args);
			}
		}
コード例 #2
0
		private void channelsControl_OnStreamOpen(object sender, StreamOpenEventArgs e)
		{
			if (e != null && !string.IsNullOrEmpty(e.ChannelName) && !isStreamVisible(e.ChannelName))
			{
				Utility.GetAccessToken(user);

				try
				{
					if (!string.IsNullOrEmpty(user.AccessToken) && !string.IsNullOrEmpty(user.Name))
					{
						if (userOptions.ShowEmoticonsInChat && emoticons == null)
						{
							emoticons = DataFileManager.GetEmoticons();
						}

						visibleStreams.Add(e.ChannelName);

						if (userOptions.OpenStreamsInNewTab)
						{
							var stream = new Stream(user,
								e.ChannelName,
								user.AccessToken,
								potentialNicknameColors,
								streamTitleAutoCompleteOptions,
								streamGameAutoCompleteOptions,
								emoticons);

							var tab = new ClosableTab
							{
								Title = e.ChannelName,
								VerticalContentAlignment = VerticalAlignment.Stretch,
								Content = stream
							};

							tab.Closed += delegate
							{
								visibleStreams.Remove(e.ChannelName);
								stream.Disconnect();
							};

							mainTabs.Items.Add(tab);
						}
						else
						{
							var stream = new Stream(user,
								e.ChannelName,
								user.AccessToken,
								potentialNicknameColors,
								streamTitleAutoCompleteOptions,
								streamGameAutoCompleteOptions,
								emoticons);

							var ibd =
								new IconBitmapDecoder(new Uri("pack://application:,,,/LivestreamBuddyNew;component/livestream-ICON.ico"),
									BitmapCreateOptions.None, BitmapCacheOption.Default);
							var brush = new LinearGradientBrush((Color) ColorConverter.ConvertFromString("#FF515151"), Colors.LightGray,
								new Point(.5, 0), new Point(.5, 1));

							var newWindow = new Window
							{
								Width = 525,
								MinWidth = 525,
								Height = 675,
								MinHeight = 675,
								Title = e.ChannelName,
								Icon = ibd.Frames[0],
								Background = brush,
								Content = new Border {Padding = new Thickness(13, 13, 13, 13), Child = stream}
							};

							newWindow.Closed += delegate
							{
								visibleStreams.Remove(e.ChannelName);
								stream.Disconnect();
							};

							newWindow.Show();
						}
					}
					else
					{
						throw new Exception();
					}
				}
				catch
				{
					Utility.ClearUserData(user);
					MessageBox.Show("Something went wrong. Try again.");
				}
			}
		}