Ejemplo n.º 1
0
 /// <summary>Creates a new instance of Notification.</summary>
 /// <param name="text">Text to be displayed.</param>
 /// <param name="windowName">Title to be displayed on the Window.</param>
 /// <param name="buttons">Determines which buttons should be displayed on the Window</param>
 public Notification(string text, string windowName, NotificationButton buttons)
 {
     InitializeComponent();
     Title         = windowName;
     TxtPopup.Text = text;
     YesNoButtons(buttons == NotificationButton.OK);
 }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Notification notification = new System.Windows.Desktop.Notification();
            notification.HeaderText = "Self-Host Vote";
            notification.BodyText = "You have been using this Longhorn build for a few hours now.  By using the Vote Now button below, you can vote to let us know what you think of it.  To learn more, click this text.";

            notification.IsBodyClickable = true;
            NotificationButton notificationButton = new NotificationButton();
            notificationButton.Text = "Vote Now";
            notification.AddButton(notificationButton);

            NotificationButton notificationButton1 = new NotificationButton();
            notificationButton1.Text = "Later";
            notification.AddButton(notificationButton1);

            // Image
            try
            {
                FileStream fs = File.Open("ThumbsUp.png", FileMode.Open, FileAccess.Read, FileShare.None);
                ImageData imageData = new ImageData(fs);
                notification.HeaderIcon = imageData;
            }
            catch (Exception e) { Console.WriteLine(e); }

            notification.Send();
        }
Ejemplo n.º 3
0
        public TelegramButton(NotificationButton notificationButton)
        {
            Link = notificationButton.Link;

            /* Telegram doesn't support links to localhost so replace domain */
            Link = Link.Replace("localhost", "replace.to.localhost");

            Link = Link.AddQueryParameter("utm_source", "telegram");

            Text = notificationButton.Text;
        }
Ejemplo n.º 4
0
    public void NewNotification(string title, string des, int iconIndex, float posX)
    {
        //If Other Notifications Exist, Destroy Them
        foreach (Transform child in transform)
        {
            Destroy(child.gameObject);
        }

        //Create New Notification Object
        GameObject iii = Instantiate(NotificationPrefab, transform.position, transform.rotation);

        iii.transform.SetParent(gameObject.transform);
        NotificationButton scr = iii.GetComponent <NotificationButton>();

        if (scr)
        {
            scr.setButton(title, des, iconSprites[iconIndex], posX);
        }
    }
Ejemplo n.º 5
0
    //void FilterChellengers()
    //{
    //    LoadFriends(
    //             ParseObject.GetQuery("Notifications")
    //            .WhereEqualTo("asked_facebookID", Data.Instance.userData.facebookID)
    //            .Limit(90)
    //        );
    //}
    //void LoadFriends(ParseQuery<ParseObject> query)
    //{
    //    query.FindAsync().ContinueWith(t =>
    //    {
    //        IEnumerable<ParseObject> results = t.Result;
    //        foreach (var result in results)
    //        {
    //            string asked_facebookID = result.Get<string>("asked_facebookID");
    //            string facebookID = result.Get<string>("facebookID");
    //            string status = result.Get<string>("status");

    //            if (status != "3")
    //            {
    //                NotificationData notification = new NotificationData();

    //                notification.asked_facebookID = asked_facebookID;
    //                notification.facebookID = facebookID;
    //                notification.status = status;

    //                notifications.Add(notification);
    //            }
    //        }
    //        filterReady = true;
    //    }
    //    );
    //}
    //void Update()
    //{
    //    if (filterReady)
    //    {
    //        filterReady = false;
    //        CreateList();
    //    }
    //}
    public void CreateList()
    {
        //ya te dieron energia:
        foreach (Notifications.NotificationData data in Data.Instance.notifications.notifications)
        {
            NotificationButton newButton = Instantiate(button) as NotificationButton;

            newButton.transform.SetParent(container.transform);
            newButton.transform.localScale = Vector3.one;

            string username = "";

            foreach (UserData.FacebookUserData facebookData in Data.Instance.userData.FacebookFriends)
            {
                if (facebookData.facebookID == data.facebookID)
                {
                    username = facebookData.username;
                }
            }
            newButton.Init(this, username, data.facebookID, data.status);
        }

        //ya te dieron energia:
        foreach (Notifications.NotificationData data in Data.Instance.notifications.notificationsReceived)
        {
            NotificationButton newButton = Instantiate(button) as NotificationButton;

            newButton.transform.SetParent(container.transform);
            newButton.transform.localScale = Vector3.one;

            string username = "";

            foreach (UserData.FacebookUserData facebookData in Data.Instance.userData.FacebookFriends)
            {
                if (facebookData.facebookID == data.asked_facebookID)
                {
                    username = facebookData.username;
                }
            }
            newButton.Init(this, username, data.asked_facebookID, data.status);
        }
    }
