예제 #1
0
        private void DataGrid_SelectedCellsChanged(object sender, FastWpfGrid.SelectionChangedEventArgs e)
        {
            var grid = copyTargetGrid = sender as FastGridControl;

            if (grid == null)
            {
                return;
            }

            copyTargetGrid = grid;

            DataGridEventDispatcher.DispatchSelectedCellChangeEvent(grid, container);

            if (!SrcDataGrid.CurrentCell.Row.HasValue || !DstDataGrid.CurrentCell.Row.HasValue)
            {
                return;
            }

            if (!SrcDataGrid.CurrentCell.Column.HasValue || !DstDataGrid.CurrentCell.Column.HasValue)
            {
                return;
            }

            if (SrcDataGrid.Model == null || DstDataGrid.Model == null)
            {
                return;
            }

            var srcValue =
                (SrcDataGrid.Model as DiffGridModel).GetCellText(SrcDataGrid.CurrentCell.Row.Value, SrcDataGrid.CurrentCell.Column.Value, true);
            var dstValue =
                (DstDataGrid.Model as DiffGridModel).GetCellText(DstDataGrid.CurrentCell.Row.Value, DstDataGrid.CurrentCell.Column.Value, true);

            UpdateValueDiff(srcValue, dstValue);
        }
예제 #2
0
        public void OnRowHeaderReset(FastGridControl target, IUnityContainer container)
        {
            var dataGrid = container.Resolve <FastGridControl>(Key);

            (dataGrid.Model as DiffGridModel).SetRowHeader(-1);

            dataGrid.NotifyColumnArrangeChanged();
            DataGridEventDispatcher.DispatchModelUpdateEvent(dataGrid, container);
        }
예제 #3
0
        private void ShowOnlyDiffRadioButton_Checked(object sender, RoutedEventArgs e)
        {
            if (SrcDataGrid?.Model != null && DstDataGrid?.Model != null)
            {
                (SrcDataGrid.Model as DiffGridModel).HideEqualRows();
                DataGridEventDispatcher.DispatchModelUpdateEvent(SrcDataGrid, container);

                (DstDataGrid.Model as DiffGridModel).HideEqualRows();
                DataGridEventDispatcher.DispatchModelUpdateEvent(DstDataGrid, container);
            }
        }
예제 #4
0
        private void ResetColumnHeader_Click(object sender, RoutedEventArgs e)
        {
            var menuItem = sender as MenuItem;

            if (menuItem != null)
            {
                var dataGrid = ((ContextMenu)menuItem.Parent).PlacementTarget as FastGridControl;
                if (dataGrid != null)
                {
                    DataGridEventDispatcher.DispatchColumnHeaderResetEvent(sender as FastGridControl, container);
                }
            }
        }
예제 #5
0
        public DiffView()
        {
            InitializeComponent();

            container = new UnityContainer();
            container
            .RegisterInstance(srcKey, SrcDataGrid)
            .RegisterInstance(dstKey, DstDataGrid)
            .RegisterInstance(srcKey, SrcLocationGrid)
            .RegisterInstance(dstKey, DstLocationGrid)
            .RegisterInstance(srcKey, SrcViewRectangle)
            .RegisterInstance(dstKey, DstViewRectangle)
            .RegisterInstance(srcKey, SrcValueTextBox)
            .RegisterInstance(dstKey, DstValueTextBox);

            var srcEventHandler = new EventHandler(srcKey);
            var dstEventHandler = new EventHandler(dstKey);

            DataGridEventDispatcher.Listeners.Add(srcEventHandler);
            DataGridEventDispatcher.Listeners.Add(dstEventHandler);
            LocationGridEventDispatcher.Listeners.Add(srcEventHandler);
            LocationGridEventDispatcher.Listeners.Add(dstEventHandler);
            ViewportEventDispatcher.Listeners.Add(srcEventHandler);
            ViewportEventDispatcher.Listeners.Add(dstEventHandler);
            ValueTextBoxEventDispatcher.Listeners.Add(srcEventHandler);
            ValueTextBoxEventDispatcher.Listeners.Add(dstEventHandler);

            App.Instance.OnSettingUpdated += () =>
            {
                SrcDataGrid.AlternatingColors = App.Instance.Setting.AlternatingColors;
                SrcDataGrid.CellFontName      = App.Instance.Setting.FontName;
                DataGridEventDispatcher.DispatchModelUpdateEvent(SrcDataGrid, container);
                DstDataGrid.AlternatingColors = App.Instance.Setting.AlternatingColors;
                DstDataGrid.CellFontName      = App.Instance.Setting.FontName;
                DataGridEventDispatcher.DispatchModelUpdateEvent(DstDataGrid, container);
            };

            SearchTextCombobox.ItemsSource = App.Instance.Setting.SearchHistory.ToList();

            ToolExpander.IsExpanded = true;
        }
