前回、PathListBoxを使って遊んでみましたが、今回もPathListBoxを使ってみます。
iyemon018.hatenablog.com
カルーセルパネル(Carousel Panel)は、左右にコンテンツをスライドするあれです。
まずはサンプルプログラムの動作を見てみます。
このように複数のコンテンツを無限にスライドし続けることができます。
以下、サンプルソースです。
必要なアセンブリは名前空間は、前回の記事を参照してください。
WPFのコントロールにPathListBoxというものがあります。
これは、通常のItemsControlとは少し異なる動作をします。
百聞は一見にしかず、まずは以下のイメージを御覧ください。
単純な動作ではありますが他のList系コントロールとは明らかに動作が異なります。
このような一風変わったPathListBoxですが、かなり簡単に実装することができます。
PathListBoxには以下のプロパティがあります。
ItemsSourceに設定したコレクション要素の開始インデックスのプロパティです。
例えば"StartItemIndex=2"に設定すると以下の様になります。
このプロパティをtrueにすると、表示範囲外にあるコレクション要素をラップします。
falseにすると、表示範囲外のコレクション要素はラップされずに見切れてしまいます。
ItemsSourceにバインドしたコレクションを配置するためのレイアウト要素を設定することができます。
上記のサンプルでは、赤いPathを作成し、そのPathをLayoutPathsに設定しています。
以下、サンプルのソースです。
PathListBoxを使用するには、以下のアセンブリを参照する必要があります。
Blendを使用すればドラッグアンドドロップで自動的に参照が追加されます。
PathListBoxを参照するには、予め以下の名前空間を追加しておきましょう。
xmlns:ec="http://schemas.microsoft.com/expression/2010/controls"
<Window x:Class="PathListBoxSample.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:ec="http://schemas.microsoft.com/expression/2010/controls" xmlns:local="clr-namespace:PathListBoxSample" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" Title="MainWindow" Width="240" Height="240" mc:Ignorable="d"> <Window.DataContext> <local:MainViewModel /> </Window.DataContext> <Grid> <ec:PathListBox ItemsSource="{Binding Values, Mode=OneWay}" StartItemIndex="2" WrapItems="True"> <ec:PathListBox.LayoutPaths> <ec:LayoutPath SourceElement="{Binding ElementName=path}" /> </ec:PathListBox.LayoutPaths> </ec:PathListBox> <Border> <Path x:Name="path" Margin="47.958,56.296,51.484,48.649" Data="M167.9651,297.05052 C167.1821,300.96551 298.95333,358.22029 298.95333,358.22029 L336.53545,481.93313 501.22995,268.87785 584.51969,339.3325" Stretch="Fill" Stroke="#FFE40000" /> </Border> <Button Width="32" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding AddCommand, Mode=OneWay}" Content="+" /> <Button Width="32" Margin="36,0,0,0" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding SubCommand, Mode=OneWay}" Content="-" /> </Grid> </Window>
namespace PathListBoxSample { using System.Collections.ObjectModel; using System.Linq; using Microsoft.Practices.Prism.Commands; using Microsoft.Practices.Prism.Mvvm; public class MainViewModel : BindableBase { public ObservableCollection<int> Values { get; private set; } public DelegateCommand AddCommand { get; private set; } public DelegateCommand SubCommand { get; private set; } public MainViewModel() { Values = new ObservableCollection<int>(Enumerable.Range(1, 5)); AddCommand = new DelegateCommand(() => Values.Add(Values.Max() + 1)); SubCommand = new DelegateCommand(() => { if (Values.Any()) Values.Remove(Values.Max()); }); } } }
このようにPathListBoxはWPFの中でもかなり特殊なコントロールです。
以下のページにもう少し詳しい使い方が記述されています。
今回作成したサンプルはこちら↓↓↓↓↓
github.com
JenkinsでxUnitを実行したときに少しハマったのでメモメモ。
JenkinsでxUnitを使用している場合、MSTestと同じ方法では実行できません。
xUnitを使用するには、"xunit.runner.console"が必要です。
以下、実行環境です。
NuGetで以下のパッケージを取得します。
Jenkinsのジョブ設定で、ビルドから"Windowsバッチコマンドの実行"を追加して以下のコマンドを入力します。
::過去の結果があれば削除 rmdir /S /Q <レポート出力フォルダ> mkdir <レポート出力フォルダ> ::xUnitは通常のMSTestではなく、以下の方法で実行する必要がある。 cd %WORKSPACE%\packages\xunit.runner.console.2.1.0\tools xunit.console.exe "%WORKSPACE%<ユニットテストプロジェクトDLLパス>" -nunit "%WORKSPACE%<レポート出力フォルダ>\<レポートファイル名>.xml"
"xunit.console.exe"はxUnitをコンソールで実行するための実行ファイルです。
ちなみに、"-?"で以下のようなヘルプが表示されます。
Valid options: -nologo : do not show the copyright message -nocolor : do not output results with colors -noappdomain : do not use app domains to run test code -failskips : convert skipped tests into failures -parallel option : set parallelization based on option : none - turn off all parallelization : collections - only parallelize collections : assemblies - only parallelize assemblies : all - parallelize assemblies & collections -maxthreads count : maximum thread count for collection parallelization : default - run with default (1 thread per CPU thread) : unlimited - run with unbounded thread count : (number) - limit task thread pool size to 'count' -noshadow : do not shadow copy assemblies -wait : wait for input after completion -diagnostics : enable diagnostics messages for all test assemblies -debug : launch the debugger to debug the tests -serialize : serialize all test cases (for diagnostic purposes only) -trait "name=value" : only run tests with matching name/value traits : if specified more than once, acts as an OR operation -notrait "name=value" : do not run tests with matching name/value traits : if specified more than once, acts as an AND operation -method "name" : run a given test method (should be fully specified; : i.e., 'MyNamespace.MyClass.MyTestMethod') : if specified more than once, acts as an OR operation -class "name" : run all methods in a given test class (should be fully : specified; i.e., 'MyNamespace.MyClass') : if specified more than once, acts as an OR operation -namespace "name" : run all methods in a given namespace (i.e., : 'MyNamespace.MySubNamespace') : if specified more than once, acts as an OR operation Reporters: (optional, choose only one) -appveyor : forces AppVeyor CI mode (normally auto-detected) -quiet : do not show progress messages -teamcity : forces TeamCity mode (normally auto-detected) -verbose : show verbose progress messages Result formats: (optional, choose one or more) -xml <filename> : output results to xUnit.net v2 style XML file -xmlv1 <filename> : output results to xUnit.net v1 style XML file -nunit <filename> : output results to NUnit-style XML file -html <filename> : output results to HTML file
Jenkinsには、xUnitでのレポート出力フォーマットに対応していないので、NUnitのフォーマットで出力します。
Publish HTML reportプラグインでレポートを確認したい場合は、HTML出力も追加してもいいかもしれません。
Visual Studio 2012以降、昔ながらのインストーラセットアップ プロジェクトが拡張機能で使用することができます。
(Visual Studio 2010は、Install Shield一択だったのですがあれは何だったのか…)
できればこのあたりもJenkinsで実行できれば、
ということができます。
まずは下準備としてJenkinsを起動しているPCのVisual Studioの拡張機能からインストーラーを追加します。
[ツール] - [拡張機能と更新プログラム]を選択し、オンラインから"install"で検索してインストーラープロジェクトを追加します。
次にレジストリエディタを開いて以下の値を追加します。
"12.0_Config"と言うのは"Visual Studio 2013"の構成情報のことです。
2012の場合は、"11.0_Config"、2015の場合は、"14.0_Config"となっています。
ちなみに、これを追加しないとビルドしても以下のようなメッセージが出力されてインストーラーが作成されません。
(これに結構ハマってました…)
ERROR: An error occurred while validating. HRESULT = '8000000A'
続いてJenkinsの設定です。
ジョブの設定から、"Windowsバッチコマンドの実行"を選択して以下のコマンドを入力します。
:: 開発環境によって実行フォルダを変えてください。 cd C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE devenv "%WORKSPACE%<ソリューションファイルパス>" /Project "%WORKSPACE%<セットアッププロジェクトパス>" /Build "Release"
上記では"Release"モードでビルドしていますが、ここは必要に応じて変更してください。
なお、"devenv.exe"のコマンドライン引数は以下を参照してください。
以前、Jenkinsを使用してNuGetパッケージを復元することができました。
iyemon018.hatenablog.com
今回は独自に作成したNuGetパッケージの復元を行います。
例えば社内で管理しているライブラリの復元も行うことができます。
まずは下準備
1. Jenkins実行ユーザーの"%AppData%\NuGet"フォルダから"NuGet.Config"を参照します。
2. ファイルを開き以下のように変更します。※1.
<?xml version="1.0" encoding="utf-8"?> <configuration> <packageRestore> <add key="enabled" value="True" /> <add key="automatic" value="True" /> </packageRestore> <packageSources> <add key="nuget.org" value="https://www.nuget.org/api/v2/" /> <add key="<独自NuGet>" value="<独自NuGetパッケージ保存パス>" /> </packageSources> <disabledPackageSources /> <activePackageSource> <add key="All" value="(Aggregate source)" /> </activePackageSource> <bindingRedirects> <add key="skip" value="False" /> </bindingRedirects> </configuration>
3. Jenkinsのジョブで"Windowsバッチコマンドの実行"を選択し、以下のコマンドを入力します。
cd "C:\Nuget" nuget.exe restore %WORKSPACE%\<ソリューション ファイル パス>
※1. 以下の方法でもOKです。
1. NuGet.configを別名で保存し、任意のフォルダにコピーします。(内容は上記2.のものを保存します。)
2. Jenkinsのジョブで"Windowsバッチコマンドの実行"を選択肢、以下のコマンドを入力します。
cd "C:\Nuget" nuget.exe restore %WORKSPACE%\<ソリューション ファイル パス> -configfile "<NuGet.configファイルパス>"
(NuGet.exeのコマンドライン引数については以下を参照)
NuGet Command-Line Interface (CLI) Reference | Microsoft Docs
独自NuGetパッケージが共有フォルダに配置されている場合は、アクセス権を持つユーザーで実行する必要があります。
Jenkinsの実行ユーザーを変更するには以下を参照してください。
iyemon018.hatenablog.com