예제 #1
0
 /// <summary>
 /// output an allocatedItem
 /// </summary>
 private void Output(RegionTag aTag, anAllocatedItem item, PointF basePt)
 {
     item.allocatedTag.needRedraw = false;
     //TODO: Clean up code
     if (item.allocatedTag is TextTag)
     {
         PointF     itemBasePoint = new PointF(item.actualRect().X + basePt.X, item.actualRect().Y + basePt.Y);
         RectangleF itemRect      = new RectangleF(itemBasePoint, new SizeF(item.allocatedRect.Width, item.allocatedRect.Height));
         outputTextTag(((TextTag)(item.allocatedTag)), itemRect, item.extraInfo);
     }
     else
     if (item.allocatedTag is ElementTag)
     {
         PointF     itemBasePoint = new PointF(item.actualRect().X + basePt.X, item.actualRect().Y + basePt.Y);
         RectangleF itemRect      = new RectangleF(itemBasePoint, new SizeF(item.allocatedRect.Width, item.allocatedRect.Height));
         outputElementTag(((ElementTag)(item.allocatedTag)), itemRect);
     }
     else
     if (item.allocatedTag is RegionTag)
     {
         RectangleF rect = ((RegionTag)(item.allocatedTag)).state.DrawableRect(item.allocatedRect, true);
         rect.Offset(basePt);
         {
             output((RegionTag)item.allocatedTag, rect);
         }
     }
 }
예제 #2
0
    public static string Stringify(RegionTag region)
    {
        string result = string.Empty;

        switch (region)
        {
        case RegionTag.BandleCity:
            result = "Bandle City";
            break;

        case RegionTag.MountTargon:
            result = "Mount Targon";
            break;

        case RegionTag.ShadowIsles:
            result = "Shadow Isles";
            break;

        default:
            result = Enum.GetName(typeof(RegionTag), region);
            break;
        }

        return(result);
    }
예제 #3
0
 /// <summary>
 /// constructor
 /// </summary>
 internal DocumentOutputType(RegionTag aMasterTag)
 {
     masterTag    = aMasterTag;
     parentHtml   = aMasterTag.parentHtml;
     selection    = new Selection(aMasterTag.parentHtml);
     outputBounds = new RectangleF(0, 0, 99999, 99999);
 }
예제 #4
0
        /// <summary>
        /// output all tag in specified regionTag
        /// </summary>
        private void output(RegionTag aTag, RectangleF baseRect)
        {
            PointF basePt = new PointF(baseRect.X, baseRect.Y);

//          RectangleF itemRect = new RectangleF(basePt.X + aTag.state.startPosition, basePt.Y,
//                                               aTag.state.endPosition - aTag.state.startPosition, aTag.spaceAlloc.Height());
//          itemRect = baseRect;
            outputBulletTag(aTag, baseRect);
            OutputRect(aTag.state.bkColor, baseRect, true);
            PointF pt1 = new PointF(baseRect.X, baseRect.Y);
            PointF pt2 = new PointF(baseRect.X, baseRect.Y + baseRect.Height);
            PointF pt3 = new PointF(baseRect.X + baseRect.Width, baseRect.Y + baseRect.Height);
            PointF pt4 = new PointF(baseRect.X + baseRect.Width, baseRect.Y);

            OutputLine(aTag.state.borderColor[(Int32)fourSide._top], pt1, pt2, aTag.state.borderWidth[(Int32)fourSide._top]);
            OutputLine(aTag.state.borderColor[(Int32)fourSide._right], pt2, pt3, aTag.state.borderWidth[(Int32)fourSide._right]);
            OutputLine(aTag.state.borderColor[(Int32)fourSide._bottom], pt3, pt4, aTag.state.borderWidth[(Int32)fourSide._bottom]);
            OutputLine(aTag.state.borderColor[(Int32)fourSide._left], pt4, pt1, aTag.state.borderWidth[(Int32)fourSide._left]);

            foreach (anAllocatedItem item in aTag.spaceAlloc.allocList)
            {
                Output(aTag, item, basePt);
            }
            foreach (anAllocatedItem item in aTag.spaceAlloc.floatList)
            {
                Output(aTag, item, basePt);
            }
        }
