Zastone/HPG-68D/LanguageHelper.cs
2024-06-25 23:18:56 +02:00

158 lines
4.5 KiB
C#

// Decompiled with JetBrains decompiler
// Type: HPG_68D.LanguageHelper
// Assembly: HPG-68D, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 530C99A8-8EEF-42C8-8A74-66FDE7B322C3
// Assembly location: C:\Program Files (x86)\HONGKAIDE\HPG-68D\HPG-68D.exe
using Microsoft.VisualBasic.CompilerServices;
using System;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Threading;
using System.Windows.Forms;
using System.Windows.Forms.Layout;
namespace HPG_68D
{
public class LanguageHelper
{
[DebuggerNonUserCode]
public LanguageHelper()
{
}
public static bool SetLanguage(string languageName, Form frm)
{
bool flag;
try
{
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(languageName);
Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(languageName);
ComponentResourceManager res = new ComponentResourceManager(frm.GetType());
res.ApplyResources((object) frm, "$this");
ApplyResouce((Control) frm, res);
flag = true;
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
flag = false;
ProjectData.ClearProjectError();
}
return flag;
}
private static void ApplyResouce(Control control, ComponentResourceManager res)
{
try
{
foreach (Control control1 in control.Controls)
{
res.ApplyResources((object) control1, control1.Name);
if (control1 is TabControl)
ApplyResouce((TabControl) control1, res);
if (control1 is DataGridView)
ApplyResouce((DataGridView) control1, res);
if (control1.GetType().IsSubclassOf(typeof (ToolStrip)))
ApplyResouce((ToolStrip) control1, res);
if (control1 is ComboBox)
ApplyResouce((ComboBox) control1, res);
ApplyResouce(control1, res);
}
}
finally
{
}
}
private static void ApplyResouce(ToolStrip toolstrip, ComponentResourceManager resources)
{
if (toolstrip.Items.Count <= 0)
return;
try
{
foreach (ToolStripItem toolStripItem in (ArrangedElementCollection) toolstrip.Items)
ApplyResouce(toolStripItem, resources);
}
finally
{
}
}
private static void ApplyResouce(ToolStripItem item, ComponentResourceManager resources)
{
resources.ApplyResources((object) item, item.Name);
if (!item.GetType().IsSubclassOf(typeof (ToolStripDropDownItem)))
return;
ToolStripDropDownItem stripDropDownItem = (ToolStripDropDownItem) item;
if (stripDropDownItem.DropDownItems.Count > 0)
{
try
{
foreach (ToolStripItem dropDownItem in (ArrangedElementCollection) stripDropDownItem.DropDownItems)
ApplyResouce(dropDownItem, resources);
}
finally
{
}
}
}
private static void ApplyResouce(DataGridView datagridview, ComponentResourceManager resources)
{
if (datagridview.Columns.Count <= 0)
return;
try
{
foreach (DataGridViewColumn column in (BaseCollection) datagridview.Columns)
ApplyResouce(column, resources);
}
finally
{
}
}
private static void ApplyResouce(DataGridViewColumn item, ComponentResourceManager resources)
{
resources.ApplyResources((object) item, item.Name);
}
private static void ApplyResouce(ComboBox combobox, ComponentResourceManager resources)
{
if (combobox.Items.Count <= 0)
return;
int num = checked (combobox.Items.Count - 1);
int index = 0;
while (index <= num)
{
combobox.Items[index] = index == 0 ? (object) resources.GetString(combobox.Name + ".Items") : (object) resources.GetString(combobox.Name + ".Items" + Conversions.ToString(index));
checked { ++index; }
}
}
private static void ApplyResouce(TabControl tabcontrol, ComponentResourceManager resources)
{
if (tabcontrol.TabCount <= 0)
return;
resources.ApplyResources((object) tabcontrol, tabcontrol.Name);
try
{
foreach (TabPage tabPage in tabcontrol.TabPages)
ApplyResouce(tabPage, resources);
}
finally
{
}
}
private static void ApplyResouce(TabPage item, ComponentResourceManager resources)
{
resources.ApplyResources((object) item, item.Name);
}
}
}