예제 #1
0
        public void MoveColumn(int columnIndex, int positionIndex)
        {
            if (columnIndex < 0 || columnIndex >= ColumnCount ||
                positionIndex < 0 || positionIndex >= ColumnCount)
            {
                NLogger.Instance.WriteString(LogType.Info, string.Format(System.Globalization.CultureInfo.CurrentCulture, "The specified index ({0}) is out of range for this ListHeader.", columnIndex));
            }
            else
            {
                // if the target position is out of range, move to the end
                if (positionIndex > ColumnCount)
                {
                    positionIndex = ColumnCount - 1;
                }

                UIListHeaderSegment seg = segments[columnIndex];

                // remove original copy of segment
                segments.Remove(seg);

                // re-insert segment at its new position
                segments.Insert(positionIndex, seg);

                // fire event
                OnSegmentSequenceChanged(new HeaderSequenceEventArgs(columnIndex, positionIndex));

                LayoutSegments();
            }
        }
예제 #2
0
        protected void DestroyListSegment(UIListHeaderSegment segment)
        {
            if (sortSegment == segment)
            {
                SortSegment = null;
            }

            segments.Remove(segment);

            LayoutSegments();
        }
예제 #3
0
 public int GetColumnIndexFromSegment(UIListHeaderSegment segment)
 {
     for (int i = 0; i < ColumnCount; ++i)
     {
         if (segments[i] == segment)
         {
             return(i);
         }
     }
     return(-1);
 }
예제 #4
0
        }                         //default ctor not valid - we want to enforce initializing our data

        public UIListHeader(string name)
            : base(name)
        {
            sortSegment      = null;
            sizingEnabled    = true;
            sortingEnabled   = true;
            sortingDirection = SortDirection.None;
            //this.segmentOffset = 0.0f;

            backgroundRenderComp = new UIComp_DrawTextureAtlas(this);

            backgroundRenderComp.ResourceAtlasLocation = new NexusEngine.NResourceLoc(@"engine_data:/ui/Atlas/engine_data1.txa");
            backgroundRenderComp.AtlasItemName         = "0";
        }
예제 #5
0
        protected UIListHeaderSegment CreateInitialisedSegment(string text, float width)
        {
            UIListHeaderSegment seg = WindowManager.Instance.CreateWindow("Nexus.GUI.Widgets.UIListHeaderSegment", this) as UIListHeaderSegment;

            seg.Width = new UIDim(0, width);

            seg.NormalText.Text   = text;
            seg.HoveringText.Text = text;
            seg.PushedText.Text   = text;
            seg.DisableText.Text  = text;

            seg.SegmentSized += new EventHandler <WindowEventArgs>(SegmentSized_handler);
            return(seg);
        }
예제 #6
0
        public void SetColumnPixelWidth(int columnIndex, float width)
        {
            if (columnIndex >= ColumnCount)
            {
                NLogger.Instance.WriteString(LogType.Info, string.Format(System.Globalization.CultureInfo.CurrentCulture, "The specified index ({0}) is out of range for this ListHeader.", columnIndex));
            }
            else
            {
                UIListHeaderSegment seg = segments[columnIndex];

                seg.Width = new UIDim(seg.Width.scale, width);

                LayoutSegments();

                OnSegmentSized(new WindowEventArgs(segments[columnIndex]));
            }
        }
예제 #7
0
        public float GetPixelOffsetToSegment(UIListHeaderSegment segment)
        {
            float offset = 0.0f;

            for (int i = 0; i < ColumnCount; ++i)
            {
                if (segments[i] == segment)
                {
                    return(offset);
                }

                offset += segments[i].Rect.Width;
            }

            // no such segment...
            throw new InvalidRequestException("The specified UIListHeaderSegment is not attached to this ListHeader.");
        }
예제 #8
0
        protected override void PostCustomSerial(Window _parent)
        {
            base.PostCustomSerial(_parent);

            foreach (Window window in children)
            {
                UIListHeaderSegment segment = window as UIListHeaderSegment;
                if (segment != null)
                {
                    this.segments.Add(segment);
                    segment.SegmentSized += new EventHandler <WindowEventArgs>(SegmentSized_handler);
                }
            }

            if (this.backgroundRenderComp != null)
            {
                this.backgroundRenderComp.PostCustomSerial(this);
            }
        }
예제 #9
0
        public void RemoveColumn(int columnIndex)
        {
            if (columnIndex < 0 || columnIndex >= ColumnCount)
            {
                NLogger.Instance.WriteString(LogType.Info, string.Format(System.Globalization.CultureInfo.CurrentCulture, "The specified index ({0}) is out of range for this ListHeader.", columnIndex));
            }
            else
            {
                UIListHeaderSegment seg = segments[columnIndex];

                // remove the segment from the list
                segments.Remove(seg);

                // patch up sort segment if we have removed it
                if (sortSegment == seg)
                {
                    // more columns?
                    if (ColumnCount > 0)
                    {
                        // make first column the new sort column
                        sortingDirection = SortDirection.None;
                        SortColumnIndex  = 0;
                    }
                    // no columns
                    else
                    {
                        sortSegment = null;
                    }
                }

                // remove the segment from our child list
                RemoveChild(seg);

                DestroyListSegment(seg);
                LayoutSegments();

                // fire event
                OnSegmentRemoved(new WindowEventArgs(this));
            }
        }
예제 #10
0
        public void InsertColumn(string text, float width, int position)
        {
            // if position is too big, insert at end
            if (position > ColumnCount)
            {
                position = ColumnCount;
            }

            UIListHeaderSegment newSegment = CreateInitialisedSegment(text, width);

            segments.Insert(position, newSegment);

            LayoutSegments();

            // fire event
            OnSegmentAdded(new WindowEventArgs(this));

            // if sort segment is invalid, set-up sorting now we have a segment
            if (sortSegment != null)
            {
                SortColumnIndex = position;
            }
        }
예제 #11
0
 public void RemoveSegment(UIListHeaderSegment segment)
 {
     RemoveColumn(GetColumnIndexFromSegment(segment));
 }