Ejemplo n.º 6
0
        void ReleaseDesignerOutlets()
        {
            if (AlertButton != null)
            {
                AlertButton.Dispose();
                AlertButton = null;
            }

            if (DialogButton != null)
            {
                DialogButton.Dispose();
                DialogButton = null;
            }

            if (Field != null)
            {
                Field.Dispose();
                Field = null;
            }

            if (FieldLabel != null)
            {
                FieldLabel.Dispose();
                FieldLabel = null;
            }

            if (NotificationButton != null)
            {
                NotificationButton.Dispose();
                NotificationButton = null;
            }

            if (ResultLabel != null)
            {
                ResultLabel.Dispose();
                ResultLabel = null;
            }
        }
Ejemplo n.º 7
0
 public EmailButton(NotificationButton notificationButton)
     : this(notificationButton.Link, notificationButton.Text)
 {
 }
 /// <summary>
 /// Two button version.
 /// </summary>
 public Notification(string text, string tooltip, NotificationType type, string image_name, string button_text_1, WaitCallback stuff_to_do_when_button_pressed_1, string button_text_2, WaitCallback stuff_to_do_when_button_pressed_2)
     : this(text, tooltip, type, image_name, button_text_1, stuff_to_do_when_button_pressed_1)
 {
     Button2 = new NotificationButton(button_text_2, stuff_to_do_when_button_pressed_2);
 }
        void ReleaseDesignerOutlets()
        {
            if (btnBack != null)
            {
                btnBack.Dispose();
                btnBack = null;
            }

            if (btnDone != null)
            {
                btnDone.Dispose();
                btnDone = null;
            }

            if (cnsVActionBarAlignmentBasisHeight != null)
            {
                cnsVActionBarAlignmentBasisHeight.Dispose();
                cnsVActionBarAlignmentBasisHeight = null;
            }

            if (HandleImage != null)
            {
                HandleImage.Dispose();
                HandleImage = null;
            }

            if (Image != null)
            {
                Image.Dispose();
                Image = null;
            }

            if (NotificationButton != null)
            {
                NotificationButton.Dispose();
                NotificationButton = null;
            }

            if (NotificationButtonImage != null)
            {
                NotificationButtonImage.Dispose();
                NotificationButtonImage = null;
            }

            if (Score != null)
            {
                Score.Dispose();
                Score = null;
            }

            if (ScoreImage != null)
            {
                ScoreImage.Dispose();
                ScoreImage = null;
            }

            if (Title != null)
            {
                Title.Dispose();
                Title = null;
            }

            if (vActionBarAlignmentBasis != null)
            {
                vActionBarAlignmentBasis.Dispose();
                vActionBarAlignmentBasis = null;
            }

            if (vHandleImageLeftBottomBasis != null)
            {
                vHandleImageLeftBottomBasis.Dispose();
                vHandleImageLeftBottomBasis = null;
            }

            if (vLeftBottomBasis != null)
            {
                vLeftBottomBasis.Dispose();
                vLeftBottomBasis = null;
            }
        }
        protected override void DrawSectionBody()
        {
            DemoGuiUtils.DrawRow(() =>
            {
                GUILayout.Label("Notification Title: ", GSStyles.NormalLabelText);
                _title = GUILayout.TextField(_title, GSStyles.TextField);
            });

            DemoGuiUtils.DrawRow(() =>
            {
                GUILayout.Label("Notification Text: ", GSStyles.NormalLabelText);
                _text = GUILayout.TextField(_text, GSStyles.TextField);
            });

            DemoGuiUtils.DrawRow(() =>
            {
                GUILayout.Label("Image url: ", GSStyles.NormalLabelText);
            });
            DemoGuiUtils.DrawRow(() =>
            {
                _imageUrl = GUILayout.TextField(_imageUrl, GSStyles.TextField);
            });

            DemoGuiUtils.DrawRow(() =>
            {
                GUILayout.Label("Video url: ", GSStyles.NormalLabelText);
            });
            DemoGuiUtils.DrawRow(() =>
            {
                _videoUrl = GUILayout.TextField(_videoUrl, GSStyles.TextField);
            });

            DemoGuiUtils.DrawRow(() =>
            {
                _useCustomImage = GUILayout.Toggle(_useCustomImage, "", GSStyles.Toggle);
                GUILayout.Label("Send Custom Image", GSStyles.NormalLabelText, GUILayout.Width(Screen.width * 0.25f));
            });

            DemoGuiUtils.DrawRow(() =>
            {
                _useCustomVideo = GUILayout.Toggle(_useCustomVideo, "", GSStyles.Toggle);
                GUILayout.Label("Send Custom Video", GSStyles.NormalLabelText, GUILayout.Width(Screen.width * 0.25f));
            });

            DemoGuiUtils.DrawRow(() =>
            {
                GUILayout.Label("Background image: ", GSStyles.NormalLabelText);
            });
            DemoGuiUtils.DrawRow(() =>
            {
                _backgroundImageConfiguration = GUILayout.TextField(_backgroundImageConfiguration, GSStyles.TextField);
            });

            DemoGuiUtils.DrawRow(() =>
            {
                GUILayout.Label("Title color: ", GSStyles.NormalLabelText);
                _titleColor = GUILayout.TextField(_titleColor, GSStyles.TextField);
            });

            DemoGuiUtils.DrawRow(() =>
            {
                GUILayout.Label("Text color: ", GSStyles.NormalLabelText);
                _textColor = GUILayout.TextField(_textColor, GSStyles.TextField);
            });

            DemoGuiUtils.DrawRow(() =>
            {
                Placeholders.Keys.ToList().ForEach(key =>
                {
                    if (GUILayout.Button(key, GSStyles.Button))
                    {
                        _text += Placeholders[key];
                    }
                });
            });

            GUILayout.Label("Action: " + (_action ?? "Default"), GSStyles.NormalLabelText);
            DemoGuiUtils.DrawRow(() =>
            {
                if (GUILayout.Button("Default", GSStyles.ShortButton))
                {
                    _action = null;
                }

                var actions = new[] { GetSocialActionType.Custom, GetSocialActionType.OpenProfile, GetSocialActionType.OpenActivity, GetSocialActionType.OpenInvites, GetSocialActionType.OpenUrl, GetSocialActionType.AddFriend };
                actions.ToList().ForEach(action =>
                {
                    if (GUILayout.Button(action, GSStyles.ShortButton))
                    {
                        _action = action;
                    }
                });
            });

            DemoGuiUtils.DynamicRowFor(_actionData, "Action Data");
            DemoGuiUtils.DynamicRowFor(_actionButtons, "Action Buttons");

            DemoGuiUtils.DrawRow(() =>
            {
                GUILayout.Label("Template Name: ", GSStyles.NormalLabelText);
                _templateName = GUILayout.TextField(_templateName, GSStyles.TextField);
            });

            DemoGuiUtils.DynamicRowFor(_templatePlaceholders, "Template Placeholders");

            GUILayout.Label("Recipients:", GSStyles.NormalLabelText);

            DemoGuiUtils.DrawRow(() =>
            {
                _referrer = GUILayout.Toggle(_referrer, "", GSStyles.Toggle);
                GUILayout.Label("Referrer", GSStyles.NormalLabelText);
            });
            DemoGuiUtils.DrawRow(() =>
            {
                _referredUsers = GUILayout.Toggle(_referredUsers, "Referred Users", GSStyles.Toggle);
                GUILayout.Label("Referred Users", GSStyles.NormalLabelText);
            });
            DemoGuiUtils.DrawRow(() =>
            {
                _friends = GUILayout.Toggle(_friends, "Friends", GSStyles.Toggle);
                GUILayout.Label("Friends", GSStyles.NormalLabelText);
            });
            DemoGuiUtils.DrawRow(() =>
            {
                _me = GUILayout.Toggle(_me, "Me", GSStyles.Toggle);
                GUILayout.Label("Me", GSStyles.NormalLabelText);
            });

            DemoGuiUtils.DynamicRowFor(_userIds, "Custom Users ID");

            DemoGuiUtils.DrawRow(() =>
            {
                _sendBadgeValue = GUILayout.Toggle(_sendBadgeValue, "", GSStyles.Toggle);
                if (_sendBadgeValue)
                {
                    _sendBadgeIncrease = false;
                    _badgeIncrease     = "";
                }
                GUILayout.Label("Badge Count", GSStyles.NormalLabelText);
            });

            if (_sendBadgeValue)
            {
                _badgeValue = GUILayout.TextField(_badgeValue, GSStyles.TextField);
            }

            DemoGuiUtils.DrawRow(() =>
            {
                _sendBadgeIncrease = GUILayout.Toggle(_sendBadgeIncrease, "", GSStyles.Toggle);
                if (_sendBadgeIncrease)
                {
                    _sendBadgeValue = false;
                    _badgeValue     = "";
                }
                GUILayout.Label("Badge Increase", GSStyles.NormalLabelText);
            });

            if (_sendBadgeIncrease)
            {
                _badgeIncrease = GUILayout.TextField(_badgeIncrease, GSStyles.TextField);
            }

            if (GUILayout.Button("Send", GSStyles.Button))
            {
                var userIds = _userIds.ConvertAll(user => user.UserIdString);
                if (_me)
                {
                    userIds.Add(GetSocial.GetCurrentUser().Id);
                }
                var notificationTarget = new SendNotificationTarget(UserIdList.Create(userIds));
                if (_referrer)
                {
                    notificationTarget.AddPlaceholder(NotificationReceiverPlaceholders.Referrer);
                }
                if (_referredUsers)
                {
                    notificationTarget.AddPlaceholder(NotificationReceiverPlaceholders.ReferredUsers);
                }
                if (_friends)
                {
                    notificationTarget.AddPlaceholder(NotificationReceiverPlaceholders.Friends);
                }

                if (GetSocialActionType.AddFriend.Equals(_action) && string.IsNullOrEmpty(_text) && string.IsNullOrEmpty(_templateName))
                {
                    var addFriend = NotificationContent.CreateWithText(
                        NotificationContentPlaceholders.SenderDisplayName + " wants to become friends.")
                                    .WithTitle("Friend request")
                                    .WithAction(GetSocialAction.Create(_action, new Dictionary <string, string>()
                    {
                        { GetSocialActionKeys.AddFriend.UserId, GetSocial.GetCurrentUser().Id },
                        { "user_name", GetSocial.GetCurrentUser().DisplayName }
                    }));


                    Notifications.Send(addFriend,
                                       notificationTarget,
                                       () => _console.LogD("Notification sending started"),
                                       error => _console.LogE("Error: " + error.Message)
                                       );
                    return;
                }
                var mediaAttachment = _imageUrl.Length > 0 ? MediaAttachment.WithImageUrl(_imageUrl)
                    : _videoUrl.Length > 0 ? MediaAttachment.WithVideoUrl(_videoUrl)
                    : _useCustomImage?MediaAttachment.WithImage(Resources.Load <Texture2D>("activityImage"))
                                          : _useCustomVideo?MediaAttachment.WithVideo(DemoUtils.LoadSampleVideoBytes())
                                              : null;

                var customization = NotificationCustomization
                                    .WithBackgroundImageConfiguration(_backgroundImageConfiguration.ToNullIfEmpty())
                                    .WithTitleColor(_titleColor.ToNullIfEmpty())
                                    .WithTextColor(_textColor.ToNullIfEmpty());
                var content = NotificationContent.CreateWithText(_text)
                              .WithTitle(_title)
                              .WithTemplateName(_templateName)
                              .AddTemplatePlaceholders(_templatePlaceholders.ToDictionary(data => data.Key, data => data.Val))
                              .WithMediaAttachment(mediaAttachment)
                              .WithCustomization(customization)
                              .AddActionButtons(_actionButtons.ConvertAll(item => NotificationButton.Create(item.Key, item.Val))
                                                );

                if (_sendBadgeValue)
                {
                    content.WithBadge(Badge.SetTo(int.Parse(_badgeValue)));
                }
                else if (_sendBadgeIncrease)
                {
                    content.WithBadge(Badge.IncreaseBy(int.Parse(_badgeIncrease)));
                }

                if (_action != null)
                {
                    var action = GetSocialAction.Create(_action, _actionData.ToDictionary(data => data.Key, data => data.Val));
                    content.WithAction(action);
                }

                Notifications.Send(content,
                                   notificationTarget,
                                   () => _console.LogD("Notifications sending started"),
                                   error => _console.LogE("Error: " + error.Message)
                                   );
            }
        }