diff --git a/Import/GacUI.cpp b/Import/GacUI.cpp index 21a75a3e..06291926 100644 --- a/Import/GacUI.cpp +++ b/Import/GacUI.cpp @@ -6864,7 +6864,7 @@ GuiControlHost { if(host->GetNativeWindow()) { - host->GetNativeWindow()->Hide(); + host->GetNativeWindow()->Hide(false); } } @@ -6875,7 +6875,7 @@ GuiControlHost { if(GetCurrentController()->WindowService()->GetMainWindow()!=window) { - window->Hide(); + window->Hide(false); } else { diff --git a/Import/GacUI.h b/Import/GacUI.h index 967a9426..32ad098e 100644 --- a/Import/GacUI.h +++ b/Import/GacUI.h @@ -1559,7 +1559,8 @@ Native Window /// /// Hide the window. /// - virtual void Hide()=0; + /// Set to true to really close the window. Or the window will just be hidden. This parameter only affect the main window. + virtual void Hide(bool closeWindow)=0; /// /// Test is the window visible. /// diff --git a/Import/GacUICompiler.cpp b/Import/GacUICompiler.cpp index 5811af78..c7bfccb5 100644 --- a/Import/GacUICompiler.cpp +++ b/Import/GacUICompiler.cpp @@ -3558,7 +3558,7 @@ WorkflowGenerateBindingVisitor FOREACH(Ptr, localized, resolvingResult.context->localizeds) { - auto code = L"bind(" + localized->className + L"::Get(presentation::controls::GuiApplication::GetApplication().Locale) of (" + localized->interfaceName + L"^))"; + auto code = L"bind(" + localized->className.ToString() + L"::Get(presentation::controls::GuiApplication::GetApplication().Locale))"; if (auto bindExpr = Workflow_ParseExpression(precompileContext, { resolvingResult.resource }, code, localized->tagPosition, errors)) { auto instancePropertyInfo = resolvingResult.rootTypeInfo.typeInfo->GetTypeDescriptor()->GetPropertyByName(localized->name.ToString(), true); @@ -5764,16 +5764,16 @@ GuiInstanceContext else if (element->name.value == L"ref.LocalizedStrings") { auto attName = XmlGetAttribute(element, L"Name"); - auto attUri = XmlGetAttribute(element, L"Uri"); + auto attClass = XmlGetAttribute(element, L"Class"); auto attDefault = XmlGetAttribute(element, L"Default"); - if (attName && attUri) + if (attName && attClass) { auto localized = MakePtr(); localized->name = GlobalStringKey::Get(attName->value.value); - localized->uri = GlobalStringKey::Get(attUri->value.value); + localized->className = GlobalStringKey::Get(attClass->value.value); localized->tagPosition = { { resource },element->codeRange.start }; - localized->uriPosition = { { resource },attUri->value.codeRange.start }; - localized->uriPosition.column += 1; + localized->classPosition = { { resource },attClass->value.codeRange.start }; + localized->classPosition.column += 1; if (attDefault) { @@ -5783,7 +5783,7 @@ GuiInstanceContext } else { - errors.Add(GuiResourceError({ { resource },element->codeRange.start }, L"ref.LocalizedStrings requires the following attributes existing at the same time: Name, Uri.")); + errors.Add(GuiResourceError({ { resource },element->codeRange.start }, L"ref.LocalizedStrings requires the following attributes existing at the same time: Name, Class.")); } } @@ -5892,9 +5892,9 @@ GuiInstanceContext attName->value.value = localized->name.ToString(); xmlParameter->attributes.Add(attName); - auto attUri = MakePtr(); - attUri->name.value = L"Class"; - attUri->value.value = localized->uri.ToString(); + auto attClass = MakePtr(); + attClass->name.value = L"Class"; + attClass->value.value = localized->className.ToString(); xmlParameter->attributes.Add(attClass); auto attDefault = MakePtr(); @@ -7989,31 +7989,6 @@ Instance Type Resolver (Instance) } } - FOREACH(Ptr, localized, obj->localizeds) - { - WString protocol, path; - if (IsResourceUrl(localized->uri.ToString(), protocol, path)) - { - if (auto ls = context.resolver->ResolveResource(protocol, path).Cast()) - { - localized->className = ls->className; - localized->interfaceName = ls->GetInterfaceTypeName(true); - } - else - { - errors.Add(GuiResourceError({ resource }, localized->tagPosition, - L"Failed to find the localized string referred in attribute \"Uri\": \"" + localized->uri.ToString() + L"\".") - ); - } - } - else - { - errors.Add(GuiResourceError({ resource }, localized->tagPosition, - L"Invalid path in attribute \"Uri\": \"" + localized->uri.ToString() + L"\".") - ); - } - } - obj->ApplyStyles(resource, context.resolver, errors); types::ResolvingResult resolvingResult; @@ -9942,19 +9917,59 @@ Workflow_GenerateInstanceClass FOREACH(Ptr, localized, context->localizeds) { - if (auto type = GetTypeDescriptor(localized->interfaceName)) + if (auto lsTd = GetTypeDescriptor(localized->className.ToString())) { - auto prop = MakePtr(); - addDecl(prop); + ITypeDescriptor* lsiTd = nullptr; + if (auto group = lsTd->GetMethodGroupByName(L"Get", false)) + { + vint count = group->GetMethodCount(); + for (vint i = 0; i < count; i++) + { + auto method = group->GetMethod(i); + if (method->GetParameterCount() == 1) + { + auto paramTd = method->GetParameter(0)->GetType()->GetTypeDescriptor(); + if (paramTd == description::GetTypeDescriptor()) + { + lsiTd = method->GetReturn()->GetTypeDescriptor(); + break; + } + } + } + } - prop->name.value = localized->name.ToString(); - prop->type = GetTypeFromTypeInfo(Workflow_GetSuggestedParameterType(type).Obj()); - prop->configConst = WfAPConst::Writable; - prop->configObserve = WfAPObserve::Observable; + if (lsiTd) + { + auto prop = MakePtr(); + addDecl(prop); - auto nullExpr = MakePtr(); - nullExpr->value = WfLiteralValue::Null; - prop->expression = nullExpr; + prop->name.value = localized->name.ToString(); + prop->type = GetTypeFromTypeInfo(Workflow_GetSuggestedParameterType(lsiTd).Obj()); + prop->configConst = WfAPConst::Writable; + prop->configObserve = WfAPObserve::Observable; + + auto nullExpr = MakePtr(); + nullExpr->value = WfLiteralValue::Null; + prop->expression = nullExpr; + } + else + { + errors.Add(GuiResourceError({ resolvingResult.resource }, localized->classPosition, + L"Precompile: Class \"" + + localized->className.ToString() + + L"\" of localized strings \"" + + localized->name.ToString() + + L"\" is not a correct localized strings class.")); + } + } + else + { + errors.Add(GuiResourceError({ resolvingResult.resource }, localized->classPosition, + L"Precompile: Class \"" + + localized->className.ToString() + + L"\" of localized strings \"" + + localized->name.ToString() + + L"\" cannot be found.")); } } @@ -11131,30 +11146,6 @@ WorkflowReferenceNamesVisitor resolvingResult.typeInfos.Add(parameter->name, { GlobalStringKey::Get(type->GetTypeName()),referenceType }); } } - - FOREACH(Ptr, localized, resolvingResult.context->localizeds) - { - auto type = GetTypeDescriptor(localized->interfaceName); - if (!type) - { - errors.Add(GuiResourceError({ resolvingResult.resource }, localized->tagPosition, - L"Precompile: Cannot find type \"" + - localized->interfaceName + - L"\".")); - } - else if (resolvingResult.typeInfos.Keys().Contains(localized->name)) - { - errors.Add(GuiResourceError({ resolvingResult.resource }, localized->tagPosition, - L"[INTERNAL-ERROR] Precompile: Parameter \"" + - localized->name.ToString() + - L"\" conflict with an existing named object.")); - } - else - { - auto referenceType = Workflow_GetSuggestedParameterType(type); - resolvingResult.typeInfos.Add(localized->name, { GlobalStringKey::Get(type->GetTypeName()),referenceType }); - } - } List infos; vint generatedNameCount = 0; diff --git a/Import/GacUICompiler.h b/Import/GacUICompiler.h index a2dabb0d..03945181 100644 --- a/Import/GacUICompiler.h +++ b/Import/GacUICompiler.h @@ -415,12 +415,10 @@ Instance Namespace { public: GlobalStringKey name; - GlobalStringKey uri; + GlobalStringKey className; GuiResourceTextPos tagPosition; - GuiResourceTextPos uriPosition; + GuiResourceTextPos classPosition; bool defaultStrings = false; - WString className; - WString interfaceName; }; /*********************************************************************** diff --git a/Import/GacUIWindows.cpp b/Import/GacUIWindows.cpp index f57c097f..136bd9f3 100644 --- a/Import/GacUIWindows.cpp +++ b/Import/GacUIWindows.cpp @@ -13264,7 +13264,7 @@ WindowsForm } return false; case INativeWindowListener::ButtonClose: - Hide(); + Hide(true); return false; } } @@ -13568,9 +13568,16 @@ WindowsForm ShowWindow(handle, SW_SHOWMINIMIZED); } - void Hide() + void Hide(bool closeWindow) { - PostMessage(handle, WM_CLOSE, NULL, NULL); + if (closeWindow) + { + PostMessage(handle, WM_CLOSE, NULL, NULL); + } + else + { + ShowWindow(handle, SW_HIDE); + } } bool IsVisible() @@ -13866,7 +13873,7 @@ WindowsController { if(windows.Values().Get(i)->IsVisible()) { - windows.Values().Get(i)->Hide(); + windows.Values().Get(i)->Hide(true); } } while(windows.Count()) diff --git a/Tools/CppMerge.exe b/Tools/CppMerge.exe index a9045629..a65fdcc8 100644 Binary files a/Tools/CppMerge.exe and b/Tools/CppMerge.exe differ diff --git a/Tools/GacBuild.ps1 b/Tools/GacBuild.ps1 index e218c881..86098179 100644 --- a/Tools/GacBuild.ps1 +++ b/Tools/GacBuild.ps1 @@ -29,24 +29,9 @@ you should add the following metadata in GacGenConfig like this: - - The output path for unscripted binary resource. Use GetResourceManager()->LoadResourceOrPending to load the resource. - The output path for unscripted compressed binary resource. Call DecompressStream before loading the resource. - The output path for unscripted binary resource embedded in C++ code. Just add this cpp file to your project and it just works. - The output path for unscripted binary resource embedded in C++ code. Just add this cpp file to your project and it just works. - #include targets in generated C++ files, seperated by semicolon. - #include targets in generated C++ files when you turn on reflection, seperated by semicolon. - General file name for generated C++ files without extension. - The output folder for all generated C++ files. - - - The output path for scripted binary resource. Use GetResourceManager()->LoadResourceOrPending with GuiResourceUsage::InstanceClass to load the resource. - The output path for scripted compressed binary resource. Use GetResourceManager()->LoadResourceOrPending to load the resource. - Generated Workflow script, which is equivalent to generated C++ code. All assemblies are included in scripted binary resources, but if you want to load unscripted binary resources and assemblies separately, you will need this file. - - - - + ... + ... + ... ... @@ -73,8 +58,8 @@ try { $FileName = (Resolve-Path -Path $FileName).Path if (Test-Path -Path "$($FileName).log") { Remove-Item -Path "$($FileName).log" -Recurse | Out-Null + New-Item -ItemType Directory "$($FileName).log" | Out-Null } - New-Item -ItemType Directory "$($FileName).log" | Out-Null EnumerateResourceFiles $FileName if (-not (Test-Path -Path "$($FileName).log\ResourceFiles.txt")) { diff --git a/Tools/GacClear.ps1 b/Tools/GacClear.ps1 index f44f4555..217c0ad7 100644 --- a/Tools/GacClear.ps1 +++ b/Tools/GacClear.ps1 @@ -22,8 +22,8 @@ try { $FileName = (Resolve-Path -Path $FileName).Path if (Test-Path -Path "$($FileName).log") { Remove-Item -Path "$($FileName).log" -Recurse | Out-Null + New-Item -ItemType Directory "$($FileName).log" | Out-Null } - New-Item -ItemType Directory "$($FileName).log" | Out-Null EnumerateResourceFiles $FileName if (-not (Test-Path -Path "$($FileName).log\ResourceFiles.txt")) { diff --git a/Tools/GacGen32.exe b/Tools/GacGen32.exe index 7747416d..d49e769b 100644 Binary files a/Tools/GacGen32.exe and b/Tools/GacGen32.exe differ diff --git a/Tools/GacGen64.exe b/Tools/GacGen64.exe index 40b64ac5..8b403472 100644 Binary files a/Tools/GacGen64.exe and b/Tools/GacGen64.exe differ diff --git a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/LocalizedStringsTabPage.xml b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/LocalizedStringsTabPage.xml index 93d5ad45..6671c768 100644 --- a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/LocalizedStringsTabPage.xml +++ b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/LocalizedStringsTabPage.xml @@ -33,7 +33,7 @@ - + - + diff --git a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoPartialClasses.cpp b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoPartialClasses.cpp index f55972db..2bc0033a 100644 --- a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoPartialClasses.cpp +++ b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoPartialClasses.cpp @@ -16051,7 +16051,6 @@ Class (::demo::LocalizedStringsTabPageConstructor) LocalizedStringsTabPageConstructor::LocalizedStringsTabPageConstructor() : self(static_cast<::demo::LocalizedStringsTabPage*>(nullptr)) - , Strings(::vl::Ptr<::demo::IStringResourceStrings>()) , comboLocales(static_cast<::vl::presentation::controls::GuiComboBoxListControl*>(nullptr)) , listLocales(static_cast<::vl::presentation::controls::GuiTextList*>(nullptr)) , __vwsn_precompile_0(static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr)) diff --git a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoPartialClasses.h b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoPartialClasses.h index 1e87d2dc..59003ad0 100644 --- a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoPartialClasses.h +++ b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoPartialClasses.h @@ -1382,7 +1382,6 @@ namespace demo #endif protected: ::demo::LocalizedStringsTabPage* self; - ::vl::Ptr<::demo::IStringResourceStrings> Strings; ::vl::presentation::controls::GuiComboBoxListControl* comboLocales; ::vl::presentation::controls::GuiTextList* listLocales; ::vl::presentation::compositions::GuiTableComposition* __vwsn_precompile_0; diff --git a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoReflection.cpp b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoReflection.cpp index 2449d5a8..2616e701 100644 --- a/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoReflection.cpp +++ b/Tutorial/GacUI_ControlTemplate/BlackSkin/UI/FullControlTest/Source/DemoReflection.cpp @@ -926,7 +926,6 @@ namespace vl CLASS_MEMBER_FIELD(__vwsn_precompile_7) CLASS_MEMBER_FIELD(__vwsn_precompile_8) CLASS_MEMBER_FIELD(__vwsn_precompile_9) - CLASS_MEMBER_FIELD(Strings) CLASS_MEMBER_FIELD(comboLocales) CLASS_MEMBER_FIELD(listLocales) CLASS_MEMBER_FIELD(self) diff --git a/Tutorial/GacUI_Controls/Localization/UI/Source/DemoPartialClasses.cpp b/Tutorial/GacUI_Controls/Localization/UI/Source/DemoPartialClasses.cpp index a278bd80..95b5838b 100644 --- a/Tutorial/GacUI_Controls/Localization/UI/Source/DemoPartialClasses.cpp +++ b/Tutorial/GacUI_Controls/Localization/UI/Source/DemoPartialClasses.cpp @@ -1853,8 +1853,7 @@ Class (::demo::MainWindowConstructor) } MainWindowConstructor::MainWindowConstructor() - : Strings(::vl::Ptr<::demo::IStringResourceStrings>()) - , self(static_cast<::demo::MainWindow*>(nullptr)) + : self(static_cast<::demo::MainWindow*>(nullptr)) , comboLocales(static_cast<::vl::presentation::controls::GuiComboBoxListControl*>(nullptr)) , listLocales(static_cast<::vl::presentation::controls::GuiTextList*>(nullptr)) , __vwsn_precompile_0(static_cast<::vl::presentation::compositions::GuiTableComposition*>(nullptr)) diff --git a/Tutorial/GacUI_Controls/Localization/UI/Source/DemoPartialClasses.h b/Tutorial/GacUI_Controls/Localization/UI/Source/DemoPartialClasses.h index b7ceb985..4aeb2849 100644 --- a/Tutorial/GacUI_Controls/Localization/UI/Source/DemoPartialClasses.h +++ b/Tutorial/GacUI_Controls/Localization/UI/Source/DemoPartialClasses.h @@ -132,7 +132,6 @@ namespace demo friend struct ::vl::reflection::description::CustomTypeDescriptorSelector; #endif protected: - ::vl::Ptr<::demo::IStringResourceStrings> Strings; ::demo::MainWindow* self; ::vl::presentation::controls::GuiComboBoxListControl* comboLocales; ::vl::presentation::controls::GuiTextList* listLocales; diff --git a/Tutorial/GacUI_Controls/Localization/UI/Source/DemoReflection.cpp b/Tutorial/GacUI_Controls/Localization/UI/Source/DemoReflection.cpp index 5529cf44..f1c411d6 100644 --- a/Tutorial/GacUI_Controls/Localization/UI/Source/DemoReflection.cpp +++ b/Tutorial/GacUI_Controls/Localization/UI/Source/DemoReflection.cpp @@ -94,7 +94,6 @@ namespace vl CLASS_MEMBER_FIELD(__vwsn_precompile_7) CLASS_MEMBER_FIELD(__vwsn_precompile_8) CLASS_MEMBER_FIELD(__vwsn_precompile_9) - CLASS_MEMBER_FIELD(Strings) CLASS_MEMBER_FIELD(comboLocales) CLASS_MEMBER_FIELD(listLocales) CLASS_MEMBER_FIELD(self) diff --git a/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x64 b/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x64 index 8602a6a8..a39a1774 100644 Binary files a/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x64 and b/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x64 differ diff --git a/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x86 b/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x86 index 95f398b3..16c8a764 100644 Binary files a/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x86 and b/Tutorial/GacUI_HelloWorlds/UIRes/Xml.bin.x86 differ