导入,导出01

 

//
// ImpExpSettPanel.cs
//
// Copyright(c) 2011 Actia (China) Co., Ltd. All Rights Reserved.
//
// Owner: Vincent BRIARD
// Created on: 2011/4/28
//
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using AppCore.UI.Interface;
using Utils.Model;
using AppCore.UI.CustomComponents;
using Utils.App;

namespace AppCore.UI.Settings
{
    /// <summary>
    /// Class to represent the import and export settigns for the options
    /// </summary>
    public partial class ImpExpSettPanel : UserControl, ILocalizable, ISettings
    {
        #region attributes
        //Import panel
        private FileSelectionPanel importPanel;
        //Export panel
        private FileSelectionPanel exportPanel;
        //table layout
        private TableLayoutPanel tlp;
        //从xml读取的import的路径的节点
        private static String IMP_PATH = "ExportImport/Import/ImportFilePath";
        //从xml读取的export的路径的节点
        private static String EXP_PATH = "ExportImport/Export/ExportFilePath";

        #endregion attributes

        public void SetSettingsPtr(IntPtr ptr)
        {
            IntPtr _SettingsPtr = ptr;
            if (_SettingsPtr != IntPtr.Zero)
            {
                importPanel.SetPtr(_SettingsPtr);
                exportPanel.SetPtr(_SettingsPtr);
            }
        }
        /// <summary>
        /// 构造函数
        /// </summary>
        public ImpExpSettPanel()
        {
            InitializeComponent();

            this.SuspendLayout();

            this.Margin = new Padding(0, 0, 0, 0);

            // create tlp
            this.tlp = new TableLayoutPanel();

            // Set the BorderStyle to Inset
            this.tlp.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;

            this.tlp.ColumnCount = 2;
            this.tlp.RowCount = 2;

            // the table layout panel fill the whole main window
            this.tlp.Dock = DockStyle.Fill;

            // If grid is full do nothing
            this.tlp.GrowStyle = TableLayoutPanelGrowStyle.FixedSize;

            // Padding of the tlp (usefull?!)
            this.tlp.Padding = new Padding(0, 0, 0, 0);

            // Adding column style
            this.tlp.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));
            this.tlp.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50));

            // Adding row style
            this.tlp.RowStyles.Add(new RowStyle(SizeType.Percent, 50));
            this.tlp.RowStyles.Add(new RowStyle(SizeType.Percent, 50));

            // adding import panel
            this.importPanel = new FileSelectionPanel(FileSelType.Import);
            this.importPanel.Dock = DockStyle.Fill;
           
            this.tlp.Controls.Add(this.importPanel, 0, 0);

            // adding export panel
            this.exportPanel = new FileSelectionPanel(FileSelType.Export);
            this.exportPanel.Dock = DockStyle.Fill;
            this.tlp.Controls.Add(this.exportPanel, 0, 1);

 

            // add tlp to the control
            this.Controls.Add(this.tlp);

            this.ResumeLayout(false);
        }

        #region ILocalizable Members

        public bool CanBeValidated()
        {
            Boolean validated = true;
            validated = validated && this.importPanel.CanBeValidated();
            validated = validated && this.exportPanel.CanBeValidated();
            return validated;
        }
        /// <summary>
        /// Load localized Content for all children elements in the UI
        /// </summary>
        public void LoadLocalizedContent()
        {

            foreach (Control ctrl in this.tlp.Controls)
            {
                if (ctrl is ILocalizable)
                {
                    ((ILocalizable)ctrl).LoadLocalizedContent();
                }
            }
        }

        #endregion

        /// <summary>
        /// Method used to resize the content of a TabControl which font changed
        /// </summary>
        public void InitialFontSize()
        {
            this.exportPanel.InitialFontSize();
            this.importPanel.InitialFontSize();
        }

        #region ISettings Members

        public SettingValueList GetRequestedSettings()
        {
            // generate the setting request
            SettingValue<String> impSett = new SettingValue<String>(IMP_PATH, "");
            SettingValue<String> expSett = new SettingValue<String>(EXP_PATH, "");


            // store the setting values in the list
            SettingValueList svl = new SettingValueList();
            svl.AddSettingValue(impSett);
            svl.AddSettingValue(expSett);

            return svl;
        }

        public SettingValueList GetSettingsFromUI()
        {
            // generate the setting request
            SettingValue<String> impSett = new SettingValue<String>(IMP_PATH, this.importPanel.GetFilePath());
            SettingValue<String> expSett = new SettingValue<String>(EXP_PATH, this.exportPanel.GetFilePath());


            // store the setting values in the list
            SettingValueList svl = new SettingValueList();
            svl.AddSettingValue(impSett);
            svl.AddSettingValue(expSett);

            return svl;
        }

        public void SetSettingFromFile(SettingValueList pSvl)
        {
            SettingValue<String> importSett = (SettingValue<String>)pSvl.FindSettingByName(IMP_PATH)[0];
            this.importPanel.SetFilePath((String)importSett.GetValue());

            SettingValue<String> exportSett = (SettingValue<String>)pSvl.FindSettingByName(EXP_PATH)[0];
            this.exportPanel.SetFilePath((String)exportSett.GetValue());
        }

        #endregion
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值