public ProfilePage() { this.Account = ServiceLocator.Current.GetService <Account>(); this.MyViewModel = ServiceLocator.Current.GetService <MyViewModel>(); this.XmppClientEx = ServiceLocator.Current.GetService <XmppClientEx>(); SelectProfileImageCommand = ReactiveCommand.Create(() => { // Wrap the creation of the OpenFileDialog instance in a using statement, // rather than manually calling the Dispose method to ensure proper disposal OpenFileDialog dlg = new OpenFileDialog(); dlg.Title = "Open Image"; dlg.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png,*.gif)|*.BMP;*.JPG;*.JPEG;*.PNG;*.GIF"; if (dlg.ShowDialog() == true) { imgProfile.Source = CreateResizedImage(new BitmapImage(new Uri(dlg.FileName)), 250); // set the tag to null, because we have a custom image now imgProfile.Tag = null; } } ); PublishProfileDataCommand = ReactiveCommand.Create(async() => { byte[] imageBytes = null; if ((string)imgProfile.Tag != "default") { imageBytes = GetJpgBytesFromBitmapSource(imgProfile.Source as BitmapSource); } //await PublishVCard(imageBytes); if (imageBytes != null) { var publishAvatarDataIq = AvatarManager.CreatePublishAvatarDataStanza(this.GetJpgBytesFromBitmapSource(imgProfile.Source as BitmapSource)); var res1 = await this.XmppClientEx.SendIqAsync(publishAvatarDataIq); var publishAvatarMetadataIq = AvatarManager.CreatePublishAvatarMetadataStanza(imageBytes, (int)imgProfile.Source.Height, (int)imgProfile.Source.Height, "image/jpg"); var res2 = await this.XmppClientEx.SendIqAsync(publishAvatarMetadataIq); var publishNickIq = NicknameManager.CreatePublishNicknameStanza(txtNickname.Text); var res3 = await this.XmppClientEx.SendIqAsync(publishNickIq); } } , MyViewModel.IsConnectedObervalble ); InitializeComponent(); }
public void CreatePublishNicknameStanzaTest() { var expectedXml = @"<iq type='set' id='foo' xmlns='jabber:client'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <publish node='http://jabber.org/protocol/nick'> <item> <nick xmlns='http://jabber.org/protocol/nick'>Alex</nick> </item> </publish> </pubsub> </iq>"; var pIq = NicknameManager.CreatePublishNicknameStanza("Alex"); pIq.Id = "foo"; pIq.ShouldBe(expectedXml); }
private void Awake() { Instance = this; }