예제 #5
0
        /// <summary>
        /// Adds a given WorldObject to the region given by the region coordinates
        /// </summary>
        /// <param name="rx"></param>
        /// <param name="ry"></param>
        /// <param name="b"></param>
        public static void AddToRegion(int rx, int ry, WorldObjectBase b)
        {
            RegionTag reg = new RegionTag(rx, ry);

            if (currentRegions.ContainsKey(reg))
            {
                currentRegions[reg].GetWorldObjects().Add(b);
            }
        }
예제 #6
0
 private RegionTag CreateRegionTag(int regId, RegionTag tag)
 {
     return(new RegionTag
     {
         Id = tag.Id,
         RegionId = regId,
         Tag = tag.Tag,
         Value = tag.Value
     });
 }
예제 #7
0
        /// <summary>
        /// Unloads the region at the region coordinates given and removes it from the world stack
        /// </summary>
        /// <param name="rx"></param>
        /// <param name="ry"></param>
        private static void UnloadRegion(int rx, int ry)
        {
            RegionTag reg = new RegionTag(rx, ry);

            if (currentRegions.ContainsKey(reg))
            {
                currentRegions[reg].Unload();
                lock (currentRegions)
                    currentRegions.Remove(reg);
            }
        }
예제 #8
0
        /// <summary>
        /// Return top (relative to pMastertag) of current space allocator.
        /// </summary>
        /// <returns></returns>
        public float SpaceAllocTop()
        {
            RegionTag cTag   = ownerTag;
            float     RetVal = 0;

            while (cTag != cTag.parentHtml.masterTag)
            {
                RetVal += cTag.LastSpaceAllocator().GetTagRect(cTag).Top;
                cTag    = cTag.LastRegionTag();
            }

            return(RetVal);
        }
예제 #9
0
        /// <summary>
        /// Constructor
        /// </summary>
        internal SpaceAllocator(RegionTag anOwnerTag)
        {
            ownerTag  = anOwnerTag;
            allocList = new AllocatedList();
            floatList = new AllocatedList();
            lineInfo  = new LineInfoList();
            lineInfo.Clear();

            currentLine = -1;
            currentX    = 0;
            currentY    = 0;
            NewLine();
        }
예제 #10
0
        /// <summary>
        /// Returns the region file responsible for the passed world coordinates if loaded, null if not loaded
        /// </summary>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <returns></returns>
        public static RegionBase GetRegion(float x, float y)
        {
            RegionTag reg = GetRegionTag(x, y);

            if (currentRegions.ContainsKey(reg))
            {
                return(currentRegions[reg]);
            }
            else
            {
                return(null);
            }
        }
예제 #11
0
        public AllocatedList floatList;  //A list for items that is have cssPositiontype

        public RectangleF absoluteBaseRect()
        {
            PointF    basePt     = new PointF(baseRect.X, baseRect.Y);
            RegionTag currentTag = ownerTag.LastRegionTag();

            while (!(currentTag is MasterTag))
            {
                RectangleF tagPos = currentTag.LastSpaceAllocator().GetTagRect(currentTag, -1);
                basePt     = new PointF(basePt.X + tagPos.X, basePt.Y + tagPos.Y);
                currentTag = currentTag.LastRegionTag();
            }

            return(new RectangleF(basePt.X, basePt.Y, baseRect.Width, baseRect.Height));
        }
예제 #12
0
        /// <summary>
        /// insert a linebreak at cursor
        /// </summary>
        public void InsertBreak(bool paragraph)
        {
            //TODO: Make paragraph InsertBreak not require full reload.
            if (paragraph)
            {
                CursorPosition cur = firstCursor.CursorPosition();
//				string seperator = "<p>";
//				if (firstCursor.selectedTag.HaveLastTagNamed("p"))
//					seperator = "</p><p>";

                string seperator = firstCursor.selectedTag.LastRegionTag().name;
                if (firstCursor.selectedTag.HaveLastTagNamed(seperator))
                {
                    seperator = String.Format("</{0}><{0}{1}> ", seperator, firstCursor.selectedTag.LastRegionTag().variables.Html());
                }
                else
                {
                    seperator = String.Format("<{0}> ", seperator);
                }

                string BeforeSel = parentHtml.HtmlBeforeSelection();
                string AfterSel  = parentHtml.HtmlAfterSelection();

                parentHtml.parser.Parse(BeforeSel + seperator + AfterSel);
                parentHtml.documentOutput.Update();
                SetStartCursor(cur);
                startCursor = startCursor.RightShiftText();
                SetEndCursor(startCursor.selectedTag, startCursor.selectedLine, startCursor.selectedChar);
            }
            else
            {
                TextTag txtTag = new TextTag(parentHtml, SplitText());
                //if (txtTag.text == "") return;
                firstCursor.selectedTag.parentTag.AddTag(firstCursor.selectedTag.ParentTagIndex() + 1,
                                                         txtTag);

                Int32     tagID  = Utils.LocateTag(Utils.RemoveFrontSlash("br"));
                RegionTag newTag = new RegionTag(parentHtml, "br", new PropertyList(), tagID, 0);
                firstCursor.selectedTag.parentTag.AddTag(firstCursor.selectedTag.ParentTagIndex() + 1,
                                                         newTag);
                parentHtml.Invalidate();
                parentHtml.documentOutput.Update();

                SetStartCursor(txtTag, 0);
                SetEndCursor(startCursor.selectedTag, startCursor.selectedLine, startCursor.selectedChar);
            }
        }
