Wednesday, July 27, 2016

SharePoint "features"

when i searched Pharmaceutical with Pharmaceutica - 0 results

Tuesday, July 26, 2016

Do not call overridable methods in constructors

make the class sealed

seconds to minutes and seconds function

  public static string secondsToMinutes(double secs)
        {
            TimeSpan time = TimeSpan.FromSeconds(secs);
            return time.ToString(@"hh\:mm\:ss").Replace("00:00:","").Replace("00:","")  ;

        }

simple json call from c#

string URL = "http://www.blah.com/";
                    string urlParameters = “?v=1”;
                   

                    HttpClient client = new HttpClient();
                    client.BaseAddress = new Uri(URL);
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    HttpResponseMessage response = client.GetAsync(urlParameters).Result; 
                    if (response.IsSuccessStatusCode)
                    {
                        string dataObjects = response.Content.ReadAsStringAsync().Result;
                        var jss = new JavaScriptSerializer();
                        var dict = jss.Deserialize<Dictionary<string, dynamic>>(dataObjects);

                        foreach (Dictionary<string, object> x in dict["items"])

                        {

using sound in wpf

add wav file as Embedded Resource in file structure for e.g. resources/sounds.blah.wav

var _assembly = Assembly.GetExecutingAssembly();
                SoundPlayer sp = new SoundPlayer(_assembly.GetManifestResourceStream("Blah.Resources.Sounds.Blah.wav"));

                sp.Play();

wpf code upon closing app

public partial class App : Application
    {
        private void Application_Exit(object sender, ExitEventArgs e)
        {
            blah.ShutDown(); 
        }

    }

adding email link to wpf form

<Hyperlink NavigateUri="mailto:blah@blah.net" RequestNavigate="OnNavigate">blah@blah.net</Hyperlink>

private void OnNavigate(object sender, RequestNavigateEventArgs e)
        {
            Process.Start(e.Uri.AbsoluteUri);
            e.Handled = true;

        }