【问题标题】:add links discord presenceRPC添加链接不和谐的存在RPC
【发布时间】:2022-10-17 21:23:34
【问题描述】:

我在C# 中有这段代码,我正在尝试添加 url 按钮以便能够添加 web url,但我不知道如何添加它,这是我的代码:

this.handlers = default(DiscordRpc.EventHandlers);
DiscordRpc.Initialize("xxx", ref this.handlers, true, null);
this.handlers = default(DiscordRpc.EventHandlers);
DiscordRpc.Initialize("xxx", ref this.handlers, true, null);
this.presence.details = "Barcelona";
this.presence.state = "Barcelona";
this.presence.startTimestamp = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
this.presence.largeImageKey = "https://media.tenor.com/Y_bfmgZ2sZ0AAAAM/aubameyang-fc-barcelona.gif";
this.presence.smallImageKey = "https://media.tenor.com/Y_bfmgZ2sZ0AAAAM/aubameyang-fc-barcelona.gif";
this.presence.largeImageText = "HI";

this.presence.smallImageText = "FCB";
DiscordRpc.UpdatePresence(ref this.presence);

这就是我要添加的内容。

【问题讨论】:

  • 您应该提供更详细的信息,例如,您使用的是什么 UI 框架?表格? wpf? blazor?...等等。
  • .net 框架? .net 核心?
  • 使用 .net 框架
  • 您是否对如何在 .net 框架中的表单上添加按钮有疑问?
  • 这就是我想做的,添加按钮链接但我不知道该怎么做

标签: c# winforms


【解决方案1】:

只需创建System.Windows.Forms.Button 类的实例并将其添加到表单Controls 集合中,如下所示

private void InitializeComponent()
{
    this.twitterButton = new System.Windows.Forms.Button();

    // 
    // twitterButton
    // 
    this.twitterButton.Location = new System.Drawing.Point(44, 111);
    this.twitterButton.Name = "twitterButton";
    this.twitterButton.Size = new System.Drawing.Size(89, 23);
    this.twitterButton.TabIndex = 1;
    this.twitterButton.Text = "twitter";
    this.twitterButton.UseVisualStyleBackColor = true;
    this.twitterButton.Click += new System.EventHandler(this.twitterButton_Click);

    this.Controls.Add(this.twitterButton);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-05-08
    • 1970-01-01
    • 2017-11-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-19
    • 2018-09-12
    相关资源
    最近更新 更多