Example #1
0
 public ActiveSection(string name, long startTick, ActiveSection parent)
 {
     this.Name      = name;
     this.StartTick = startTick;
     this.Parent    = parent;
     this.Children  = new List <SectionResult>();
 }
Example #2
0
        public void End(string section)
        {
            if (activeSections.Count == 0)
            {
                throw new InvalidOperationException("No active sections");
            }
            if (activeSections.Peek().Name != section)
            {
                throw new ArgumentException("Section begin/end mismatch", "section");
            }

            ActiveSection activeSection = activeSections.Pop();
            long          endTick       = timer.CurrentTick();
            long          duration      = endTick - activeSection.StartTick;
            SectionResult result        = new SectionResult(section, duration);

            if (activeSection.Children.Count != 0)
            {
                foreach (SectionResult childResult in activeSection.Children)
                {
                    childResult.Parent = result;
                    result.Children.Add(childResult);
                }
            }

            if (activeSection.Parent == null)
            {
                // Last element is the active frame.
                frameResults[frameResults.Count - 1].Sections.Add(result);
            }
            else
            {
                activeSection.Parent.Children.Add(result);
            }
        }
Example #3
0
        public void Begin(string section)
        {
            long          currentTick = timer.CurrentTick();
            ActiveSection parent      = activeSections.Count == 0 ? null : activeSections.Peek();
            ActiveSection newSection  = new ActiveSection(section, currentTick, parent);

            activeSections.Push(newSection);
        }
Example #4
0
        public bool InsertLiteStream(Stream stream)
        {
            bool vResult = false;

            DataLoadLiteStream(stream, delegate(ushort fileVersion, HCStyle style)
            {
                vResult = ActiveSection.InsertStream(stream, style, fileVersion);
            });

            return(vResult);
        }
Example #5
0
        public bool LoadFromText(string text)
        {
            Clear();
            FStyle.Initialize();

            if (text != "")
            {
                return(ActiveSection.InsertText(text));
            }
            else
            {
                return(false);
            }
        }
Example #6
0
        public bool LoadFromText(string text)
        {
            Clear();
            FStyle.Initialize();

            if (text != "")
            {
                FStyle.States.Include(HCState.hosLoading);
                try
                {
                    return(ActiveSection.InsertText(text));
                }
                finally
                {
                    FStyle.States.Exclude(HCState.hosLoading);
                }
            }
            else
            {
                return(false);
            }
        }
Example #7
0
        /// <summary> 直接设置当前数据元的值为扩展内容 </summary>
        /// <param name="aStream">扩展内容流</param>
        public void SetActiveItemExtra(Stream aStream)
        {
            string vFileFormat  = "";
            ushort vFileVersion = 0;
            byte   vLang        = 0;

            HC.View.HC._LoadFileFormatAndVersion(aStream, ref vFileFormat, ref vFileVersion, ref vLang);
            HCStyle vStyle = new HCStyle();

            try
            {
                vStyle.LoadFromStream(aStream, vFileVersion);
                this.BeginUpdate();
                try
                {
                    this.UndoGroupBegin();
                    try
                    {
                        HCRichData vTopData = this.ActiveSectionTopLevelData() as HCRichData;
                        this.DeleteActiveDataItems(vTopData.SelectInfo.StartItemNo);
                        ActiveSection.InsertStream(aStream, vStyle, vFileVersion);
                    }
                    finally
                    {
                        this.UndoGroupEnd();
                    }
                }
                finally
                {
                    this.EndUpdate();
                }
            }
            finally
            {
                vStyle.Dispose();
            }
        }
Example #8
0
 /// <summary>
 ///   Event handler for when the Play Game menu entry is selected.
 /// </summary>
 private void PlayGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     if (_activeSection == ActiveSection.Play)
     {
         LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                            new GamePlayScreen(_maps[_selectedMap]));
     }
     else
     {
         _activeSection = ActiveSection.Play;
         Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
         _position = new Point(0, -viewport.Height);
         AdjustEntriesPosition(new Vector2(0, -viewport.Height));
     }
 }
Example #9
0
 /// <summary>
 ///   Event handler for when the Options menu entry is selected.
 /// </summary>
 private void OptionsMenuEntrySelected(object sender, PlayerIndexEventArgs e)
 {
     //ScreenManager.AddScreen(new OptionsMenuScreen(), e.PlayerIndex);
     Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
     _position = new Point(-viewport.Width, 0);
     AdjustEntriesPosition(new Vector2(-viewport.Width, 0));
     _activeSection = ActiveSection.Settings;
 }
Example #10
0
        public override void HandleInput(GameTime gameTime, InputState input)
        {
            PlayerIndex playerIndex;

            if (_menuLeft.Evaluate(input, ControllingPlayer, out playerIndex))
            {
                _selectedMap++;

                if (_selectedMap >= _maps.Count)
                {
                    _selectedMap = 0;
                }
            }

            //go back to main menu
            if (_activeSection != ActiveSection.Main && menuCancel.Evaluate(input, ControllingPlayer, out playerIndex))
            {
                AdjustEntriesPosition(new Vector2(-_position.X, -_position.Y));
                _position = new Point(0, 0);
                _activeSection = ActiveSection.Main;
                return;
            }

            if (_activeSection != ActiveSection.Settings)
            {
                base.HandleInput(gameTime, input);
            }
        }
		/// <summary>
		/// Renders the section as a string.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="sectionName">The name of the section which to render.</param>
		/// <returns>Returns the rendered content of the section.</returns>
		public string RenderToString(IMansionContext context, string sectionName)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (string.IsNullOrEmpty(sectionName))
				throw new ArgumentNullException("sectionName");

			// find the section in the open templates
			var section = FindSection(context, sectionName);

			// create a buffer field
			var targetField = new StringBufferField();

			// create an active section
			var activeSection = new ActiveSection(this, section, targetField);

			// finish the rendering
			activeSection.FinalizeRendering(context);

			// return the content
			return targetField.Content;
		}
		/// <summary>
		/// Renders the section with the specified name.
		/// </summary>
		/// <param name="context">The <see cref="IMansionContext"/>.</param>
		/// <param name="sectionName">The name of the section which to render.</param>
		/// <param name="targetField">The name of the field to which to render.</param>
		/// <returns>Returns a marker which will close the active section automatically.</returns>
		public IDisposable Render(IMansionContext context, string sectionName, string targetField)
		{
			// validate arguments
			if (context == null)
				throw new ArgumentNullException("context");
			if (string.IsNullOrEmpty(sectionName))
				throw new ArgumentNullException("sectionName");

			// find the section in the open templates
			var section = FindSection(context, sectionName);

			// find the target field
			var target = FindTargetField(context, string.IsNullOrEmpty(targetField) ? section.TargetField : targetField);

			// return th active section
			var activeSection = new ActiveSection(this, section, target);

			// push the active section to the stack
			return context.ActiveSectionStack.Push(activeSection, x => x.FinalizeRendering(context));
		}