Ref: https://docs.microsoft.com/zh-tw/aspnet/core/security/enforcing-ssl?view=aspnetcore-2.1&tabs=visual-studio
1. ASUS X450J @ Windows 10 x64
2. Visual Studio 2017 (dotnet --version 2.1.403)
3. IP: 192.168.1.108
//-------------
4. dotnet new web -o https1 // create server template
5. Program.cs
// add .UseUrls("http://192.168.1.108:5000/", "https://192.168.1.108:5001/")
6. Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc(); // Add
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
/* ----------------------
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
-------------------------------*/
// Ref: https://docs.microsoft.com/zh-tw/aspnet/core/security/enforcing-ssl?view=aspnetcore-2.1&tabs=visual-studio
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseCookiePolicy();
app.UseMvc();
}
7. dotnet run // Testing
2018年11月26日 星期一
2018年11月25日 星期日
WPF Webcam (nuget WPF-MediaKit)
Ref: https://github.com/Sascha-L/WPF-MediaKit/
1. ASUS X450J @ Windows 10 x64
2. Visual Studio 2017
3. nuget add
3-1 Helixtoolkit.wpf
3-2 WPFMediaKit
4. new WPF Project
4-1 xaml
<Window x:Class="wk1108.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:wk1108"
xmlns:med="clr-namespace:WPFMediaKit.DirectShow.Controls;assembly=WPFMediaKit"
xmlns:h="http://helix-toolkit.org/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<h:HelixViewport3D>
<h:DefaultLights/>
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions="-1 -1 0 1 -1 0 -1 1 0 1 1 0"
TextureCoordinates="1 0 0 0 1 1 0 1 "
TriangleIndices="0 1 2 1 3 2" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<VisualBrush>
<VisualBrush.Visual>
<med:VideoCaptureElement Name="VC" EnableSampleGrabbing="True" />
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
<!-- Translate the plane. -->
<GeometryModel3D.Transform>
<TranslateTransform3D
OffsetX="2" OffsetY="0" OffsetZ="-1" >
</TranslateTransform3D>
</GeometryModel3D.Transform>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
</h:HelixViewport3D>
</Grid>
</Window>
4-2 C# code
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Closing += MainWindow_Closing;
VC.VideoCaptureDevice = WPFMediaKit.DirectShow.Controls.MultimediaUtil.VideoInputDevices[0];
}
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
VC.Stop();
}
}
4-3 手動加入 DirectShowLib-2005.DLL @ package build folder
5. Result
1. ASUS X450J @ Windows 10 x64
2. Visual Studio 2017
3. nuget add
3-1 Helixtoolkit.wpf
3-2 WPFMediaKit
4. new WPF Project
4-1 xaml
<Window x:Class="wk1108.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:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:wk1108"
xmlns:med="clr-namespace:WPFMediaKit.DirectShow.Controls;assembly=WPFMediaKit"
xmlns:h="http://helix-toolkit.org/wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<h:HelixViewport3D>
<h:DefaultLights/>
<ModelVisual3D>
<ModelVisual3D.Content>
<GeometryModel3D>
<GeometryModel3D.Geometry>
<MeshGeometry3D
Positions="-1 -1 0 1 -1 0 -1 1 0 1 1 0"
TextureCoordinates="1 0 0 0 1 1 0 1 "
TriangleIndices="0 1 2 1 3 2" />
</GeometryModel3D.Geometry>
<GeometryModel3D.Material>
<DiffuseMaterial>
<DiffuseMaterial.Brush>
<VisualBrush>
<VisualBrush.Visual>
<med:VideoCaptureElement Name="VC" EnableSampleGrabbing="True" />
</VisualBrush.Visual>
</VisualBrush>
</DiffuseMaterial.Brush>
</DiffuseMaterial>
</GeometryModel3D.Material>
<!-- Translate the plane. -->
<GeometryModel3D.Transform>
<TranslateTransform3D
OffsetX="2" OffsetY="0" OffsetZ="-1" >
</TranslateTransform3D>
</GeometryModel3D.Transform>
</GeometryModel3D>
</ModelVisual3D.Content>
</ModelVisual3D>
</h:HelixViewport3D>
</Grid>
</Window>
4-2 C# code
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Closing += MainWindow_Closing;
VC.VideoCaptureDevice = WPFMediaKit.DirectShow.Controls.MultimediaUtil.VideoInputDevices[0];
}
private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
VC.Stop();
}
}
4-3 手動加入 DirectShowLib-2005.DLL @ package build folder
5. Result
2018年11月17日 星期六
Helixtoolkit Input Gesture
1. 原來在 http://helixtoolkit.codeplex.com/wikipage?title=Input%20gestures&referringTitle=Documentation 的說明,網路上找不到了。
2. 儲存的文件,供參考。
2. 儲存的文件,供參考。
2018年11月9日 星期五
C# plplot 1 - Simple plot
Ref: http://plplot.sourceforge.net/docbook-manual/plplot-html-5.13.0/simple-graph.html
VS 2017 @ Windows 10 x64 (ASUS X450J)
VS 2017 @ Windows 10 x64 (ASUS X450J)
In order to draw such a simple graph, it is necessary to call at least four of the PLplot functions:
plinit
, to initialize PLplot.plenv
, to define the range and scale of the graph, and draw labels, axes, etc.- One or more calls to
plline
orplstring
to draw lines or points as needed. Other more complex routines includeplbin
andplhist
to draw histograms, andplerrx
andplerry
to draw error-bars. plend
, to close the plot.
1-1 New console project
1-2 nuget add plplot (5.13.4 latest 5.13.7)
1-3 using PLplot;
1-4 example 0x1
1-5 error
System.BadImageFormatException: '試圖載入格式錯誤的程式。 (發生例外狀況於 HRESULT: 0x8007000B)'
1-6 Any cpu 改成 x64
double[] x = new double[10], y = new double[10];
for (int i=0; i<10; i++)
{
x[i] = (double)i;
y[i] = Math.Pow(x[i], 2);
}
var pl = new PLStream();
pl.sdev("pngcairo");
pl.sfnam("pngex1.png");
pl.spal0("cmap0_alternate.pal");
pl.init();
pl.env(0, 10, 0, 100, AxesScale.Independent, AxisBox.BoxTicksLabelsAxes);
pl.schr(0, 1.25);
pl.lab("X-axis", "Y-axis", "Title");
pl.col0(9);
pl.line(x, y);
pl.col0(3);
pl.sym(x, y, '0');
pl.eop();
pl.gver(out var verText);
//Console.ReadLine();
Console.WriteLine("Showing chart...");
var p = new Process();
string chartFileNamePath = @".\" + "pngex1.png";
p.StartInfo = new ProcessStartInfo(chartFileNamePath)
{
UseShellExecute = true
};
p.Start();
// Console.ReadLine();
1-7 Console mode 程式需結束,否則會有一個大的黑色方塊在中下方。
2018年11月8日 星期四
a-frame 全景內外層不同貼圖
Ref: https://stackoverflow.com/questions/39626036/how-do-i-texture-the-inside-of-a-cylinder-in-a-frame
1. a-frame 沒有backmaterial 屬性,只有src設定貼圖。
2. side="double" 設定內外相同貼圖。
3. 內側貼圖鏡射圖。
4. 內側以鏡射圖貼於略小模型,如下:
<a-assets>
<img id="sky" src="grid.png">
<img id="ins" src="grid鏡射圖.png">
</a-assets>
<a-sphere radius="2.99" side="double" src="#ins"/>
<a-sphere radius="3" src="#sky"/>
1. a-frame 沒有backmaterial 屬性,只有src設定貼圖。
2. side="double" 設定內外相同貼圖。
3. 內側貼圖鏡射圖。
4. 內側以鏡射圖貼於略小模型,如下:
<a-assets>
<img id="sky" src="grid.png">
<img id="ins" src="grid鏡射圖.png">
</a-assets>
<a-sphere radius="2.99" side="double" src="#ins"/>
<a-sphere radius="3" src="#sky"/>
訂閱:
文章 (Atom)