📄 mainform.cs
字号:
this.downMenuItem_Click( sender, null );
} else if ( e.Button == this.botUpButton ){
this.upMenuItem_Click( sender, null );
}
}
private void newMenuItem_Click(object sender, System.EventArgs e)
{
if( ! this.CheckChanges() ){
return;
}
this.config = new YariSoft.DBCommander.Misc.ConfigInfo();
this.InitConnections();
}
private void openMenuItem_Click(object sender, System.EventArgs e)
{
if( ! this.CheckChanges() ){
return;
}
OpenFileDialog Dialog = new OpenFileDialog();
if( Dialog.ShowDialog() == DialogResult.Cancel ){
return;
}
string fileName = Dialog.FileName;
Dialog.Dispose();
this.config = YariSoft.DBCommander.Misc.ConfigInfo.LoadFromFile ( fileName );
this.InitConnections();
}
private void saveMenuItem_Click(object sender, System.EventArgs e)
{
this.UpdateGridStyles();
this.config.SaveToFile();
this.RefreshButtons();
}
private void saveAsmenuItem_Click(object sender, System.EventArgs e)
{
this.UpdateGridStyles();
this.config.SaveAsToFile();
this.SetFormCaption();
this.RefreshButtons();
}
private void optionsMenuItem_Click(object sender, System.EventArgs e)
{
Modals.OptionsForm options = new Modals.OptionsForm( this.options );
if( options.ShowDialog() == DialogResult.OK ){
this.RefreshToolBars();
this.SetIdentityState();
this.agent.Init ( this.options.AgentOptions, true );
}
options.Dispose();
}
private void exitMenuItem_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void connectionMenuItem_Click(object sender, System.EventArgs e)
{
this.focusPanel.PrepareConnection();
if( this.focusPanel == this.leftDataPanel ){
this.config.LeftConnection = this.leftDataPanel.Connection.ConnectionString;
}else{
this.config.RightConnection = this.rightDataPanel.Connection.ConnectionString;
}
this.RefreshButtons();
}
private void viewMenuItem_Click(object sender, System.EventArgs e)
{
}
private void editMenuItem_Click(object sender, System.EventArgs e)
{
}
private void copyMenuItem_Click(object sender, System.EventArgs e)
{
string Question = "Do you wish to copy selected row";
if( this.focusPanel.SelectedRows.Count > 1 ){
Question += "s";
}
Question += "?";
if( ! this.ShowQuestionToUser( Question, "Copy" ) ){
return;
}
DataPanel previousFocusPanel = this.focusPanel;
this.focusPanel.CopyData( this.GetDestinationPanel() );
if( previousFocusPanel != this.focusPanel ){
this.ChangeActivePanel();
}
}
private void moveMenuItem_Click(object sender, System.EventArgs e)
{
string Question = "Do you wish to move selected row";
if( this.focusPanel.SelectedRows.Count > 1 ){
Question += "s";
}
Question += "?";
if( ! this.ShowQuestionToUser( Question, "Move" ) ){
return;
}
if( this.focusPanel.CopyData( this.GetDestinationPanel() ) ){
this.focusPanel.DeleteData();
}
}
private void createMenuItem_Click(object sender, System.EventArgs e)
{
}
private void deleteMenuItem_Click(object sender, System.EventArgs e)
{
string Question = "Do you wish to delete selected row";
if( this.focusPanel.SelectedRows.Count > 1 ){
Question += "s";
}
Question += "?";
if( ! this.ShowQuestionToUser( Question, "Delete" ) ){
return;
}
this.focusPanel.DeleteData();
}
private void downMenuItem_Click(object sender, System.EventArgs e)
{
this.focusPanel.MoveDown();
}
private void upMenuItem_Click(object sender, System.EventArgs e)
{
this.focusPanel.MoveUp();
}
private void aboutMenuItem_Click(object sender, System.EventArgs e)
{
YariSoft.DBCommander.Modals.AboutForm about = new YariSoft.DBCommander.Modals.AboutForm();
about.ShowDialog();
about.Dispose();
}
private void chanegPanelMenuItem_Click(object sender, System.EventArgs e)
{
this.ChangeActivePanel();
}
private void selectMenuItem_Click(object sender, System.EventArgs e)
{
SendKeys.Send( "{ADD}" );
}
private void unselectMenuItem_Click(object sender, System.EventArgs e)
{
SendKeys.Send( "{SUBTRACT}" );
}
private void filterMenuItem_Click(object sender, System.EventArgs e)
{
SendKeys.Send( "{MULTIPLY}" );
}
private void clearFilterMenuItem_Click(object sender, System.EventArgs e)
{
SendKeys.Send( "{DIVIDE}" );
}
private void refreshMenuItem_Click(object sender, System.EventArgs e)
{
this.focusPanel.RefreshData();
}
private void hideLeftPanelMenuItem_Click(object sender, System.EventArgs e)
{
this.ShowHidePanel( this.leftDataPanel );
}
private void hideRightPanelMenuItem_Click(object sender, System.EventArgs e)
{
this.ShowHidePanel( this.rightDataPanel );
}
#endregion
#region Other functions
private void ChangeActivePanel()
{
if( ! this.leftDataPanel.Visible || ! this.rightDataPanel.Visible ){
return;
}
this.ForceChangeActivePanel();
}
private void ForceChangeActivePanel()
{
if( this.focusPanel == this.leftDataPanel ){
this.focusPanel = this.rightDataPanel;
this.leftDataPanel.Active = false;
} else {
this.focusPanel = this.leftDataPanel;
this.rightDataPanel.Active = false;
}
this.RefreshButtons();
this.focusPanel.Focus();
this.focusPanel.Active = true;
}
private YariSoft.DBCommander.DataPanel GetDestinationPanel()
{
if( this.focusPanel == this.leftDataPanel ){
return this.rightDataPanel;
} else {
return this.leftDataPanel;
}
}
private void RefreshButtons()
{
this.RefreshUpDownButtons();
this.RefreshSaveButtons();
this.RefreshCopyButtons();
}
private void RefreshUpDownButtons()
{
bool editEnable = true;
if( this.focusPanel.Connection.ConnectionString == "" ){
editEnable = false;
this.upMenuItem.Enabled = editEnable;
this.toolUpButton.Enabled = editEnable;
this.botUpButton.Enabled = editEnable;
this.downMenuItem.Enabled = editEnable;
this.toolDownButton.Enabled = editEnable;
this.botDownButton.Enabled = editEnable;
return;
}
if( this.focusPanel.DetailLevel == YariSoft.DBCommander.DetailLevel.TableLevel ){
this.upMenuItem.Enabled = !editEnable;
this.toolUpButton.Enabled = !editEnable;
this.botUpButton.Enabled = !editEnable;
this.downMenuItem.Enabled = editEnable;
this.toolDownButton.Enabled = editEnable;
this.botDownButton.Enabled = editEnable;
this.selectMenuItem.Enabled = !editEnable;
this.unselectMenuItem.Enabled = !editEnable;
} else {
this.upMenuItem.Enabled = editEnable;
this.toolUpButton.Enabled = editEnable;
this.botUpButton.Enabled = editEnable;
this.downMenuItem.Enabled = !editEnable;
this.toolDownButton.Enabled = !editEnable;
this.botDownButton.Enabled = !editEnable;
this.selectMenuItem.Enabled = editEnable;
this.unselectMenuItem.Enabled = editEnable;
}
}
private void RefreshSaveButtons()
{
bool editEnable = true;
if( ! this.config.HasChanges ){
editEnable = false;
}
this.toolSaveButton.Enabled = editEnable;
this.saveMenuItem.Enabled = editEnable;
}
private void RefreshCopyButtons()
{
bool editEnable = true;
if( this.focusPanel.Connection.ConnectionString == "" ){
editEnable = false;
}
this.deleteMenuItem.Enabled = editEnable;
this.botDeleteButton.Enabled = editEnable;
if( editEnable && this.GetDestinationPanel().Connection.ConnectionString == "" ){
editEnable = false;
}
if( editEnable && this.focusPanel.DetailLevel != this.GetDestinationPanel().DetailLevel ){
editEnable = false;
}
this.copyMenuItem.Enabled = editEnable;
this.moveMenuItem.Enabled = editEnable;
this.botCopyButton.Enabled = editEnable;
this.botMoveButton.Enabled = editEnable;
}
private bool ShowQuestionToUser( string Question, string Caption ){
if( YariSoft.Utils.YMessages.Show( Question, Caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question ) == DialogResult.No ){
return false;
}
return true;
}
private bool CheckChanges(){
if( this.config.HasChanges ){
DialogResult res = YariSoft.Utils.YMessages.Show( "Do you want to save changes to file '" + this.config.FileName + "'?", applicationName, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question );
if( res == DialogResult.Cancel ){
return false;
} else if( res == DialogResult.Yes ){
this.UpdateGridStyles();
this.config.SaveToFile();
}
}
return true;
}
private void OnNeedSelectionMasks( ref ArrayList Selections )
{
Selections = this.options.Selections;
}
private void OnNeedSetGridStyle( object Sender, DataGridTableStyle style )
{
bool status;
if( Sender == this.leftDataPanel ){
status = this.config.LeftGridStyles.SetStyleToGrid ( style );
} else {
status = this.config.RightGridStyles.SetStyleToGrid ( style );
}
}
private void ShowHidePanel( DataPanel Panel )
{
if( Panel == this.leftDataPanel ){
if( ! this.rightDataPanel.Visible ){
this.ShowHidePanel( this.rightDataPanel );
}
} else {
if( ! this.leftDataPanel.Visible ){
this.ShowHidePanel( this.leftDataPanel );
}
}
bool visible = !Panel.Visible;
Panel.Visible = visible;
this.splitter.Visible = visible;
if( visible ){
if( Panel == this.rightDataPanel ){
this.leftDataPanel.Dock = DockStyle.Left;
}
if( this.focusPanel != Panel ){
this.ForceChangeActivePanel();
}
} else {
if( Panel == this.rightDataPanel ){
this.leftDataPanel.Dock = DockStyle.Fill;
}
if( this.focusPanel == Panel ){
this.ForceChangeActivePanel();
}
}
this.RefreshButtons();
}
private void SetIdentityState()
{
this.leftDataPanel.IdentityOff = this.options.TableOptions.IdentityOff;
this.rightDataPanel.IdentityOff = this.options.TableOptions.IdentityOff;
}
private void UpdateGridStyles()
{
this.config.RightGridStyles.Update( this.rightDataPanel.PanelGrid.TableStyles );
this.config.LeftGridStyles.Update( this.leftDataPanel.PanelGrid.TableStyles );
}
private void OnColumnResize( object Sender, DataGrid.HitTestInfo Info )
{
this.config.HasChanges = true;
this.RefreshButtons();
}
#endregion
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -