コード例 #1
0
ファイル: HistoryDialog.cs プロジェクト: chantsunman/nUpdate
        /// <summary>
        ///     Initializes the log.
        /// </summary>
        private void InitializeLog()
        {
            if (Project.Log == null) return;
            if (Project.Log.Count == 0) return;
            foreach (var logEntry in Project.Log)
            {
                var item = new ActionListItem
                {
                    ItemText = String.Format("{0} - {1}", logEntry.PackageVersion, logEntry.EntryTime)
                };

                switch (logEntry.Entry)
                {
                    case LogEntry.Create:
                        item.HeaderText = "Created package";
                        item.ItemImage = Resources.Create;
                        break;
                    case LogEntry.Delete:
                        item.HeaderText = "Deleted package";
                        item.ItemImage = Resources.Remove;
                        break;
                    case LogEntry.Upload:
                        item.HeaderText = "Uploaded package";
                        item.ItemImage = Resources.Upload;
                        break;
                }
                _logItemsStack.Push(item);
            }

            foreach (var item in _logItemsStack)
            {
                historyList.Items.Add(item);
            }
        }
コード例 #2
0
        public static bool TryParse(object source, out ActionListItem item)
        {
            ActionListItem dest;

            try
            {
                dest = (ActionListItem)source;
            }
            catch
            {
                item = null;
                return(false);
            }

            item = dest;
            return(true);
        }
コード例 #3
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            base.OnDrawItem(e);
            e.Graphics.Clip = new Region(e.Bounds);
            e.Graphics.Clear(Color.White);

            if (e.State.HasFlag(DrawItemState.Selected))
            {
                _ren =
                    new VisualStyleRenderer(VisualStyleElement.CreateElement("LISTVIEW",
                                                                             (int)ListViewParts.LVP_GROUPHEADER, (int)GroupHeaderStates.LVGH_OPENSELECTEDNOTFOCUSEDHOT));
            }
            else
            {
                _ren =
                    new VisualStyleRenderer(VisualStyleElement.CreateElement("LISTVIEW",
                                                                             (int)ListViewParts.LVP_GROUPHEADER, (int)GroupHeaderStates.LVGH_OPEN));
            }

            _ren.DrawBackground(e.Graphics, e.Bounds);

            if (Items.Count != 0)
            {
                ActionListItem itm;
                ActionListItem.TryParse(Items[e.Index], out itm);

                if (itm != null)
                {
                    e.Graphics.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
                    e.Graphics.DrawString(itm.HeaderText, Font, new SolidBrush(itm.HeaderColor), 40, e.Bounds.Y + 10);
                    e.Graphics.DrawString(itm.ItemText, Font, new SolidBrush(ForeColor), 20, e.Bounds.Y + 43);
                    e.Graphics.DrawImage(itm.ItemImage, 20, e.Bounds.Y + 10);
                }
                else
                {
                    Items.RemoveAt(e.Index);
                }
            }
        }
コード例 #4
0
ファイル: ActionList.cs プロジェクト: chantsunman/nUpdate
        public static bool TryParse(object source, out ActionListItem item)
        {
            ActionListItem dest;
            try
            {
                dest = (ActionListItem) source;
            }
            catch
            {
                item = null;
                return false;
            }

            item = dest;
            return true;
        }