Skip to content

Instantly share code, notes, and snippets.

View zacktian89's full-sized avatar

Zack Fair zacktian89

View GitHub Profile
@zacktian89
zacktian89 / gist:6401966
Last active December 22, 2015 02:18 — forked from bgrins/gist:1789787
http multipart post c#
// Implements multipart/form-data POST in C# http://www.ietf.org/rfc/rfc2388.txt
// http://www.briangrinstead.com/blog/multipart-form-post-in-c
public static class FormUpload
{
private static readonly Encoding encoding = Encoding.UTF8;
public static HttpWebResponse MultipartFormDataPost(string postUrl, string userAgent, Dictionary<string, object> postParameters)
{
string formDataBoundary = String.Format("----------{0:N}", Guid.NewGuid());
string contentType = "multipart/form-data; boundary=" + formDataBoundary;
using Microsoft.Phone.Controls;
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
namespace Ocell.Controls
@zacktian89
zacktian89 / HideWhenTextEmpty.cs
Created September 2, 2013 14:06
In wp7 if the textblock's text content is empty and the height is set to auto,when layout the height of this textblock will be zero. but in WP8 Is different.the HideWhenTextEmpty fix the layout problem.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Interactivity;
namespace RenRen.WPOfficial.Client.Shared.Behavior
{
public class HideWhenTextEmpty : Behavior<TextBlock>
{
protected override void OnAttached()
{
@zacktian89
zacktian89 / gist:6422225
Created September 3, 2013 10:33
IRandomAccessStream to Byte Array
var reader = new DataReader(myMemoryStream.GetInputStreamAt(0));
var bytes = new byte[myMemoryStream.Size];
await reader.LoadAsync((uint)myMemoryStream.Size);
reader.ReadBytes(bytes);
@zacktian89
zacktian89 / gist:6432535
Created September 4, 2013 03:39
int array to byte array in C#
byte[] result = new byte[intArray.Length * sizeof(int)];
Buffer.BlockCopy(intArray, 0, result, 0, result.Length);
@zacktian89
zacktian89 / DataTempleteSelector.cs
Created October 10, 2013 03:35
Windowsphone DatatempleteSelector
using System.Windows;
using System.Windows.Controls;
namespace MeituanWP8.Controls.CustomControl {
public abstract class DataTemplateSelector : ContentControl {
public virtual DataTemplate SelectTemplate(object item, DependencyObject container) {
return null;
}
protected override void OnContentChanged(object oldContent, object newContent) {
@zacktian89
zacktian89 / Feedback.cs
Created October 12, 2013 03:57
Json.net custom PropertyName
[JsonProperty(PropertyName = "id")]
public long Id { get; set; }
@zacktian89
zacktian89 / MTLonglistselector.cs
Last active December 25, 2015 15:39
LLS with datarequest
using System;
using System.Windows;
using Microsoft.Phone.Controls;
namespace Sample.Controls {
public class MTLonglistselector : LongListSelector {
public MTLonglistselector() {
ItemRealized += OnItemRealized;
}
@zacktian89
zacktian89 / Style.xaml
Created October 16, 2013 02:09
Change WPToolkit rating control color
<Style x:Key="RatingStyle" TargetType="toolkit:Rating">
<Setter Property="AllowHalfItemIncrement" Value="True" />
<Setter Property="Width" Value="100" />
<Setter Property="Height" Value="20" />
<Setter Property="FilledItemStyle">
<Setter.Value>
<Style TargetType="toolkit:RatingItem">
<Setter Property="Background"
Value="#FF9900" />
</Style>
@zacktian89
zacktian89 / Jsonparse
Created November 7, 2013 03:31
json parse
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.IsolatedStorage;
using System.Linq;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Threading.Tasks;
namespace Edooon.Model