Skip to content

Instantly share code, notes, and snippets.

View tkouba's full-sized avatar

Tomas Kouba tkouba

  • Prague, Czech Republic
View GitHub Profile
@tkouba
tkouba / PetaPocoValueConverter.cs
Last active January 9, 2019 00:29
PetaPoco value converters using PetaPoco.ConventionMapper
using System;
using System.Drawing;
namespace PetaPoco
{
/// <summary>
/// Specifies a persistent property value converter.
/// </summary>
[AttributeUsage(AttributeTargets.Property)]
@tkouba
tkouba / InstallClickOnceApp.cs
Created October 18, 2019 06:07 — forked from josheinstein/InstallClickOnceApp.cs
Install ClickOnce application programmatically (C#)
using System;
using System.Collections.Generic;
using System.Deployment.Application;
using System.Linq;
using System.Text;
using System.Threading;
namespace InstallClickOnceApp
{
@tkouba
tkouba / FontImageButtonRenderrer.WPF.cs
Created February 25, 2020 13:24
Xamarin custom button renderrer for buttons with FontImagesource
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Xamarin.Forms;
using Xamarin.Forms.Platform.WPF;
using MyDemo.WPF.Renderers;
@tkouba
tkouba / TrayIconApplicationContext.cs
Created August 27, 2020 10:52
System.Windows.Forms.ApplicationContext enhancement with tray icon and menu.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace MyVpnManager.Base
{
/// <summary>
/// Specifies the contextual information about an application thread with <see cref="Icon"/> and <see cref="ContextMenuStrip"/>
@tkouba
tkouba / Reinstaller.cs
Created September 14, 2020 16:57
ClickOnce application migration tool
/* ClickOnceReinstaller v 1.1.0
* - Author: Tomas Kouba (tomas.kouba@gmail.com)*
* - Changes:
* - add reinstall file extension .txt
* - using log4net
* - migration should be cancelled by user
* - TODO
* - add cancellation message to reinstall.txt file
*
* v 1.0.0
@tkouba
tkouba / MainActivity.cs
Created November 26, 2020 09:09
Show indicator workaround for Xamarin.Forms.PageIs.IsBusy
// Android MainActivity
using Android.App;
using Android.Content.PM;
using Android.OS;
using AndroidHUD; // https://github.com/redth-org/AndHUD
namespace ThemingDemo.Droid
{
[Activity(Label = "ThemingDemo", Icon = "@mipmap/icon", Theme = "@style/MainTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
@tkouba
tkouba / UserDialogsImplWPF.cs
Created November 26, 2020 16:25
Acr.UserDialog WPF implementation preview
namespace Acr.UserDialogs
{
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Input;
using System.Windows.Threading;
using Acr.UserDialogs.Infrastructure;
using SAPXamarinTransporter.WPF.UserDialogs;
using Xamarin.Forms.Platform.WPF.Controls;
@tkouba
tkouba / Extensions.GetAttributeValue.cs
Created January 28, 2021 13:25
Simple get attribute value helper extension
public static TValue GetAttributeValue<TAttribute, TValue>(this Type type, Func<TAttribute, TValue> valueSelector) where TAttribute : Attribute
{
var att = type.GetCustomAttributes(typeof(TAttribute), true).FirstOrDefault() as TAttribute;
if (att != null)
{
return valueSelector(att);
}
return default(TValue);
}
@tkouba
tkouba / LockBitmap.cs
Created February 7, 2016 21:23
Work with bitmap faster in C#, solution for positive and negative stride.
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
namespace ImageHelper
{
@tkouba
tkouba / RSAKeys.cs
Created June 16, 2021 14:50 — forked from therightstuff/RSAKeys.cs
Import and export RSA Keys between C# and PEM format using BouncyCastle
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.OpenSsl;
using Org.BouncyCastle.Security;
using System;
using System.IO;
using System.Security.Cryptography;
namespace MyProject.Data.Encryption
{