private void avatar_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog fileDialog = new Microsoft.Win32.OpenFileDialog();
            fileDialog.Multiselect = false;
            Nullable <bool> result = fileDialog.ShowDialog();

            if (result.HasValue && result.Value)
            {
                if (this.sipService.IsRegistered && this.sipService.IsXcapEnabled)
                {
                    LOG.Debug("Saving avatar(remote)...");
                    String mimeType  = null;
                    String avatarB64 = this.GetAvatarBase64FromFilePath(fileDialog.FileName, out mimeType);
                    if (!String.IsNullOrEmpty(avatarB64))
                    {
                        // ImageSource will be updated when xcapcallback is received
                        this.xcapService.AvatarPublish(avatarB64, mimeType);
                    }
                }
                else
                {
                    LOG.Debug("Saving avatar(local)...");
                    System.Drawing.Imaging.ImageFormat rawFormat;
                    System.Drawing.Image avatar = this.GetAvatarFromFilePath(fileDialog.FileName, out rawFormat);
                    if (avatar != null)
                    {
                        try
                        {
                            avatar.Save(MainWindow.AVATAR_PATH);
                            this.imageAvatar.Source = MyImageConverter.FromImage(avatar);
                            EventHandlerTrigger.TriggerEvent(this.onAvatarChanded, this, new StringEventArgs(MainWindow.AVATAR_PATH));
                        }
                        catch (Exception ex)
                        {
                            LOG.Error(ex);
                        }
                    }
                }
            }
        }
Example #2
0
 void ItemRunningApp_ValueLoaded(object sender, EventArgs e)
 {
     labelDescription.Text       = this.Value.Description;
     imageIcon.Source            = MyImageConverter.FromImage(this.Value.Icon);
     labelDescription.FontWeight = (this.Value.hWnd == IntPtr.Zero) ? FontWeights.Bold : FontWeights.Normal;
 }