Beispiel #1
0
        protected override void OnNavigatedTo(NavigationEventArgs args)
        {
            IDictionary <string, string> parameters = this.NavigationContext.QueryString;

            if (parameters.ContainsKey("UID"))
            {
                this.UID      = parameters["UID"];
                this.UserName = parameters["Name"].ToUpper();
                this.NotifyPropertyChanged("UID");
                this.Items = App.MainPageData.GetMessage(this.UID);
                this.NotifyPropertyChanged("Items");
                this.NotifyPropertyChanged("UserName");
                this.online = App.MainPageData.GetOnline(this.UID);
                this.NotifyPropertyChanged("OnlineVisibility");
                if (parameters.ContainsKey("mid"))
                {
                    scrollToMessage = App.MainPageData.GetMessageByMid(parameters["mid"]);
                    this.Mid        = parameters["mid"];
                    this.MarkMessagesAsRead();
                }
                this.MarkMessagesAsRead();
            }
            if (parameters.ContainsKey("ClearBackStack"))
            {
                NavigationService.RemoveBackEntry();
            }
            this.NumberOfAttachments = App.Attachments.Count;
            //this.NotifyPropertyChanged("ManageAttachmentsVisibility");
            //this.NotifyPropertyChanged("ImageIconVisibility");
            //this.NotifyPropertyChanged("ManageAttachmentsIconUri");
            base.OnNavigatedTo(args);
        }
Beispiel #2
0
        public void GetMessage(string mid, CallBack onSuccess, CallBack onError)
        {
            if (!this.connected)
            {
                return;
            }
            var    access_token = this.access_token;
            string URL          = "https://api.vk.com/method/messages.getById";
            Dictionary <string, string> sendData = new Dictionary <string, string>();

            sendData.Add("access_token", access_token);
            sendData.Add("mid", mid);
            this.GetQuery(URL, sendData, result =>
            {
                var responseString = (string)result;
                Newtonsoft.Json.Linq.JObject obj = Newtonsoft.Json.Linq.JObject.Parse(responseString);

                if (obj["response"] != null)
                {
                    obj["response"].First.Remove();
                    VKMessageModel[] messages = obj["response"].ToObject <VKMessageModel[]>();
                    VKMessageModel message    = messages[0];
                    List <object> retVal      = new List <object>();
                    message.fwd_messages      = ParseFwdMessages(message.fwd_messages, retVal);
                    onSuccess(new VKMessageModel[] { message });
                }
                else
                {
                    onError(new object());
                }
            }, onError);
        }
Beispiel #3
0
        private void ResendItem_Click(object sender, RoutedEventArgs e)
        {
            VKMessageModel message     = (sender as MenuItem).DataContext as VKMessageModel;
            var            destination = "/Views/FriendsCheck.xaml";

            destination += string.Format("?mids={0}", message.mid);
            NavigationService.Navigate(new Uri(destination, UriKind.Relative));
        }
Beispiel #4
0
 void OnPageLoaded(object sender, RoutedEventArgs e)
 {
     Dispatcher.BeginInvoke(() =>
     {
         this.ListMessages.ScrollIntoView(scrollToMessage);
         ListBoxItem listBoxItem = (ListBoxItem)this.ListMessages.ItemContainerGenerator.ContainerFromItem(scrollToMessage);
         scrollToMessage         = null;
     });
 }
Beispiel #5
0
        private void RemoveItem_Click(object sender, RoutedEventArgs e)
        {
            VKMessageModel message = (sender as MenuItem).DataContext as VKMessageModel;

            App.VK.DeleteMessages(
                message.mid,
                res => Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                App.MainPageData.RemoveMessage(message);
                this.Items = App.MainPageData.GetMessage(this.UID);
                NotifyPropertyChanged("Items");
            }),
                err =>
            {
            });
        }
