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;

        }

Thursday, July 21, 2016

wpf getting which button was clicked

MouseEventArgs me = (MouseEventArgs)e;

if(me.LeftButton== MouseButtonState.Pressed)  //left

get the control that has the context menu

MenuItem mnu = sender as MenuItem;
      
        if (mnu != null)
        {

            Button button = ((ContextMenu)mnu.Parent).PlacementTarget as Button;

wpf rtb ScrollToEnd not working

this is a workaround


  _textbox.Focus();
                 
                    TextPointer caretPos = _textbox.CaretPosition;
                    caretPos = caretPos.DocumentEnd;
                    _textbox.CaretPosition = caretPos;

Wednesday, July 20, 2016

javascript style brackets

there is an added benefit of doing brackets thusly

blah {
}

instead of

blah
{
}

because with return statements
return
{
x:67,y:679
}

this will return undefined

dont run selected change event on load

i added the events after filling the combo boxes on loading

example of call setting context

x = {name:"george",children:[{name:"herby",age:46},{name:"herby2",age:47} ,{name:"herby6",age:45} ]}
test = function(){
for (i = 0; i < this.children.length; i++) {
    console.log("Name:" + this.children[i].name + " age:" + this.children[i].age);
}
}
test.call(x);

 Name:herby age:46
 Name:herby2 age:47
 Name:herby6 age:45


btw - what is output when the data is thus
{name:"george",children:[{name:"herby",age:46},{name:"herby",age:46} ,{name:"herby",age:46} ]}

multiple lines in console

shift + enter

Simple example of closure


s= function(r){
i=89;
return function(){
return i * r;
}
}
s(10)();

Wednesday, July 6, 2016

reset certificates for fiddler

since i cleared the cache I get all sorts of errors so I needed to do this