Page 1 of 3
How to switch interface language of DesignerControl by code
Posted: Thu Aug 09, 2007 7:59 am
by Markus Weiß
Hi
how do i switch the interface language of the DesignerControl by code. I have disabled the main menu so i do have to change the interface language corresponding to my container application.
Thanks
Markus Weiss
How to switch interface language of DesignerControl by code
Posted: Thu Aug 09, 2007 8:19 am
by Vital
You can use following code:
Code: Select all
string language;
string description;
string cultureName;
StiLocalization.GetParam(localizationFile, out language, out description, out cultureName);
if (language != null && language != "")
{
StiLocalization.Localization = localizationFile;
StiSettings.Load();
StiSettings.Set("Localization", "FileName", localizationFile);
StiSettings.Save();
designer.LocalizeDesigner();
}
How to switch interface language of DesignerControl by code
Posted: Fri Aug 10, 2007 1:42 am
by Markus Weiß
Do i always havoe to load a xml file to do that? What is with the build in cultures - englisch, german etc.?
How to switch interface language of DesignerControl by code
Posted: Mon Aug 13, 2007 10:14 am
by Vital
Yes, you need always load xml file.
How to switch interface language of DesignerControl by code
Posted: Mon Aug 13, 2007 10:16 am
by Vital
In latest build we have added new method SetLocalization to StiMainMenuService.
Thank you.
How to switch interface language of DesignerControl by code
Posted: Sun Aug 19, 2007 11:30 am
by Fabio Pagano
Vital wrote:In latest build we have added new method SetLocalization to StiMainMenuService.
I'm using build of 14 August for 2.0 Framework, i see the "SetLocalization method", but it always gives me "NullReferenceException", here is my code:
Code: Select all
Dim MainMenuService As Stimulsoft.Report.Design.StiMainMenuService = CType(Stimulsoft.Report.StiConfig.Services.GetService(GetType(Stimulsoft.Report.Design.StiMainMenuService)), Stimulsoft.Report.Design.StiMainMenuService)
'This works
MainMenuService.ShowFileReportNew = False
'This gives NullReferenceException
MainMenuService.SetLocalization("C:\Programmi\Stimulsoft\StimulReport.Net 2007.1 Trial\.Net 2.0\Bin\Localization\it.xml")
I've already checked that the "it.xml" file exists in the given path.
Thanks.
How to switch interface language of DesignerControl by code
Posted: Sun Aug 19, 2007 4:27 pm
by Fabio Pagano
Sorry but i didn't know that localization files must be present in a folder called "Localization" in the executable path. I created it and put in it only the "it.xml" localization file.
So, if i don't set anything in code i obtain the desired language (actually i only need Italian), but if i expressely set "it.xml" using "LocalizeReport" method, the problem "NullReferenceException" still exists.
Thanks.
How to switch interface language of DesignerControl by code
Posted: Tue Aug 21, 2007 5:21 am
by Edward
Fabio wrote:
Code: Select all
Dim MainMenuService As Stimulsoft.Report.Design.StiMainMenuService = CType(Stimulsoft.Report.StiConfig.Services.GetService(GetType(Stimulsoft.Report.Design.StiMainMenuService)), Stimulsoft.Report.Design.StiMainMenuService)
'This works
MainMenuService.ShowFileReportNew = False
'This gives NullReferenceException
MainMenuService.SetLocalization("C:\Programmi\Stimulsoft\StimulReport.Net 2007.1 Trial\.Net 2.0\Bin\Localization\it.xml")
I've already checked that the "it.xml" file exists in the given path.
Please modify your code in the following way:
Code: Select all
Dim designerControl As New StiDesignerControl
Dim MainMenuService As Stimulsoft.Report.Design.StiMainMenuService = Stimulsoft.Report.Design.StiMainMenuService.GetService(designerControl)
MainMenuService.ShowFileReportNew = False
StiOptions.Configuration.DirectoryLocalization = "C:\Programmi\Stimulsoft\StimulReport.Net 2007.1 Trial\.Net 2.0\Bin\Localization\it.xml"
MainMenuService.SetLocalization("it.xml")
In the current version of the StimulReport.Net this code will work...
Thank you.
How to switch interface language of DesignerControl by code
Posted: Wed Aug 29, 2007 6:40 am
by Fabio Pagano
Sorry, i can't make it work.
I'm using 23 august build.
I've put the "it.xml" localization file in my application directory.
So this is the code:
Code: Select all
Dim designerControl As New Stimulsoft.Report.Design.StiDesignerControl
Dim MainMenuService As Stimulsoft.Report.Design.StiMainMenuService = Stimulsoft.Report.Design.StiMainMenuService.GetService(designerControl)
Stimulsoft.Report.StiOptions.Configuration.DirectoryLocalization = My.Application.Info.DirectoryPath
MainMenuService.SetLocalization("it.xml")
The line "MainMenuService.SetLocalization("it.xml")" gives the following error:
"Value cannot be null.
Parameter name: control"
This is the beginning of the stack trace:
"System.ArgumentNullException was unhandled
Message="Value cannot be null.
Parameter name: control"
ParamName="control"
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.ToolTip.SetToolTipInternal(Control control, TipInfo info)
at System.Windows.Forms.ToolTip.SetToolTip(Control control, String caption)
at Stimulsoft.Report.Design.Toolbars.StiStandardToolbarService.Localize()
at Stimulsoft.Report.Design.StiDesigner.LocalizeToolbars()
at Stimulsoft.Report.Design.StiDesigner.LocalizeDesigner()
at Stimulsoft.Report.Design.StiMainMenuService.UpdateLocalization()
at Stimulsoft.Report.Design.StiMainMenuService.SetLocalization(String localizationFile)"
Please note that i use your designer, invoked through ".Design" method on Report.
Thanks.
How to switch interface language of DesignerControl by code
Posted: Wed Aug 29, 2007 9:43 am
by Edward
If you do not use StiDesignerControl please modify your code as the following:
Code: Select all
Dim designer As New StiDesigner
Dim MainMenuService As StiMainMenuService = StiMainMenuService.GetService(designer)
Configuration.DirectoryLocalization = AppDomain.CurrentDomain.BaseDirectory
MainMenuService.SetLocalization("it.xml")
Dim report As New StiReport
report.Load("Report.mrt")
designer.Report = report
designer.ShowDialog
Thank you.