コード例 #1
0
		private void closeTabPageToolStripMenuItem_Click(object sender, EventArgs e)
		{
			if (tabStrip1.SelectedTab != null)
			{
				ucFunction function = (ucFunction)tabStrip1.SelectedTab.AttachedControl.Controls["ucFunction"];

				if (function.IsDirty)// &&
				//(function.DefaultValueFunction == null ||
				// function.DefaultValueFunction.UseCustomCode))
				{
					if (
						MessageBox.Show(this,
										"You have modified the code of the function you are closing without saving. Save the changes?",
										"Save Changes", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) ==
						DialogResult.Yes)
					{
						function.Save();
					}
				}
				//else if (function.DefaultValueFunction != null && !function.DefaultValueFunction.UseCustomCode)
				//{
				//    if (Project.Instance.FindFunction(function.CurrentFunction.Name, function.CurrentFunction.Parameters) != null)
				//    {
				//        Project.Instance.DeleteFunction(function.CurrentFunction);
				//    }
				//}
				tabStrip1.Tabs.Remove(tabStrip1.SelectedTab);

				if (tabStrip1.SelectedTab != null)
				{
					tabStrip1.SelectedTab.AttachedControl.Controls["ucFunction"].Controls[3].Focus();
				}
			}
		}
コード例 #2
0
		/// <summary>
		/// Removes the specified tab and closes the screen if no more tabs remain.
		/// </summary>
		/// <param name="tab">Tab to remove.</param>
		internal void RemoveTab(TabItem tab)
		{
			foreach (Control ctl in tab.AttachedControl.Controls)
			{
				if (ctl.GetType() == typeof(ucFunction))
				{
					ucFunction function = (ucFunction)ctl;

					if (function.IsDirty)// &&
					//(function.DefaultValueFunction == null ||
					// function.DefaultValueFunction.UseCustomCode))
					{
						DialogResult result = MessageBox.Show(this,
											"You have modified the code of the function you are closing without saving. Save the changes?",
											"Save Changes: " + function.CurrentFunction.Name, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning);

						switch (result)
						{
							case DialogResult.Yes:
								function.Save();
								break;
							case DialogResult.Cancel:
								return;
						}
					}
					//else if (function.DefaultValueFunction != null &&
					//         !function.DefaultValueFunction.UseCustomCode &&
					//         !function.DefaultValueFunction.IsForUserOption)
					//{
					//    if (Project.Instance.FindFunction(function.CurrentFunction.Name, function.CurrentFunction.Parameters) != null)
					//    {
					//        Project.Instance.DeleteFunction(function.CurrentFunction);
					//    }
					//}
				}
			}
			if (tabStrip1.Tabs.Contains(tab))
			{
				tabStrip1.Tabs.Remove(tab);
			}
			if (tabStrip1.Tabs.Count == 0)
			{
				tabStrip1.Visible = false;
				lblStatus.Visible = true;
				Refresh();
			}
			Refresh();
		}