Esempio n. 1
0
        async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Start.channel.PushNotificationReceived += channel_PushNotificationReceived;
            test = new ObservableCollection<ChatPubList>();

            items = await Table.OrderByDescending(ChatPublic => ChatPublic.__CreatedAt).ToCollectionAsync();
            var networkProfiles = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
            var adapter = networkProfiles.First<Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;//takes the first network adapter
            string networkAdapterId = adapter.NetworkAdapterId.ToString();

            foreach (ChatPublic k in items)
            {
                ChatPubList a = new ChatPubList();
                a.date = k.__CreatedAt.Date.ToString();
                a.time = k.__CreatedAt.TimeOfDay.ToString();
                a.time=a.time.Remove(5);
                a.date=a.date.Remove(10);
                a.Name = k.Name;
                a.Message = k.Message;
                if (a.Name == networkAdapterId)
                {
                    a.col = "#FF9B0E00";
                }
                else
                {
                    a.col = "#FF5D340C";
                }
                test.Add(a);
            }
            lol.ItemsSource = test;
            test.CollectionChanged += test_CollectionChanged;

        }
Esempio n. 2
0
        async void channel_PushNotificationReceived(Windows.Networking.PushNotifications.PushNotificationChannel sender, Windows.Networking.PushNotifications.PushNotificationReceivedEventArgs args)
        {
            if (args.ToastNotification.Content.InnerText.Contains("Event"))
            {
            }
            else
            {
                args.Cancel = true;
                items       = await Table.OrderByDescending(ChatPublic => ChatPublic.CreatedAt).Take(1).ToCollectionAsync();

                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    ChatPubList a           = new ChatPubList();
                    a.date                  = items[0].CreatedAt.Date.ToString();
                    a.time                  = items[0].CreatedAt.TimeOfDay.ToString();
                    a.time                  = a.time.Remove(5);
                    a.date                  = a.date.Remove(10);
                    a.Message               = items[0].Message;
                    a.Name                  = items[0].Name;
                    var networkProfiles     = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
                    var adapter             = networkProfiles.First <Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;//takes the first network adapter
                    string networkAdapterId = adapter.NetworkAdapterId.ToString();
                    if (a.Name == networkAdapterId)
                    {
                        a.col = "#FF9B0E00";
                    }
                    else
                    {
                        a.col = "#FF5D340C";
                    }
                    MainPage.test.Insert(0, a);
                });
            }
        }
Esempio n. 3
0
        async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Start.channel.PushNotificationReceived += channel_PushNotificationReceived;
            test = new ObservableCollection <ChatPubList>();

            items = await Table.OrderByDescending(ChatPublic => ChatPublic.CreatedAt).ToCollectionAsync();

            var    networkProfiles  = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
            var    adapter          = networkProfiles.First <Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;//takes the first network adapter
            string networkAdapterId = adapter.NetworkAdapterId.ToString();

            foreach (ChatPublic k in items)
            {
                ChatPubList a = new ChatPubList();
                a.date    = k.CreatedAt.Date.ToString();
                a.time    = k.CreatedAt.TimeOfDay.ToString();
                a.time    = a.time.Remove(5);
                a.date    = a.date.Remove(10);
                a.Name    = k.Name;
                a.Message = k.Message;
                if (a.Name == networkAdapterId)
                {
                    a.col = "#FF9B0E00";
                }
                else
                {
                    a.col = "#FF5D340C";
                }
                test.Add(a);
            }
            lol.ItemsSource         = test;
            test.CollectionChanged += test_CollectionChanged;
        }
