Наследование: System.Windows.Forms.UserControl, IFWDisposable
Пример #1
0
		/// <summary></summary>
		public virtual void Install(DataTree parent)
		{
			CheckDisposed();

			if (parent == null) // Parent == null ||
				throw new InvalidOperationException("The slice '" + GetType().Name + "' must be placed in the Parent.Controls property before installing it.");

			SplitContainer sc = SplitCont;

			// prevents the controls of the new 'SplitContainer' being NAMELESS
			if (sc.Panel1.AccessibleName == null)
				sc.Panel1.AccessibleName = "Panel1";
			if (sc.Panel2.AccessibleName == null)
				sc.Panel2.AccessibleName = "Panel2";

			SliceTreeNode treeNode;
			bool isBeingReused = sc.Panel1.Controls.Count > 0;
			if (isBeingReused)
			{
				treeNode = (SliceTreeNode)sc.Panel1.Controls[0];
			}
			else
			{
				// Make a standard SliceTreeNode now.
				treeNode = new SliceTreeNode(this);
				treeNode.SuspendLayout();
				treeNode.Dock = DockStyle.Fill;
				sc.Panel1.Controls.Add(treeNode);
				sc.AccessibleName = "SplitContainer";
			}

			if (!string.IsNullOrEmpty(Label))
			{
				// Susanna wanted to try five, rather than the default of four
				// to see if wider and still invisble made it easier to work with.
				// It may end up being made visible in a light grey color, but then it would
				// go back to the default of four.
				// Being visible at four may be too overpowering, so we may have to
				// manually draw a thin line to give the user a que as to where the splitter bar is.
				// Then, if it gets to be visible, we will probably need to add a bit of padding between
				// the line and the main slice content, or its text will be connected to the line.
				sc.SplitterWidth = 5;

				// It was hard-coded to 40, but it isn't right for indented slices,
				// as they then can be shrunk so narrow as to completely cover up their label.
				sc.Panel1MinSize = (20 * (Indent + 1)) + 20;
				sc.Panel2MinSize = 0; // min size of right pane
				// This makes the splitter essentially invisible.
				sc.BackColor = Color.FromKnownColor(KnownColor.Window); //to make it invisible
				treeNode.MouseEnter += treeNode_MouseEnter;
				treeNode.MouseLeave += treeNode_MouseLeave;
				treeNode.MouseHover += treeNode_MouseEnter;
			}
			else
			{
				// SummarySlice is one of these kinds of Slices.
				//Debug.WriteLine("Slice gets no usable splitter: " + GetType().Name);
				sc.SplitterWidth = 1;
				sc.Panel1MinSize = LabelIndent();
				sc.SplitterDistance = LabelIndent();
				sc.IsSplitterFixed = true;
				// Just in case it was previously installed with a different label.
				treeNode.MouseEnter -= treeNode_MouseEnter;
				treeNode.MouseLeave -= treeNode_MouseLeave;
				treeNode.MouseHover -= treeNode_MouseEnter;
			}

			int newHeight;
			Control mainControl = Control;
			if (mainControl != null)
			{
				// Has SliceTreeNode and Control.

				// Set stylesheet on every view-based child control that doesn't already have one.
				SetViewStylesheet(mainControl, parent);
				mainControl.AccessibleName = string.IsNullOrEmpty(Label) ? "Slice_unknown" : Label;
				// By default the height of the slice comes from the height of the embedded
				// control.
				// Just store the new height for now, as actually settig it, will cause events,
				// and the slice has no parent yet, which will be bad for those event handlers.
				//this.Height = Math.Max(Control.Height, LabelHeight);
				newHeight = Math.Max(mainControl.Height, LabelHeight);
				mainControl.Dock = DockStyle.Fill;
				sc.FixedPanel = FixedPanel.Panel1;
			}
			else
			{
				// Has SliceTreeNode but no Control.

				// LexReferenceMultiSlice has no control, as of 12/30/2006.
				newHeight = LabelHeight;
				sc.Panel2Collapsed = true;
				sc.FixedPanel = FixedPanel.Panel2;
			}

			if (!isBeingReused)
			{
				parent.Controls.Add(this); // Parent will have to move it into the right place.
				parent.Slices.Add(this);
			}
#if __MonoCS__ // FWNX-266
			if (mainControl != null && mainControl.Visible == false)
			{
				// ensure Launcher Control is shown.
				mainControl.Visible = true;
			}
#endif
			SetSplitPosition();

			// Don'f fire off all those size changed event handlers, unless it is really needed.
			if (Height != newHeight)
				Height = newHeight;
			treeNode.ResumeLayout(false);
		}
