本文整理汇总了C#中System.Windows.Documents.Run.AddHandler方法的典型用法代码示例。如果您正苦于以下问题:C# Run.AddHandler方法的具体用法?C# Run.AddHandler怎么用?C# Run.AddHandler使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.Run
的用法示例。
在下文中一共展示了Run.AddHandler方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getUserRun
private Run getUserRun(String user, string fulltext)
{
Run r = new Run(fulltext);
r.ToolTip = DateTime.Now.ToLongTimeString() + " " + DateTime.Now.ToLongDateString() + "\nClick to whisper " + user;
r.Cursor = Cursors.Hand;
r.Background = Brushes.White;
r.MouseEnter += delegate(object sender, MouseEventArgs e)
{
r.Background = new RadialGradientBrush(Colors.DarkGray, Colors.WhiteSmoke);
};
r.MouseLeave += delegate(object sender, MouseEventArgs e)
{
r.Background = Brushes.White;
};
r.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(delegate(object sender, MouseButtonEventArgs e)
{
tbMess.Text = "/w " + user + " ";
tbMess.SelectionStart = tbMess.Text.Length - 1;
tbMess.Focus();
tbMess.Focus();
}));
return r;
}
示例2: GetUserRun
private static Run GetUserRun(String user, string fulltext, DateTime rTime)
{
var r = new Run(fulltext)
{
ToolTip =
rTime.ToLongTimeString() + " " + rTime.ToLongDateString() +
"\nClick to whisper " +
user,
Cursor = Cursors.Hand,
Background = Brushes.White
};
r.MouseEnter += delegate { r.Background = new RadialGradientBrush(Colors.DarkGray, Colors.WhiteSmoke); };
r.MouseLeave += delegate { r.Background = Brushes.White; };
r.AddHandler(MouseLeftButtonDownEvent, new MouseButtonEventHandler
(delegate{
if (user == Program.LobbyClient.Me.User.User) return;
var room = Program.LobbyClient.Chatting.GetRoom(new NewUser(new Jid(user + "@" + Program.ChatServerPath)));
var cw = Program.ChatWindows.SingleOrDefault(x => x.Room.RID == room.RID);
if(cw != null)
cw.Show();
}));
return r;
}
示例3: getGameRun
private Run getGameRun(String user, HostedGame game)
{
Run r = new Run("game");
r.ToolTip = "Click to join " + user + "'s game";
r.Cursor = Cursors.Hand;
r.Foreground = Brushes.Blue;
r.Background = Brushes.White;
r.MouseEnter += delegate(object sender, MouseEventArgs e)
{
r.Background = new RadialGradientBrush(Colors.DarkGray, Colors.WhiteSmoke);
};
r.MouseLeave += delegate(object sender, MouseEventArgs e)
{
r.Background = Brushes.White;
};
r.AddHandler(UIElement.MouseLeftButtonDownEvent, new MouseButtonEventHandler(delegate(object sender, MouseButtonEventArgs e)
{
if(user.Equals(Program.LClient.strUserName))
return;
if(!Program.LClient.isHosting && !Program.LClient.isJoining)
{
if((Application.Current.MainWindow as Play.PlayWindow) != null)
Application.Current.MainWindow.Close();
else if((Application.Current.MainWindow as DeckBuilder.DeckBuilderWindow) != null)
Application.Current.MainWindow.Close();
Program.LClient.isJoining = true;
if(SelectGame(game.getStrGUID()))
{
intIpTried = 0;
port = game.getIntPort();
ips = game.getStrHost();
IPHostEntry host = Dns.GetHostEntry(ips[0]);
// Addres of the host.
IPAddress[] addressList = host.AddressList;
ips[0] = addressList[0].ToString();
Join_Game(ips, game.getIntPort());
}
else
{
//change_join_text("Join");
MessageBox.Show("You do not have the correct game installed.");
Program.LClient.isJoining = false;
}
}
else
{
if(Program.LClient.isHosting)
{
MessageBox.Show("Please stop hosting first.");
}
if(Program.LClient.isJoining)
{
MessageBox.Show("Please stop joining first.");
}
}
}));
return r;
}