예제 #1
0
        public ColumnChooser(SpreadSheetModel dataModel)
        {
            InitializeComponent();

            _dataModel       = dataModel;
            this.DataContext = dataModel;

            int i = 0;

            foreach (var column in dataModel.ColumnNames)
            {
                this.SampleData.Columns.Add(new DataGridTextColumn()
                {
                    Header = column, Binding = new Binding($"[{i}]")
                });
                i++;
            }
        }
예제 #2
0
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Get spreadsheet details from the user
        /// </summary>
        /// -----------------------------------------------------------------------------------
        public override bool HandlePreScan(Seed seed)
        {
            _spreadSheetModel = new SpreadSheetModel(seed.Id);

            var chooser  = new ColumnChooser(_spreadSheetModel);
            var settings = SettingsHandler.GetSettings <SpreadsheetSettings>("SpreadSheetHandler");

            if (settings == null)
            {
                settings = new SpreadsheetSettings();
            }
            if (_spreadSheetModel.ColumnNames.Contains(settings.PathColumn))
            {
                _spreadSheetModel.SelectedPathColumn = _spreadSheetModel.GetColumnIndex(settings.PathColumn);
            }
            if (settings.SizeColumn != null)
            {
                _spreadSheetModel.SizeColumn = settings.SizeColumn;
            }
            if (settings.DoubleClickTemplate != null)
            {
                _spreadSheetModel.DoubleClickTemplate = settings.DoubleClickTemplate;
            }

            if (chooser.ShowDialog().Value)
            {
                var pathColumn = _spreadSheetModel.ColumnNames[_spreadSheetModel.SelectedPathColumn];
                _columnInfo = ColumnInfo.CreateFromFixedColumns(_spreadSheetModel.ColumnNames, _spreadSheetModel.ValueColumns, pathColumn);
                SizeColumn  = _spreadSheetModel.SizeColumn;

                settings.PathColumn          = pathColumn;
                settings.SizeColumn          = _spreadSheetModel.SizeColumn;
                settings.DoubleClickTemplate = _spreadSheetModel.DoubleClickTemplate;
                SettingsHandler.SaveSettings("SpreadSheetHandler", settings);
                return(true);
            }
            return(false);
        }