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
function Init-VsDevShell | |
{ | |
# 現在インストールされている Visual Studio の情報を取得するためのコマンドラインツールの存在をチェック | |
$vswherePath = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio" "Installer" "vswhere.exe" | |
if( -not (Test-Path $vswherePath) ){ | |
Write-Error "VisualStudio がインストールされていません" | |
exit 1 | |
} | |
# 特定のバージョンを利用したい場合は、-latest の代わりに -version "[17.0,18.0)" のように特定1バージョンとなるように設定を行う | |
# 複数エディションをインストールしている場合は考慮していないので要注意 |
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; | |
public class IsoImage | |
{ | |
// 固定値(自動判定) | |
private const int mediaBlockSize = 2048; | |
private const long maxSizeDVD = 4488L * 512 * mediaBlockSize; | |
private const long maxSizeCD = 650L * 512 * mediaBlockSize; | |
public string SourceImageFolder { get; set; } |
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; | |
using System.Windows; | |
namespace Tocchann.Interop; | |
public static class NativeMethods | |
{ | |
public static IntPtr GetSafeOwnerWindow( Window? ownerWindow ) | |
{ |
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.Windows; | |
namespace Tocchann; | |
public static class Utilities | |
{ | |
public static Window? GetOwnerWindow() | |
{ | |
var window = default(Window); | |
foreach( Window search in Application.Current.Windows ) | |
{ |
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
int CMyApp::DoMessageBox( LPCTSTR lpszPrompt, UINT nType, UINT nIDPrompt ) | |
{ | |
// アイコンを整理しておく | |
if( (nType & MB_ICONMASK) == 0 ) | |
{ | |
switch( nType & MB_TYPEMASK ) | |
{ | |
case MB_OK: | |
case MB_OKCANCEL: | |
nType |= MB_ICONEXCLAMATION; |
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.Diagnostics; | |
using System.Windows.Input; | |
namespace SimpleMVVM | |
{ | |
public class RelayCommand : ICommand | |
{ | |
private readonly Action<object> execute; | |
private readonly Predicate<object> canExecute; |
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
# StdinPipe.ps1 [-InputObject] <string[]> [-ReqireParam] <string> [[-OptionalParam] <string>] [<CommonParameters>] | |
[CmdletBinding()] | |
param ( | |
[parameter(Mandatory=$true,ValueFromPipeline=$true,HelpMessage="標準入力か引数で受け取るデータ")] | |
[string[]]$InputObject, | |
[parameter(Mandatory=$true,ValueFromPipeline=$false,HelpMessage="必須パラメータ")] | |
[string]$ReqireParam, | |
[parameter(Mandatory=$false,ValueFromPipeline=$false,HelpMessage="オプションパラメータ")] | |
[string]$OptionalParam | |
) |
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 ImageSource CreateThumbnail( stirng filePath, Cube.Pdf.Page page ) | |
{ | |
using( var renderer = new DocumentRenderer( filePath ) ) | |
using( var image = renderer.Render( page, page.Size ) ) | |
using( var stream = new MemoryStream() ) | |
{ | |
image.Save( stream, ImageFormat.png ); | |
stream.Seek( 0, SeekOrigin.Begin ); | |
return BitmapFrame( stream, BitmapCreateOptions.None, BitmapCacheOption.OnLoad ); |
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
class ClassA | |
{ | |
public: | |
static bool IsValidHandle( HANDLE handle ) | |
{ | |
//return handle != INVALID_HANDLE_VALUE; | |
return handle != INVALID_HANDLE_VALUE && handle != nullptr; | |
//return handle != nullptr; | |
} | |
// ハンドルの複製をどうするかは何のハンドルかに依存するのでここでは言及しない |
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
// リソースファイル上はこんな感じで格納 | |
// #define IDB_PNG 12345 | |
// IDB_PNG PNG "res\\png.png" | |
Gdiplus::Bitmap* LoadPngFromResource( HINSTANCE hInst, UINT resID ) | |
{ | |
HRSRC hResInfo = FindResource( hInst, MAKEINTRESOURCE(resID), _T("PNG") ); | |
HGLOBAL hResImage = LoadResource( hModule, hResInfo ); | |
DWORD size = SizeofResource( hModule, hResInfo ); | |
const BYTE* srcImage = static_cast<const BYTE*>( LockResource( hResImage ) ); | |
IStreamPtr ptrStream( SHCreateMemStream( srcImage, size ) ); |
NewerOlder