Exemplo n.º 1
0
    /// <summary>
    /// Creats a new Presence object, copying values of the Rich Presence
    /// </summary>
    /// <param name="presence">The rich presence, often received by discord.</param>
    public DiscordPresence(DiscordRPC.RichPresence presence)
    {
        this.state   = presence.State;
        this.details = presence.Details;

        this.party   = presence.HasParty() ? new DiscordParty(presence.Party) : new DiscordParty();
        this.secrets = presence.HasSecrets() ? new DiscordSecrets(presence.Secrets) : new DiscordSecrets();

        if (presence.HasAssets())
        {
            this.smallAsset = new DiscordAsset()
            {
                image   = presence.Assets.SmallImageKey,
                tooltip = presence.Assets.SmallImageText
            };

            this.largeAsset = new DiscordAsset()
            {
                image   = presence.Assets.LargeImageKey,
                tooltip = presence.Assets.LargeImageText
            };
        }
        else
        {
            this.smallAsset = new DiscordAsset();
            this.largeAsset = new DiscordAsset();
        }

        if (presence.HasTimestamps())
        {
            this.startTime = presence.Timestamps.Start.HasValue ? new DiscordTimestamp(presence.Timestamps.Start.Value) : new DiscordTimestamp(0);
            this.endTime   = presence.Timestamps.End.HasValue ? new DiscordTimestamp(presence.Timestamps.End.Value) : new DiscordTimestamp(0);
        }
    }
        internal ClickableImage(DiscordAsset asset)
        {
            this.InitializeComponent();

            this.Asset        = asset;
            this.Image.Source = asset.Image;
        }
Exemplo n.º 3
0
        private void OnDoubleClickImage(Object sender, ExecutedRoutedEventArgs e)
        {
            String parameter = (String)e.Parameter;

            ImagePicker picker = new ImagePicker(this._assets);

            if (!(picker.ShowDialog() ?? false))
            {
                return;
            }

            if (parameter == "large")
            {
                this._largeAsset       = picker.SelectedAsset;
                this.LargeImage.Source = picker.SelectedAsset.Image;
            }
            else if (parameter == "small")
            {
                this._smallAsset       = picker.SelectedAsset;
                this.SmallImage.Source = picker.SelectedAsset.Image;
            }
            else
            {
                throw new ArgumentOutOfRangeException(
                          $"Expected parameter to be one of \"small\" and \"large\". Received: \"{parameter}\" instead."
                          );
            }
        }
Exemplo n.º 4
0
 public DiscordPresence UpdateSmallAsset(DiscordAsset asset)
 {
     if (_client == null)
     {
         return(null);
     }
     if (asset == null)
     {
         return((DiscordPresence)_client.UpdateSmallAsset("", ""));
     }
     return((DiscordPresence)_client.UpdateSmallAsset(asset.image, asset.tooltip));
 }
    /// <summary>
    /// Creats a new Presence object, copying values of the Rich Presence
    /// </summary>
    /// <param name="presence">The rich presence, often received by discord.</param>
    public DiscordPresence(DiscordRPC.BaseRichPresence presence)
    {
        if (presence != null)
        {
            this.state   = presence.State;
            this.details = presence.Details;

            this.party   = presence.HasParty() ? new DiscordParty(presence.Party) : new DiscordParty();
            this.secrets = presence.HasSecrets() ? new DiscordSecrets(presence.Secrets) : new DiscordSecrets();

            if (presence.HasAssets())
            {
                this.smallAsset = new DiscordAsset()
                {
                    image     = presence.Assets.SmallImageKey,
                    tooltip   = presence.Assets.SmallImageText,
                    snowflake = presence.Assets.SmallImageID.GetValueOrDefault(0)
                };


                this.largeAsset = new DiscordAsset()
                {
                    image     = presence.Assets.LargeImageKey,
                    tooltip   = presence.Assets.LargeImageText,
                    snowflake = presence.Assets.LargeImageID.GetValueOrDefault(0)
                };
            }
            else
            {
                this.smallAsset = new DiscordAsset();
                this.largeAsset = new DiscordAsset();
            }

            if (presence.HasTimestamps())
            {
                //This could probably be made simpler
                this.startTime = presence.Timestamps.Start.HasValue ? new DiscordTimestamp((long)presence.Timestamps.StartUnixMilliseconds.Value) : DiscordTimestamp.Invalid;
                this.endTime   = presence.Timestamps.End.HasValue ? new DiscordTimestamp((long)presence.Timestamps.EndUnixMilliseconds.Value) : DiscordTimestamp.Invalid;
            }
        }
        else
        {
            this.state      = "";
            this.details    = "";
            this.party      = new DiscordParty();
            this.secrets    = new DiscordSecrets();
            this.smallAsset = new DiscordAsset();
            this.largeAsset = new DiscordAsset();
            this.startTime  = DiscordTimestamp.Invalid;
            this.endTime    = DiscordTimestamp.Invalid;
        }
    }
 private void OnImageDoubleClick(Object sender, EventArgs e)
 {
     this.DialogResult  = true;
     this.SelectedAsset = ((ClickableImage)sender).Asset;
     this.Close();
 }
Exemplo n.º 7
0
 private void OnRemoveLargeImageMenuItemClick(Object sender, RoutedEventArgs e)
 {
     this._largeAsset       = null;
     this.LargeImage.Source = null;
 }
Exemplo n.º 8
0
 private void OnRemoveSmallImageMenuItemClick(Object sender, RoutedEventArgs e)
 {
     this._smallAsset       = null;
     this.SmallImage.Source = null;
 }