private View CreateView(ViewEntry v)
        {
            String type   = v.ItemKey.Contains("||") ? "DataSet" : "Request";
            View   result = new View()
            {
                Date         = v.Date,
                ItemKey      = v.ItemKey,
                RequestedUrl = v.RequestedUrl,
                EntityType   = type,
            };

            if (type == "DataSet")
            {
                EntitySet e = null;
                if (_entities.TryGetValue(v.ItemKey, out e))
                {
                    result.Name                  = e.EntitySetName;
                    result.Description           = e.Description;
                    result.DatasetCategoryValue  = e.CategoryValue;
                    result.DatasetContainerAlias = e.ContainerAlias;
                }
            }
            else
            {
                RequestEntry r = null;
                if (_requestsList.TryGetValue(v.ItemKey, out r))
                {
                    result.Name = r.Subject;
                }
            }

            return(result);
        }
 public static void CreateAsync(Type type, Transform parent, object data = null, Action <AView> onCreated = null, Action <float> onProgress = null, Action <UnityEngine.Object> onLoaded = null)
 {
     if (_type2EntryDic.ContainsKey(type))
     {
         ViewEntry ve = _type2EntryDic[type];
         new ViewAsyncCreater <AView>(ve.type, ve.abName, ve.viewName).Create(parent, data, onCreated, onProgress, onLoaded);
     }
 }
 public static AView Create(Type type, Transform parent, object data = null)
 {
     if (_type2EntryDic.ContainsKey(type))
     {
         ViewEntry ve = _type2EntryDic[type];
         return(Create(ve.type, ve.abName, ve.viewName, parent, data));
     }
     return(null);
 }
示例#4
0
		public int GetEntryOffset(ViewEntry entry)
		{
			int totalHeight = 0;
			foreach (ViewEntry e in this.displayedEntryList)
			{
				if (e == entry) break;
				totalHeight += e.Height;
			}
			return totalHeight;
		}
示例#5
0
		private void UpdateHoveredEntry(Point mouseLoc)
		{
			ViewEntry lastHovered = this.hoveredEntry;

			if (mouseLoc.IsEmpty || !this.ClientRectangle.Contains(mouseLoc))
				this.hoveredEntry = null;
			else
				this.hoveredEntry = this.GetEntryAt(mouseLoc.Y + this.ScrollOffset);

			if (lastHovered != this.hoveredEntry)
				this.Invalidate();
		}
示例#6
0
		public void EnsureVisible(ViewEntry entry)
		{
			int offset = this.GetEntryOffset(entry);
			if (offset - this.ScrollOffset <= entry.Height)
			{
				this.ScrollOffset = offset - entry.Height;
			}
			else if (offset - this.ScrollOffset >= this.ClientSize.Height - entry.Height)
			{
				this.ScrollOffset = offset - this.ClientSize.Height + entry.Height;
			}
		}
 public static void CreateAsync(string abName, string viewName, Transform parent, object data = null, Action <AView> onCreated = null, Action <float> onProgress = null, Action <UnityEngine.Object> onLoaded = null)
 {
     if (_ab2view2EntryDic.ContainsKey(abName))
     {
         var v2eDic = _ab2view2EntryDic[abName];
         if (v2eDic.ContainsKey(viewName))
         {
             ViewEntry ve = v2eDic[viewName];
             new ViewAsyncCreater <AView>(ve.type, ve.abName, ve.viewName).Create(parent, data, onCreated, onProgress, onLoaded);
         }
     }
 }
