|
Let me illustrate with the below code. mSource used to be local variable but it is disposed before it can be used in the 4th lambda. So I make this temporary variable as a class member to work around that problem.
void ClampImageApp::MainPage::btnOpenImage_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
FileOpenPicker^ fileOpenPicker = ref new FileOpenPicker();
fileOpenPicker->SuggestedStartLocation = PickerLocationId::PicturesLibrary;
fileOpenPicker->FileTypeFilter->Append(L".jpg");
fileOpenPicker->ViewMode = PickerViewMode::Thumbnail;
mSource = ref new SoftwareBitmapSource();
concurrency::create_task(fileOpenPicker->PickSingleFileAsync())
.then([&](StorageFile^ file)->IAsyncOperation<IRandomAccessStream^>^
{
if (file)
{
return file->OpenAsync(FileAccessMode::Read);
}
else
{
throw task_canceled();
}
}).then([&](IRandomAccessStream^ stream)->IAsyncOperation<BitmapDecoder^>^
{
return BitmapDecoder::CreateAsync(stream);
}).then([&](BitmapDecoder^ decoder)->IAsyncOperation<SoftwareBitmap^>^
{
return decoder->GetSoftwareBitmapAsync();
}).then([&](SoftwareBitmap^ sw_bmp)->IAsyncAction^
{
if (sw_bmp->BitmapPixelFormat != BitmapPixelFormat::Bgra8 ||
sw_bmp->BitmapAlphaMode == BitmapAlphaMode::Straight)
{
sw_bmp = SoftwareBitmap::Convert(sw_bmp, BitmapPixelFormat::Bgra8, BitmapAlphaMode::Premultiplied);
}
return mSource->SetBitmapAsync(sw_bmp);
}).then([&]()->void {
this->imgPhoto->Source = mSource;
});
}
This is the C# code to use composite value
Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
Windows.Storage.ApplicationDataCompositeValue composite = new Windows.Storage.ApplicationDataCompositeValue();
composite["intVal"] = 1212;
composite["strVal"] = "string";
localSettings.Values["RawCompositeSetting"] = composite;
Windows.Storage.ApplicationDataCompositeValue composite2 =
(Windows.Storage.ApplicationDataCompositeValue)localSettings.Values["RawCompositeSetting"];
And compared to C++/CX equivalent code
Windows::Storage::ApplicationDataContainer^ localSettings =
Windows::Storage::ApplicationData::Current->LocalSettings;
ApplicationDataCompositeValue^ composite = ref new ApplicationDataCompositeValue();
composite->Insert("intVal", dynamic_cast<PropertyValue^>(PropertyValue::CreateInt32(1212)));
composite->Insert("strVal", dynamic_cast<PropertyValue^>(PropertyValue::CreateString("string")));
auto values = localSettings->Values;
values->Insert("RawCompositeSetting", composite);
ApplicationDataCompositeValue^ composite2 = safe_cast<ApplicationDataCompositeValue^>(localSettings->Values->Lookup("RawCompositeSetting"));
UWP is a native platform where native C++/CX is orders of magnitude slower than managed C#. Not sure how that is possible. Microsoft just developed a new C++ language to replace C++/CX, called C++/winrt which has async/await and much better performance and full C++ standard compliant. But it is not ready yet as 2 months ago, I found VS cannot build a newly generated C++/winrt project without errors and it does not support win2D.
|
|
|
|
|
|
Interesting but I didn't notice that they even mention building desktop apps in that course.
I just took my web app and converted it directly to UWP by bringing in the HTML,CSS , Bootstrap etc. and it ran perfectly as a desktop app even though it uses localstorage and other web-centric tech.
It's quite amazing and quite smooth.
But there is a bug in MS project template for UWP Desktop via JS. It doesn't set the document URL properly and then it doesn't want to allow your JS to run. It should be an extremely easy fix for them but they haven't done so yet in the preview 2017 version.
|
|
|
|
|
It's not the same thing, but MS also develops and supports React Native for Windows, which also lets you write UWP apps using JavaScript or TypeScript.
As a bonus, it also includes a WPF back-end, which would potentially allow you to publish both UWP and WPF apps from a single codebase. I think the performance of RN would likely be better than the HTML/CSS/JS UWP app, since RN is using native views for rendering instead of HTML.
Heck, without too much work you could also take your UWP/WPF app and run it on MacOS, Linux, Android, and iOS using the versions of React Native for those platforms. You'd probably need a bit of platform specific code here and there, but the majority of your code would be portable.
|
|
|
|
|
Very interesting points, I will definitely keep in mind.
The biggest one is that I am able to convert a pure HTML5 / JavaScript app directly to UWP.
Just so shocked that HTML Canvas and localStorage works seamlessly.
|
|
|
|
|
What's this article doing in the forum?
Wout
|
|
|
|
|
wout de zeeuw wrote: What's this article doing in the forum?
I know... This definitely needs more details to be an article, but this subject has really captured my attention so much that I am planning an article on it.
|
|
|
|
|
I hope you write the article !
cheers, Bill
«... thank the gods that they have made you superior to those events which they have not placed within your own control, rendered you accountable for that only which is within you own control For what, then, have they made you responsible? For that which is alone in your own power—a right use of things as they appear.» Discourses of Epictetus Book I:12
|
|
|
|
|
Funny seeing enable developer mode in an application intended for developers.
|
|
|
|
|
Yeah, it is interesting.
It's really because it is an OS setting similar to what they do in Android OS.
In Android OS to enable dev mode you had to tap on the Android About... item 7 times.
It was odd.
|
|
|
|
|
I ran across a Stack Overflow post that stated that C# 7.3 supports a new feature in which I am keenly interested. The obvious next question is whether I have C# 7.3, and how do I find out?
The answer given elsewhere on SO works great on the dedicated C# compiler, but falls short on the new Roslyn compiler. The new command, along with an example of its output from my installation, follows.
C:\Users\DAG 2018/08/13 20:21:18.28>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\Roslyn\csc.exe" /langversion:?
Supported language versions:
default
1
2
3
4
5
6
7.0 (default)
7.1
7.2
7.3 (latest)
latest
C:\Users\DAG 2018/08/13 20:21:31.33>
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
|
|
|
|
|
That output looks like the command works as expected. What were you expecting to see?
Your compiler supports C# 7.3, but defaults to 7.0. To turn on 7.3, you need to change the advanced build settings. Open the properties of your project, select the "Build" tab, click the "Advanced" button, and select the language version you want.
NB: For some bizarre reason, you need to change the version separately for each build configuration.
4 ways to enable the latest C# features - Meziantou's blog[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
My point is that the instructions in the SO post, which version of C# am I using - Stack Overflow, which I forgot to cite, imply that it's in the general help message displayed when you pass the compiler "/?" to display the general help message. While that command yields lots of useful tidbits, you must amplify it a bit to get the list of supported C# language versions.
Nevertheless, your reply called to my attention something which I hadn't noticed, which is that the default version in my installation is 7.0, not 7.3, as at first appeared to be the case. Thanks for the additional tidbits about how to override that.
Of the four ways mentioned, the one that calls to me is the properties file, since that supports overriding all sorts of default values for every project. Though I haven't dug into the global property sheets for C#, I've made extensive changes to my C++ settings.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
|
|
|
|
|
I never got that too, why not default to the latest stable release?
|
|
|
|
|
Nish Nishant wrote: why not default to the latest stable release? If it was that easy... everyone could do it
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
Rating helpful answers is nice, but saying thanks can be even nicer.
|
|
|
|
|
That's exactly what I expected it to do. However, I can understand some motivation for setting it to the last whole version.
David A. Gray
Delivering Solutions for the Ages, One Problem at a Time
Interpreting the Fundamental Principle of Tabular Reporting
|
|
|
|
|
I think the idea is to avoid breaking previously-compiling code unless you ask it to.
(I haven't seen any C# 7.0 code that would be broken by the 7.3 compiler; but it's always best to CYA.)
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yeah, but Visual Studio 2017 defaults to 7.0 for new projects too.
|
|
|
|
|
I agree, it's annoying.
You can apparently override it by putting a magic file in a directory somewhere above your project:
Customize your build - Visual Studio | Microsoft Docs[^]
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
But I don't like that solution. As soon as you share your project with someone who doesn't have the magic file, they'll start getting compiler errors for all the new features.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
|
I created a datetime variable like so
LET vTEST = '2018-09-05 13:27:14.5';
Then, I tried various methods to strip the time component from the date. Here are the various techniques for doing this, along with their generated results:
DATE(MAKEDATE(YEAR($(vTEST)), MONTH($(vTEST)), DAY($(vTEST))), 'YYYY-MM-DD HH:MM:SS.FFF') = "2018-09-05 00:27:00.000"
DATE(FLOOR($vTEST)), 'YYYY-MM-DD HH:MM:SS.FFF') = "2018-09-05 00:27:00.000"
DATE(NUM(DATE(FLOOR($(vTEST)) 'YYYY-MM-DD HH:MM:SS.FFF') = "2018-09-05" <======== THIS is what I wanted
A Qlikview datetime is represented by a floating point number with the date on the integer side of the decimal point, and the time on the fractional side. I honestly thought the FLOOR function would do what I want, but it left the minutes untouched, which resulted in the variable still having a time component. The only way I could get the time completely stripped is illustrated in the last example.
Have I mentioned how much I hate working in Qlikview?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Perl scripts?
Is regex possible with this Qlikview crap?
modified 7-Aug-18 10:42am.
|
|
|
|
|
John Simmons / outlaw programmer wrote: YYYY-MM-DD HH:MM:SS.FFF
Seriously? The format strings don't differentiate between "month" and "minute"? 💩
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Perhaps it's context sensitive.
Everyone is born right handed. Only the strongest overcome it.
Fight for left-handed rights and hand equality.
|
|
|
|
|
I like positive thinking.
|
|
|
|