This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static string ExtractIpAddress(this string input) => string.Join("", Regex.Matches(input, @"[\d\.]+")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Windows; | |
using System.Windows.Media; | |
using System.Windows.Media.Imaging; | |
using SamNolan.Emoji.WPF; //Remeber to get this from nuget | |
public static class CustomIconHelper | |
{ | |
public static ImageSource CreateCustomIcon(Color ledColor, double reflectionOpacity = 0, string imageResourceName = "") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void SetImageSourceFromResource() | |
{ | |
try | |
{ | |
// Replace "YourNamespace" with the namespace where the image resource is located | |
Uri imageUri = new Uri("pack://application:,,,/YourNamespace;component/MyImage.png"); | |
// Create a BitmapImage and set it as the source for the Image control | |
BitmapImage bitmapImage = new BitmapImage(imageUri); | |
myImageControl.Source = bitmapImage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private float getTextSize(string text) | |
{ | |
Font font = new Font("Courier New", 10.0F); | |
Image fakeImage = new Bitmap(1, 1); | |
Graphics graphics = Graphics.FromImage(fakeImage); | |
SizeF size = graphics.MeasureString(text, font); | |
return size.Width; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static async Task<string> HashOf(string filename, int chunkSizeInMb) | |
{ | |
var returnMd5 = string.Empty; | |
var chunkSize = chunkSizeInMb * 1024 * 1024; | |
await Task.Run(() => | |
{ | |
using (var crypto = new System.Security.Cryptography.MD5CryptoServiceProvider()) | |
{ | |
var hashLength = crypto.HashSize / 8; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
Queue<T> queue = new Queue<T>(); | |
T result; | |
result = queue.ElementAt(2); | |
result = queue.ElementAtOrDefault(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------------------------------- | |
// <copyright file="TextBlockExtension.cs" > | |
// This file is part of the MyS3Uploader distribution | |
// | |
// Copyright (c) 2022 | |
// | |
// This program is distributed WITHOUT ANY WARRANTY; without even the implied | |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
// </copyright> | |
// <summary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Linq; | |
using System.Security.Cryptography; | |
using System.Text; | |
namespace SearchIdentityExample.Models { | |
public static class StringCipher | |
{ | |
// This constant is used to determine the keysize of the encryption algorithm in bits. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Runtime.InteropServices; | |
namespace BrutalDev.Helpers | |
{ | |
public static class NativeMethods | |
{ | |
// Used to check if the screen saver is running | |
[DllImport("user32.dll", CharSet = CharSet.Auto)] | |
[return: MarshalAs(UnmanagedType.Bool)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GetBaseUrl() | |
{ | |
var appUrl = HttpRuntime.AppDomainAppVirtualPath; | |
return $"{Request?.Url.Scheme}://{Request?.Url.Authority}/{appUrl.TrimStart('/')}"; | |
} |
NewerOlder