Beispiel #6
0
        protected override void OnContentChanged(object oldContent, object newContent)
        {
            var phoneThemeBrush       = (SolidColorBrush)Resources["PhoneAccentBrush"];
            var darkenPhoneColorBrush = Darken(phoneThemeBrush.Color, 0.2).ToString();

            base.OnContentChanged(oldContent, newContent);
            VKMessageModel message = newContent as VKMessageModel;
            string         xaml    =
                "<DataTemplate xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' " +
                "xmlns:contribControls='clr-namespace:WP7Contrib.View.Controls;assembly=WP7Contrib.View.Controls' " +
                "xmlns:src='clr-namespace:Templates;assembly=Templates'>";

            if (message.type == "0")
            {   //YouTemplate
                xaml += "<Grid Margin='5, 0, 65, 10' contribControls:GridUtils.RowDefinitions='Auto,Auto,Auto' contribControls:GridUtils.ColumnDefinitions='*,Auto' Width='385' >" +
                        "<Path Data='m 0,0 l 0,12 l 12,0 l -12,-12' Fill='{StaticResource PhoneAccentBrush}' " +
                        "Margin='5,0,0,0' HorizontalAlignment='Left' Grid.Row='0'  Grid.Column='0'/>" +
                        "<Rectangle Fill='{StaticResource PhoneAccentBrush}' Grid.Row='1' Grid.RowSpan='2' Grid.Column='0'/>" +
                        "<StackPanel Grid.Row='1' Grid.Column='0' Orientation='Vertical'>" +
                        "<TextBlock Text='{Binding Path=Message}' HorizontalAlignment='Left' TextWrapping='Wrap' " +
                        "Margin='10,5,10,0'/>";
                if (message.attachment != null && message.attachment.type == "photo")
                {
                    foreach (var attachment in message.attachments)
                    {
                        //xaml += "<Image Source='{Binding Path=attachment.photo.src_big}' Margin='10' Stretch='Uniform'/>";
                        xaml += "<Image Source='" + attachment.photo.src_big + "' Margin='10' Stretch='Uniform'/>";
                    }
                }
                if (message.attachment != null && message.attachment.type == "audio")
                {
                    foreach (var attachment in message.attachments)
                    {
                        xaml += "<src:AudioTemplate Source='" + attachment.audio.url + "' Performer='" + attachment.audio.performer + "' Title='" + attachment.audio.title + "'/>";
                    }
                }
                if (message.fwd_messages != null)
                {
                    foreach (Dictionary <string, string> fwdmsg in message.fwd_messages)
                    {
                        xaml += "<TextBlock Style = '{StaticResource PhoneTextSubtleStyle}' Margin='11,0,0,0' Text='" + Localization.AppResources.ForwardedMessage + "'/>" +
                                "<Grid> " +
                                "<Grid.ColumnDefinitions>" +
                                "<ColumnDefinition Width='Auto'/>" +
                                "<ColumnDefinition Width='Auto'/>" +
                                "<ColumnDefinition Width='*'/>" +
                                "</Grid.ColumnDefinitions>" +
                                "<Path Grid.Column='0' Stretch='Fill' Stroke='Black' StrokeThickness='3' Opacity='0.6'  Width='22' Height='45' Data='M0,0 L0,1' />" +
                                "<Image Margin='0,0,10,0' Grid.Column='1' Width='40' Height='40' HorizontalAlignment='Left' Source='" + App.MainPageData.GetPhoto(fwdmsg["uid"]) + "'/>" +
                                "<Grid Grid.Column='2'>" +
                                "<Grid.RowDefinitions>" +
                                "<RowDefinition Height='Auto'/>" +
                                "<RowDefinition Height='*'/>" +
                                "</Grid.RowDefinitions>" +
                                "<StackPanel Grid.Row='0' Orientation='Horizontal'>" +
                                "<TextBlock Text='" + App.MainPageData.GetName(fwdmsg["uid"]) + "'/>" +
                                "<TextBlock Style = '{StaticResource PhoneTextSubtleStyle}' Margin='7,0,0,0' Text='" + fwdmsg["date"].ParseDate() + "'/>" +
                                "</StackPanel>" +
                                "<TextBlock Grid.Row='1' Text='" + fwdmsg["body"] + "'/>" +
                                "</Grid>" +
                                "</Grid>";
                    }
                }
                xaml +=
                    "</StackPanel>" +
                    "<TextBlock Style = '{StaticResource PhoneTextSubtleStyle}' Text='{Binding Path=Date}' HorizontalAlignment='Right' " +
                    "Margin='10,0,10,5' Grid.Row='2' Grid.Column='0'/>" +
                    "<CheckBox  IsEnabled='False'  Style='{StaticResource CheckBoxStyle1}' Visibility='{Binding Path=Checked}' IsChecked='{Binding Path=Checked}' Grid.Column='1' Grid.Row='1' Grid.RowSpan='2'/>" +
                    "</Grid>";
            }
            else
            {   //MeTemplate
                xaml += "<Grid Margin='65, 10, 5, 0' contribControls:GridUtils.RowDefinitions=',,' contribControls:GridUtils.ColumnDefinitions='Auto,*' Width='385' >" +
                        "<Rectangle Fill='" + darkenPhoneColorBrush + "' Grid.Row='0' Grid.RowSpan='2'  Grid.Column='1'/>" +
                        "<StackPanel Grid.Row='0' Grid.Column='1' Orientation='Vertical'>" +
                        "<TextBlock Text='{Binding Path=Message}' HorizontalAlignment='Left' TextWrapping='Wrap' " +
                        "Margin='10,5,10,0'/>";
                //if (message.attachment != null && message.attachment.type == "photo")
                //    xaml +=     "<Image Source='{Binding Path=attachment.photo.src_big}' Margin='10' Stretch='Uniform'/>";
                if (message.attachment != null && message.attachment.type == "photo")
                {
                    foreach (var attachment in message.attachments)
                    {
                        xaml += "<Image Source='" + attachment.photo.src_big + "' Margin='10' Stretch='Uniform'/>";
                    }
                }
                if (message.attachment != null && message.attachment.type == "audio")
                {
                    xaml += "<src:AudioTemplate Source='" + message.attachment.audio.url + "' Performer='" + message.attachment.audio.performer + "' Title='" + message.attachment.audio.title + "'/>";
                }
                if (message.fwd_messages != null)
                {
                    foreach (Dictionary <string, string> fwdmsg in message.fwd_messages)
                    {
                        xaml += "<TextBlock Style = '{StaticResource PhoneTextSubtleStyle}' Margin='11,0,0,0' Text='" + Localization.AppResources.ForwardedMessage + "'/>" +
                                "<Grid> " +
                                "<Grid.ColumnDefinitions>" +
                                "<ColumnDefinition Width='Auto'/>" +
                                "<ColumnDefinition Width='Auto'/>" +
                                "<ColumnDefinition Width='*'/>" +
                                "</Grid.ColumnDefinitions>" +
                                "<Path Grid.Column='0' Stretch='Fill' Stroke='Black' StrokeThickness='3' Opacity='0.6'  Width='22' Height='45' Data='M0,0 L0,1' />" +
                                "<Image Margin='0,0,10,0' Grid.Column='1' Width='40' Height='40' HorizontalAlignment='Left' Source='" + App.MainPageData.GetPhoto(fwdmsg["uid"]) + "'/>" +
                                "<Grid Grid.Column='2'>" +
                                "<Grid.RowDefinitions>" +
                                "<RowDefinition Height='Auto'/>" +
                                "<RowDefinition Height='*'/>" +
                                "</Grid.RowDefinitions>" +
                                "<StackPanel Grid.Row='0' Orientation='Horizontal'>" +
                                "<TextBlock Text='" + App.MainPageData.GetName(fwdmsg["uid"]) + "'/>" +
                                "<TextBlock Style = '{StaticResource PhoneTextSubtleStyle}' Margin='7,0,0,0' Text='" + fwdmsg["date"].ParseDate() + "'/>" +
                                "</StackPanel>" +
                                "<TextBlock Grid.Row='1' Text='" + fwdmsg["body"] + "'/>" +
                                "</Grid>" +
                                "</Grid>";
                    }
                }
                xaml += "</StackPanel>" +
                        "<TextBlock Style = '{StaticResource PhoneTextSubtleStyle}'  Text='{Binding Path=Date}' HorizontalAlignment='Right' " +
                        "Margin='10,0,10,5' Grid.Row='1' Grid.Column='1'/>" +
                        "<Path Data='m 0,0 l 12,0 l 0,12 l -12,-12' Fill='" + darkenPhoneColorBrush + "' " +
                        "Margin='0,0,5,0' HorizontalAlignment='Right' Grid.Row='2' Grid.Column='1'/>" +
                        "<CheckBox  IsEnabled='False' Style='{StaticResource CheckBoxStyle1}' Visibility='{Binding Path=Checked}' IsChecked='{Binding Path=Checked}' Grid.Column='0' Grid.Row='0' Grid.RowSpan='2'/>" +
                        "</Grid>";
            }
            xaml           += "</DataTemplate>";
            ContentTemplate = (DataTemplate)XamlReader.Load(xaml);
        }
Beispiel #7
0
        private void CopyItem_Click(object sender, RoutedEventArgs e)
        {
            VKMessageModel message = (sender as MenuItem).DataContext as VKMessageModel;

            Clipboard.SetText(message.body);
        }