/// <summary>
        /// Takes a IHistoryEntry and binds it to a created HistoryEntryComponent to be used in the history list.
        /// </summary>
        /// <param name="entry">History entry to bind</param>
        /// <param name="expanded">Whether or not to show its list of changed entries.</param>
        /// <returns>Inflated and bound component.</returns>
        HistoryEntryComponent CreateHistoryEntry([NotNull] IHistoryEntry entry, bool expanded)
        {
            Assert.IsNotNull(m_Presenter, "Invalid state when creating history entry");
            var comp = new HistoryEntryComponent();

            // Handle expanded vs compact layout
            if (expanded)
            {
                // Hide fields used for compact view
                comp.showFilesButton.AddToClassList(UiConstants.ussHidden);
                comp.cloudStatusText.AddToClassList(UiConstants.ussHidden);

                comp.changedFilesCount.text = $"Changes ( {entry.Changes.Count} )";

                var listAdapter = new HistoryEntryChangeListAdapter(m_Presenter, entry.RevisionId, entry.Changes.ToList());
                comp.changedFiles.SetAdapter(listAdapter);
                listAdapter.NotifyDataSetChanged();

                // Configure button
                comp.gotoButton.text = entry.GetGotoText();
                comp.gotoButton.clickable.clicked += () => m_Presenter.RequestGoto(entry.RevisionId, entry.Status);
            }
            else
            {
                // Hide fields used for expanded view
                comp.changedFilesCount.AddToClassList(UiConstants.ussHidden);
                comp.changedFiles.AddToClassList(UiConstants.ussHidden);
                comp.gotoButton.text = string.Empty;
                comp.gotoButton.AddToClassList(UiConstants.ussHidden);

                // Setup show button
                comp.showFilesButton.text = entry.Changes.Count == 1
                    ? StringAssets.showChange
                    : string.Format(StringAssets.showChanges, entry.Changes.Count);
                comp.showFilesButton.clickable.clicked += () => m_Presenter.SelectedRevisionId = entry.RevisionId;

                // TODO: cloud status text
            }

            // Trim whitespace on either side and grab initial for profile circle
            var trimmedAuthorName = entry.AuthorName.Trim();

            comp.profileInitial.text = trimmedAuthorName.Substring(0, 1).ToUpper();
            comp.authorName.text     = trimmedAuthorName;

            // Display relative or absolute timestamp. If relative, show absolute as a tooltip.
            comp.timestamp.text = TimeStamp.GetTimeStamp(entry.Time);
            if (TimeStamp.UseRelativeTimeStamps)
            {
                comp.timestamp.tooltip = TimeStamp.GetLocalisedTimeStamp(entry.Time);
            }

            // Display revision id and show full length id as a tooltip
            comp.revisionId.text    = $"ID: {entry.RevisionId.Substring(0, 10)}";
            comp.revisionId.tooltip = entry.RevisionId;

            comp.commitMessage.text = entry.Message;

            return(comp);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public void SetSelection(IHistoryEntry entry)
        {
            // Hide paginator
            m_Paginator.AddToClassList(UiConstants.ussHidden);

            // Clear out old content
            m_ListNotice.AddToClassList(UiConstants.ussHidden);
            m_Content.Clear();

            // Add new content
            m_Content.Add(CreateHistoryEntry(entry, true));
        }
Esempio n. 3
0
        /// <summary>
        /// Event handler to receive requested single revision.
        /// </summary>
        /// <param name="entry">Received single revision.</param>
        void OnSelectedRevisionReceived(IHistoryEntry entry)
        {
            if (entry == null)
            {
                // Return back to all revisions list
                m_HistoryModel.RequestPageOfRevisions(pageSize);
                Debug.LogError("Unable to find requested revision");
                return;
            }

            m_MainModel.RegisterBackNavigation(historyEntrySelectedId, StringAssets.allHistory, OnBackEvent);
            m_View.SetSelection(entry);
        }
        private void DrawEntry(IHistoryEntry entry, DataGridViewCellPaintingEventArgs e, int i)
        {
            var color = DecisionStateColor.ConvertStateToColor(entry.State);

            var rectangle = new Rectangle(
                e.CellBounds.X + RectangleMargin,
                e.CellBounds.Y + (i * dataGridView1.RowTemplate.Height) + RectangleMargin,
                e.CellBounds.Width - (2 * RectangleMargin),
                dataGridView1.RowTemplate.Height - 2 * RectangleMargin);


            var path = RoundedRectangle.Create(rectangle);

            e.Graphics.FillPath(new SolidBrush(color), path);

            //e.Graphics.FillRectangle(new SolidBrush(color), rectangle);

            var text       = entry.Decision.Name;
            var temp       = text;
            var stringSize = e.Graphics.MeasureString(text, DefaultFont);

            while (stringSize.Width > rectangle.Width)
            {
                if (text.Length < 2)
                {
                    break;
                }
                text       = text.Substring(0, text.Length - 2);
                temp       = text + "..";
                stringSize = e.Graphics.MeasureString(temp, DefaultFont);
            }
            var horizontalMargin = (rectangle.Width - stringSize.Width) / 2;
            var verticalMargin   = (rectangle.Height - stringSize.Height) / 2;



            var textRectangle = new RectangleF(rectangle.X + horizontalMargin, rectangle.Y + verticalMargin, stringSize.Width, stringSize.Height);

            e.Graphics.DrawString(temp, DefaultFont, Brushes.Black, textRectangle);
        }
Esempio n. 5
0
        public void HandleOneEntity(IBaseEntity entity)
        {
            if (entity as ISupportHistoryEntity == null)
            {
                return;
            }
            _entity = entity;

            _lastValues.Clear();
            var e   = entity as ISupportHistoryEntity;
            var hrs = new List <IHistoryEntry>();

            foreach (var hr in e.GetHistoryRecords(e.NewHistoryFilter()))
            {
                hrs.Add(hr);
            }
            hrs.Sort(new HistoryRecComparer());
            foreach (var hr in hrs)
            {
                _historyEntry = hr;
                HandleOneHistoryRecord();
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Event handler for when a requested single history entry has been received.
 /// </summary>
 /// <param name="entry">Received entry.</param>
 void OnReceivedHistoryEntry(IHistoryEntry entry)
 {
     RemoveRequest(k_RequestEntry);
     SelectedRevisionReceived?.Invoke(entry);
 }
Esempio n. 7
0
 public void SetSelection(IHistoryEntry entry)
 {
     ReceivedEntry = entry;
     ReceivedList  = null;
 }
Esempio n. 8
0
 public void SetHistoryList(IReadOnlyList <IHistoryEntry> list)
 {
     ReceivedList  = list;
     ReceivedEntry = null;
 }
Esempio n. 9
0
 public int CompareTo(IHistoryEntry other)
 {
     return(Started.CompareTo(other.Started));
 }