Skip to content

Instantly share code, notes, and snippets.

View dkalamari's full-sized avatar

Dino Kalamari dkalamari

  • Međimurje IPC d.d.
  • Čakovec, Croatia
View GitHub Profile
@dkalamari
dkalamari / Cross thread UI
Created May 7, 2013 10:07
Ažuriranje elementa forme iz druge dretve
this.Dispatcher.Invoke((Action)(() =>
{
//Code
}));
//OR
this.Dispatcher.BeginInvoke(new Action(() => {METHOD(ARGS)}));
@dkalamari
dkalamari / Shallow copy
Created May 7, 2013 10:47
Shallow copy
public class Korisnik
{
public string Ime { get; set; }
public string Prezime { get; set; }
public int oib { get; set; }
public Korisnik getShallow()
{
return (Korisnik)this.MemberwiseClone();
}
}
@dkalamari
dkalamari / Deep copy.cs
Last active December 17, 2015 01:58
Deep copy
public clsDeep CreateDeepCopy(clsDeep inputcls)
{
MemoryStream m = new MemoryStream();
BinaryFormatter b = new BinaryFormatter();
b.Serialize(m, inputcls);
m.Position = 0;
return (clsDeep)b.Deserialize(m);
}
//USE
@dkalamari
dkalamari / App working directory
Last active June 28, 2018 10:11
Current app folder
Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
//OR
Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)
@dkalamari
dkalamari / gist:5612067
Created May 20, 2013 12:57
Update UI control from 2. thread
//Control.Invoke: Executes on the UI thread, but calling thread waits for completion before continuing.
//Control.BeginInvoke: Executes on the UI thread, and calling thread doesn't wait for completion.
//Normally every BeginXXX should have a corresponding EndXXX call, usually in the callback.
public void updateGuiFromWorkerThread(String message, Color color)
{
Invoke(new StatusEventHandler(UpdateUI), new StatusArguments(message, color));
}
private void UpdateUI(StatusArguments e)
@dkalamari
dkalamari / gist:5625732
Last active December 17, 2015 14:39
ORACLE Insert & select datetime
INSERT INTO TEST_TABLE_2013 (DATUM,ID) VALUES (TO_DATE('22.05.2013 08:56:12', 'DD.MM.YYYY hh24:mi:ss'), 'ASD111')
/*SELECT*/
select to_char(datum,'DD.MM.YYYY. hh24:mi:ss') dat, id, rfid, geo_d, geo_s from TEST_TABLICA_2013 order by dat desc
@dkalamari
dkalamari / gist:5625954
Last active December 17, 2015 14:39
C# current datetime formated
DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss")
//22.05.2013 08:56:12
@dkalamari
dkalamari / gist:5626073
Last active December 17, 2015 14:39
Start thread with multiple arguments
var t = new Thread(() => SaljiPodatke(BarCode, lastRFID, Longitude, Latitude));
t.Start();
@dkalamari
dkalamari / gist:5633134
Created May 23, 2013 06:38
Write TXT file
using (StreamWriter outfile = new StreamWriter("TxtFile.txt", true))
{
outfile.WriteLine("Test" + Environment.NewLine + "2. row");
}
@dkalamari
dkalamari / gist:5633172
Created May 23, 2013 06:53
C# array custom sort
class ComparerGeneric : IComparer<Customer>
{
#region IComparer<Customer> Members
public int Compare(Customer x, Customer y)
{
return x.Name.CompareTo(y.Name);
}
#endregion
}