private void DesignTabChanged(object sender, System.EventArgs e)
{
MDIChild mc = this.ActiveMdiChild as MDIChild;
DesignTabs tab = DesignTabs.Edit;
if (mc != null)
tab = mc.DesignTab;
bool bEnableEdit = false;
bool bEnableDesign = false;
bool bEnablePreview = false;
bool bShowProp = _ShowProperties;
switch (tab)
{
case DesignTabs.Edit:
bEnableEdit = true;
if (_PropertiesAutoHide)
bShowProp = false;
break;
case DesignTabs.Design:
bEnableDesign = true;
break;
case DesignTabs.Preview:
if (_PropertiesAutoHide)
bShowProp = false;
bEnablePreview = true;
break;
}
if (!bEnableEdit && this._ValidateRdl != null)
{
this._ValidateRdl.Close();
}
mainProperties.Visible = mainSP.Visible = bShowProp;
if (leftAlignToolStripButton2 != null)
{
leftAlignToolStripButton2.Enabled = bEnableDesign;
}
if (centerAlignToolStripButton2 != null)
{
centerAlignToolStripButton2.Enabled = bEnableDesign;
}
if (rightAlignToolStripButton3 != null)
{
rightAlignToolStripButton3.Enabled = bEnableDesign;
}
if (boldToolStripButton1 != null)
{
boldToolStripButton1.Enabled = bEnableDesign;
}
if (italiacToolStripButton1 != null)
{
italiacToolStripButton1.Enabled = bEnableDesign;
}
if (underlineToolStripButton2 != null)
{
underlineToolStripButton2.Enabled = bEnableDesign;
}
if (fontToolStripComboBox1 != null)
{
fontToolStripComboBox1.Enabled = bEnableDesign;
}
if (fontSizeToolStripComboBox1 != null)
{
fontSizeToolStripComboBox1.Enabled = bEnableDesign;
}
if (foreColorPicker1 != null)
{
foreColorPicker1.Enabled = bEnableDesign;
}
if (backColorPicker1 != null)
{
backColorPicker1.Enabled = bEnableDesign;
}
if (cutToolStripButton1 != null)
{
cutToolStripButton1.Enabled = bEnableDesign | bEnableEdit;
}
if (copyToolStripButton1 != null)
{
copyToolStripButton1.Enabled = bEnableDesign | bEnableEdit | bEnablePreview;
}
if (undoToolStripButton1 != null)
{
undoToolStripButton1.Enabled = bEnableDesign | bEnableEdit;
}
if (pasteToolStripButton1 != null)
{
pasteToolStripButton1.Enabled = bEnableDesign | bEnableEdit;
}
if (printToolStripButton2 != null)
{
printToolStripButton2.Enabled = bEnablePreview;
}
if (textboxToolStripButton1 != null)
{
textboxToolStripButton1.Enabled = bEnableDesign;
}
if (selectToolStripButton2 != null)
{
selectToolStripButton2.Enabled = bEnablePreview;
selectToolStripButton2.Checked = mc == null ? false : mc.SelectionTool;
}
if (chartToolStripButton1 != null)
{
chartToolStripButton1.Enabled = bEnableDesign;
}
if (rectangleToolStripButton1 != null)
{
rectangleToolStripButton1.Enabled = bEnableDesign;
}
if (tableToolStripButton1 != null)
{
tableToolStripButton1.Enabled = bEnableDesign;
}
if (matrixToolStripButton1 != null)
{
matrixToolStripButton1.Enabled = bEnableDesign;
}
if (listToolStripButton1 != null)
{
listToolStripButton1.Enabled = bEnableDesign;
}
if (lineToolStripButton1 != null)
{
lineToolStripButton1.Enabled = bEnableDesign;
}
if (imageToolStripButton1 != null)
{
imageToolStripButton1.Enabled = bEnableDesign;
}
if (subreportToolStripButton1 != null)
{
subreportToolStripButton1.Enabled = bEnableDesign;
}
if (pdfToolStripButton2 != null)
{
pdfToolStripButton2.Enabled = bEnablePreview;
}
if (TifToolStripButton2 != null)
{
TifToolStripButton2.Enabled = bEnablePreview;
}
if (XmlToolStripButton2 != null)
{
XmlToolStripButton2.Enabled = bEnablePreview;
}
if (htmlToolStripButton2 != null)
{
htmlToolStripButton2.Enabled = bEnablePreview;
}
if (MhtToolStripButton2 != null)
{
MhtToolStripButton2.Enabled = bEnablePreview;
}
if (CsvToolStripButton2 != null)
{
CsvToolStripButton2.Enabled = bEnablePreview;
}
if (excelToolStripButton2 != null)
{
excelToolStripButton2.Enabled = bEnablePreview;
}
if (RtfToolStripButton2 != null)
{
RtfToolStripButton2.Enabled = bEnablePreview;
}
foreach (var item in insertToolStripMenuItem.DropDownItems.OfType<ToolStripItem>())
{
item.Enabled = bEnableDesign;
}
this.EnableEditTextBox();
if (zoomToolStripComboBox1 != null)
{
zoomToolStripComboBox1.Enabled = bEnablePreview;
string zText = "Actual Size";
if (mc != null)
{
switch (mc.ZoomMode)
{
case ZoomEnum.FitWidth:
zText = "Fit Width";
break;
case ZoomEnum.FitPage:
zText = "Fit Page";
break;
case ZoomEnum.UseZoom:
if (mc.Zoom == 1)
zText = "Actual Size";
else
zText = string.Format("{0:0}", mc.Zoom * 100f);
break;
}
zoomToolStripComboBox1.Text = zText;
}
}
// when no active sheet
if (this.saveToolStripButton1 != null)
this.saveToolStripButton1.Enabled = mc != null;
// Update the status and position information
SetStatusNameAndPosition();
}