예제 #6
0
        private void ExecuteDiff(bool isStartup = false)
        {
            if (!File.Exists(SrcPathTextBox.Text) || !File.Exists(DstPathTextBox.Text))
            {
                return;
            }

            SrcDataGrid.ScrollIntoView(FastGridCellAddress.Empty);
            DstDataGrid.ScrollIntoView(FastGridCellAddress.Empty);

            SrcDataGrid.FirstVisibleColumnScrollIndex = 0;
            SrcDataGrid.FirstVisibleRowScrollIndex    = 0;
            DstDataGrid.FirstVisibleColumnScrollIndex = 0;
            DstDataGrid.FirstVisibleRowScrollIndex    = 0;

            SrcDataGrid.InitializeComponent();
            DstDataGrid.InitializeComponent();

            SrcDataGrid.SetMaxColumnSize(App.Instance.Setting.CellWidth);
            DstDataGrid.SetMaxColumnSize(App.Instance.Setting.CellWidth);
            SrcDataGrid.SetMinColumnSize(App.Instance.Setting.CellWidth);
            DstDataGrid.SetMinColumnSize(App.Instance.Setting.CellWidth);

            var           srcPath = SrcPathTextBox.Text;
            var           dstPath = DstPathTextBox.Text;
            ExcelWorkbook wb1     = null;
            ExcelWorkbook wb2     = null;

            ProgressWindow.DoWorkWithModal(progress =>
            {
                progress.Report(Properties.Resources.Msg_ReadingFiles);

                var config = CreateReadConfig();
                wb1        = ExcelWorkbook.Create(srcPath, config);
                wb2        = ExcelWorkbook.Create(dstPath, config);
            });

            FileSetting srcSetting = null;
            FileSetting dstSetting = null;

            if (!IgnoreFileSettingCheckbox.IsChecked.Value)
            {
                srcSetting =
                    FindFilseSetting(Path.GetFileName(SrcPathTextBox.Text), SrcSheetCombobox.SelectedIndex, SrcSheetCombobox.SelectedItem.ToString(), isStartup);

                dstSetting =
                    FindFilseSetting(Path.GetFileName(DstPathTextBox.Text), DstSheetCombobox.SelectedIndex, DstSheetCombobox.SelectedItem.ToString(), isStartup);

                diffConfig = CreateDiffConfig(srcSetting, dstSetting, isStartup);
            }
            else
            {
                diffConfig = new ExcelSheetDiffConfig();

                diffConfig.SrcSheetIndex = Math.Max(SrcSheetCombobox.SelectedIndex, 0);
                diffConfig.DstSheetIndex = Math.Max(DstSheetCombobox.SelectedIndex, 0);
            }

            SrcSheetCombobox.SelectedIndex = diffConfig.SrcSheetIndex;
            DstSheetCombobox.SelectedIndex = diffConfig.DstSheetIndex;

            var sheet1 = wb1.Sheets[SrcSheetCombobox.SelectedItem.ToString()];
            var sheet2 = wb2.Sheets[DstSheetCombobox.SelectedItem.ToString()];

            if (sheet1.Rows.Count > 10000 || sheet2.Rows.Count > 10000)
            {
                MessageBox.Show(Properties.Resources.Msg_WarnSize);
            }

            ExcelSheetDiff diff = null;

            ProgressWindow.DoWorkWithModal(progress =>
            {
                progress.Report(Properties.Resources.Msg_ExtractingDiff);
                diff = ExcelSheet.Diff(sheet1, sheet2, diffConfig);
            });

            var modelConfig = new DiffGridModelConfig();
            var srcModel    = new DiffGridModel(DiffType.Source, diff, modelConfig);
            var dstModel    = new DiffGridModel(DiffType.Dest, diff, modelConfig);

            (DataContext as ViewModels.DiffViewModel).UpdateDiffSummary(diff.CreateSummary());

            SrcDataGrid.AlternatingColors = App.Instance.Setting.AlternatingColors;
            DstDataGrid.AlternatingColors = App.Instance.Setting.AlternatingColors;
            SrcDataGrid.CellFontName      = App.Instance.Setting.FontName;
            DstDataGrid.CellFontName      = App.Instance.Setting.FontName;

            SrcDataGrid.Model = srcModel;
            DstDataGrid.Model = dstModel;

            if (ShowOnlyDiffRadioButton.IsChecked.Value)
            {
                srcModel.HideEqualRows();
                srcModel.HideEqualRows();
            }

            if (srcSetting != null)
            {
                srcModel.SetColumnHeader(srcSetting.ColumnHeaderIndex);
                if (string.IsNullOrEmpty(srcSetting.RowHeaderName))
                {
                    srcModel.SetRowHeader(srcSetting.RowHeaderIndex);
                }
                else
                {
                    srcModel.SetRowHeader(srcSetting.RowHeaderName);
                }
                SrcDataGrid.MaxRowHeaderWidth = srcSetting.MaxRowHeaderWidth;
            }

            if (dstSetting != null)
            {
                dstModel.SetColumnHeader(dstSetting.ColumnHeaderIndex);
                if (string.IsNullOrEmpty(dstSetting.RowHeaderName))
                {
                    dstModel.SetRowHeader(dstSetting.RowHeaderIndex);
                }
                else
                {
                    dstModel.SetRowHeader(dstSetting.RowHeaderName);
                }
                DstDataGrid.MaxRowHeaderWidth = dstSetting.MaxRowHeaderWidth;
            }

            DataGridEventDispatcher.DispatchModelUpdateEvent(SrcDataGrid, container);
            DataGridEventDispatcher.DispatchModelUpdateEvent(DstDataGrid, container);

            if (!App.Instance.KeepFileHistory)
            {
                App.Instance.UpdateRecentFiles(SrcPathTextBox.Text, DstPathTextBox.Text);
            }
        }
예제 #7
0
 private void DataGrid_SizeChanged(object sender, SizeChangedEventArgs e)
 {
     DataGridEventDispatcher.DispatchSizeChangeEvent(sender as FastGridControl, container, e);
 }
예제 #8
0
 private void DataGrid_Scrolled(object sender, EventArgs e)
 {
     DataGridEventDispatcher.DispatchScrollEvnet(sender as FastGridControl, container);
 }