示例#8
0
		public ViewEntry AddEntry(LogEntry entry)
		{
			ViewEntry viewEntry = new ViewEntry(this, entry);
			this.entryList.Add(viewEntry);
			this.UpdateDisplayedEntries();

			if (this.NewEntry != null)
				this.NewEntry(this, new ViewEntryEventArgs(viewEntry));

			this.OnContentChanged();
			return viewEntry;
		}
        /// <summary>
        /// 注册一个界面
        /// </summary>
        /// <param name="abName"></param>
        /// <param name="viewName"></param>
        /// <param name="type">Prefab的Type</param>
        static public void Register(string abName, string viewName, Type type)
        {
            ViewEntry entry = new ViewEntry(abName, viewName, type);

            if (false == _ab2view2EntryDic.ContainsKey(abName))
            {
                _ab2view2EntryDic[abName] = new Dictionary <string, ViewEntry>();
            }

            _ab2view2EntryDic[abName][viewName] = entry;
            _type2EntryDic[type] = entry;
        }
示例#10
0
 public static AView Create(Type type, Transform parent, object data = null)
 {
     if (_type2EntryDic.ContainsKey(type))
     {
         ViewEntry ve = _type2EntryDic[type];
         return(Create(ve.type, ve.abName, ve.viewName, parent, data));
     }
     else
     {
         Debug.LogErrorFormat("AView类[{0}]并没有对应的已注册视图", type.FullName);
     }
     return(null);
 }
示例#11
0
        public static void CreateAsync <T>(Transform parent, object data = null, Action <T> onCreated = null, Action <float> onProgress = null, Action <UnityEngine.Object> onLoaded = null) where T : AView
        {
            Type type = typeof(T);

            if (_type2EntryDic.ContainsKey(type))
            {
                ViewEntry ve = _type2EntryDic[type];
                new ViewAsyncCreater <T>(ve.type, ve.abName, ve.viewName).Create(parent, data, onCreated, onProgress, onLoaded);
            }
            else
            {
                Debug.LogErrorFormat("AView类[{0}]并没有对应的已注册视图", type.FullName);
            }
        }
示例#12
0
        public ViewEntry AddEntry(DataLogOutput.LogEntry entry)
        {
            ViewEntry viewEntry = new ViewEntry(this, entry);

            this.entryList.Add(viewEntry);

            if (this.NewEntry != null)
            {
                this.NewEntry(this, new ViewEntryEventArgs(viewEntry));
            }

            this.OnContentChanged();
            return(viewEntry);
        }
示例#13
0
        public static AView Create(string abName, string viewName, Transform parent, object data = null)
        {
            if (_ab2view2EntryDic.ContainsKey(abName))
            {
                var v2eDic = _ab2view2EntryDic[abName];
                if (v2eDic.ContainsKey(viewName))
                {
                    ViewEntry ve = v2eDic[viewName];
                    return(Create(ve.type, ve.abName, ve.viewName, parent, data));
                }
            }

            return(null);
        }
示例#14
0
        public void AddEntries(LogEntry[] entries, int count)
        {
            for (int i = 0; i < count; i++)
            {
                ViewEntry viewEntry = new ViewEntry(this, entries[i]);
                this.entryList.Add(viewEntry);

                if (this.NewEntry != null)
                {
                    this.NewEntry(this, new ViewEntryEventArgs(viewEntry));
                }
            }
            this.OnContentChanged();
        }
示例#15
0
        public void AddEntry(IEnumerable <DataLogOutput.LogEntry> entries)
        {
            foreach (DataLogOutput.LogEntry entry in entries)
            {
                ViewEntry viewEntry = new ViewEntry(this, entry);
                this.entryList.Add(viewEntry);

                if (this.NewEntry != null)
                {
                    this.NewEntry(this, new ViewEntryEventArgs(viewEntry));
                }
            }
            this.OnContentChanged();
        }
示例#16
0
        public int GetEntryOffset(ViewEntry entry)
        {
            int totalHeight = 0;

            foreach (ViewEntry e in this.DisplayedEntries)
            {
                if (e == entry)
                {
                    break;
                }
                totalHeight += e.Height;
            }
            return(totalHeight);
        }