Пример #2
0
		/// <summary>
		/// Set up the submenu items for 'Create' and 'Insert' menus.
		/// </summary>
		protected void SetupContextMenu(Slice slice, SliceTreeNode sliceTreeNode)
		{
			// Get rid of old sub-menu items.
			m_mnuCreate.MenuItems.Clear();

			m_helper = new ContextMenuHelper(sliceTreeNode);
			m_rgcpiCreateOptions = slice.Object.PropsAndClassesOwnedBy;
			// Fill in info about which object will be the new owner.
			for (int index = m_rgcpiCreateOptions.Count; --index >= 0; )
			{
				ClassAndPropInfo cpi = m_rgcpiCreateOptions[index];
				cpi.hvoOwner = slice.Object.Hvo;
			}
			// Drop atomic property options if not empty
			for (int index = m_rgcpiCreateOptions.Count; --index >= 0; )
			{
				ClassAndPropInfo cpi = (ClassAndPropInfo)m_rgcpiCreateOptions[index];
				if (cpi.fieldType == (int)FieldType.kcptOwningAtom)
				{
					FDO.FdoCache cache = slice.ContainingDataTree.Cache;
					if (cache.GetObjProperty(cpi.hvoOwner, (int)(cpi.flid)) != 0)
						m_rgcpiCreateOptions.RemoveAt(index);
				}
			}
			int iBefore = m_rgcpiCreateOptions.Count;
			GetCreateSiblingOptions(slice, m_rgcpiCreateOptions, true);
			bool fSeq = m_rgcpiCreateOptions.Count > iBefore &&
				m_rgcpiCreateOptions[iBefore].fieldType == (int)FieldType.kcptOwningSequence;
			int iAfter = m_rgcpiCreateOptions.Count;
			if (fSeq)
			{
				// In a sequence we make another set of options to insert after the current item.
				GetCreateSiblingOptions(slice, m_rgcpiCreateOptions, false);
			}
			for(int index = 0; index < m_rgcpiCreateOptions.Count; index++)
			{
				ClassAndPropInfo cpi = (ClassAndPropInfo)m_rgcpiCreateOptions[index];
				String format = DetailControlsStrings.ksNewItem;
				if (index >= iAfter)
				{
					format = DetailControlsStrings.ksNewItemAfter; // can't happen if not sequence
				}
				else if (index >= iBefore)
				{
					if (fSeq)
						format = DetailControlsStrings.ksNewItemBefore;
					else // sibling collection
						format = DetailControlsStrings.ksNewItemWithin;
				}
				m_mnuCreate.MenuItems.Add(new MenuItem(
					String.Format(format, new object[] {cpi.signatureClassName, cpi.fieldName}),
					new EventHandler(this.HandleCreateMenuItem)));
			}
			m_mnuCreate.Enabled = m_mnuCreate.MenuItems.Count > 0;
			m_helper.SetupDeleteMenu(m_mnuDelete);
		}
Пример #3
0
			/// -----------------------------------------------------------------------------------
			/// <summary>
			/// Initializes a new instance of the <see cref="ContextMenuHelper"/> class, linked
			/// to a particular tree node.
			/// </summary>
			/// -----------------------------------------------------------------------------------
			public ContextMenuHelper(SliceTreeNode stn)
			{
				m_sliceTreeNode = stn;
				m_cache= m_sliceTreeNode.Slice.ContainingDataTree.Cache;
				m_mdc = m_cache.DomainDataByFlid.MetaDataCache;
			}
Пример #4
0
			/// -----------------------------------------------------------------------------------
			/// <summary>
			/// Initializes a new instance of the <see cref="ContextMenuHelper"/> class, linked
			/// to a particular tree node.
			/// </summary>
			/// -----------------------------------------------------------------------------------
			public ContextMenuHelper(SliceTreeNode stn)
			{
				m_sliceTreeNode = stn;
				m_cache= m_sliceTreeNode.Slice.ContainingDataTree.Cache;
				m_mdc = m_cache.MetaDataCacheAccessor;
			}
Пример #5
0
		/// <summary>
		/// Set up the submenu items for 'Create' and 'Insert' menus.
		/// </summary>
		protected void SetupContextMenu(Slice slice, SliceTreeNode sliceTreeNode)
		{
			throw new NotSupportedException("Attempt to execute FW 6.0 code that was believed obsolete and not ported");
		}