コード例 #1
0
 public void delegaty(ToOptions e)
 {
     this.AppContext.Invoke(() => {
         okButton.Sensitive = false;
     });
     SeedTableInterface.InformationMessageEventHandler handler =
         (string message) => {
         Console.WriteLine(message);
         this.AppContext.Invoke(() => {
             textBox.Insert(message + "\n", textBox.CursorPosition);
         });
     };
     SeedTableInterface.InformationMessageEvent += handler;
     try {
         SeedTableInterface.SeedToExcel(e);
         Status = true;
     } catch (SeedTableInterface.CannotContinueException) {
         Status = false;
     }
     finally {
         this.AppContext.Invoke(() => {
             okButton.Sensitive = true;
         });
         SeedTableInterface.InformationMessageEvent -= handler;
     }
 }
コード例 #2
0
ファイル: SeedTableX11.cs プロジェクト: enpel/seedtable
        private void YamlToExcel(string[] fileNames)
        {
            if (fileNames == null)
            {
                return;
            }
            var fileBaseNames = fileNames.Select(fileName => Path.GetFileName(fileName));
            var fileDirNames  = fileNames.Select(fileName => Path.GetDirectoryName(fileName));
            var fileDirName   = fileDirNames.First();

            if (!fileDirNames.All(_fileDirName => fileDirName == _fileDirName))
            {
                ShowMessageBox("同じフォルダにあるxlsxファイルのみにして下さい", "エラー");
                return;
            }
            var setting = LoadSetting();

            if (setting == null)
            {
                return;
            }
            var d = new FileSelectionDialog();

            d.FileTypeMask = FileTypeMask.Directory;
            d.DialogStyle  = DialogStyle.FullApplicationModal;
            d.PathMode     = PathMode.Relative;
            d.Directory    = YamlToExcelTargetFolder;
            d.CancelEvent += (x, y) => {
                d.Destroy();
            };
            d.OkEvent += (x, y) => {
                YamlToExcelTargetFolder = System.IO.Path.Combine(d.Directory, d.TextString);
                SaveFormValues();

                var options = new ToOptions();
                options.files          = fileBaseNames;
                options.seedInput      = SeedPath;
                options.xlsxInput      = fileDirName;
                options.output         = YamlToExcelTargetFolder;
                options.columnNamesRow = setting.columnNamesRow;
                options.dataStartRow   = setting.dataStartRow;
                options.engine         = setting.engine;
                options.ignoreColumns  = setting.ignoreColumns;
                options.ignore         = setting.ignore;
                options.only           = setting.only;
                options.subdivide      = setting.subdivide;
                options.mapping        = setting.mapping;
                options.versionColumn  = setting.versionColumn;
                options.requireVersion = setting.requireVersion;
                options.delete         = setting.delete;
                options.seedExtension  = setting.seedExtension;
                options.calcFormulas   = setting.calcFormulas;
                d.Destroy();

                var dialog = new YamlToExcelDialogX11(options);
                this.Layout.Children.Add(dialog);
                dialog.Popup(GrabOption.Exclusive);
            };
            this.Layout.Children.Add(d);
        }
コード例 #3
0
ファイル: SeedTableGUI.cs プロジェクト: enpel/seedtable
        private void YamlToExcel(string[] fileNames)
        {
            if (fileNames == null)
            {
                return;
            }
            var fileBaseNames = fileNames.Select(fileName => Path.GetFileName(fileName));
            var fileDirNames  = fileNames.Select(fileName => Path.GetDirectoryName(fileName));
            var fileDirName   = fileDirNames.First();

            if (!fileDirNames.All(_fileDirName => fileDirName == _fileDirName))
            {
                MessageBox.Show("同じフォルダにあるxlsxファイルのみにして下さい", "エラー");
                return;
            }
            var setting = LoadSetting();

            if (setting == null)
            {
                return;
            }
            dataExcelFolderBrowserDialog.SelectedPath = DataExcelsDirectoryPath;
            if (dataExcelFolderBrowserDialog.ShowDialog() == DialogResult.OK)
            {
                DataExcelsDirectoryPath = dataExcelFolderBrowserDialog.SelectedPath;
            }
            else
            {
                return;
            }
            var options = new ToOptions();

            options.files          = fileBaseNames;
            options.seedInput      = SeedPath;
            options.xlsxInput      = fileDirName;
            options.output         = DataExcelsDirectoryPath;
            options.columnNamesRow = setting.columnNamesRow;
            options.dataStartRow   = setting.dataStartRow;
            options.engine         = setting.engine;
            options.ignoreColumns  = setting.ignoreColumns;
            options.ignore         = setting.ignore;
            options.only           = setting.only;
            options.subdivide      = setting.subdivide;
            options.mapping        = setting.mapping;
            options.versionColumn  = setting.versionColumn;
            options.requireVersion = setting.requireVersion;
            options.delete         = setting.delete;
            options.seedExtension  = options.seedExtension;
            options.calcFormulas   = setting.calcFormulas;
            var dialog = new YamlToExcelDialog(options);

            dialog.ShowDialog();
        }