示例#17
0
        private void OnDisplayFilterChanged()
        {
            bool      wasAtEnd  = this.IsScrolledToEnd;
            ViewEntry lastEntry = this.GetEntryAt(this.ScrollOffset);
            int       entryOff  = this.ScrollOffset - this.GetEntryOffset(lastEntry);

            this.UpdateDisplayedEntries();
            this.OnContentChanged();

            if (wasAtEnd)
            {
                this.ScrollToEnd();
            }
            else
            {
                this.ScrollToEntry(lastEntry, entryOff);
            }
        }
示例#18
0
        public void AddLogEntries(EditorLogEntry[] entries)
        {
            // Update content
            ViewEntry[] newEntries = new ViewEntry[entries.Length];
            for (int i = 0; i < entries.Length; i++)
            {
                ViewEntry viewEntry = new ViewEntry(this, entries[i]);
                this.entryList.Add(viewEntry);
                newEntries[i] = viewEntry;
            }
            this.UpdateDisplayedEntries();

            // Fire events
            if (this.LogEntriesAdded != null)
            {
                this.LogEntriesAdded(this, new ViewEntryEventArgs(newEntries));
            }
            this.OnContentChanged();
        }
示例#19
0
		public void AddEntries(LogEntry[] entries, int count)
		{
			// Update content
			List<ViewEntry> newEntries = new List<ViewEntry>(entries.Length);
			for (int i = 0; i < count; i++)
			{
				ViewEntry viewEntry = new ViewEntry(this, entries[i]);
				this.entryList.Add(viewEntry);
				newEntries.Add(viewEntry);
			}
			this.UpdateDisplayedEntries();

			// Fire events
			foreach (ViewEntry viewEntry in newEntries)
			{
				if (this.NewEntry != null)
					this.NewEntry(this, new ViewEntryEventArgs(viewEntry));
			}
			this.OnContentChanged();
		}
示例#20
0
		public void AddEntry(IEnumerable<DataLogOutput.LogEntry> entries)
		{
			foreach (DataLogOutput.LogEntry entry in entries)
			{
				ViewEntry viewEntry = new ViewEntry(entry);
				this.entryList.Add(viewEntry);

				if (this.NewEntry != null)
					this.NewEntry(this, new ViewEntryEventArgs(viewEntry));
			}
			this.OnContentChanged();
		}
示例#21
0
 public void ScrollToEntry(ViewEntry entry, int offsetY)
 {
     this.ScrollOffset = this.GetEntryOffset(entry) + offsetY;
 }
