using DevExpress.Data.Localization;
using DevExpress.Utils.Localization;
using DevExpress.XtraBars.Docking2010;
using DevExpress.XtraBars.Localization;
using DevExpress.XtraEditors;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraGrid.Localization;
using DevExpress.XtraLayout.Localization;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DbBackup
{
    static class ChsLocalizer
    {
        /// <summary>
        /// UI控件本地化
        /// </summary>
        public static void UseChs()
        {
            //GridControl
            GridLocalizer.Active = new ChsGridLocalizer();

            //Bar
            BarLocalizer.Active = new ChsBarLocalizer();

            //DocumentManager
            DocumentManagerLocalizer.Active = new ChsDocumentManagerLocalizer();

            //LayoutControl
            LayoutLocalizer.Active = new ChsLayoutLocalizer();

            //Control
            Localizer.Active = new ChsControlLocalizer();

            XtraLocalizer.QueryLocalizedString += XtraLocalizer_QueryLocalizedString;
        }

        private static void XtraLocalizer_QueryLocalizedString(object sender, XtraLocalizer.QueryLocalizedStringEventArgs e)
        {
            if (e.StringIDType == typeof(StringId))
            {
                if ((StringId)e.StringID == StringId.FilterShowAll)
                {
                    e.Value = "(全选)";
                }
            }
        }
    }
    class ChsControlLocalizer : Localizer
    {
        public override string GetLocalizedString(StringId id)
        {
            switch (id)
            {
                case StringId.TextEditMenuUndo:
                    return "撤销";
                case StringId.TextEditMenuCut:
                    return "剪切";
                case StringId.TextEditMenuCopy:
                    return "复制";
                case StringId.TextEditMenuPaste:
                    return "粘贴";
                case StringId.TextEditMenuDelete:
                    return "删除";
                case StringId.TextEditMenuSelectAll:
                    return "全选";
                case StringId.XtraMessageBoxYesButtonText:
                    return "是";
                case StringId.XtraMessageBoxNoButtonText:
                    return "否";
                case StringId.XtraMessageBoxOkButtonText:
                    return "确定";
                case StringId.XtraMessageBoxCancelButtonText:
                    return "取消";
                case StringId.XtraMessageBoxRetryButtonText:
                    return "重试";
                case StringId.NavigatorTextStringFormat:
                    return "Record {0} of {1}";
                case StringId.SearchControlNullValuePrompt:
                    return "输入搜索文本...";
                case StringId.TabHeaderButtonClose:
                    return "关闭选项卡";
                case StringId.OK:
                    return "确定";
                case StringId.Cancel:
                    return "取消";
            }
            var res = base.GetLocalizedString(id);
            return res;
        }
    }

    class ChsGridLocalizer : GridLocalizer
    {
        public override string GetLocalizedString(GridStringId id)
        {
            switch (id)
            {
                case GridStringId.MenuColumnSortAscending:
                    return "升序排列";
                case GridStringId.MenuColumnSortDescending:
                    return "降序排列";
                case GridStringId.MenuColumnUnGroup:
                    return "取消分组";
                case GridStringId.MenuColumnGroup:
                    return "分组";
                case GridStringId.MenuGroupPanelShow:
                    return "显示分组面板";
                case GridStringId.MenuGroupPanelHide:
                    return "隐藏分组面板";
                case GridStringId.MenuColumnRemoveColumn:
                    return "移除列";
                case GridStringId.MenuColumnColumnCustomization:
                    return "列选择";
                case GridStringId.MenuColumnBestFit:
                    return "最佳匹配";
                case GridStringId.MenuColumnBestFitAllColumns:
                    return "最佳匹配(所有列)";
                case GridStringId.MenuColumnFilterEditor:
                    return "自定义筛选";
                case GridStringId.MenuColumnFindFilterShow:
                    return "显示搜索面板";
                case GridStringId.MenuColumnFindFilterHide:
                    return "隐藏搜索面板";
                case GridStringId.MenuColumnAutoFilterRowShow:
                    return "显示自动过滤";
                case GridStringId.MenuColumnAutoFilterRowHide:
                    return "隐藏自动过滤";
                case GridStringId.FindNullPrompt:
                    return "输入搜索文本...";
                case GridStringId.FindControlFindButton:
                    return "搜索";
                case GridStringId.FindControlClearButton:
                    return "清除";
                case GridStringId.FindControlNextButton:
                    return "下一项";
                case GridStringId.FindControlPrevButton:
                    return "上一项";
                case GridStringId.CustomizationCaption:
                    return "自定义";
                case GridStringId.CustomizationFormColumnHint:
                    return "拖拽列到此处以自定义布局";
                case GridStringId.GridGroupPanelText:
                    return "拖拽列到此处以分组";
                case GridStringId.MenuColumnShowColumn:
                    return "显示此列";
                case GridStringId.MenuColumnClearSorting:
                    return "清除排序";
                case GridStringId.MenuColumnClearAllSorting:
                    return "清除所有排序";
                case GridStringId.FilterPanelCustomizeButton:
                    return "自定义";
                case GridStringId.FilterBuilderOkButton:
                    return "确定";
                case GridStringId.FilterBuilderCancelButton:
                    return "取消";
                case GridStringId.FilterBuilderApplyButton:
                    return "应用";
                case GridStringId.MenuGroupPanelFullExpand:
                    return "全部展开";
                case GridStringId.MenuGroupPanelFullCollapse:
                    return "全部折叠";
                case GridStringId.MenuGroupPanelClearGrouping:
                    return "清除分组";
                case GridStringId.FilterBuilderCaption:
                    return "筛选条件";
                case GridStringId.MenuColumnClearFilter:
                    return "取消过滤";
            }
            var res = base.GetLocalizedString(id);
            return res;
        }
    }

    class ChsBarLocalizer : BarLocalizer
    {
        public override string GetLocalizedString(BarString id)
        {
            switch (id)
            {
                case BarString.CloseButton:
                    return "关闭";
                case BarString.RibbonToolbarAdd:
                    return "添加快速访问工具栏";
                case BarString.RibbonToolbarRemove:
                    return "移除快速访问工具栏";
                case BarString.RibbonToolbarMinimizeRibbon:
                    return "最小化功能区";
                case BarString.CollapseRibbonSuperTipHeader:
                    return "最小化任务栏(Ctrl+F1)";
                case BarString.CollapseRibbonSuperTipText:
                    return "在任务栏中只显示标签名";
                case BarString.CustomizeToolbarText:
                    return "自定义工具栏";
                case BarString.ExpandRibbonSuperTipHeader:
                    return "展开任务栏(Ctrl+F1)";
                case BarString.ExpandRibbonSuperTipText:
                    return "始终展开任务栏";
                case BarString.RestoreButton:
                    return "还原";
                case BarString.MinimizeButton:
                    return "最小化";
                case BarString.CustomizeButton:
                    return "自定义";
                case BarString.ToolbarNameCaption:
                    return "工具栏";
            }
            var res = base.GetLocalizedString(id);
            return res;
        }
    }

    class ChsDocumentManagerLocalizer : DevExpress.XtraBars.Docking2010.DocumentManagerLocalizer
    {
        public override string GetLocalizedString(DocumentManagerStringId id)
        {
            switch (id)
            {
                case DocumentManagerStringId.CommandCloseAll:
                    return "关闭所有文档";
                case DocumentManagerStringId.CommandOpenedWindowsDialog:
                    return "窗体...";
                case DocumentManagerStringId.ActivateDocumentButtonText:
                    return "激活";
                case DocumentManagerStringId.CloseDocumentButtonText:
                    return "关闭窗体";
                case DocumentManagerStringId.CloseAllDocumentsButtonText:
                    return "关闭所有";
                case DocumentManagerStringId.OpenedWindowsDialogNameColumnCaption:
                    return "名称";
                case DocumentManagerStringId.OpenedWindowsDialogPathColumnCaption:
                    return "路径";
                case DocumentManagerStringId.OpenedWindowsDialogCaption:
                    return "窗口";
                case DocumentManagerStringId.CloseAllDocumentsWarningMessage:
                    return "确定关闭所有文档";
                case DocumentManagerStringId.CloseDocumentWarningMessage:
                    return "确定关闭文档[{0}]?";
            }
            var res = base.GetLocalizedString(id);
            return res;
        }
    }
    class ChsLayoutLocalizer : LayoutLocalizer
    {
        public override string GetLocalizedString(LayoutStringId id)
        {
            switch (id)
            {
                case LayoutStringId.AddItem:
                    return "添加项";
                case LayoutStringId.ShowCustomizationFormMenuText:
                    return "定制面板";
                case LayoutStringId.UndoHintCaption:
                    return "撤销(Ctrl+Z)";
                case LayoutStringId.RedoHintCaption:
                    return "重复(Ctrl+Y)";
                case LayoutStringId.SaveHintCaption:
                    return "保存(Ctrl+S)";
                case LayoutStringId.LoadHintCaption:
                    return "加载(Ctrl+O)";
                case LayoutStringId.UndoButtonHintText:
                    return "撤销上次操作";
                case LayoutStringId.RedoButtonHintText:
                    return "重复上次操作";
                case LayoutStringId.SaveButtonHintText:
                    return "将布局信息保存在xml文件中";
                case LayoutStringId.LoadButtonHintText:
                    return "从xml文件中加载布局信息";
                case LayoutStringId.CustomizationFormTitle:
                    return "自定义";
                case LayoutStringId.ControlGroupDefaultText:
                    return "分组";
                case LayoutStringId.TreeViewPageTitle:
                    return "树状视图";
                case LayoutStringId.HiddenItemsPageTitle:
                    return "隐藏条目";
                case LayoutStringId.EmptySpaceItemDefaultText:
                    return "空白区域项目";
                case LayoutStringId.HiddenItemsNodeText:
                    return "隐藏数据项";
                case LayoutStringId.SimpleLabelItemDefaultText:
                    return "标签";
                case LayoutStringId.SimpleSeparatorItemDefaultText:
                    return "分隔符";
                case LayoutStringId.SplitterItemDefaultText:
                    return "拆分器";
                case LayoutStringId.HideCustomizationFormMenuText:
                    return "隐藏布局面板";
                case LayoutStringId.BestFitMenuText:
                    return "最佳匹配";
                case LayoutStringId.LockMenuGroup:
                    return "强制限定大小";
                case LayoutStringId.ResetConstraintsToDefaultsMenuItem:
                    return "重置";
                case LayoutStringId.FreeSizingMenuItem:
                    return "允许改变大小";
                case LayoutStringId.LockSizeMenuItem:
                    return "锁定大小";
                case LayoutStringId.LockWidthMenuItem:
                    return "锁定宽度";
                case LayoutStringId.LockHeightMenuItem:
                    return "锁定高度";
                case LayoutStringId.RenameMenuText:
                    return "重命名";
                case LayoutStringId.ShowTextMenuItem:
                    return "显示文本";
                case LayoutStringId.HideTextMenuItem:
                    return "隐藏文本";
                case LayoutStringId.TextPositionMenuText:
                    return "文本位置";
                case LayoutStringId.TextPositionTopMenuText:
                    return "上方";
                case LayoutStringId.TextPositionBottomMenuText:
                    return "下方";
                case LayoutStringId.TextPositionLeftMenuText:
                    return "左边";
                case LayoutStringId.TextPositionRightMenuText:
                    return "右边";
                case LayoutStringId.HideItemMenutext:
                    return "隐藏条目";
                case LayoutStringId.GroupItemsMenuText:
                    return "分组";
                case LayoutStringId.CreateTabbedGroupMenuText:
                    return "创建群组标签页";
                case LayoutStringId.CreateEmptySpaceItem:
                    return "创建空白区域项";
                case LayoutStringId.UnGroupItemsMenuText:
                    return "取消分组";
                case LayoutStringId.ConvertToText:
                    return "转换为";
                case LayoutStringId.FlowLayoutText:
                    return "流式布局";
                case LayoutStringId.RegularLayoutText:
                    return "常规布局";
                case LayoutStringId.TableLayoutText:
                    return "表格布局";
                case LayoutStringId.GroupStyleMenuText:
                    return "分组样式";
                case LayoutStringId.UnGroupTabbedGroupMenuText:
                    return "解除分组标签页";
                case LayoutStringId.AddTabMenuText:
                    return "添加标签页";
            }
            var res = base.GetLocalizedString(id);
            return res;
        }
    }

}
