示例#1
0
        private void btnUpdate_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                var dialog = new UpdateWizard();

                System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(dialog);
                helper.Owner = (IntPtr)ThisAddIn.ExcelApplication.Hwnd;

                var viewModel = new UpdateWizardViewModel();

                var latList  = viewModel.ColumnHeaders.Where(lt => Common.Constants.LatSearchList.Contains(lt.ToLower()));
                var longList = viewModel.ColumnHeaders.Where(ln => Common.Constants.LonSearchList.Contains(ln.ToLower()));

                // if (string.Compare(viewModel.ColumnHeaders[0], "lat", true) == 0 && string.Compare(viewModel.ColumnHeaders[1], "lon", true) == 0)
                if (latList.Count() > 0 && longList.Count() > 0)
                {
                    viewModel.RequestClose += new EventHandler(dialog.OnRequestClose);
                    dialog.DataContext      = viewModel;
                    dialog.ShowDialog();

                    viewModel.RequestClose -= new EventHandler(dialog.OnRequestClose);
                    dialog.Close();
                }
                else
                {
                    Ribbon.ShowError("The excel spreadsheet is not in expected format. Current worksheet should have \"lat\" and \"lon\" columns.");
                }
            }
            catch (CustomException ex)
            {
                Ribbon.ShowError(ex.HasCustomMessage ? ex.Message : Resources.LayerOperationError);
            }
            catch (Exception exception)
            {
                Logger.LogException(exception);
                Ribbon.ShowError(Resources.DefaultErrorMessage);
            }
        }
示例#2
0
        private void btnUpdate_Click(object sender, RibbonControlEventArgs e)
        {
            try
            {
                var dialog = new UpdateWizard();

                System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(dialog);
                helper.Owner = (IntPtr)ThisAddIn.ExcelApplication.Hwnd;

                var viewModel = new UpdateWizardViewModel();

                var latList = viewModel.ColumnHeaders.Where(lt => Common.Constants.LatSearchList.Contains(lt.ToLower()));
                var longList = viewModel.ColumnHeaders.Where(ln => Common.Constants.LonSearchList.Contains(ln.ToLower()));

                // if (string.Compare(viewModel.ColumnHeaders[0], "lat", true) == 0 && string.Compare(viewModel.ColumnHeaders[1], "lon", true) == 0)
                if (latList.Count() > 0 && longList.Count() > 0)
                {
                    viewModel.RequestClose += new EventHandler(dialog.OnRequestClose);
                    dialog.DataContext = viewModel;
                    dialog.ShowDialog();

                    viewModel.RequestClose -= new EventHandler(dialog.OnRequestClose);
                    dialog.Close();
                }
                else
                {
                    Ribbon.ShowError("The excel spreadsheet is not in expected format. Current worksheet should have \"lat\" and \"lon\" columns.");
                }
            }
            catch (CustomException ex)
            {
                Ribbon.ShowError(ex.HasCustomMessage ? ex.Message : Resources.LayerOperationError);
            }
            catch (Exception exception)
            {
                Logger.LogException(exception);
                Ribbon.ShowError(Resources.DefaultErrorMessage);
            }
        }