コード例 #1
0
        private void OnDialogSelected(object sender, DialogModel model)
        {
            InputPeer inputPeer = null;

            if (!(model is DialogModelPlain))
            {
                return;
            }

            DialogModelPlain dmp = (DialogModelPlain)model;

            if (fromMedia == 1)
            {
                MessageMedia media = MediaTransitionHelper.Instance.Media;

                InputMedia im = null;
                if (media.Constructor == Constructor.messageMediaPhoto)
                {
                    MessageMediaPhotoConstructor mmpc = (MessageMediaPhotoConstructor)media;
                    InputPhoto ip = TL.inputPhoto(((PhotoConstructor)mmpc.photo).id, ((PhotoConstructor)mmpc.photo).access_hash);

                    im = TL.inputMediaPhoto(ip);
                }
                else if (media.Constructor == Constructor.messageMediaVideo)
                {
                    MessageMediaVideoConstructor mmvc = (MessageMediaVideoConstructor)media;
                    InputVideo iv = TL.inputVideo(((VideoConstructor)mmvc.video).id, ((VideoConstructor)mmvc.video).access_hash);

                    im = TL.inputMediaVideo(iv);
                }
                else if (media.Constructor == Constructor.messageMediaGeo)
                {
                    MessageMediaGeoConstructor mmgc = (MessageMediaGeoConstructor)media;
                    GeoPointConstructor        gpc  = (GeoPointConstructor)mmgc.geo;

                    InputGeoPoint point = TL.inputGeoPoint(gpc.lat, gpc.lng);
                    im = TL.inputMediaGeoPoint(point);
                }

                if (im != null)
                {
                    dmp.SendMedia(im);
                    NavigationService.GoBack();
                }

                return;
            }

            if (messageId.Count == 0)
            {
                logger.error("error forwarding, no messageId");
            }

            Peer peer = model.Peer;

            if (model.IsChat)
            {
                inputPeer = TL.inputPeerChat(((PeerChatConstructor)peer).chat_id);
            }
            else
            {
                inputPeer = TL.inputPeerContact(((PeerUserConstructor)peer).user_id);
            }

            DoForwardMessages(inputPeer);

            int modelId = TelegramSession.Instance.Dialogs.Model.Dialogs.IndexOf(model);

            NavigationService.Navigate(new Uri("/UI/Pages/DialogPage.xaml?modelId=" + modelId, UriKind.Relative));
        }