예제 #13
0
        public static void DebugUnit()
        {
            RegionTag        rTag   = new RegionTag(null, "Debug", null, 0, 0);
            CurrentStateType cState = new CurrentStateType(new MiniHtml(), 100);

            rTag.Update(ref cState);
            SpaceAllocator spaceAlloc = new SpaceAllocator(rTag);
            HtmlTag        aTag       = new HtmlTag(); aTag.name = "abc";

            spaceAlloc.AllocateSpace(aTag, 20, 15, -1);
            aTag = new HtmlTag(); aTag.name = "cde";
            spaceAlloc.AllocateSpace(aTag, 70, 15, -1);
            aTag = new HtmlTag(); aTag.name = "xyz";
            spaceAlloc.AllocateSpace(aTag, 50, 15, -1);
            spaceAlloc.allocList.PrintItems();
            spaceAlloc.floatList.PrintItems();
        }
예제 #14
0
        /// <summary>
        /// output bullets
        /// </summary>
        private void outputBulletTag(RegionTag aTag, RectangleF baseRect)
        {
            if ((aTag.type == RegionTag.tagType.listItem) && aTag.StartTag())
            {
                switch (aTag.LastRegionTag().type)
                {
                case RegionTag.tagType.orderedList:
                    Int32  idx       = aTag.parentTag.childTags.IndexOfType(aTag);
                    String idxString = Utils.Number2BulletValue((UInt32)idx, aTag.state.bulletType);

                    float txtWidth = TextSize(idxString, aTag.state.font).Width;
                    OutputString(idxString, aTag.state.font, Color.Black,
                                 new PointF(baseRect.Left - (Defines.defaultListIndent / 3) - txtWidth,
                                            baseRect.Top));
                    break;
                }
            }
        }
예제 #15
0
        /// <summary>
        /// Loads the region at the region coordinates given and adds it to the world stack
        /// Ignores if the region is already loaded
        /// </summary>
        /// <param name="rx"></param>
        /// <param name="ry"></param>
        private static void LoadRegion(int rx, int ry)
        {
            RegionTag reg = new RegionTag(rx, ry);

            if (currentRegions.ContainsKey(reg))
            {
                return;
            }
            RegionBase s = Save.SaveData.LoadRegion(reg);

            if (s == null)
            {
                s = new RegionBase(reg);
            }
            s.Load();
            lock (currentRegions)
                currentRegions.Add(reg, s);
        }
예제 #16
0
 private void PrintItems(RegionTag aTag)
 {
     aTag.spaceAlloc.allocList.PrintItems();
     aTag.spaceAlloc.floatList.PrintItems();
     foreach (anAllocatedItem item in aTag.spaceAlloc.allocList)
     {
         if (item.allocatedTag is RegionTag)
         {
             PrintItems((RegionTag)(item.allocatedTag));
         }
     }
     foreach (anAllocatedItem item in aTag.spaceAlloc.floatList)
     {
         if (item.allocatedTag is RegionTag)
         {
             PrintItems((RegionTag)(item.allocatedTag));
         }
     }
 }
예제 #17
0
 /// <summary>
 /// constructor
 /// </summary>
 internal GraphicsOutputType(RegionTag aMasterTag)
     : base(aMasterTag)
 {
 }