示例#1
0
        protected void AddGraph(PocGraphInfo graphInfo)
        {
            LayoutStates.Clear();

            if (graphInfo == null)
            {
                return;
            }

            HighlightAlgorithm?.ResetHighlight();

            RemoveAllGraphElement();

            Children.Clear();


            Dictionary <int, PocVertex> vertexControlsById = new Dictionary <int, PocVertex>();

            foreach (VertexInfo <PocVertex> info in graphInfo.Verteces.OfType <VertexInfo <PocVertex> >())
            {
                AddVertexControl(info);
                vertexControlsById.Add(info.ID, info.Vertex);
            }

            int i = 0;

            foreach (EdgeInfo <PocEdge> info in graphInfo.Edges.OfType <EdgeInfo <PocEdge> >())
            {
                PocVertex source = vertexControlsById[info.SourceID];
                PocVertex target = vertexControlsById[info.TargetID];

                CreateEdgeControl(new PocEdge(i.ToString(), source, target));
                i++;
            }
        }
示例#2
0
 public void SwitchLayouts(string layout)
 {
     foreach (Layout _layout in manuLayouts)
     {
         if (_layout.layoutName.ToString() == layout)
         {
             currentState = _layout.layoutName;
             _layout.layoutGameobject.gameObject.SetActive(true);
         }
         else
         {
             _layout.layoutGameobject.gameObject.SetActive(false);
         }
     }
 }
示例#3
0
		protected override void OnPaint(PaintEventArgs e)
		{
			if (m_layoutState != LayoutStates.klsNormal)
			{
				// re-entrant call, in the middle of doing layout! Suppress it. But, we need to paint sometime...
				// so queue a new paint event.
				Invalidate(false);
				return;
			}
			try
			{
				// Optimize JohnT: Could we do a binary search for the
				// slice at the top? But the chop point slices may not be real...
				m_layoutState = LayoutStates.klsChecking;
				Rectangle requiredReal = ClientRectangle; // all slices in this must be real
				HandleLayout1(false, requiredReal);
				bool fNeedResume = (m_layoutState == LayoutStates.klsLayoutSuspended);
				m_layoutState = LayoutStates.klsNormal;
				if (fNeedResume)
				{
					Point oldPos = AutoScrollPosition;
					ResumeLayout(); // will cause another paint (and may cause unwanted scroll of parent!)
					Invalidate(false); // Well, apparently doesn't always do so...we were sometimes not getting the lines. Make sure.
					PerformLayout();
					if (AutoScrollPosition != oldPos)
						AutoScrollPosition = new Point(-oldPos.X, -oldPos.Y);
				}
				else
				{
					base.OnPaint(e);
					HandlePaintLinesBetweenSlices(null, e);
				}
			}
			finally
			{
				m_layoutState = LayoutStates.klsNormal;
			}
		}
示例#4
0
		protected override void OnLayout(LayoutEventArgs levent)
		{
			if (m_layoutState == LayoutStates.klsChecking)
			{
				SuspendLayout();
				m_layoutState = LayoutStates.klsLayoutSuspended;
				return;
			}
			// doesn't seem we should ever be called with layout suspended, but it happens,
			// and we want to ignore it.
			if (m_layoutState == LayoutStates.klsLayoutSuspended || m_layoutState == LayoutStates.klsClearingAll)
				return;
			bool fNeedInternalLayout = true; // call HandleLayout1 at least once

			Size smallestSize = new Size();
			// if we don't converge in three iterations, we probably never will. It is possible to get
			// in to an infinite loop, when scrollbars appear and disappear changing the width on every
			// iteration
			for (int i = 0; i < 3; i++)
			//for ( ; ; )
			{
				int clientWidth = ClientRectangle.Width;
				// Somehow this sometimes changes the scroll position.
				// This might be reasonable if it changed the range, but it does it other times.
				// I can't figure out why, so just force it back if it does. Grrrr!
				Point aspOld = AutoScrollPosition;
				base.OnLayout(levent);
				if (AutoScrollPosition != aspOld)
					AutoScrollPosition = new Point(-aspOld.X, -aspOld.Y);

				if (smallestSize.IsEmpty || ClientSize.Width < smallestSize.Width)
					smallestSize = ClientSize;
				// If that changed the width of our client rectangle we definitely need to
				// call HandleLayout1 again.
				fNeedInternalLayout |= (clientWidth != ClientRectangle.Width);
				if (!fNeedInternalLayout)
					return;

				fNeedInternalLayout = false; // don't need to do again unless client rect width changes.
				Rectangle clipRect = ClientRectangle;
				clipRect.Offset(-AutoScrollPosition.X, -AutoScrollPosition.Y);
				int yTop = HandleLayout1(true, clipRect);
				if (yTop != AutoScrollMinSize.Height)
				{
					AutoScrollMinSize = new Size(0, yTop);
					// If we don't do this, the system thinks only the previously hidden part of the
					// data pane was affected, whereas all of it may have been if control heights
					// changed.
					// (I suppose there could be a pathological case where two slices changed heigtht
					// by opposite amounts and we need this redraw even though the height did not change,
					// but it seems very unlikely.)
					Invalidate();
				}
				// Do the BASE.layout AGAIN...this seems to be the only way to get the scroll bars to
				// apppear and disappear as required by more or less slices...
			}

			// if we make it thru all three iterations, resize to the smallest layout size, which usually
			// means scrollbars will be visible. This ensures that no content will be cut off.
			if (ClientSize.Width != smallestSize.Width)
			{
				ClientSize = smallestSize;
			}
		}