Esempio n. 4
0
        async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {

            //PushNotificationChannel channel;
            //channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
            //try
            //{
            //    await App.Mugd_appClient.GetPush().RegisterNativeAsync(channel.Uri);
            //    //await App.Mugd_appClient.InvokeApiAsync("notifyAllUsers",
            //    //    new JObject(new JProperty("toast", "Sample Toast")));
            //}
            //catch (Exception exception)
            //{
            //    HandleRegisterException(exception);
            //}
            Start.channel.PushNotificationReceived += channel_PushNotificationReceived;
            test = new ObservableCollection<ChatPubList>();

            items = await Table.OrderByDescending(ChatPublic => ChatPublic.CreatedAt).ToCollectionAsync();
            var networkProfiles = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
            var adapter = networkProfiles.First<Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;//takes the first network adapter
            string networkAdapterId = adapter.NetworkAdapterId.ToString();

            foreach (ChatPublic k in items)
            {
                ChatPubList a = new ChatPubList();
                a.date = k.CreatedAt.Date.ToString();
                a.time = k.CreatedAt.TimeOfDay.ToString();
                a.time = a.time.Remove(5);
                a.date = a.date.Remove(10);
                a.Name = k.Name;
                a.Message = k.Message;
                if (a.Name == networkAdapterId)
                {
                    a.col = "#FF9B0E00";
                }
                else
                {
                    a.col = "#FF5D340C";
                }
                test.Add(a);
            }
            lol.ItemsSource = test;
            test.CollectionChanged += test_CollectionChanged;
            

        }
Esempio n. 5
0
        async void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            //PushNotificationChannel channel;
            //channel = await Windows.Networking.PushNotifications.PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
            //try
            //{
            //    await App.Mugd_appClient.GetPush().RegisterNativeAsync(channel.Uri);
            //    //await App.Mugd_appClient.InvokeApiAsync("notifyAllUsers",
            //    //    new JObject(new JProperty("toast", "Sample Toast")));
            //}
            //catch (Exception exception)
            //{
            //    HandleRegisterException(exception);
            //}
            Start.channel.PushNotificationReceived += channel_PushNotificationReceived;
            test = new ObservableCollection <ChatPubList>();

            items = await Table.OrderByDescending(ChatPublic => ChatPublic.CreatedAt).ToCollectionAsync();

            var    networkProfiles  = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
            var    adapter          = networkProfiles.First <Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;//takes the first network adapter
            string networkAdapterId = adapter.NetworkAdapterId.ToString();

            foreach (ChatPublic k in items)
            {
                ChatPubList a = new ChatPubList();
                a.date    = k.CreatedAt.Date.ToString();
                a.time    = k.CreatedAt.TimeOfDay.ToString();
                a.time    = a.time.Remove(5);
                a.date    = a.date.Remove(10);
                a.Name    = k.Name;
                a.Message = k.Message;
                if (a.Name == networkAdapterId)
                {
                    a.col = "#FF9B0E00";
                }
                else
                {
                    a.col = "#FF5D340C";
                }
                test.Add(a);
            }
            lol.ItemsSource         = test;
            test.CollectionChanged += test_CollectionChanged;
        }
Esempio n. 6
0
        async void channel_PushNotificationReceived(Windows.Networking.PushNotifications.PushNotificationChannel sender, Windows.Networking.PushNotifications.PushNotificationReceivedEventArgs args)
        {
            if (args.ToastNotification.Content.InnerText.Contains("Event"))
            {
               

            }
            else
            {
                args.Cancel = true;
                items = await Table.OrderByDescending(ChatPublic => ChatPublic.CreatedAt).Take(1).ToCollectionAsync();
                await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {

                    ChatPubList a = new ChatPubList();
                    a.date = items[0].CreatedAt.Date.ToString();
                    a.time = items[0].CreatedAt.TimeOfDay.ToString();
                    a.time = a.time.Remove(5);
                    a.date = a.date.Remove(10);
                    a.Message = items[0].Message;
                    a.Name = items[0].Name;
                    var networkProfiles = Windows.Networking.Connectivity.NetworkInformation.GetConnectionProfiles();
                    var adapter = networkProfiles.First<Windows.Networking.Connectivity.ConnectionProfile>().NetworkAdapter;//takes the first network adapter
                    string networkAdapterId = adapter.NetworkAdapterId.ToString();
                    if (a.Name == networkAdapterId)
                    {
                        a.col = "#FF9B0E00";
                    }
                    else
                    {
                        a.col = "#FF5D340C";
                    }
                    MainPage.test.Insert(0, a);


                });




            }
        }