示例#22
0
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            e.Graphics.TranslateTransform(this.AutoScrollPosition.X, this.AutoScrollPosition.Y);

            Pen   foregroundPen        = new Pen(this.ForeColor);
            Brush foregroundBrush      = new SolidBrush(this.ForeColor);
            Brush foregroundBrushAlpha = new SolidBrush(Color.FromArgb(128, this.ForeColor));
            Brush baseBrush            = new SolidBrush(this.baseColor);
            Brush backgroundBrush      = new SolidBrush(this.BackColor);
            Brush backgroundBrushAlt   = new SolidBrush(Color.FromArgb(
                                                            Math.Max(0, this.BackColor.R - 10),
                                                            Math.Max(0, this.BackColor.G - 10),
                                                            Math.Max(0, this.BackColor.B - 10)));
            StringFormat messageFormat = StringFormat.GenericDefault;

            messageFormat.Alignment     = StringAlignment.Near;
            messageFormat.LineAlignment = StringAlignment.Center;
            messageFormat.Trimming      = StringTrimming.EllipsisCharacter;
            messageFormat.FormatFlags   = 0;
            StringFormat messageFormatTimestamp = new StringFormat(messageFormat);

            messageFormatTimestamp.Alignment = StringAlignment.Far;

            e.Graphics.FillRectangle(baseBrush, this.ClientRectangle);

            int  offsetY         = this.firstDisplayOffset;
            bool showTimestamp   = this.ClientRectangle.Width >= 350;
            bool showFramestamp  = this.ClientRectangle.Width >= 400;
            int  timeStampWidth  = this.Font.Height * 6;
            int  frameStampWidth = this.Font.Height * 5;
            Size textMargin      = new Size(10, 2);

            for (int i = this.firstDisplayIndex; i < this.displayedEntryList.Count; i++)
            {
                ViewEntry entry       = this.displayedEntryList[i];
                int       entryHeight = entry.Height;

                if (offsetY + entryHeight >= -this.AutoScrollPosition.Y)
                {
                    int       textIndent   = entry.Indent * 20;
                    Rectangle entryRect    = new Rectangle(this.ClientRectangle.X, offsetY, this.ClientRectangle.Width, entryHeight);
                    Rectangle typeIconRect = new Rectangle(
                        entryRect.X + textMargin.Width / 2,
                        entryRect.Y,
                        20,
                        entryRect.Height);
                    Rectangle sourceIconRect = new Rectangle(
                        typeIconRect.Right,
                        entryRect.Y,
                        20,
                        entryRect.Height);
                    Rectangle timeTextRect = new Rectangle(
                        entryRect.Width - textMargin.Width - (showTimestamp ? timeStampWidth : 0) - (showFramestamp ? frameStampWidth : 0),
                        entryRect.Y + textMargin.Height,
                        (showTimestamp ? timeStampWidth : 0) + (showFramestamp ? frameStampWidth : 0),
                        entryRect.Height - textMargin.Height * 2);
                    Rectangle textRect = new Rectangle(
                        sourceIconRect.Right + textMargin.Width / 2 + textIndent,
                        entryRect.Y + textMargin.Height,
                        Math.Max(1, entryRect.Width - sourceIconRect.Right - textMargin.Width / 2 - textIndent - timeTextRect.Width),
                        entryRect.Height - textMargin.Height * 2);
                    Image typeIcon   = entry.TypeIcon;
                    Image sourceIcon = entry.SourceIcon;

                    {
                        int newTextHeight;
                        newTextHeight       = this.Font.Height * (textRect.Height / this.Font.Height);
                        textRect.Y          = textRect.Y + textRect.Height / 2 - newTextHeight / 2;
                        textRect.Height     = newTextHeight;
                        timeTextRect.Y      = textRect.Y;
                        timeTextRect.Height = textRect.Height;
                    }

                    bool highlightBgColor = (this.selectedEntry == entry && this.Focused) || this.hoveredEntry == entry;
                    e.Graphics.FillRectangle(((i % 2) == 0 && !highlightBgColor) ? backgroundBrushAlt : backgroundBrush, entryRect);
                    if (entry.LogEntry.Type == LogMessageType.Warning)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 245, 200, 85)), entryRect);
                    }
                    else if (entry.LogEntry.Type == LogMessageType.Error)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 230, 105, 90)), entryRect);
                    }

                    if (this.selectedEntry == entry && this.Focused)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(128, 255, 255, 255)), entryRect);
                    }
                    else if (this.hoveredEntry == entry)
                    {
                        e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(64, 255, 255, 255)), entryRect);
                    }

                    e.Graphics.DrawImage(typeIcon,
                                         typeIconRect.X + typeIconRect.Width / 2 - typeIcon.Width / 2,
                                         typeIconRect.Y + typeIconRect.Height / 2 - typeIcon.Height / 2);
                    e.Graphics.DrawImage(sourceIcon,
                                         sourceIconRect.X + sourceIconRect.Width / 2 - sourceIcon.Width / 2,
                                         sourceIconRect.Y + sourceIconRect.Height / 2 - sourceIcon.Height / 2);
                    e.Graphics.DrawString(entry.LogEntry.Message, this.Font, foregroundBrush, textRect, messageFormat);
                    if (showTimestamp)
                    {
                        e.Graphics.DrawString(
                            string.Format("{0:00}:{1:00}:{2:00}",
                                          entry.LogEntry.TimeStamp.Hour,
                                          entry.LogEntry.TimeStamp.Minute,
                                          entry.LogEntry.TimeStamp.Second),
                            this.Font, foregroundBrushAlpha,
                            new Rectangle(timeTextRect.Right - timeStampWidth, timeTextRect.Y, timeStampWidth, timeTextRect.Height),
                            messageFormatTimestamp);
                    }
                    if (showFramestamp)
                    {
                        e.Graphics.DrawString(
                            string.Format("#{0}", entry.LogEntry.FrameStamp),
                            this.Font, foregroundBrushAlpha,
                            new Rectangle(timeTextRect.X + 5, timeTextRect.Y, timeTextRect.Width - (showTimestamp ? timeStampWidth + 10 : 0), timeTextRect.Height),
                            messageFormatTimestamp);
                    }

                    if (this.selectedEntry == entry && this.Focused)
                    {
                        e.Graphics.DrawRectangle(
                            new Pen(Color.FromArgb(32, this.ForeColor)),
                            entryRect.X + 1,
                            entryRect.Y + 1,
                            entryRect.Width - 3,
                            entryRect.Height - 3);
                        e.Graphics.DrawRectangle(
                            new Pen(Color.FromArgb(192, this.ForeColor)),
                            entryRect.X,
                            entryRect.Y,
                            entryRect.Width - 1,
                            entryRect.Height - 1);
                    }
                    else if (this.hoveredEntry == entry)
                    {
                        e.Graphics.DrawRectangle(
                            new Pen(Color.FromArgb(128, this.ForeColor)),
                            entryRect.X,
                            entryRect.Y,
                            entryRect.Width - 1,
                            entryRect.Height - 1);
                    }
                }

                offsetY += entryHeight;
                if (offsetY > this.ClientRectangle.Height + (-this.AutoScrollPosition.Y))
                {
                    break;
                }
            }
        }
