This file contains hidden or 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
| <Target Name="_removeUnusedWebView2" BeforeTargets="ResolveAssemblyReferences"> | |
| <ItemGroup> | |
| <Reference Remove="@(Reference->WithMetadataValue('FileName', 'Microsoft.Web.WebView2.WinForms'))" Condition="'$(UseWindowsForms)' != 'true'" /> | |
| <Reference Remove="@(Reference->WithMetadataValue('FileName', 'Microsoft.Web.WebView2.Wpf'))" Condition="'$(UseWpf)' != 'true'" /> | |
| </ItemGroup> | |
| </Target> |
This file contains hidden or 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.Net.Sockets; | |
| using System.Text; | |
| // DIの練習として、HTTPクライアントを実装する。 | |
| // DI(Dependency Injection)とは、クラスが必要とする依存関係を外部から注入することで、クラスの柔軟性とテスト容易性を向上させる設計パターンである。 | |
| // この例では、WebFetcherクラスがHTTPプロトコルを使用してウェブページを取得するための依存関係を注入する。 | |
| // WebFetcherはIProtocolに依存しているが、具体的なプロトコルの実装には依存していない。 | |
| // 更に、Http11ProtocolはITransportに依存しているが、具体的なトランスポートの実装には依存していない。 | |
| // これにより、具体的な実装との結合度が低くなり、柔軟性とテスト容易性が向上する。 |
This file contains hidden or 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
| #define SWAP(a, b) if (arr[a] > arr[b]) { uint8_t tmp = arr[a]; arr[a] = arr[b]; arr[b] = tmp; } | |
| uint8_t Median9(uint8_t arr[9]) { | |
| SWAP(0, 1); | |
| SWAP(1, 2); | |
| SWAP(0, 1); | |
| SWAP(3, 4); | |
| SWAP(4, 5); | |
| SWAP(3, 4); | |
| SWAP(6, 7); |
This file contains hidden or 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
| #define SWAP(a, b) if (arr[a] > arr[b]) { uint8_t tmp = arr[a]; arr[a] = arr[b]; arr[b] = tmp; } | |
| // Sorting network for 9 elements (25 steps) | |
| void SortingNetwork9(uint8_t *arr) { | |
| SWAP(0, 1); | |
| SWAP(3, 4); | |
| SWAP(6, 7); | |
| SWAP(1, 2); | |
| SWAP(4, 5); | |
| SWAP(7, 8); |
This file contains hidden or 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.Diagnostics; | |
| namespace OaktreeLab.Utils.Common { | |
| /// <summary> | |
| /// A lightweight lock wrapper that allows <see cref="SemaphoreSlim"/> to be used with the <c>using</c> pattern. | |
| /// </summary> | |
| [DebuggerStepThrough] | |
| public sealed class SemaphoreSlimLock : IDisposable { | |
| private readonly SemaphoreSlim _semaphore; | |
| private bool _disposed; |
This file contains hidden or 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
| namespace OaktreeLab.Utils.Common { | |
| /// <summary> | |
| /// Synchronous version of IProgress | |
| /// </summary> | |
| /// <typeparam name="T"></typeparam> | |
| public sealed class SynchronousProgress<T> : IProgress<T> { | |
| private readonly SynchronizationContext? _context; | |
| private readonly Action<T> _handler; | |
| public SynchronousProgress( Action<T> handler ) { |
This file contains hidden or 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
| //*********************************************************************** | |
| // WindowsPathChecker | |
| // A simple console application to check | |
| // the validity of paths in the Windows PATH environment variable. | |
| //*********************************************************************** | |
| namespace WindowsPathChecker { | |
| internal class Program { | |
| static void Main( string[] args ) { | |
| // Get the value of the PATH environment variable |
This file contains hidden or 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 Microsoft.UI.Xaml.Controls; | |
| using Windows.Foundation; | |
| namespace OaktreeLab.Utils.WinUI3 { | |
| /// <summary> | |
| /// Class that provides extension methods for TextBox. | |
| /// </summary> | |
| public static class TextBoxExtensions { | |
| /// <summary> | |
| /// Gets the rectangle of the caret in the TextBox. |
This file contains hidden or 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 OaktreeLab.Utils { | |
| internal class DisplayHelper { | |
| public static uint GetRefreshRate( IntPtr hWnd ) { | |
| IntPtr hmonitor = MonitorFromWindow( hWnd, MONITOR_DEFAULTTONEAREST ); | |
| MONITORINFOEXW monitorInfo = new MONITORINFOEXW(); | |
| monitorInfo.cbSize = (uint)Marshal.SizeOf<MONITORINFOEXW>(); | |
| GetMonitorInfoW( hmonitor, ref monitorInfo ); |
NewerOlder