public static SerializableMemoryStream FromImage(Image image)
        {
            SerializableMemoryStream ret = new SerializableMemoryStream();

            image.Save(ret, image.RawFormat);
            return(ret);
        }
Exemplo n.º 2
0
        internal void CreateDefaultDisplayImage(SerializableMemoryStream sms)
        {
            if (sms == null)
            {
                sms = new SerializableMemoryStream();
                Image msnpsharpDefaultImage = Properties.Resources.MSNPSharp_logo.Clone() as Image;
                msnpsharpDefaultImage.Save(sms, msnpsharpDefaultImage.RawFormat);
            }

            DisplayImage displayImage = new DisplayImage(Account.ToLowerInvariant(), sms);

            this.DisplayImage = displayImage;
        }
 public static SerializableMemoryStream FromImage(Image image)
 {
     SerializableMemoryStream ret = new SerializableMemoryStream();
     image.Save(ret, image.RawFormat);
     return ret;
 }
Exemplo n.º 4
0
        internal void SyncUserTile(string usertitleURL, bool syncToOwner, GetUsertitleByURLhandler callBackHandler, GetUsertitleByURLhandler errorHandler)
        {
            try
            {
                Uri uri = new Uri(usertitleURL);

                HttpWebRequest fwr = (HttpWebRequest)WebRequest.Create(uri);
                NSMessageHandler.ConnectivitySettings.SetupWebRequest(fwr);
                fwr.Timeout = 30000;
                fwr.BeginGetResponse(delegate(IAsyncResult result)
                {
                    try
                    {
                        Stream stream = ((WebRequest)result.AsyncState).EndGetResponse(result).GetResponseStream();
                        SerializableMemoryStream ms = new SerializableMemoryStream();
                        byte[] data = new byte[8192];
                        int read;
                        while ((read = stream.Read(data, 0, data.Length)) > 0)
                        {
                            ms.Write(data, 0, read);
                        }
                        stream.Close();

                        if (syncToOwner)
                        {
                            DisplayImage newDisplayImage = new DisplayImage(NSMessageHandler.Owner.Account.ToLowerInvariant(), ms);

                            NSMessageHandler.Owner.DisplayImage = newDisplayImage;
                        }

                        if (callBackHandler != null)
                        {
                            callBackHandler(ms);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (errorHandler != null)
                            errorHandler(ex);

                        return;
                    }

                }, fwr);
            }
            catch (Exception e)
            {
                if (errorHandler != null)
                    errorHandler(e);

                return;
            }
        }