本文整理匯總了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;
}