void NextStep() { next.IsEnabled = false; ++currentStep; switch (currentStep) { case 0: pageTransition.TransitionType = Transitions.PageTransitionType.GrowAndFade; var step0 = new Step0(); next.IsEnabled = true; pageTransition.ShowPage(step0); break; case 1: pageTransition.TransitionType = Transitions.PageTransitionType.SlideAndFade; var step1 = new Step1(); step1.Success += OnSuccess; pageTransition.ShowPage(step1); break; case 2: var step2 = new Step2(); step2.Success += OnSuccess; pageTransition.ShowPage(step2); break; case 3: Telestat.CancelGetDialogs(); var step3 = new Step3(); step3.Success += OnSuccess; step3.Failure += OnFailure; pageTransition.ShowPage(step3); break; case 4: var step4 = new Step4(); pageTransition.ShowPage(step4); break; } }
public static async Task <Msg> BuildMessage(MessageConstructor msg) { var id = msg.id; LC s = msg.from_id.HasValue ? await Telestat.GetContact(msg.from_id.Value) : null; var sender = s != null ? s.FullName : string.Empty; var content = msg.message; var forwarded = string.Empty; if (msg.fwd_from_id != null) { var contact = await Telestat.GetContact(msg.fwd_from_id); forwarded = contact == null ? "Unknown" : contact.FullName; } var replyTo = msg.reply_to_msg_id.HasValue ? msg.reply_to_msg_id.Value : -1; var date = msg.date; var mediaType = ""; var mediaName = ""; InputFileLocation mediaIfl = null; if (msg.media is MessageMediaEmptyConstructor) { var m = (MessageMediaEmptyConstructor)msg.media; } else if (msg.media is MessageMediaPhotoConstructor) { var m = (MessageMediaPhotoConstructor)msg.media; content = m.caption; if (m.photo is PhotoConstructor) { var p = (PhotoConstructor)m.photo; // Should be largest var loc = ((PhotoSizeConstructor)p.sizes[p.sizes.Count - 1]).location; if (loc is FileLocationConstructor) { var l = (FileLocationConstructor)loc; mediaType = "photo"; mediaName = l.local_id + ".jpg"; mediaIfl = new InputFileLocationConstructor(l.volume_id, l.local_id, l.secret); } } } else if (msg.media is MessageMediaVideoConstructor) { var m = (MessageMediaVideoConstructor)msg.media; content = m.caption; if (m.video is VideoConstructor) { var v = (VideoConstructor)m.video; mediaType = "video"; mediaName = v.id + ".mp4"; // i guess, may not be mp4 mediaIfl = new InputVideoFileLocationConstructor(v.id, v.access_hash); } } else if (msg.media is MessageMediaGeoConstructor) { var m = (MessageMediaGeoConstructor)msg.media; // TODO implement } else if (msg.media is MessageMediaContactConstructor) { var m = (MessageMediaContactConstructor)msg.media; // TODO implement } else if (msg.media is MessageMediaUnsupportedConstructor) { var m = (MessageMediaUnsupportedConstructor)msg.media; // TODO implement } else if (msg.media is MessageMediaDocumentConstructor) { var m = (MessageMediaDocumentConstructor)msg.media; if (m.document is DocumentConstructor) { var d = (DocumentConstructor)m.document; mediaType = "document"; foreach (var atr in d.attributes) { if (atr is DocumentAttributeFilenameConstructor) { var a = (DocumentAttributeFilenameConstructor)atr; mediaName = d.id.ToString() + "_" + a.file_name; break; } } if (string.IsNullOrEmpty(mediaName)) { mediaName = d.id.ToString(); } mediaIfl = new InputDocumentFileLocationConstructor(d.id, d.access_hash); } } else if (msg.media is MessageMediaAudioConstructor) { var m = (MessageMediaAudioConstructor)msg.media; if (m.audio is AudioConstructor) { var a = (AudioConstructor)m.audio; mediaType = "audio"; var spl = a.mime_type.Split('/'); if (spl.Length > 1) { mediaName = a.id.ToString() + "." + spl[1]; } else { mediaName = a.id.ToString() + ".mp3"; // TODO it probs isn't mp3, but well! } mediaIfl = new InputAudioFileLocationConstructor(a.id, a.access_hash); } } else if (msg.media is MessageMediaWebPageConstructor) { var m = (MessageMediaWebPageConstructor)msg.media; // TODO implement } else if (msg.media is MessageMediaVenueConstructor) { var m = (MessageMediaVenueConstructor)msg.media; // TODO implement } var self = s != null ? s.Self : false; return(new Msg( id, sender, content, date, self, string.Empty, forwarded, replyTo, mediaType, mediaName, mediaIfl)); }