Sunday, February 15, 2009

LINQ And Picture

TypeConverter tc = TypeDescriptor.GetConverter(typeof(Bitmap));
Bitmap b = (Bitmap)tc.ConvertFrom(c.Picture);
b.Save(context.Response.OutputStream, ImageFormat.Jpeg);
b.Dispose();

Wednesday, February 11, 2009

Silverligt UploadStringAsync ve Ado.net DataService


        string uri = Application.Current.Host.Source.AbsoluteUri;
        int index = uri.IndexOf("/ClientBin");
        uri = uri.Substring(0, index);
        WebClient wc = new WebClient();
        wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
        var query = "ad=" + txtAd.Text + "&soyad=" + txtSoyad.Text;
        wc.UploadStringAsync(new Uri(uri + "/Default.aspx"), query);
        wc.UploadStringCompleted += new UploadStringCompletedEventHandler(wc_UploadStringCompleted);

Monday, February 9, 2009

This collection already contains an address with scheme http. There can be at most one address per scheme in this collection

<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
    <baseAddressPrefixFilters>
        <add prefix="http://www.blabla.com/"/>
    </baseAddressPrefixFilters>
</serviceHostingEnvironment>

You encounter this error in the web.config file and enter the above code in the part.

Wednesday, February 4, 2009

Silverlight and Cookie

DateTime expiration = DateTime.Now.AddDays(5);
string cookie = string.Format("ad={0};expires={1}", txtCookie.Text, expiration.ToString("R"));
HtmlPage.Document.SetProperty("cookie", cookie);

Read All Cookies in Silverlight

var cooks = HtmlPage.Document.Cookies.Split(';');
foreach (var s in cooks)
{
    cook = s.Split('=');
    MessageBox.Show(cook[1]);
}

This also can easily access cookies by asp.net.

SilverLight And Double Click


Normally, double-click does not exist in Silverlight.But within a period of time after you press the left button pressing the left button  double click event in a more duration 300 ms.


public partial class Page : UserControl
    {
        DispatcherTimer timer;
        public Page()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(Page_Loaded);
        }

        void Page_Loaded(object sender, RoutedEventArgs e)
        {
            timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromMilliseconds(300);
            timer.Tick += new EventHandler(timer_Tick);
        }

        void timer_Tick(object sender, EventArgs e)
        {
            timer.Stop();
        }

        private void Image_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            if (timer.IsEnabled)
            {
                MessageBox.Show("Double Clicked.");
            }
            else
            {
                timer.Start();
            }
        }
    }

Sunday, February 1, 2009

Sql Server Read An External Scheme and Create

declare @schema xml
select @schema=c from openrowset(bulk 'c:\data.xsd',single_blob) as temp(c)
create xml schema collection DataSchema as @schema