示例#23
0
 public ViewEntryEventArgs(ViewEntry entry)
 {
     this.entry = entry;
 }
示例#24
0
		public int GetEntryOffset(ViewEntry entry)
		{
			int totalHeight = 0;
			foreach (ViewEntry e in this.DisplayedEntries)
			{
				if (e == entry) break;
				totalHeight += e.Height;
			}
			return totalHeight;
		}
示例#25
0
		private void UpdateHoveredEntry(Point mouseLoc)
		{
			ViewEntry lastHovered = this.hoveredEntry;

			if (mouseLoc.IsEmpty || !this.ClientRectangle.Contains(mouseLoc))
				this.hoveredEntry = null;
			else
				this.hoveredEntry = this.GetEntryAt(mouseLoc.Y + this.ScrollOffset);

			if (lastHovered != this.hoveredEntry)
				this.Invalidate();
		}
示例#26
0
		public void EnsureVisible(ViewEntry entry)
		{
			int offset = this.GetEntryOffset(entry);
			if (offset - this.ScrollOffset <= entry.Height)
			{
				this.ScrollOffset = offset - entry.Height;
			}
			else if (offset - this.ScrollOffset >= this.ClientSize.Height - entry.Height)
			{
				this.ScrollOffset = offset - this.ClientSize.Height + entry.Height;
			}
		}
示例#27
0
		public void ScrollToEntry(ViewEntry entry, int offsetY)
		{
			this.ScrollOffset = this.GetEntryOffset(entry) + offsetY;
		}
示例#28
0
 public void RegisterView(ViewEntry viewEntry)
 {
     if (viewEntry == null) throw new ArgumentNullException("viewEntry");
     _viewEntries.Add(viewEntry);
 }
示例#29
0
		public ViewEntry AddEntry(DataLogOutput.LogEntry entry)
		{
			ViewEntry viewEntry = new ViewEntry(entry);
			this.entryList.Add(viewEntry);

			if (this.NewEntry != null)
				this.NewEntry(this, new ViewEntryEventArgs(viewEntry));

			this.OnContentChanged();
			return viewEntry;
		}
示例#30
0
			public ViewEntryEventArgs(ViewEntry entry)
			{
				this.entry = entry;
			}