示例#5
0
		/// <summary>
		/// Intended to be called by Datatree.FieldAt just before it creates a new slice.
		/// </summary>
		internal void AboutToCreateField()
		{
			CheckDisposed();
			if (m_layoutState == LayoutStates.klsChecking)
			{
				SuspendLayout();
				m_layoutState = LayoutStates.klsLayoutSuspended;
			}
		}
示例#6
0
		/// <summary>
		/// Private wrapper to remove the slices from the Datatree.
		/// </summary>
		private void ClearSlices()
		{
			LayoutStates oldState = m_layoutState;
			m_layoutState = LayoutStates.klsClearingAll;

			List<Slice> allSlices = new List<Slice>(Controls.Count);
			foreach (Slice slice in Controls)
			{
				slice.SplitCont.SplitterMoved -= new SplitterEventHandler(slice_SplitterMoved);
				allSlices.Add(slice);
				slice.AboutToDiscard();
			}

			// It's safer to set m_currentSlice to null here, so that we don't allow using
			// CurrentSlice during windows message side-effects that occur during Controls.Clear().
			m_currentSlice = null;
			Controls.Clear();

			if (m_tooltip != null)
				m_tooltip.RemoveAll(); // has many tooltips for old slices.

			foreach (Slice gonner in allSlices)
				gonner.Dispose();


			m_layoutState = oldState;
			AutoScrollPosition = new Point(0, 0);
		}
示例#7
0
		/// <summary>
		/// For sure make the CurrentSlice if any visible.
		/// If possible also make the prececing summary slice visible.
		/// Then make as many as possible of the slices which are children of that summary visible.
		/// </summary>
		void ScrollCurrentAndIfPossibleSectionIntoView()
		{
			if (CurrentSlice == null)
				return; // can't do anything.
			// Make sure all the slices up to one screen above and below are real and valid heights.
			// This is only called in response to a user action, so m_layoutState should be normal.
			// We set this state to make quite sure that if we somehow get an OnPaint() or OnLayout call
			// that is effectively re-entrant, we don't re-enter HandleLayout1, which can really mess things up.
			Debug.Assert(m_layoutState == LayoutStates.klsNormal);
			m_layoutState = LayoutStates.klsDoingLayout;
			try
			{
				HandleLayout1(false, new Rectangle(0, Math.Max(0, CurrentSlice.Top - ClientRectangle.Height),
					ClientRectangle.Width, ClientRectangle.Height * 2));
			}
			finally
			{
				m_layoutState = LayoutStates.klsNormal;
			}
			ScrollControlIntoView(CurrentSlice);
			int previousSummaryIndex = CurrentSlice.IndexInContainer;
			while (!(Slices[previousSummaryIndex] is SummarySlice))
			{
				previousSummaryIndex--;
				if (previousSummaryIndex < 0)
					return;
			}
			var previousSummary = Slices[previousSummaryIndex];
			if (previousSummary.Top < 0 && CurrentSlice.Bottom - previousSummary.Top < ClientRectangle.Height - 20)
				ScrollControlIntoView(previousSummary);
			var lastChildIndex = CurrentSlice.IndexInContainer;
			while (lastChildIndex < Slices.Count && Slice.StartsWith(((Slice)Slices[lastChildIndex]).Key, previousSummary.Key)
				&& Slices[lastChildIndex].Bottom - previousSummary.Top < ClientRectangle.Height - 20)
				lastChildIndex++;
			lastChildIndex--;
			if (lastChildIndex > CurrentSlice.IndexInContainer)
				ScrollControlIntoView(Slices[lastChildIndex]);
		}
示例#8
0
		public Slice FieldAt(int i)
		{
			CheckDisposed();
			Slice slice = FieldOrDummyAt(i);
			// Keep trying until we get a real slice. It's possible, for example, that the first object
			// in a sequence expands into an embedded lazy sequence, which in turn needs to have its
			// first item made real.
			while (!slice.IsRealSlice)
			{
				var oldState = m_layoutState;
				// guard against OnPaint() while slice is being constructed. Especially dangerous if it is a view,
				// which might end up doing a re-entrant call to Construct() the root box. LT-11052.
				m_layoutState = LayoutStates.klsDoingLayout;
				try
				{
					if (slice.BecomeRealInPlace())
					{
						SetTabIndex(Slices.IndexOf(slice));
						return slice;
					}
					AboutToCreateField();
					slice.BecomeReal(i);
					RemoveSliceAt(i);
					if (i >= Slices.Count)
					{
						// BecomeReal produced nothing; range has decreased!
						return null;
					}
					// Make sure something changed; otherwise, we have an infinite loop here.
					Debug.Assert(slice != Slices[i]);
					slice = Slices[i];

				}
				finally
				{
					// If something changed the layout state during this, it probably knows what it's doing.
					// Otherwise go back to our original state.
					if (m_layoutState == LayoutStates.klsDoingLayout)
						m_layoutState = oldState;
				}
			}
			return slice;
		}