示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="EditDataDialog"/> class.
        /// </summary>
        /// <param name="parentTaskPane">The <see cref="ExcelAddInPane"/> from which the <see cref="EditDataDialog"/> is called.</param>
        /// <param name="parentWindow">The parent window assigned to the <see cref="EditDataDialog"/> to be opened as a dialog.</param>
        /// <param name="wbConnection">The connection to a MySQL server instance selected by users.</param>
        /// <param name="originalEditDataRange">The Excel cells range containing the MySQL table's data being edited.</param>
        /// <param name="importTable">The table containing the data imported from the MySQL table that will be edited.</param>
        /// <param name="editingWorksheet">The Excel worksheet tied to the current editing session.</param>
        public EditDataDialog(ExcelAddInPane parentTaskPane, IWin32Window parentWindow, MySqlWorkbenchConnection wbConnection, ExcelInterop.Range originalEditDataRange, MySqlDataTable importTable, ExcelInterop.Worksheet editingWorksheet)
        {
            _mouseDownPoint = Point.Empty;
            _neverBeenShown = true;
            _updatingUSeOptimisticUpdateSetting = false;

            InitializeComponent();

            var existingProtectionKey = editingWorksheet.GetProtectionKey();

            WorksheetProtectionKey            = string.IsNullOrEmpty(existingProtectionKey) ? Guid.NewGuid().ToString() : existingProtectionKey;
            _parentTaskPane                   = parentTaskPane;
            _parentWindow                     = parentWindow;
            _wbConnection                     = wbConnection;
            _editDataRange                    = originalEditDataRange;
            _mySqlTable                       = importTable;
            EditingWorksheet                  = editingWorksheet;
            EditingWorksheet.SelectionChange += EditingWorksheet_SelectionChange;
            ResetToolTip();
            Opacity = 0.60;
            AddNewRowToEditingRange(false);
            _useOptimisticUpdateForThisSession           = Settings.Default.EditUseOptimisticUpdate;
            ForThisSessionToolStripMenuItem.Checked      = _useOptimisticUpdateForThisSession;
            ForAllSessionsToolStripMenuItem.Checked      = _useOptimisticUpdateForThisSession;
            UseOptimisticUpdateToolStripMenuItem.Checked = _useOptimisticUpdateForThisSession;
            Settings.Default.PropertyChanged            += SettingsPropertyValueChanged;
        }