コード例 #4
0
 public YamlToExcelDialogX11(ToOptions options) : base()
 {
     Options = options;
     this.AllowAutoManage        = false;
     this.DeleteResponse         = DeleteResponse.DoNothing;
     this.CreatePopupChildEvent += (x, y) => {
         Sinatra();
         new Task(() => {
             delegaty(options);
         }).Start();
     };
 }
コード例 #5
0
        protected virtual ToOptions BuildToOptions(IEnumerable <string> files, string seedInput, string xlsxInput, string output, bool calcFormulas = true)
        {
            var options = new ToOptions();

            options.files        = files;
            options.engine       = CommonOptions.Engine.EPPlus;
            options.calcFormulas = calcFormulas;
            options.xlsxInput    = xlsxInput;
            options.seedInput    = seedInput;
            options.output       = output;
            OptionsList.Add(options);
            return(options);
        }
コード例 #6
0
ファイル: SeedTableX11.cs プロジェクト: enpel/seedtable
        private void settingButton_Click(object sender, EventArgs e)
        {
            var setting = LoadSetting(false);

            if (setting == null)
            {
                setting = new ToOptions();
            }
            var settingReadOnly = SettingReadOnly();

            var dialog = new SettingDialogX11(setting, !settingReadOnly, new SettingHandler(this));

            this.Layout.Children.Add(dialog);
            dialog.Popup(GrabOption.Exclusive);
        }
コード例 #7
0
 public SettingDialogX11(ToOptions options, bool changeable, SeedTableX11.SettingHandler handler) : base()
 {
     this.Width                  = 700;
     this.Height                 = 600;
     Options                     = options;
     XHandler                    = handler;
     Changable                   = changeable;
     this.AllowAutoManage        = false;
     this.AllowShellResize       = true;
     this.Title                  = "Settings";
     this.CreatePopupChildEvent += (x, y) => {
         Sinatra();
     };
     this.PopdownEvent += (x, p) => {
         this.Destroy();
     };
 }
コード例 #8
0
ファイル: SeedTableGUI.cs プロジェクト: enpel/seedtable
        private void SaveSetting(ToOptions options)
        {
            // 使わないパス情報は空にして出力しないようにする
            options.output    = null;
            options.seedInput = null;
            options.xlsxInput = null;
            var builder = new SerializerBuilder();

            builder.WithNamingConvention(new HyphenatedNamingConvention());
            var serializer = builder.Build();
            var yaml       = serializer.Serialize(options);

            if (SettingPath == null || SettingPath.Length == 0)
            {
                SettingPath = Path.Combine(Application.StartupPath, DefaultSettingFile);
            }
            File.WriteAllText(SettingPath, yaml);
        }
コード例 #9
0
        public SettingDialog(ToOptions options, bool changeable = true)
        {
            InitializeComponent();
            foreach (Control controll in Controls)
            {
                controll.Enabled = changeable;
            }

            var toOptionsStringListDataSource = new ToOptionsStringListDataSource(options);

            subdivideTextBox.DataBindings.Add("Text", toOptionsStringListDataSource, "subdivide", true, DataSourceUpdateMode.OnPropertyChanged);
            onlyTextBox.DataBindings.Add("Text", toOptionsStringListDataSource, "only", true, DataSourceUpdateMode.OnPropertyChanged);
            ignoreTextBox.DataBindings.Add("Text", toOptionsStringListDataSource, "ignore", true, DataSourceUpdateMode.OnPropertyChanged);
            mappingTextBox.DataBindings.Add("Text", toOptionsStringListDataSource, "mapping", true, DataSourceUpdateMode.OnPropertyChanged);
            ignoreColumnsTextBox.DataBindings.Add("Text", toOptionsStringListDataSource, "ignoreColumns", true, DataSourceUpdateMode.OnPropertyChanged);
            yamlColumnsTextBox.DataBindings.Add("Text", toOptionsStringListDataSource, "yamlColumns", true, DataSourceUpdateMode.OnPropertyChanged);

            engineComboBox.DataSource         = Enum.GetValues(typeof(ToOptions.Engine));
            toOptionsBindingSource.DataSource = options;
        }
コード例 #10
0
ファイル: SeedTableX11.cs プロジェクト: enpel/seedtable
        internal void SaveSetting(ToOptions options)
        {
            // 使わないパス情報は空にして出力しないようにする
            options.output    = null;
            options.seedInput = null;
            options.xlsxInput = null;
            var builder = new SerializerBuilder();

            builder.WithNamingConvention(new HyphenatedNamingConvention());
            var serializer = builder.Build();
            var yaml       = serializer.Serialize(options);

            if (SettingPath == null || SettingPath.Length == 0)
            {
                // TODO: もう少しエレガントな方法は無いものか
                SettingPath =
                    Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), DefaultSettingFile);
            }
            File.WriteAllText(SettingPath, yaml);
        }
コード例 #11
0
 public YamlToExcelDialog(ToOptions options) : base()
 {
     InitializeComponent();
     Options = options;
 }
コード例 #12
0
 protected void Prepare(ToOptions options)
 {
     SeedTableInterface.SeedToExcel(options);
 }
コード例 #13
0
 public ToOptionsStringListDataSource(ToOptions options)
 {
     Options = options;
 }
コード例 #14
0
ファイル: SeedTableX11.cs プロジェクト: enpel/seedtable
 public void Save(ToOptions opt)
 {
     x11.SaveSetting(opt);
 }