public LaunchGuiForm() { InitializeComponent(); Icon = Resources.Unit4; RestoreWindowInfo(); _list = new TypedObjectListView<LaunchItemBase>(olv); LaunchCommon.LaunchForm = this; }
public EncountersWindow() { InitializeComponent(); this.typedView = new TypedObjectListView<Encounter>(this.objectListView); // setup text search throttle var textChanged = Observable.FromEventPattern(this.searchTextBox, "TextChanged").Select(x => ((TextBox)x.Sender).Text); this.textChanged = textChanged.Throttle(TimeSpan.FromMilliseconds(300)) .ObserveOn(SynchronizationContext.Current) .Subscribe(text => { this.Search(text); }); }
internal UninstallerListViewUpdater(MainWindow reference) { _reference = reference; _listView = new TypedObjectListView <ApplicationUninstallerEntry>(reference.uninstallerObjectListView); _iconGetter = new UninstallerIconGetter(); _reference.olvColumnDisplayName.ImageGetter = _iconGetter.ColumnImageGetter; // Refresh items marked as invalid after corresponding setting change _settings.Subscribe((x, y) => { if (CheckIsAppDisposed()) { return; } if (!_firstRefresh) { _listView.ListView.RefreshObjects(AllUninstallers.Where(u => !u.IsValid).ToList()); } }, x => x.AdvancedTestInvalid, this); // Refresh items marked as orphans after corresponding setting change _settings.Subscribe((x, y) => { if (CheckIsAppDisposed()) { return; } if (!_firstRefresh) { _listView.ListView.UpdateColumnFiltering(); } }, x => x.AdvancedDisplayOrphans, this); }
public UninstallerListConfigurator(MainWindow reference) { _reference = reference; _listView = new TypedObjectListView <ApplicationUninstallerEntry>(reference.uninstallerObjectListView); _reference.filterEditor1.TargetFilterCondition = _filteringFilterCondition; _updateThrottleTimer = new Timer { Interval = 500 }; _updateThrottleTimer.Tick += (sender, args) => { _updateThrottleTimer.Stop(); _listView.ListView.UpdateColumnFiltering(); }; SetupListView(); RatingManagerWrapper = new RatingManagerWrapper(); RatingManagerWrapper.InitializeRatingColumn(_reference.olvColumnRating, _reference.uninstallerObjectListView); _reference.FormClosed += (x, y) => { RatingManagerWrapper.ProcessGatheredRatings(); }; _settings.Subscribe((sender, args) => RatingManagerWrapper.InitializeRatings(), x => x.MiscUserRatings, this); }
private void TaskProgress_Load(object sender, EventArgs e) { typedResultsView = new TypedObjectListView <FileItem>(this.listViewResults); logger.Trace("Set width to {0}", settingsManager.app.TaskProgressWidth); logger.Trace("Set height to {0}", settingsManager.app.TaskProgressHeight); this.Size = new Size() { Width = (int)settingsManager.app.TaskProgressWidth, Height = (int)settingsManager.app.TaskProgressHeight }; listViewLocations.SetObjects(targetDirectories); listViewResults.SetObjects(detections); SetListViewOverlay(); RichTextBoxTarget.ReInitializeAllTextboxes(this); /* Subscribe to ScanTask status changed event */ runningTask.StatusChanged += Task_OnStatusChanged; StartScan(); }
private void GameListForm_Load(object sender, EventArgs e) { TypedObjectListViewEntry = new TypedObjectListView<GameList.GameEntry>(objectListView1); objectListView1.ShowGroups = false; objectListView1.FullRowSelect = true; DiscIdColumn.TextAlign = HorizontalAlignment.Center; FirmwareColumn.TextAlign = HorizontalAlignment.Center; objectListView1.StateImageList = new ImageList(); var img = new Bitmap(640, 120); var g = Graphics.FromImage(img); g.DrawLine(new Pen(new SolidBrush(Color.Red)), new Point(0, 0), new Point(100, 100)); objectListView1.StateImageList.Images.Add("test", img); objectListView1.OwnerDraw = true; //var IconSize = new Size(144, 80); var IconSize = new Size(108, 60); objectListView1.RowHeight = IconSize.Height; //objectListView1.AllowColumnReorder = true; //objectListView1.AutoResizeColumns(); objectListView1.Resize += objectListView1_Resize; ResetColumns(); objectListView1.GridLines = true; objectListView1.Sort(TitleColumn, SortOrder.Ascending); //TitleColumn.HeaderFont = new Font("MS Gothic Normal", 16); TitleColumn.RendererDelegate = (ee, gg, rr, oo) => { var Entry = ((GameList.GameEntry)oo); var Selected = (objectListView1.SelectedObjects.Contains((object)Entry)); gg.FillRectangle(new SolidBrush(!Selected ? SystemColors.Window : SystemColors.Highlight), new Rectangle(rr.Left - 1, rr.Top - 1, rr.Width + 1, rr.Height + 1)); var Measure = gg.MeasureString(Entry.TITLE, Font2, new Size(rr.Width, rr.Height)); gg.Clip = new System.Drawing.Region(rr); gg.DrawString( Entry.TITLE, Font2, new SolidBrush(!Selected ? SystemColors.WindowText : SystemColors.HighlightText), new Rectangle( new Point(rr.Left + 8, (int)(rr.Top + rr.Height / 2 - Measure.Height / 2)), new Size(rr.Width, rr.Height) ) ); //gg.FillRectangle(new SolidBrush(Color.White), rr); //gg.DrawImageUnscaled(Entry.CachedBitmap, new Point(rr.Left, rr.Top)); return true; }; BannerColumn.MinimumWidth = BannerColumn.MaximumWidth = BannerColumn.Width = IconSize.Width; //BannerColumn.AspectGetter = delegate(object _entry) { return null; }; BannerColumn.RendererDelegate = (ee, gg, rr, oo) => { var Entry = ((GameList.GameEntry)oo); var Data = Entry.Icon0Png; if (Entry.CachedBitmap == null) { Entry.CachedBitmap = new Bitmap(IconSize.Width, IconSize.Height); using (var gg2 = Graphics.FromImage(Entry.CachedBitmap)) { gg2.CompositingQuality = CompositingQuality.HighQuality; gg2.Clear(Color.White); gg2.DrawImage(Image.FromStream(new MemoryStream(Data)), new Rectangle(0, 0, IconSize.Width, IconSize.Height)); } } gg.FillRectangle(new SolidBrush(Color.White), new Rectangle(rr.Left - 1, rr.Top - 1, rr.Width + 1, rr.Height + 1)); gg.DrawImageUnscaled(Entry.CachedBitmap, new Point(rr.Left - 1, rr.Top - 1)); return true; }; TitleColumn.AspectGetter = delegate(object _entry) { return ((GameList.GameEntry)_entry).TITLE; }; DiscIdColumn.AspectGetter = delegate(object _entry) { return ((GameList.GameEntry)_entry).DiscId0; }; PathColumn.AspectGetter = delegate(object _entry) { return Path.GetFileName(((GameList.GameEntry)_entry).IsoFile); }; MediaTypeColumn.AspectGetter = delegate(object _entry) { var Entry = ((GameList.GameEntry)_entry); var DISC_ID = Entry.DISC_ID; switch (DISC_ID[0]) { case 'S': return "CD/DVD"; case 'U': return "UMD"; case 'B': return "BluRay"; default: return "Unknown"; } }; LicenseTypeColumn.AspectGetter = delegate(object _entry) { var Entry = ((GameList.GameEntry)_entry); var DISC_ID = Entry.DISC_ID; switch (DISC_ID[1]) { case 'C': return "Sony"; case 'L': return "Other"; default: return "Unknown"; } }; RegionColumn.AspectGetter = delegate(object _entry) { var Entry = ((GameList.GameEntry)_entry); var DISC_ID = Entry.DISC_ID; switch (DISC_ID[2]) { case 'P': case 'J': return "Japan"; case 'E': return "Europe"; case 'K': return "Korea"; case 'U': return "USA"; case 'A': return "Asia"; default: return "Unknown"; } }; ReleaseTypeColumn.AspectGetter = delegate(object _entry) { var Entry = ((GameList.GameEntry)_entry); var DISC_ID = Entry.DISC_ID; switch (DISC_ID[3]) { case 'D': return "Demo"; case 'M': return "Malasian"; case 'S': return "Retail"; default: return "Unknown"; } }; FirmwareColumn.AspectGetter = delegate(object _entry) { return ((GameList.GameEntry)_entry).PSP_SYSTEM_VER; }; }
private void InitializeOLVMembers() { // don't allow edit this.objectListView_TeamAuditingMembers.CellEditActivation = ObjectListView.CellEditActivateMode.None; this.objectListView_TeamAuditingMembers.UseExplorerTheme = false; this.objectListView_TeamAuditingMembers.UseTranslucentHotItem = true; this.objectListView_TeamAuditingMembers.FullRowSelect = false; this.objectListView_TeamAuditingMembers.HotTracking = false; this.objectListView_TeamAuditingMembers.HeaderToolTip.IsBalloon = false; this.objectListView_TeamAuditingMembers.HotItemStyle.BackColor = Color.AliceBlue; this.objectListView_TeamAuditingMembers.HotItemStyle.ForeColor = Color.MediumBlue; TypedObjectListView <TeamAuditingListViewItemModel> olv = new TypedObjectListView <TeamAuditingListViewItemModel>( this.objectListView_TeamAuditingMembers ); olv.GetColumn((int)OlvMembersIndex.Timestamp).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.Timestamp : DateTime.Now); }; olv.GetColumn((int)OlvMembersIndex.ActorType).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.ActorType : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.Email).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.Email : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.Context).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.Context : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.EventType).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.EventType : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.Origin).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.Origin : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.IpAddress).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.IpAddress : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.City).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.City : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.Region).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.Region : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.Country).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.Country : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.Participants).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.Participants : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.Assets).AspectGetter = delegate(TeamAuditingListViewItemModel model) { return((model != null) ? model.Assets : string.Empty); }; }
// Initalize the Format of the ObjectListView private void InitModel() { if (ObjectListView.IsVistaOrLater) { this.Font = new Font("msyh", 8); } this.folvAnime.AddDecoration(new EditingCellBorderDecoration(true)); TypedObjectListView <Anime> tolv = new TypedObjectListView <Anime>(this.folvAnime); tolv.GenerateAspectGetters(); // Name of Anime TypedColumn <Anime> tc = new TypedColumn <Anime>(this.olvColName); tc.AspectPutter = (Anime a, object opn) => { a.Name = opn.ToString(); }; // Schedule of Anime tc = new TypedColumn <Anime>(this.olvColSchedule); tc.GroupKeyGetter = (Anime a) => a.Year; // Type of Anime tc = new TypedColumn <Anime>(this.olvColType); tc.AspectPutter = (Anime a, object opt) => { a.Type = (MediaType)opt; }; tc.ImageGetter = (Anime a) => { switch (a.Format) { case MergeFormat.MKV: return(Properties.Resources.MKV); case MergeFormat.MP4: return(Properties.Resources.MP4); case MergeFormat.AVI: return(Properties.Resources.AVI); case MergeFormat.WMV: return(Properties.Resources.WMV); case MergeFormat.M2TS: return(Properties.Resources.M2TS); default: return(-1); } }; // Format of Anime #region //this.olvColFormat.Renderer = new MappedImageRenderer(new object[] { // MergeFormat.MKV, Properties.Resources.MKV, // MergeFormat.MP4, Properties.Resources.MP4, // MergeFormat.AVI, Properties.Resources.AVI, // MergeFormat.WMV, Properties.Resources.WMV, // MergeFormat.M2TS, Properties.Resources.M2TS //}); //tc = new TypedColumn<Anime>(this.olvColFormat); //tc.AspectPutter = delegate(Anime a, object opf) { a.Format = (MergeFormat)opf; }; #endregion // SubTeam of Anime tc = new TypedColumn <Anime>(this.olvColSubTeam); tc.AspectPutter = (Anime a, object opp) => { a.SubTeam = opp.ToString(); }; tc.ImageGetter = (Anime a) => { switch (a.SubStyle) { case SubStyles.External: return(Properties.Resources.External); case SubStyles.Sealed: return(Properties.Resources.Sealed); case SubStyles.Embedded: return(Properties.Resources.Embedded); default: return(-1); } }; // SubStyle of Anime #region //this.olvColSubStyle.Renderer = new MappedImageRenderer(new object[] { // SubStyles.External, Properties.Resources.External, // SubStyles.Sealed, Properties.Resources.Sealed, // SubStyles.Embedded, Properties.Resources.Embedded //}); //tc = new TypedColumn<Anime>(this.olvColSubStyle); //tc.AspectPutter = delegate(Anime a, object ops) { a.SubStyle = (SubStyles)ops; }; #endregion // Size of Anime this.olvColSize.AspectToStringConverter = ots => { long ls = (long)ots; if (ls == 0L) { return("-"); } else if (ls >= 1000000000L) { return(String.Format("{0:#,##0.#0} G", ls / 1073741824D)); } else { return(String.Format("{0:#,##0.#0} M", ls / 1048576D)); } }; this.olvColSize.MakeGroupies( new long[] { 5368709120L, 10737418240L }, new string[] { "0~5 GB", "5~10 GB", ">10 GB" } ); // Store of Anime tc = new TypedColumn <Anime>(this.olvColStore); tc.AspectPutter = (Anime a, object opg) => { a.Store = (bool)opg; }; this.olvColStore.Renderer = new MappedImageRenderer(true, Properties.Resources.Accept, false, Properties.Resources.Alert); // Enjoy of Anime tc = new TypedColumn <Anime>(this.olvColEnjoy); tc.AspectPutter = (Anime a, object opv) => { a.Enjoy = (bool)opv; }; this.olvColEnjoy.Renderer = new MappedImageRenderer(true, Properties.Resources.Smile, false, Properties.Resources.Sad); // Grade of Anime tc = new TypedColumn <Anime>(this.olvColGrade); tc.AspectPutter = (Anime a, object opr) => { int onr = (int)opr; a.Grade = onr; //onr < 1 ? 1 : onr; }; this.olvColGrade.Renderer = new MultiImageRenderer(Properties.Resources.Diamond, 3, 0, 4); this.olvColGrade.MakeGroupies( new int[] { 1, 2 }, new string[] { "Normal", "Nice", "Good" } ); // Note of Anime this.olvColNote.AspectToStringConverter = otn => otn.ToString().Replace('\u0002', '\u0020'); //RowBorderDecoration rbd = new RowBorderDecoration(); //rbd.BorderPen = new Pen(Color.Orchid, 1); //rbd.FillBrush = null; //rbd.CornerRounding = 4.0f; //HotItemStyle hotItemStyle = new HotItemStyle(); //hotItemStyle.Decoration = rbd; //hotItemStyle.Overlay = new AnimeViewOverlay(); //this.folvAnime.HotItemStyle = hotItemStyle; this.folvAnime.UseTranslucentHotItem = true; this.folvAnime.UseTranslucentSelection = true; this.folvAnime.HotItemStyle.Overlay = new AnimeViewOverlay(); this.folvAnime.HotItemStyle = this.folvAnime.HotItemStyle; this.folvAnime.PrimarySortColumn = this.olvColTitle; this.folvAnime.PrimarySortOrder = SortOrder.Ascending; }
private void InitializeOLVMembers() { // don't allow edit this.objectListView_MemberList.CellEditActivation = BrightIdeasSoftware.ObjectListView.CellEditActivateMode.None; this.objectListView_MemberList.UseExplorerTheme = false; this.objectListView_MemberList.UseTranslucentHotItem = false; this.objectListView_MemberList.FullRowSelect = true; this.objectListView_MemberList.HotTracking = true; this.objectListView_MemberList.ShowGroups = false; this.objectListView_MemberList.HeaderToolTip.IsBalloon = false; this.objectListView_MemberList.HotItemStyle.BackColor = Color.AliceBlue; this.objectListView_MemberList.HotItemStyle.ForeColor = Color.MediumBlue; TypedObjectListView<TeamListViewItemModel> olv = new TypedObjectListView<TeamListViewItemModel>( this.objectListView_MemberList ); olv.GetColumn((int)OlvTeamIndex.Email).AspectGetter = delegate (TeamListViewItemModel model) { return (model != null) ? model.Email : string.Empty; }; olv.GetColumn((int)OlvTeamIndex.TeamId).AspectGetter = delegate (TeamListViewItemModel model) { return (model != null) ? model.TeamId : string.Empty; }; olv.GetColumn((int)OlvTeamIndex.FilePath).AspectGetter = delegate (TeamListViewItemModel model) { return (model != null) ? model.FilePath : string.Empty; }; olv.GetColumn((int)OlvTeamIndex.FileName).AspectGetter = delegate (TeamListViewItemModel model) { return (model != null) ? model.FileName : string.Empty; }; olv.GetColumn((int)OlvTeamIndex.FileSize).AspectGetter = delegate (TeamListViewItemModel model) { return (model != null) ? model.FileSize : string.Empty; }; }
private void InitializeOLVMembers() { // don't allow edit this.objectListView_DeviceList.CellEditActivation = BrightIdeasSoftware.ObjectListView.CellEditActivateMode.None; this.objectListView_DeviceList.UseExplorerTheme = false; this.objectListView_DeviceList.UseTranslucentHotItem = false; this.objectListView_DeviceList.FullRowSelect = true; this.objectListView_DeviceList.HotTracking = true; this.objectListView_DeviceList.ShowGroups = false; this.objectListView_DeviceList.HeaderToolTip.IsBalloon = false; this.objectListView_DeviceList.HotItemStyle.BackColor = Color.AliceBlue; this.objectListView_DeviceList.HotItemStyle.ForeColor = Color.MediumBlue; //this.objectListView_Members.HotItemStyle.Overlay = new MemberInfoOverlay(); TypedObjectListView<DeviceListViewItemModel> olv = new TypedObjectListView<DeviceListViewItemModel>( this.objectListView_DeviceList ); olv.GetColumn((int)OlvDeviceIndex.Created).AspectGetter = delegate (DeviceListViewItemModel model) { return (model != null) ? model.Created : System.DateTime.MinValue; }; olv.GetColumn((int)OlvDeviceIndex.Email).AspectGetter = delegate (DeviceListViewItemModel model) { return (model != null) ? model.Email : string.Empty; }; olv.GetColumn((int)OlvDeviceIndex.TeamId).AspectGetter = delegate (DeviceListViewItemModel model) { return (model != null) ? model.TeamId : string.Empty; }; olv.GetColumn((int)OlvDeviceIndex.DeviceName).AspectGetter = delegate (DeviceListViewItemModel model) { return (model != null) ? model.DeviceName : string.Empty; }; olv.GetColumn((int)OlvDeviceIndex.IpAddress).AspectGetter = delegate (DeviceListViewItemModel model) { return (model != null) ? model.IpAddress : string.Empty; }; olv.GetColumn((int)OlvDeviceIndex.SessionId).AspectGetter = delegate (DeviceListViewItemModel model) { return (model != null) ? model.SessionId : string.Empty; }; olv.GetColumn((int)OlvDeviceIndex.ClientType).AspectGetter = delegate (DeviceListViewItemModel model) { return (model != null) ? model.ClientType : string.Empty; }; }
private void InitializeSongListView() { // Create a typed wrapper to remove need to perform so many casts this.typedOlvSongs = new TypedObjectListView<Song>(this.olvSongs); // Generate aspect getters which are typically 3-5x faster than reflection this.typedOlvSongs.GenerateAspectGetters(); this.olvColumnTitle.ImageGetter = delegate(object x) { return "music"; }; this.typedOlvSongs.GetColumn(1).ImageGetter = delegate(Song song) { if (String.IsNullOrEmpty(song.Artist)) return -1; else return "group"; }; // Show the current fetch status if there is one this.olvColumnLyricsStatus.AspectGetter = delegate(object x) { Song song = (Song)x; if (this.fetchManager.GetStatus(song) == LyricsFetchStatus.NotFound) return song.LyricsStatusString; else return this.fetchManager.GetStatusString(song); }; byte[] olvState = this.Preferences.ListViewState; if (olvState != null) this.olvSongs.RestoreState(olvState); }
public void InitObjectListView() { modlist_objectlistview?.Dispose(); modlist_objectlistview = new ObjectListView { // General Name = "modlist_objectlistview", Size = new Size(886, 222), Location = new Point(0, 0), Dock = DockStyle.Fill, TabIndex = 0, // Behavior FullRowSelect = true, CellEditActivation = ObjectListView.CellEditActivateMode.DoubleClick, AllowColumnReorder = true, //ShowItemToolTips = true, // Sorting ShowSortIndicators = true, TintSortColumn = true, IsSearchOnSortColumn = false, SortGroupItemsByPrimaryColumn = false, AlwaysGroupBySortOrder = SortOrder.None, // Checkbox CheckBoxes = true, CheckedAspectName = "isActive" }; horizontal_splitcontainer.Panel1.Controls.Add(modlist_objectlistview); //modlist_objectlistview.Update(); var categoryGroupingDelegate = new GroupKeyGetterDelegate(o => Mods.GetCategory(o as ModEntry)); var categoryFormatterDelegate = new GroupFormatterDelegate((@group, parameters) => { var groupName = group.Key as string; if (groupName == null) { return; } // Restore collapsed state group.Collapsed = Mods.Entries[groupName].Collapsed; // Sort Categories parameters.GroupComparer = Comparer <OLVGroup> .Create((a, b) => Mods.Entries[(string)a.Key].Index.CompareTo(Mods.Entries[(string)b.Key].Index)); }); var columns = new[] { // first column is marked as primary column new OLVColumn { Text = "Name", AspectName = "Name", Width = 500, GroupKeyGetter = categoryGroupingDelegate, GroupFormatter = categoryFormatterDelegate, IsEditable = true }, new OLVColumn { Name = "ID", Text = "ID", AspectName = "ID", Width = 200, GroupKeyGetter = categoryGroupingDelegate, GroupFormatter = categoryFormatterDelegate, IsEditable = false }, // State new OLVColumn { Text = "State", IsEditable = false, Width = 40, AspectGetter = o => { var mod = (ModEntry)o; if (mod.State.HasFlag(ModState.NotLoaded)) { return("Not Loaded"); } if (mod.State.HasFlag(ModState.ModConflict)) { return("Conflict"); } if (mod.State.HasFlag(ModState.DuplicateID)) { return("Duplicate ID"); } if (mod.State.HasFlag(ModState.New)) { return("New"); } if (mod.State.HasFlag(ModState.UpdateAvailable)) { return("Update Available"); } return("OK"); } }, new OLVColumn { Text = "Order", AspectName = "Index", TextAlign = HorizontalAlignment.Right, HeaderTextAlign = HorizontalAlignment.Center, Width = 60, MinimumWidth = 40, GroupKeyGetter = categoryGroupingDelegate, GroupFormatter = categoryFormatterDelegate, IsEditable = true, CellEditUseWholeCell = true }, new OLVColumn { Text = "Size", AspectName = "Size", AspectToStringConverter = size => ((long)size).FormatAsFileSize(), TextAlign = HorizontalAlignment.Right, Width = 100, IsEditable = false }, new OLVColumn { Text = "Last Update", AspectName = "DateUpdated", DataType = typeof(DateTime?), Width = 120, TextAlign = HorizontalAlignment.Right, IsEditable = false }, new OLVColumn { Text = "Date Added", AspectName = "DateAdded", DataType = typeof(DateTime?), Width = 120, TextAlign = HorizontalAlignment.Right, IsEditable = false, IsVisible = false }, new OLVColumn { Text = "Date Created", AspectName = "DateCreated", DataType = typeof(DateTime?), Width = 120, TextAlign = HorizontalAlignment.Right, IsEditable = false, IsVisible = false }, new OLVColumn { Text = "Path", AspectName = "Path", Width = 160, IsEditable = false, IsVisible = false, GroupKeyGetter = o => Path.GetDirectoryName((o as ModEntry)?.Path) } }; // size groupies columns.Single(c => c.AspectName == "Size").MakeGroupies( new[] { 1024, 1024 * 1024, (long)50 * 1024 * 1024, (long)100 * 1024 * 1024 }, new[] { "< 1 KB", "< 1MB", "< 50 MB", "< 100 MB", "> 100 MB" } ); // Init DateTime columns foreach (var column in columns.Where(c => c.DataType == typeof(DateTime?))) { column.AspectToStringConverter = d => (d as DateTime?)?.ToLocalTime().ToString(CultureInfo.CurrentCulture); column.MakeGroupies( new[] { DateTime.Now.Subtract(TimeSpan.FromHours(24 * 30)), DateTime.Now.Subtract(TimeSpan.FromHours(24 * 7)), DateTime.Now.Date }, new[] { "Older than one month", "Last Month", "This Week", "Today" } ); // Sord Desc column.GroupFormatter = (g, param) => { param.GroupComparer = Comparer <OLVGroup> .Create((a, b) => (param.GroupByOrder == SortOrder.Descending ? 1 : -1) *a.Id.CompareTo(b.Id)); }; } // Wrapper ModList = new TypedObjectListView <ModEntry>(modlist_objectlistview); // Events modlist_objectlistview.SelectionChanged += ModListSelectionChanged; modlist_objectlistview.ItemChecked += ModListItemChecked; modlist_objectlistview.CellRightClick += ModListCellRightClick; modlist_objectlistview.CellEditFinished += ModListEditFinished; modlist_objectlistview.CellToolTipShowing += ModListCellToolTipShowing; modlist_objectlistview.FormatRow += ModListFormatRow; modlist_objectlistview.GroupExpandingCollapsing += ModListGroupExpandingCollapsing; modlist_objectlistview.KeyUp += ModListKeyUp; modlist_objectlistview.KeyDown += ModListKeyDown; // Content modlist_objectlistview.AllColumns.AddRange(columns); modlist_objectlistview.RebuildColumns(); // move state to the beginning columns.Single(c => c.Text == "State").DisplayIndex = 0; // Restore State if (Settings.Windows.ContainsKey("main") && Settings.Windows["main"].Data != null) { modlist_objectlistview.RestoreState(Settings.Windows["main"].Data); } RefreshModList(); }
private void InitializeOLVMembers() { // don't allow edit this.objectListView_PaperMembers.CellEditActivation = ObjectListView.CellEditActivateMode.None; this.objectListView_PaperMembers.UseExplorerTheme = false; this.objectListView_PaperMembers.UseTranslucentHotItem = true; this.objectListView_PaperMembers.FullRowSelect = false; this.objectListView_PaperMembers.HotTracking = false; this.objectListView_PaperMembers.HeaderToolTip.IsBalloon = false; this.objectListView_PaperMembers.HotItemStyle.BackColor = Color.AliceBlue; this.objectListView_PaperMembers.HotItemStyle.ForeColor = Color.MediumBlue; TypedObjectListView <PaperListViewItemModel> olv = new TypedObjectListView <PaperListViewItemModel>( this.objectListView_PaperMembers ); olv.GetColumn((int)OlvMembersIndex.PaperName).AspectGetter = delegate(PaperListViewItemModel model) { return((model != null) ? model.PaperName : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.PaperId).AspectGetter = delegate(PaperListViewItemModel model) { return((model != null) ? model.PaperId : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.FolderPath).AspectGetter = delegate(PaperListViewItemModel model) { return((model != null) ? model.FolderPath : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.Status).AspectGetter = delegate(PaperListViewItemModel model) { return((model != null) ? model.Status : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.Owner).AspectGetter = delegate(PaperListViewItemModel model) { return((model != null) ? model.Owner : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.CreatedDate).AspectGetter = delegate(PaperListViewItemModel model) { return((model != null) ? model.CreatedDate : DateTime.Now); }; olv.GetColumn((int)OlvMembersIndex.LastUpdatedDate).AspectGetter = delegate(PaperListViewItemModel model) { return((model != null) ? model.LastUpdatedDate : DateTime.Now); }; olv.GetColumn((int)OlvMembersIndex.LastEditor).AspectGetter = delegate(PaperListViewItemModel model) { return((model != null) ? model.LastEditor : string.Empty); }; olv.GetColumn((int)OlvMembersIndex.Revision).AspectGetter = delegate(PaperListViewItemModel model) { return((model != null) ? model.Revision : 0); }; }
private void GameListForm_Load(object sender, EventArgs e) { TypedObjectListViewEntry = new TypedObjectListView <GameList.GameEntry>(GameListView); GameListView.ShowGroups = false; GameListView.FullRowSelect = true; DiscIdColumn.TextAlign = HorizontalAlignment.Center; FirmwareColumn.TextAlign = HorizontalAlignment.Center; GameListView.StateImageList = new ImageList(); var img = new Bitmap(640, 120); var g = Graphics.FromImage(img); g.DrawLine(new Pen(new SolidBrush(Color.Red)), new Point(0, 0), new Point(100, 100)); GameListView.StateImageList.Images.Add("test", img); GameListView.OwnerDraw = true; //var IconSize = new Size(144, 80); var IconSize = new Size(108, 60); GameListView.RowHeight = IconSize.Height; //objectListView1.AllowColumnReorder = true; //objectListView1.AutoResizeColumns(); GameListView.Resize += objectListView1_Resize; ResetColumns(); GameListView.GridLines = true; GameListView.Sort(TitleColumn, SortOrder.Ascending); //TitleColumn.HeaderFont = new Font("MS Gothic Normal", 16); TitleColumn.RendererDelegate = (ee, gg, rr, oo) => { try { var Entry = ((GameList.GameEntry)oo); var Selected = (GameListView.SelectedObjects.Contains((object)Entry)); gg.FillRectangle(new SolidBrush(!Selected ? SystemColors.Window : SystemColors.Highlight), new Rectangle(rr.Left - 1, rr.Top - 1, rr.Width + 1, rr.Height + 1)); var Text = Entry.TITLE; Font Font; if (Entry.PatchedWithPrometheus) { Text = Text + " *PATCHED*"; Font = Font3; } else { Font = Font2; } var Measure = gg.MeasureString(Text, Font, new Size(rr.Width, rr.Height)); gg.Clip = new System.Drawing.Region(rr); gg.DrawString( Text, Font, new SolidBrush(!Selected ? SystemColors.WindowText : SystemColors.HighlightText), new Rectangle( new Point(rr.Left + 8, (int)(rr.Top + rr.Height / 2 - Measure.Height / 2)), new Size(rr.Width, rr.Height) ) ); //gg.FillRectangle(new SolidBrush(Color.White), rr); //gg.DrawImageUnscaled(Entry.CachedBitmap, new Point(rr.Left, rr.Top)); } catch { } return(true); }; BannerColumn.MaximumWidth = BannerColumn.Width = BannerColumn.MinimumWidth = IconSize.Width; //BannerColumn.AspectGetter = delegate(object _entry) { return null; }; BannerColumn.RendererDelegate = (ee, gg, rr, oo) => { try { var Entry = ((GameList.GameEntry)oo); var Data = Entry.Icon0Png; if (Entry.CachedBitmap == null) { Entry.CachedBitmap = new Bitmap(IconSize.Width, IconSize.Height); using (var gg2 = Graphics.FromImage(Entry.CachedBitmap)) { var IconToBlit = Image.FromStream(new MemoryStream(Data)); var TempBuffer = new Bitmap(144, 80); using (var gg3 = Graphics.FromImage(TempBuffer)) { gg3.CompositingQuality = CompositingQuality.HighQuality; gg3.Clear(Color.Transparent); gg3.DrawImage(IconToBlit, new Rectangle(TempBuffer.Width / 2 - IconToBlit.Width / 2, 0, IconToBlit.Width, IconToBlit.Height)); } //Console.WriteLine("{0}x{1}", IconToBlit.Width, IconToBlit.Height); gg2.CompositingQuality = CompositingQuality.HighQuality; if (Entry.PatchedWithPrometheus) { gg2.Clear(Color.Red); } else { gg2.Clear(Color.White); } gg2.DrawImage(TempBuffer, new Rectangle(0, 0, IconSize.Width, IconSize.Height)); if (Entry.PatchedWithPrometheus) { gg2.DrawLine(new Pen(Color.Red), new Point(0, 0), new Point(IconSize.Width, IconSize.Height)); gg2.DrawLine(new Pen(Color.Red), new Point(IconSize.Width, 0), new Point(0, IconSize.Height)); } } } gg.FillRectangle(new SolidBrush(Entry.PatchedWithPrometheus ? Color.Red : Color.White), new Rectangle(rr.Left - 1, rr.Top - 1, rr.Width + 1, rr.Height + 1)); gg.DrawImageUnscaled(Entry.CachedBitmap, new Point(rr.Left - 1, rr.Top - 1)); } catch { } return(true); }; TitleColumn.AspectGetter = delegate(object _entry) { try { return(((GameList.GameEntry)_entry).TITLE); } catch { return("*ERROR*"); } }; DiscIdColumn.AspectGetter = delegate(object _entry) { try { return(((GameList.GameEntry)_entry).DiscId0); } catch { return("*ERROR*"); } }; PathColumn.AspectGetter = delegate(object _entry) { try { return(Path.GetFileName(((GameList.GameEntry)_entry).IsoFile)); } catch { return("*ERROR*"); } }; MediaTypeColumn.AspectGetter = delegate(object _entry) { try { var Entry = ((GameList.GameEntry)_entry); var DISC_ID = Entry.DISC_ID; switch (DISC_ID[0]) { case 'S': return("CD/DVD"); case 'U': return("UMD"); case 'B': return("BluRay"); case 'N': return("PSN"); default: return("Unknown"); } } catch { return("*ERROR*"); } }; LicenseTypeColumn.AspectGetter = delegate(object _entry) { try { var Entry = ((GameList.GameEntry)_entry); var DISC_ID = Entry.DISC_ID; switch (DISC_ID[1]) { case 'C': return("Sony"); case 'P': return("PSN"); case 'L': return("Other"); default: return("Unknown"); } } catch { return("*ERROR*"); } }; RegionColumn.AspectGetter = delegate(object _entry) { try { var Entry = ((GameList.GameEntry)_entry); var DISC_ID = Entry.DISC_ID; switch (DISC_ID[2]) { case 'P': case 'J': return("Japan"); case 'E': return("Europe"); case 'K': return("Korea"); case 'U': return("USA"); case 'A': return("Asia"); default: return("Unknown"); } } catch { return("*ERROR*"); } }; ReleaseTypeColumn.AspectGetter = delegate(object _entry) { try { var Entry = ((GameList.GameEntry)_entry); var DISC_ID = Entry.DISC_ID; switch (DISC_ID[3]) { case 'D': return("Demo"); case 'M': return("Malaysian"); case 'S': return("Retail"); default: return("Unknown"); } } catch { return("*ERROR*"); } }; FirmwareColumn.AspectGetter = delegate(object _entry) { try { return(((GameList.GameEntry)_entry).PSP_SYSTEM_VER); } catch { return("*ERROR*"); } }; }
private void InitializeOLVMembers() { // don't allow edit this.objectListView_TeamFoldersMembers.CellEditActivation = BrightIdeasSoftware.ObjectListView.CellEditActivateMode.None; this.objectListView_TeamFoldersMembers.UseExplorerTheme = false; this.objectListView_TeamFoldersMembers.UseTranslucentHotItem = true; this.objectListView_TeamFoldersMembers.FullRowSelect = false; this.objectListView_TeamFoldersMembers.HotTracking = false; this.objectListView_TeamFoldersMembers.HeaderToolTip.IsBalloon = false; this.objectListView_TeamFoldersMembers.HotItemStyle.BackColor = Color.AliceBlue; this.objectListView_TeamFoldersMembers.HotItemStyle.ForeColor = Color.MediumBlue; TypedObjectListView<TeamFoldersListViewItemModel> olv = new TypedObjectListView<TeamFoldersListViewItemModel>( this.objectListView_TeamFoldersMembers ); olv.GetColumn((int)OlvMembersIndex.TeamFolderName).AspectGetter = delegate (TeamFoldersListViewItemModel model) { return (model != null) ? model.TeamFolderName : string.Empty; }; //olv.GetColumn((int)OlvMembersIndex.DefaultSyncSetting).AspectGetter // = delegate (TeamFoldersListViewItemModel model) // { // return (model != null) ? model.DefaultSyncSetting : string.Empty; // }; olv.GetColumn((int)OlvMembersIndex.TeamFolderId).AspectGetter = delegate (TeamFoldersListViewItemModel model) { return (model != null) ? model.TeamFolderId : string.Empty; }; olv.GetColumn((int)OlvMembersIndex.Status).AspectGetter = delegate (TeamFoldersListViewItemModel model) { return (model != null) ? model.Status : string.Empty; }; }
private void InitializeOLVMembers() { // don't allow edit this.objectListView_ProvisioningMembers.CellEditActivation = BrightIdeasSoftware.ObjectListView.CellEditActivateMode.None; this.objectListView_ProvisioningMembers.UseExplorerTheme = false; this.objectListView_ProvisioningMembers.UseTranslucentHotItem = true; this.objectListView_ProvisioningMembers.FullRowSelect = false; this.objectListView_ProvisioningMembers.HotTracking = false; this.objectListView_ProvisioningMembers.HeaderToolTip.IsBalloon = false; this.objectListView_ProvisioningMembers.HotItemStyle.BackColor = Color.AliceBlue; this.objectListView_ProvisioningMembers.HotItemStyle.ForeColor = Color.MediumBlue; TypedObjectListView<MemberListViewItemModel> olv = new TypedObjectListView<MemberListViewItemModel>( this.objectListView_ProvisioningMembers ); olv.GetColumn((int)OlvMembersIndex.Email).AspectGetter = delegate (MemberListViewItemModel model) { return (model != null) ? model.Email : string.Empty; }; olv.GetColumn((int)OlvMembersIndex.FirstName).AspectGetter = delegate (MemberListViewItemModel model) { return (model != null) ? model.FirstName : string.Empty; }; olv.GetColumn((int)OlvMembersIndex.LastName).AspectGetter = delegate (MemberListViewItemModel model) { return (model != null) ? model.LastName : string.Empty; }; olv.GetColumn((int)OlvMembersIndex.Usage).AspectGetter = delegate (MemberListViewItemModel model) { return (model != null) ? model.Usage : 0; }; }
private void InitializeOLVContentDisplay() { this.fastObjectListView_DataMigrationContentDisplay.CellEditActivation = BrightIdeasSoftware.ObjectListView.CellEditActivateMode.None; this.fastObjectListView_DataMigrationContentDisplay.UseExplorerTheme = false; this.fastObjectListView_DataMigrationContentDisplay.UseTranslucentHotItem = true; this.fastObjectListView_DataMigrationContentDisplay.FullRowSelect = true; this.fastObjectListView_DataMigrationContentDisplay.HotTracking = true; this.fastObjectListView_DataMigrationContentDisplay.ShowGroups = false; this.fastObjectListView_DataMigrationContentDisplay.HeaderToolTip.IsBalloon = false; this.fastObjectListView_DataMigrationContentDisplay.GridLines = true; TypedObjectListView<ContentDisplayListViewItemModel> olv = new TypedObjectListView<ContentDisplayListViewItemModel>( this.fastObjectListView_DataMigrationContentDisplay ); olv.GetColumn((int)OlvContentIndex.OwnerName).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.OwnerName : string.Empty; }; olv.GetColumn((int)OlvContentIndex.OwnerLogin).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.Email : string.Empty; }; olv.GetColumn((int)OlvContentIndex.ItemPathDisplay).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.ItemPathDisplay : string.Empty; }; olv.GetColumn((int)OlvContentIndex.ItemId).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.ItemId : string.Empty; }; olv.GetColumn((int)OlvContentIndex.ItemName).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.ItemName : string.Empty; }; olv.GetColumn((int)OlvContentIndex.ItemId).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.ItemId : string.Empty; }; olv.GetColumn((int)OlvContentIndex.ItemType).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.ItemType : string.Empty; }; olv.GetColumn((int)OlvContentIndex.ItemSize).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.ItemSize : string.Empty; }; olv.GetColumn((int)OlvContentIndex.Created).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.Created : string.Empty; }; olv.GetColumn((int)OlvContentIndex.LastModified).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.LastModified : string.Empty; }; olv.GetColumn((int)OlvContentIndex.Uploaded).AspectGetter = delegate (ContentDisplayListViewItemModel model) { return (model != null) ? model.Uploaded : string.Empty; }; }
/// <summary> /// Initializes the form components /// </summary> private void SetupForm() { InitializeComponent(); recordList = new TypedObjectListView <DataRecord>(dataRecordListView); }
private void InitializeOLVContentDisplay() { this.fastObjectListView_DataMigrationContentDisplay.CellEditActivation = BrightIdeasSoftware.ObjectListView.CellEditActivateMode.None; this.fastObjectListView_DataMigrationContentDisplay.UseExplorerTheme = false; this.fastObjectListView_DataMigrationContentDisplay.UseTranslucentHotItem = true; this.fastObjectListView_DataMigrationContentDisplay.FullRowSelect = true; this.fastObjectListView_DataMigrationContentDisplay.HotTracking = true; this.fastObjectListView_DataMigrationContentDisplay.ShowGroups = false; this.fastObjectListView_DataMigrationContentDisplay.HeaderToolTip.IsBalloon = false; this.fastObjectListView_DataMigrationContentDisplay.GridLines = true; TypedObjectListView <ContentDisplayListViewItemModel> olv = new TypedObjectListView <ContentDisplayListViewItemModel>( this.fastObjectListView_DataMigrationContentDisplay ); olv.GetColumn((int)OlvContentIndex.OwnerName).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.OwnerName : string.Empty); }; olv.GetColumn((int)OlvContentIndex.OwnerLogin).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.Email : string.Empty); }; olv.GetColumn((int)OlvContentIndex.ItemPathDisplay).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.ItemPathDisplay : string.Empty); }; olv.GetColumn((int)OlvContentIndex.ItemId).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.ItemId : string.Empty); }; olv.GetColumn((int)OlvContentIndex.ItemName).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.ItemName : string.Empty); }; olv.GetColumn((int)OlvContentIndex.ItemId).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.ItemId : string.Empty); }; olv.GetColumn((int)OlvContentIndex.ItemType).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.ItemType : string.Empty); }; olv.GetColumn((int)OlvContentIndex.ItemSize).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.ItemSize : string.Empty); }; olv.GetColumn((int)OlvContentIndex.Created).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.Created : string.Empty); }; olv.GetColumn((int)OlvContentIndex.LastModified).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.LastModified : string.Empty); }; olv.GetColumn((int)OlvContentIndex.Uploaded).AspectGetter = delegate(ContentDisplayListViewItemModel model) { return((model != null) ? model.Uploaded : string.Empty); }; }
public void InitObjectListView() { //modlist_objectlistview?.Dispose(); var categoryGroupingDelegate = new GroupKeyGetterDelegate(o => Mods.GetCategory(o as ModEntry)); var categoryFormatterDelegate = new GroupFormatterDelegate((@group, parameters) => { var groupName = group.Key as string; if (groupName == null) { return; } // Restore collapsed state group.Collapsed = Mods.Entries[groupName].Collapsed; // Sort Categories parameters.GroupComparer = Comparer <OLVGroup> .Create((a, b) => Mods.Entries[(string)a.Key].Index.CompareTo(Mods.Entries[(string)b.Key].Index)); }); olvcActive.GroupKeyGetter = categoryGroupingDelegate; olvcActive.GroupFormatter = categoryFormatterDelegate; olvcName.GroupKeyGetter = categoryGroupingDelegate; olvcName.GroupFormatter = categoryFormatterDelegate; olvcID.GroupKeyGetter = categoryGroupingDelegate; olvcID.GroupFormatter = categoryFormatterDelegate; olvcOrder.GroupKeyGetter = categoryGroupingDelegate; olvcOrder.GroupFormatter = categoryFormatterDelegate; olvcCategory.AspectGetter = o => Mods.GetCategory((ModEntry)o); olvcTags.Renderer = new TagRenderer(modlist_ListObjectListView, AvailableTags); olvcTags.AspectPutter = (rowObject, value) => { var tags = ((string)value).Split(';'); tags.All(t => AddTag((ModEntry)rowObject, t.Trim())); }; olvcTags.SearchValueGetter = rowObject => ((ModEntry)rowObject).Tags.Select(s => s.ToLower()).ToArray(); olvcTags.AspectGetter = rowObject => ""; olvcState.AspectGetter = o => { var mod = (ModEntry)o; if (mod.State.HasFlag(ModState.NotLoaded)) { return("Not Loaded"); } if (mod.State.HasFlag(ModState.NotInstalled)) { return("Not Installed"); } if (mod.State.HasFlag(ModState.ModConflict)) { return("Conflict"); } if (mod.State.HasFlag(ModState.DuplicateID)) { return("Duplicate ID"); } if (mod.State.HasFlag(ModState.New)) { return("New"); } if (mod.State.HasFlag(ModState.UpdateAvailable)) { return("Update Available"); } return("OK"); }; olvcSize.AspectToStringConverter = size => ((long)size).FormatAsFileSize(); olvcLastUpdated.DataType = typeof(DateTime?); olvcDateAdded.DataType = typeof(DateTime?); olvcDateCreated.DataType = typeof(DateTime?); olvcPath.GroupKeyGetter = o => Path.GetDirectoryName((o as ModEntry)?.Path); // size groupies var columns = modlist_ListObjectListView.AllColumns.ToArray(); columns.Single(c => c.AspectName == "Size").MakeGroupies( new[] { 1024, 1024 * 1024, (long)50 * 1024 * 1024, (long)100 * 1024 * 1024 }, new[] { "< 1 KB", "< 1MB", "< 50 MB", "< 100 MB", "> 100 MB" } ); columns.Single(c => c.AspectName == "isHidden").MakeGroupies( new [] { false, true }, new [] { "wut?", "Not Hidden", "Hidden" }); columns.Single(c => c.AspectName == "isActive").MakeGroupies( new[] { false, true }, new[] { "wut?", "Disabled", "Enabled" }); olvcActive.AspectToStringConverter = active => ""; olvcActive.GroupFormatter = (g, param) => { param.GroupComparer = Comparer <OLVGroup> .Create((a, b) => (param.GroupByOrder == SortOrder.Descending ? 1 : -1) *a.Header.CompareTo(b.Header)); }; olvcName.AutoCompleteEditor = false; // Sort by Order or WorkshopID column removes groups modlist_ListObjectListView.BeforeSorting += (sender, args) => { modlist_ListObjectListView.ShowGroups = !(args.ColumnToSort.Equals(olvcOrder) || args.ColumnToSort.Equals(olvcWorkshopID)); }; // Init DateTime columns foreach (var column in columns.Where(c => c.DataType == typeof(DateTime?))) { column.AspectToStringConverter = d => (d as DateTime?)?.ToLocalTime().ToString(CultureInfo.CurrentCulture); column.MakeGroupies( new[] { DateTime.Now.Subtract(TimeSpan.FromHours(24 * 30)), DateTime.Now.Subtract(TimeSpan.FromHours(24 * 7)), DateTime.Now.Date }, new[] { "Older Than One Month", "This Month", "This Week", "Today" }); // Sord Desc column.GroupFormatter = (g, param) => { param.GroupComparer = Comparer <OLVGroup> .Create((a, b) => (param.GroupByOrder == SortOrder.Descending ? -1 : 1) *a.Header.CompareTo(b.Header)); }; } // Wrapper ModList = new TypedObjectListView <ModEntry>(modlist_ListObjectListView); // Events //modlist_objectlistview.SelectionChanged += ModListSelectionChanged; //modlist_objectlistview.ItemChecked += ModListItemChecked; //modlist_objectlistview.CellRightClick += ModListCellRightClick; //modlist_objectlistview.CellEditFinished += ModListEditFinished; //modlist_objectlistview.CellToolTipShowing += ModListCellToolTipShowing; //modlist_objectlistview.FormatRow += ModListFormatRow; //modlist_objectlistview.GroupExpandingCollapsing += ModListGroupExpandingCollapsing; //modlist_objectlistview.KeyUp += ModListKeyUp; //modlist_objectlistview.KeyDown += ModListKeyDown; // Restore State if (Settings.Windows.ContainsKey("main") && Settings.Windows["main"].Data != null) { modlist_ListObjectListView.RestoreState(Settings.Windows["main"].Data); } RefreshModList(); // Start out sorted by name modlist_ListObjectListView.Sort(olvcName, SortOrder.Ascending); }
private void IncidencePoolingandAggregation_Load(object sender, EventArgs e) { try { if (CommonClass.BaseControlCRSelectFunctionCalculateValue != null && CommonClass.BaseControlCRSelectFunctionCalculateValue.lstCRSelectFunctionCalculateValue != null) { this.olvAvailable.SetObjects(CommonClass.BaseControlCRSelectFunctionCalculateValue.lstCRSelectFunctionCalculateValue); TypedObjectListView <CRSelectFunctionCalculateValue> tlist = new TypedObjectListView <CRSelectFunctionCalculateValue>(this.olvAvailable); tlist.GenerateAspectGetters(); this.olvAvailable.TileSize = new Size(300, 130); this.olvAvailable.ItemRenderer = new Tools.BusinessCardRenderer(); this.olvAvailable.ItemRenderer = new Tools.BusinessCardRenderer(); olvAvailable.OwnerDraw = true; } else { List <CRSelectFunctionCalculateValue> lst = new List <CRSelectFunctionCalculateValue>(); CRSelectFunctionCalculateValue cfcv = new CRSelectFunctionCalculateValue(); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(21); lst.Add(cfcv); CRSelectFunctionCalculateValue cfcv2 = new CRSelectFunctionCalculateValue(); CRSelectFunctionCalculateValue cfcv3 = new CRSelectFunctionCalculateValue(); CRSelectFunctionCalculateValue cfcv4 = new CRSelectFunctionCalculateValue(); CRSelectFunctionCalculateValue cfcv5 = new CRSelectFunctionCalculateValue(); CRSelectFunctionCalculateValue cfcv6 = new CRSelectFunctionCalculateValue(); CRSelectFunctionCalculateValue cfcv7 = new CRSelectFunctionCalculateValue(); CRSelectFunctionCalculateValue cfcv8 = new CRSelectFunctionCalculateValue(); CRSelectFunctionCalculateValue cfcv9 = new CRSelectFunctionCalculateValue(); CRSelectFunctionCalculateValue cfcv10 = new CRSelectFunctionCalculateValue(); CRSelectFunctionCalculateValue cfcv11 = new CRSelectFunctionCalculateValue(); cfcv2.CRSelectFunction = new CRSelectFunction(); cfcv2.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(22); lst.Add(cfcv2); cfcv3.CRSelectFunction = new CRSelectFunction(); cfcv3.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(40); lst.Add(cfcv3); cfcv4.CRSelectFunction = new CRSelectFunction(); cfcv4.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(41); lst.Add(cfcv4); cfcv5.CRSelectFunction = new CRSelectFunction(); cfcv5.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(62); lst.Add(cfcv5); cfcv6.CRSelectFunction = new CRSelectFunction(); cfcv6.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(63); lst.Add(cfcv6); cfcv7.CRSelectFunction = new CRSelectFunction(); cfcv7.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(64); lst.Add(cfcv7); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); cfcv.CRSelectFunction = new CRSelectFunction(); cfcv.CRSelectFunction.BenMAPHealthImpactFunction = Configuration.ConfigurationCommonClass.getBenMAPHealthImpactFunctionFromID(56); lst.Add(cfcv); this.olvAvailable.SetObjects(lst); TypedObjectListView <CRSelectFunctionCalculateValue> tlist = new TypedObjectListView <CRSelectFunctionCalculateValue>(this.olvAvailable); tlist.GenerateAspectGetters(); this.olvAvailable.TileSize = new Size(300, 130); this.olvAvailable.ItemRenderer = new Tools.BusinessCardRenderer(); olvAvailable.OwnerDraw = true; } this.olvSelected.CheckBoxes = false; List <CRSelectFunctionCalculateValue> lstAvailable = (List <CRSelectFunctionCalculateValue>) this.olvAvailable.Objects; Dictionary <string, int> DicFilterDataSet = new Dictionary <string, int>(); DicFilterDataSet.Add("", -1); var query = from a in lstAvailable select new { a.CRSelectFunction.BenMAPHealthImpactFunction.DataSetName, a.CRSelectFunction.BenMAPHealthImpactFunction.DataSetID }; if (query != null && query.Count() > 0) { List <KeyValuePair <string, int> > lstFilterDataSet = DicFilterDataSet.ToList(); lstFilterDataSet.AddRange(query.Distinct().ToDictionary(p => p.DataSetName, p => p.DataSetID)); DicFilterDataSet = lstFilterDataSet.ToDictionary(p => p.Key, p => p.Value); } BindingSource bs = new BindingSource(); bs.DataSource = DicFilterDataSet; this.cbDataSet.DataSource = bs; cbDataSet.DisplayMember = "Key"; cbDataSet.ValueMember = "Value"; Dictionary <string, int> DicFilterGroup = new Dictionary <string, int>(); DicFilterGroup.Add("", -1); var queryGroup = from a in lstAvailable select new { a.CRSelectFunction.BenMAPHealthImpactFunction.EndPointGroup, a.CRSelectFunction.BenMAPHealthImpactFunction.EndPointGroupID }; if (queryGroup != null && queryGroup.Count() > 0) { List <KeyValuePair <string, int> > lstGroup = DicFilterGroup.ToList(); lstGroup.AddRange(queryGroup.Distinct().ToDictionary(p => p.EndPointGroup, p => p.EndPointGroupID)); DicFilterGroup = lstGroup.ToDictionary(p => p.Key, p => p.Value); } BindingSource bsqueryGroup = new BindingSource(); bsqueryGroup.DataSource = DicFilterGroup; cbEndPointGroup.DataSource = bsqueryGroup; cbEndPointGroup.DisplayMember = "Key"; cbEndPointGroup.ValueMember = "Value"; this.cboPoolingMethod.DataSource = Enum.GetNames(typeof(PoolingMethodTypeEnum)); if (CommonClass.GBenMAPGrid != null) { this.txtTargetGridType.Text = CommonClass.GBenMAPGrid.GridDefinitionName; } } catch (Exception ex) { } }
public HoursTracker() { InitializeComponent(); uxGroupsDefaultLocation = uxGroupsGroup.Location; uxHoursDefaultLocation = uxSavedHoursGroup.Location; clockInTime = DateTime.Now; clockOutTime = DateTime.Now; groupManager = new TimeGroupManager(); SystemTimeTimer.Enabled = true; SystemTimeTimer_Tick(null, null); //Do some whack ObjectListView things //set up the typed olvs typedGroupView = new TypedObjectListView<TimeGrouping>(this.uxGroupsView); typedTimeView = new TypedObjectListView<TimedInstance>(this.uxSavedHoursView); //set up weird delegate things for(int i = 0; i < uxSavedHoursView.Columns.Count; i++) { typedTimeView.GetColumn(i).GroupKeyGetter = delegate (TimedInstance timedInstance) { TimedInstance time = timedInstance; return time.CurrentGroup; }; }//end setting all columns to use group name as group key for(int i = 0; i < uxSavedHoursView.AllColumns.Count; i++) { uxSavedHoursView.AllColumns[i].GroupKeyToTitleConverter = delegate (object groupKey) { if (groupKey == null) return "No Group Found"; TimeGrouping groupObj = (TimeGrouping)groupKey; return groupObj.GroupName; };//end setting GroupKeyToTitleConverter }//end looping to set groupKeyToTitleConverter for all the columns // do the group formatters uxStartDateColumn.GroupFormatter = (OLVGroup group, GroupingParameters parms) => { parms.GroupComparer = Comparer<OLVGroup>.Create ( (x, y) => (((TimeGrouping)x.Key).EarliestDate.TimeSpan.Ticks.CompareTo( ((TimeGrouping)y.Key).EarliestDate.TimeSpan.Ticks) ) );//end group comparer definition };//end group formatter for start date uxEndDateColumn.GroupFormatter = (OLVGroup group, GroupingParameters parms) => { parms.GroupComparer = Comparer<OLVGroup>.Create ( (x, y) => (((TimeGrouping)x.Key).EarliestDate.TimeSpan.Ticks.CompareTo( ((TimeGrouping)y.Key).EarliestDate.TimeSpan.Ticks) ) );//end group comparer definition };//end group formatter for end date uxStartTimeColumn.GroupFormatter = (OLVGroup group, GroupingParameters parms) => { parms.GroupComparer = Comparer<OLVGroup>.Create ( (x, y) => (((TimeGrouping)x.Key).EarliestTime.TimeSpan.Ticks.CompareTo( ((TimeGrouping)y.Key).EarliestTime.TimeSpan.Ticks) ) );//end group comparer definition };//end group formatter for start time uxEndTimeColumn.GroupFormatter = (OLVGroup group, GroupingParameters parms) => { parms.GroupComparer = Comparer<OLVGroup>.Create ( (x, y) => (((TimeGrouping)x.Key).EarliestTime.TimeSpan.Ticks.CompareTo( ((TimeGrouping)y.Key).EarliestTime.TimeSpan.Ticks) ) );//end group comparer definition };//end group formatter for end time uxHoursColumn.GroupFormatter = (OLVGroup group, GroupingParameters parms) => { parms.GroupComparer = Comparer<OLVGroup>.Create ( (x, y) => ((TimeGrouping)x.Key).TotalHours.CompareTo( ((TimeGrouping)y.Key).TotalHours) );//end GroupCompareer };//end GroupFormatter for Hours uxMinutesColumn.GroupFormatter = (OLVGroup group, GroupingParameters parms) => { parms.GroupComparer = Comparer<OLVGroup>.Create ( (x, y) => ((TimeGrouping)x.Key).TotalMinutes.CompareTo( ((TimeGrouping)y.Key).TotalMinutes) );//end GroupCompareer };//end GroupFormatter for Minutes uxInstanceColumn.GroupFormatter = (OLVGroup group, GroupingParameters parms) => { parms.GroupComparer = Comparer<OLVGroup>.Create ( (x, y) => ((TimeGrouping)x.Key).GroupName.CompareTo(((TimeGrouping)y.Key).GroupName) );//end groupComparer };//end GroupFormatter for InstanceName }//end constructor
/// <summary> /// Initializes the lstGames Control. /// </summary> private void InitializeLstGames() { tlstGames = new TypedObjectListView<GameInfo>(this.lstGames); //Aspect Getters tlstGames.GenerateAspectGetters(); colGameID.AspectToStringConverter = delegate(object obj) { int id = (int)obj; return (id < 0) ? GlobalStrings.MainForm_External : id.ToString(); }; colCategories.AspectGetter = delegate(Object g) { return ((GameInfo)g).GetCatString(GlobalStrings.MainForm_Uncategorized); }; colFavorite.AspectGetter = delegate(Object g) { return ((GameInfo)g).IsFavorite() ? "X" : String.Empty; }; colHidden.AspectGetter = delegate(Object g) { return ((GameInfo)g).Hidden ? "X" : String.Empty; }; colGenres.AspectGetter = delegate(Object g) { int id = ((GameInfo)g).Id; if (Program.GameDB.Games.ContainsKey(id) && Program.GameDB.Games[id].Genres != null) return string.Join(", ", Program.GameDB.Games[id].Genres); return GlobalStrings.MainForm_NoGenres; }; colFlags.AspectGetter = delegate(Object g) { int id = ((GameInfo)g).Id; if (Program.GameDB.Games.ContainsKey(id) && Program.GameDB.Games[id].Flags != null) return string.Join(", ", Program.GameDB.Games[id].Flags); return GlobalStrings.MainForm_NoFlags; }; colTags.AspectGetter = delegate(Object g) { int id = ((GameInfo)g).Id; if (Program.GameDB.Games.ContainsKey(id) && Program.GameDB.Games[id].Tags != null) return string.Join(", ", Program.GameDB.Games[id].Tags); return GlobalStrings.MainForm_NoTags; }; colYear.AspectGetter = delegate(object g) { int id = ((GameInfo)g).Id; DateTime releaseDate; if (Program.GameDB.Games.ContainsKey(id) && DateTime.TryParse(Program.GameDB.Games[id].SteamReleaseDate, out releaseDate)) return releaseDate.Year.ToString(); return GlobalStrings.MainForm_Unknown; }; colAchievements.AspectGetter = delegate(object g) { int id = ((GameInfo)g).Id; return Program.GameDB.Games.ContainsKey(id) ? Program.GameDB.Games[id].Achievements : 0; }; colPlatforms.AspectGetter = delegate(Object g) { return Program.GameDB.Games[((GameInfo)g).Id].Platforms.ToString(); }; colDevelopers.AspectGetter = delegate(Object g) { int id = ((GameInfo)g).Id; if (Program.GameDB.Games.ContainsKey(id) && Program.GameDB.Games[id].Developers != null) return string.Join(", ", Program.GameDB.Games[id].Developers); return GlobalStrings.MainForm_Unknown; }; colPublishers.AspectGetter = delegate(Object g) { int id = ((GameInfo)g).Id; if (Program.GameDB.Games.ContainsKey(id) && Program.GameDB.Games[id].Publishers != null) return string.Join(", ", Program.GameDB.Games[id].Publishers); return GlobalStrings.MainForm_Unknown; }; colNumberOfReviews.AspectGetter = delegate(object g) { int id = ((GameInfo)g).Id; return Program.GameDB.Games.ContainsKey(id) ? Program.GameDB.Games[id].ReviewTotal : 0; }; colReviewScore.AspectGetter = delegate(object g) { int id = ((GameInfo)g).Id; return Program.GameDB.Games.ContainsKey(id) ? Program.GameDB.Games[id].ReviewPositivePercentage : 0; }; colReviewLabel.AspectGetter = delegate(object g) { int id = ((GameInfo)g).Id; if (Program.GameDB.Games.ContainsKey(id)) { int reviewTotal = Program.GameDB.Games[id].ReviewTotal; int reviewPositivePercentage = Program.GameDB.Games[id].ReviewPositivePercentage; if (reviewTotal <= 0) return -1; if (reviewPositivePercentage >= 95 && reviewTotal >= 500) return 9; else if (reviewPositivePercentage >= 85 && reviewTotal >= 50) return 8; else if (reviewPositivePercentage >= 80) return 7; else if (reviewPositivePercentage >= 70) return 6; else if (reviewPositivePercentage >= 40) return 5; else if (reviewPositivePercentage >= 20) return 4; else if (reviewTotal >= 500) return 3; else if (reviewTotal >= 50) return 2; else return 1; } return 0; }; colHltbMain.AspectGetter = delegate(object g) { int id = ((GameInfo)g).Id; return Program.GameDB.Games.ContainsKey(id) ? Program.GameDB.Games[id].HltbMain : 0; }; colHltbExtras.AspectGetter = delegate(object g) { int id = ((GameInfo)g).Id; return Program.GameDB.Games.ContainsKey(id) ? Program.GameDB.Games[id].HltbExtras : 0; }; colHltbCompletionist.AspectGetter = delegate(object g) { int id = ((GameInfo)g).Id; return Program.GameDB.Games.ContainsKey(id) ? Program.GameDB.Games[id].HltbCompletionist : 0; }; //Aspect to String Converters colNumberOfReviews.AspectToStringConverter = delegate(object obj) { int reviewTotal = (int)obj; return (reviewTotal <= 0) ? "0" : reviewTotal.ToString(); }; colReviewScore.AspectToStringConverter = delegate(object obj) { int reviewScore = (int)obj; return (reviewScore <= 0) ? GlobalStrings.MainForm_Unknown : reviewScore.ToString() + '%'; }; colReviewLabel.AspectToStringConverter = delegate(object obj) { int index = (int)obj; Dictionary<int, String> reviewLabels = new Dictionary<int, String> { {9, "Overwhelmingly Positive"}, {8, "Very Positive"}, {7, "Positive"}, {6, "Mostly Positive"}, {5, "Mixed"}, {4, "Mostly Negative"}, {3, "Negative"}, {2, "Very Negative"}, {1, "Overwhelmingly Negative"}, }; return reviewLabels.ContainsKey(index) ? reviewLabels[index] : GlobalStrings.MainForm_Unknown; }; AspectToStringConverterDelegate hltb = delegate(object obj) { int time = (int)obj; if (time <= 0) return GlobalStrings.MainForm_NoHltbTime; if (time < 60) return time + "m"; int hours = time / 60; int mins = time % 60; if (mins == 0) return hours + "h"; return hours + "h " + mins + "m"; }; colHltbMain.AspectToStringConverter = delegate(object obj) { int time = (int)obj; if (time <= 0) return GlobalStrings.MainForm_NoHltbTime; if (time < 60) return time + "m"; int hours = time / 60; int mins = time % 60; if (mins == 0) return hours + "h"; return hours + "h " + mins + "m"; }; colHltbExtras.AspectToStringConverter = hltb; colHltbCompletionist.AspectToStringConverter = hltb; //Filtering colCategories.ClusteringStrategy = new CommaClusteringStrategy(); colGenres.ClusteringStrategy = new CommaClusteringStrategy(); colFlags.ClusteringStrategy = new CommaClusteringStrategy(); colTags.ClusteringStrategy = new CommaClusteringStrategy(); colPlatforms.ClusteringStrategy = new CommaClusteringStrategy(); //Formating lstGames.RowFormatter = delegate(OLVListItem lvi) { if (((GameInfo)lvi.RowObject).Id < 0) lvi.Font = new Font(lvi.Font, lvi.Font.Style | FontStyle.Italic); }; lstGames.PrimarySortColumn = colTitle; lstGames.RestoreState(Convert.FromBase64String(Settings.Instance.LstGamesState)); }
internal UninstallerListViewTools(MainWindow reference) { _reference = reference; _listView = new TypedObjectListView <ApplicationUninstallerEntry>(reference.uninstallerObjectListView); SetupListView(); _reference.filterEditor1.TargetFilterCondition = _filteringFilterCondition; // Start the processing thread when user changes the test certificates option _settings.Subscribe((x, y) => { if (_firstRefresh) { return; } if (y.NewValue) { StartProcessingThread(FilteredUninstallers); } else { StopProcessingThread(false); if (CheckIsAppDisposed()) { return; } _listView.ListView.SuspendLayout(); _listView.ListView.RefreshObjects( AllUninstallers.Where(u => u.IsCertificateValid(true).HasValue).ToList()); _listView.ListView.ResumeLayout(); } }, x => x.AdvancedTestCertificates, this); // Refresh items marked as invalid after corresponding setting change _settings.Subscribe((x, y) => { if (CheckIsAppDisposed()) { return; } if (!_firstRefresh) { _listView.ListView.RefreshObjects(AllUninstallers.Where(u => !u.IsValid).ToList()); } }, x => x.AdvancedTestInvalid, this); // Refresh items marked as orphans after corresponding setting change _settings.Subscribe((x, y) => { if (CheckIsAppDisposed()) { return; } if (!_firstRefresh) { _listView.ListView.UpdateColumnFiltering(); } }, x => x.AdvancedDisplayOrphans, this); AfterFiltering += (x, y) => StartProcessingThread(FilteredUninstallers); UninstallerFileLock = new object(); _reference.FormClosed += (x, y) => { // Prevent the thread from accessing disposed resources before getting aborted. StopProcessingThread(false); ProcessRatingsFinalize(); }; _settings.Subscribe((sender, args) => ProcessRatingsInitialize(), x => x.MiscUserRatings, this); //ProcessRatingsInitialize(); Is always called once at the start by the above }
public void InitModListView() { var categoryGroupingDelegate = new GroupKeyGetterDelegate(o => Mods.GetCategory(o as ModEntry)); var categoryFormatterDelegate = new GroupFormatterDelegate((@group, parameters) => { var groupName = group.Key as string; if (groupName == null) { return; } // Restore collapsed state group.Collapsed = Mods.Entries[groupName].Collapsed; // Sort Categories parameters.GroupComparer = Comparer <OLVGroup> .Create((a, b) => Mods.Entries[(string)a.Key].Index.CompareTo(Mods.Entries[(string)b.Key].Index)); }); modlist_ListObjectListView.GroupStateChanged += delegate(object o, GroupStateChangedEventArgs args) { // Remember group expanded/collapsed state when grouping by category (name or id column) if (modlist_ListObjectListView.PrimarySortColumn == olvcName || modlist_ListObjectListView.PrimarySortColumn == olvcID) { if (args.Group.Key is string key) { if (Mods.Entries.ContainsKey(key)) { Mods.Entries[key].Collapsed = args.Group.Collapsed; } } } }; olvcActive.GroupKeyGetter = categoryGroupingDelegate; olvcActive.GroupFormatter = categoryFormatterDelegate; olvcName.GroupKeyGetter = categoryGroupingDelegate; olvcName.GroupFormatter = categoryFormatterDelegate; olvcID.GroupKeyGetter = categoryGroupingDelegate; olvcID.GroupFormatter = categoryFormatterDelegate; olvcOrder.GroupKeyGetter = categoryGroupingDelegate; olvcOrder.GroupFormatter = categoryFormatterDelegate; olvcCategory.AspectGetter = o => Mods.GetCategory((ModEntry)o); olvcTags.Renderer = new TagRenderer(modlist_ListObjectListView, AvailableTags); olvcTags.AspectPutter = (rowObject, value) => { var tags = ((string)value).Split(';'); tags.ToList().ForEach(t => AddTag((ModEntry)rowObject, t.Trim())); }; olvcTags.SearchValueGetter = rowObject => ((ModEntry)rowObject).Tags.Select(s => s.ToLower()).ToArray(); olvcTags.AspectGetter = rowObject => ""; olvcState.AspectGetter = StateAspectGetter; olvcSize.AspectToStringConverter = size => ((long)size).FormatAsFileSize(); olvcLastUpdated.DataType = typeof(DateTime?); olvcDateAdded.DataType = typeof(DateTime?); olvcDateCreated.DataType = typeof(DateTime?); olvcPath.GroupKeyGetter = o => Path.GetDirectoryName((o as ModEntry)?.Path); olvcSource.AspectGetter = rowObject => { if (rowObject is ModEntry mod) { switch (mod.Source) { case ModSource.Unknown: return("Unknown"); case ModSource.SteamWorkshop: return("Steam"); case ModSource.Manual: return("Local"); default: throw new ArgumentOutOfRangeException(nameof(mod.Source), "Unhandled ModSource"); } } return(""); }; // size groupies var columns = modlist_ListObjectListView.AllColumns.ToArray(); columns.Single(c => c.AspectName == "Size").MakeGroupies( new[] { 1024, 1024 * 1024, (long)50 * 1024 * 1024, (long)100 * 1024 * 1024 }, new[] { "< 1 KB", "< 1MB", "< 50 MB", "< 100 MB", "> 100 MB" } ); columns.Single(c => c.AspectName == "isHidden").MakeGroupies( new [] { false, true }, new [] { "wut?", "Not Hidden", "Hidden" }); columns.Single(c => c.AspectName == "isActive").MakeGroupies( new[] { false, true }, new[] { "wut?", "Disabled", "Enabled" }); olvcActive.AspectToStringConverter = active => ""; olvcActive.GroupFormatter = (g, param) => { param.GroupComparer = Comparer <OLVGroup> .Create((a, b) => (param.GroupByOrder == SortOrder.Descending ? 1 : -1) *a.Header.CompareTo(b.Header)); }; olvcName.AutoCompleteEditor = false; // Sort by Order or WorkshopID column removes groups modlist_ListObjectListView.BeforeSorting += (sender, args) => { bool isGroupableColumn = CheckIfGroupableColumn(args.ColumnToSort); bool useGrouping = cEnableGrouping.Checked && isGroupableColumn; modlist_ListObjectListView.ShowGroups = useGrouping; modlist_toggleGroupsButton.Enabled = useGrouping; cEnableGrouping.Enabled = isGroupableColumn; }; modlist_ListObjectListView.BooleanCheckStatePutter = ModListBooleanCheckStatePutter; // Init DateTime columns foreach (var column in columns.Where(c => c.DataType == typeof(DateTime?))) { column.AspectToStringConverter = d => (d as DateTime?)?.ToLocalTime().ToString(CultureInfo.CurrentCulture); column.MakeGroupies( new[] { DateTime.Now.Subtract(TimeSpan.FromHours(24 * 30)), DateTime.Now.Subtract(TimeSpan.FromHours(24 * 7)), DateTime.Now.Date }, new[] { "Older Than One Month", "This Month", "This Week", "Today" }); // Sord Desc column.GroupFormatter = (g, param) => { param.GroupComparer = Comparer <OLVGroup> .Create((a, b) => (param.GroupByOrder == SortOrder.Descending ? -1 : 1) *a.Header.CompareTo(b.Header)); }; } // Wrapper ModList = new TypedObjectListView <ModEntry>(modlist_ListObjectListView); // Restore State if (Settings.Windows.ContainsKey("main") && Settings.Windows["main"].Data != null) { modlist_ListObjectListView.RestoreState(Settings.Windows["main"].Data); } RefreshModList(); // Start out sorted by name modlist_ListObjectListView.Sort(olvcName, SortOrder.Ascending); }
public ProcessTree() { InitializeComponent(); m_typedProcessTree = new TypedObjectListView<ProcessInfo>(m_processTree); m_toolstrip.Text = "Running as administator in 64-bit mode"; if (!Util.IsRunningAsAdministrator()) { m_toolstrip.Text = "Notice: Not running as admin may result in lack of details"; } m_processTree.FullRowSelect = true; m_processTree.RowFormatter = delegate(OLVListItem olvi) { var pair = (KeyValuePair<int, ProcessInfo>)olvi.RowObject; olvi.UseItemStyleForSubItems = false; if (pair.Value.PrivateBytes > 100 * 1024 * 1024) { olvi.SubItems[2].ForeColor = Color.Red; } }; KeyPreview = true; KeyDown += OnKeyDownEvent; m_processTree.DoubleClick += OnDoubleClickEvent; //ProcessProperties props = new ProcessProperties(); //props.Show(); //this.m_processTree.CanExpandGetter = delegate(object x) //{ // return false; //}; //this.m_processTree.ChildrenGetter = delegate(object x) //{ // return new ArrayList(); //}; InitProcessList(); m_thread = new Thread(() => MonitoringLoop()); m_thread.IsBackground = true; m_end = false; m_thread.Start(); }
// Initalize the Format of the ObjectListView private void InitModel() { this.olvAnime.AddDecoration(new EditingCellBorderDecoration(true)); TypedObjectListView <Anime> tolv = new TypedObjectListView <Anime>(this.olvAnime); tolv.GenerateAspectGetters(); // Name of Anime TypedColumn <Anime> tc = new TypedColumn <Anime>(this.olvColName); tc.AspectPutter = (Anime a, object opn) => { a.Name = opn.ToString(); }; // Schedule of Anime tc = new TypedColumn <Anime>(this.olvColAirdate); tc.GroupKeyGetter = (Anime a) => a.Year; // Type of Anime tc = new TypedColumn <Anime>(this.olvColType); tc.AspectPutter = (Anime a, object opt) => { a.Type = (MediaType)opt; }; tc.ImageGetter = (Anime a) => { switch (a.Format) { case MergeFormat.MKV: return(Properties.Resources.MKV); case MergeFormat.MP4: return(Properties.Resources.MP4); case MergeFormat.AVI: return(Properties.Resources.AVI); case MergeFormat.WMV: return(Properties.Resources.WMV); case MergeFormat.M2TS: return(Properties.Resources.M2TS); default: return(-1); } }; // SubTeam of Anime tc = new TypedColumn <Anime>(this.olvColSubTeam); tc.AspectPutter = (Anime a, object opp) => { a.SubTeam = opp.ToString(); }; tc.ImageGetter = (Anime a) => { switch (a.SubStyle) { case SubStyle.External: return(Properties.Resources.External); case SubStyle.Sealed: return(Properties.Resources.Sealed); case SubStyle.Embedded: return(Properties.Resources.Embedded); default: return(-1); } }; // Size of Anime this.olvColSize.AspectToStringConverter = ots => { long ls = (long)ots; if (ls == 0L) { return("-"); } else if (ls >= 1000L * 1024L * 1024L) // 1000M -> 0.9765625G { return(String.Format("{0:#,##0.#0} G", (double)ls / (1024 * 1024 * 1024))); } else { return(String.Format("{0:#,##0.#0} M", (double)ls / (1024 * 1024))); } }; this.olvColSize.MakeGroupies( new long[] { 1024L * 1024L * 1024L * 5L, 1024L * 1024L * 1024L * 10L }, new string[] { "0~5 GB", "5~10 GB", ">10 GB" } ); // Store of Anime tc = new TypedColumn <Anime>(this.olvColStore); //tc.AspectPutter = (Anime a, object opg) => { a.Store = (bool)opg; }; //this.olvColStore.Renderer = new MappedImageRenderer(true, Properties.Resources.Accept, false, Properties.Resources.Alert); tc.AspectPutter = (Anime a, object ops) => { a.Store = (StoreState)ops; }; this.olvColStore.Renderer = new MappedImageRenderer(new object[] { StoreState.Ignore, null, StoreState.Cont, Properties.Resources.Alert, StoreState.Fin, Properties.Resources.Accept }); // Enjoy of Anime tc = new TypedColumn <Anime>(this.olvColEnjoy); //tc.AspectPutter = (Anime a, object opv) => { a.Enjoy = (bool)opv; }; //this.olvColEnjoy.Renderer = new MappedImageRenderer(true, Properties.Resources.Smile, false, Properties.Resources.Sad); tc.AspectPutter = (Anime a, object ope) => { a.Enjoy = (EnjoyState)ope; }; this.olvColEnjoy.Renderer = new MappedImageRenderer(new object[] { EnjoyState.Ignore, null, EnjoyState.NotYet, Properties.Resources.Sad, EnjoyState.Done, Properties.Resources.Smile }); // Grade of Anime tc = new TypedColumn <Anime>(this.olvColGrade); tc.AspectPutter = (Anime a, object opr) => { int onr = (int)opr; a.Grade = onr; //onr < 1 ? 1 : onr; }; this.olvColGrade.Renderer = new MultiImageRenderer(Properties.Resources.Diamond, 3, 0, 4); this.olvColGrade.MakeGroupies( new int[] { 1, 2 }, new string[] { "Normal", "Nice", "Good" } ); // Note of Anime this.olvColNote.AspectToStringConverter = otn => otn.ToString().Replace('\u0002', '\u0020'); // this.olvAnime.UseHotItem auto true this.olvAnime.UseTranslucentHotItem = true; this.olvAnime.UseTranslucentSelection = true; this.olvAnime.HotItemStyle.Overlay = new AnimeViewOverlay(); this.olvAnime.HotItemStyle = this.olvAnime.HotItemStyle; this.olvAnime.PrimarySortColumn = this.olvColTitle; this.olvAnime.PrimarySortOrder = SortOrder.Ascending; }