Example #1
1
        public Form1()
        {
            InitializeComponent();
            this.Text = Properties.Resources.AppTitleLong;
            this.Icon = Properties.Resources.Ryder25;

            this.openFileDialog.Filter = "Big files|*.big|All files|*.*";
            this.saveFileDialog.Filter = "Big files|*.big|All files|*.*";

            this.entriesObjectListView.ShowGroups = false;
            this.entriesObjectListView.FullRowSelect = true;
            this.entriesObjectListView.CellEditActivation = ObjectListView.CellEditActivateMode.DoubleClick;

            OLVColumn nameCol = new OLVColumn("Name", "Name");
            nameCol.Width = 225;
            nameCol.IsEditable = false;
            this.entriesObjectListView.Columns.Add(nameCol);

            OLVColumn fileTypeCol = new OLVColumn("File Type", "Type");
            fileTypeCol.Width = 150;
            fileTypeCol.IsEditable = false;
            this.entriesObjectListView.Columns.Add(fileTypeCol);

            OLVColumn sizeCol = new OLVColumn("Size", "Size");
            sizeCol.Width = 100;
            sizeCol.IsEditable = false;
            this.entriesObjectListView.Columns.Add(sizeCol);

            OLVColumn pSizeCol = new OLVColumn("Packed Size", "CompressedSize");
            pSizeCol.Width = 100;
            pSizeCol.IsEditable = false;
            this.entriesObjectListView.Columns.Add(pSizeCol);

            OLVColumn fullPathCol = new OLVColumn("Full Path", "FileName");
            //fullPathCol.Width = 500;
            fullPathCol.FillsFreeSpace = true;
            fullPathCol.IsEditable = false;
            this.entriesObjectListView.Columns.Add(fullPathCol);

            //string expPath = @"C:\Games\Rise Of Legends\BIGS\exp";
            //foreach (string bigFileName in Directory.GetFiles(@"C:\Games\Rise Of Legends\BIGS", "*.big", SearchOption.TopDirectoryOnly))
            //{
            //    //MessageBox.Show(bigFileName);
            //    this.file = new BigFile();
            //    this.file.Read(File.Open(bigFileName, FileMode.Open, FileAccess.Read, FileShare.Read));
            //    file.Export(expPath);
            //}
            //MessageBox.Show("Success");
        }
Example #2
0
 public static void AddColumnForOlv(Type type, ObjectListView olv)
 {
     olv.Columns.Clear();
     olv.AllColumns.Clear();
     var lColumn = ReflectionUtils.PropertysFromType(type);
     var i = 0;
     foreach (var colN in lColumn)
     {
         var col = new OLVColumn();
         col.AspectName = colN.Name;
         col.DisplayIndex = i++;
         col.Text = colN.Name;
         col.IsEditable = true;
         if (colN.PropertyType.FullName == "System.Boolean")
         {
             col.CheckBoxes = true;
         }
         if (colN.PropertyType.FullName == "System.Single")
         {
             var colName = colN.Name;
             col.AspectPutter = delegate(Object row, Object newvalue)
             {
                 ReflectionUtils.SetPropertyInternal(row, colName, float.Parse(newvalue.ToString()));
             };
         }
         olv.AllColumns.Add(col);
         olv.Columns.Add(col);
     }
 }
Example #3
0
        private void InitializeTreeList()
        {
            PluginTree.MultiSelect = true;
            PluginTree.CanExpandGetter = x => (x is IGroupRecord);
            PluginTree.ChildrenGetter = x =>
                                            {
                                                var r = x as IGroupRecord;
                                                return (r != null) ? r.Records : null;
                                            };

            _olvColumnName = new OLVColumn("Name", "Name");
            PluginTree.Columns.Add(_olvColumnName);

            _olvColumnName.AspectGetter = x =>
                                              {
                                                  var r = x as IRecord;
                                                  return (r != null) ? r.DescriptiveName : x;
                                              };
            var sink1 = (SimpleDropSink) PluginTree.DropSink;
            sink1.AcceptExternal = false;
            sink1.CanDropBetween = true;
            sink1.CanDropOnBackground = false;
            sink1.CanDropOnSubItem = false;

            UpdateRoots();
        }
Example #4
0
 /// <summary>
 /// Helper method for GenerateListColumns()
 /// </summary>
 /// <param name="objectListView"></param>
 /// <param name="data"></param>
 public static void AddListColumn(ObjectListView objectListView, string name, string aspect)
 {
     OLVColumn columnHeader = new OLVColumn();
     columnHeader.Text = name;
     columnHeader.AspectName = aspect;
     objectListView.Columns.Add(columnHeader);
 }
 private static OLVColumn MakeColumnFromAttribute(string aspectName, OLVColumnAttribute attr, bool editable) {
     string title = String.IsNullOrEmpty(attr.Title) ? aspectName : attr.Title;
     OLVColumn column = new OLVColumn(title, aspectName);
     column.AspectToStringFormat = attr.AspectToStringFormat;
     column.CheckBoxes = attr.CheckBoxes;
     column.DisplayIndex = attr.DisplayIndex;
     column.FillsFreeSpace = attr.FillsFreeSpace;
     if (attr.FreeSpaceProportion.HasValue)
         column.FreeSpaceProportion = attr.FreeSpaceProportion.Value;
     column.GroupWithItemCountFormat = attr.GroupWithItemCountFormat;
     column.GroupWithItemCountSingularFormat = attr.GroupWithItemCountSingularFormat;
     column.Hyperlink = attr.Hyperlink;
     column.ImageAspectName = attr.ImageAspectName;
     if (attr.IsEditableSet)
         column.IsEditable = attr.IsEditable;
     else
         column.IsEditable = editable;
     column.IsTileViewColumn = attr.IsTileViewColumn;
     column.IsVisible = attr.IsVisible;
     column.MaximumWidth = attr.MaximumWidth;
     column.MinimumWidth = attr.MinimumWidth;
     column.Name = String.IsNullOrEmpty(attr.Name) ? aspectName : attr.Name;
     column.Tag = attr.Tag;
     column.TextAlign = attr.TextAlign;
     column.ToolTipText = attr.ToolTipText;
     column.TriStateCheckBoxes = attr.TriStateCheckBoxes;
     column.UseInitialLetterForGroup = attr.UseInitialLetterForGroup;
     column.Width = attr.Width;
     if (attr.GroupCutoffs != null && attr.GroupDescriptions != null)
         column.MakeGroupies(attr.GroupCutoffs, attr.GroupDescriptions);
     return column;
 }
Example #6
0
        private void InitializeTreeList()
        {
            this.filterTree.SelectionChanged += this.filterTree_SelectionChanged;
            this.filterTree.SelectedIndexChanged += this.filterTree_SelectedIndexChanged;
            this.filterTree.SizeChanged += this.filterTree_SizeChanged;
            this.filterTree.Enter += this.filterTree_Enter;
            this.filterTree.KeyDown += this.filterTree_KeyDown;
            this.filterTree.MouseDoubleClick += this.filterTree_MouseDoubleClick;

            filterTree.MultiSelect = true;
            filterTree.CanExpandGetter = x => (x is ColumnSubrecord);
            filterTree.ChildrenGetter = x =>
            {
                var r = x as ColumnSubrecord;
                return (r != null) ? r.Children : null;
            };

            olvColumnName = new OLVColumn
            {
                Name = "Name", Text = "Name", AspectName = "Name", Width = 175, IsVisible = true, IsEditable = false,
                AspectGetter = x => { var r = x as ColumnCriteria; return (r != null) ? r.Name : x;}
            };
            filterTree.Columns.Add(olvColumnName);
            filterTree.CellEditActivation = ObjectListView.CellEditActivateMode.SingleClick;

            filterTree.Roots = filterTree.Roots;

            var checkedItems = new ArrayList();
            if (this.Criteria != null)
            {
                var modelItems = filterTree.Roots.OfType<ColumnSubrecord>();

                foreach (var item in this.Criteria.Items.OfType<ColumnSubrecord>())
                {
                    var modelItem = modelItems.FirstOrDefault(x => x.Name == item.Name);
                    if (modelItem != null)
                    {
                        modelItem.Checked = true;
                    }
                }
                foreach (var item in this.Criteria.Items.OfType<ColumnElement>())
                {
                    var modelItem = modelItems.FirstOrDefault(x => x.Name == item.Parent.Name);
                    if (modelItem != null)
                    {
                        filterTree.Expand(modelItem);
                        var modelElem = modelItem.Children.FirstOrDefault(x => x.Name == item.Name);
                        if (modelElem != null)
                        {
                            modelElem.Checked = true;
                            checkedItems.Add(modelElem);
                        }
                    }
                }
                this.filterTree.CheckObjects(checkedItems);
            }
        }
        private void InitializeTreeList()
        {
            this.filterTree.ModelCanDrop += this.filterTree_ModelCanDrop;
            this.filterTree.ModelDropped += this.filterTree_ModelDropped;
            this.filterTree.SelectionChanged += this.filterTree_SelectionChanged;
            this.filterTree.SelectedIndexChanged += this.filterTree_SelectedIndexChanged;
            this.filterTree.SizeChanged += this.filterTree_SizeChanged;
            this.filterTree.Enter += this.filterTree_Enter;
            this.filterTree.KeyDown += this.filterTree_KeyDown;
            this.filterTree.MouseDoubleClick += this.filterTree_MouseDoubleClick;

            filterTree.MultiSelect = true;
            filterTree.CanExpandGetter = x => (x is SearchSubrecord);
            filterTree.ChildrenGetter = x =>
            {
                var r = x as SearchSubrecord;
                return (r != null) ? r.Children : null;
            };

            olvColumnName = new OLVColumn
            {
                Name = "Name", Text = "Name", AspectName = "Name", Width = 175, IsVisible = true, IsEditable = false,
                AspectGetter = x => { var r = x as SearchCriteria; return (r != null) ? r.Name : x;}
            };
            olvColumnCond = new OLVColumn
            {
                Name = "Cond", Text = "Cond", AspectName = "Cond", Width = 100, IsVisible = true, IsEditable = true,
                AspectGetter = x => (x is SearchSubrecord) ? (object)((SearchSubrecord)x).Type : (x is SearchElement) ? (object)((SearchElement)x).Type : null,
                AspectPutter = (x,v) =>
                                   {
                                       if (x is SearchSubrecord) ((SearchSubrecord) x).Type = (SearchCondRecordType) v;
                                       if (x is SearchElement) ((SearchElement) x).Type = (SearchCondElementType) v;
                                   },
            };
            olvColumnValue = new OLVColumn
            {
                Name = "Value", Text = "Value", AspectName = "Value", Width = 100, IsVisible = true, IsEditable = true,
                AspectGetter = x => { var r = x as SearchElement; return (r != null) ? r.Value : null; }
            };
            filterTree.Columns.Add(olvColumnName);
            filterTree.Columns.Add(olvColumnCond);
            filterTree.Columns.Add(olvColumnValue);
            filterTree.CellEditActivation = ObjectListView.CellEditActivateMode.SingleClick;


            var sink1 = (SimpleDropSink)filterTree.DropSink;
            sink1.AcceptExternal = false;
            sink1.CanDropBetween = true;
            sink1.CanDropOnBackground = false;
            sink1.CanDropOnSubItem = false;

            filterTree.Roots = filterTree.Roots;
        }
Example #8
0
 /// <summary>
 /// Create a GroupingParameters
 /// </summary>
 /// <param name="olv"></param>
 /// <param name="groupByColumn"></param>
 /// <param name="groupByOrder"></param>
 /// <param name="column"></param>
 /// <param name="order"></param>
 /// <param name="secondaryColumn"></param>
 /// <param name="secondaryOrder"></param>
 /// <param name="titleFormat"></param>
 /// <param name="titleSingularFormat"></param>
 /// <param name="sortItemsByPrimaryColumn"></param>
 public GroupingParameters(ObjectListView olv, OLVColumn groupByColumn, SortOrder groupByOrder,
     OLVColumn column, SortOrder order, OLVColumn secondaryColumn, SortOrder secondaryOrder,
     string titleFormat, string titleSingularFormat, bool sortItemsByPrimaryColumn) {
     this.ListView = olv;
     this.GroupByColumn = groupByColumn;
     this.GroupByOrder = groupByOrder;
     this.PrimarySort = column;
     this.PrimarySortOrder = order;
     this.SecondarySort = secondaryColumn;
     this.SecondarySortOrder = secondaryOrder;
     this.SortItemsByPrimaryColumn = sortItemsByPrimaryColumn;
     this.TitleFormat = titleFormat;
     this.TitleSingularFormat = titleSingularFormat;
 }
        /// <summary>
        /// 1.2.初始化一个栏位
        /// </summary>
        /// <param name="Title">显示的名称</param>
        /// <param name="aspect">名称代码</param>
        /// <param name="Name">栏位名称</param>
        /// <param name="alig">对齐方式</param>
        /// <param name="bolleter">超出界限部分是否显示省略号</param>
        /// <param name="with">栏位宽度</param>
        /// <param name="columnobj">栏位对象</param>
        /// <param name="isSHow">是否显示</param>
        private OLVColumn InitializationOLVCOlumn(string Title, string aspect, string Name, HorizontalAlignment alig, bool bolleter, int with, object columnobj, bool isSHow,ObjectListView listview,IListViewColumnFormater _formater)
        {
            OLVColumn newcolumn = new OLVColumn();
            newcolumn.HeaderTextAlign = alig;
            newcolumn.UseInitialLetterForGroup = bolleter;
            newcolumn.Text = Title;
            newcolumn.Name = Name;
            newcolumn.Width = with;
            newcolumn.Tag = columnobj;
            newcolumn.IsVisible = isSHow;//是否显示

            _formater.Formater(listview,newcolumn, isSHow);

            return newcolumn;
        }
        /// <summary>
        /// Create an AutoCompleteCellEditor
        /// </summary>
        /// <param name="lv"></param>
        /// <param name="column"></param>
        public AutoCompleteCellEditor(ObjectListView lv, OLVColumn column)
        {
            this.DropDownStyle = ComboBoxStyle.DropDown;

            Dictionary<String, bool> alreadySeen = new Dictionary<string, bool>();
            for (int i = 0; i < Math.Min(lv.GetItemCount(), 1000); i++) {
                String str = column.GetStringValue(lv.GetModelObject(i));
                if (!alreadySeen.ContainsKey(str)) {
                    this.Items.Add(str);
                    alreadySeen[str] = true;
                }
            }

            this.Sorted = true;
            this.AutoCompleteSource = AutoCompleteSource.ListItems;
            this.AutoCompleteMode = AutoCompleteMode.Append;
        }
Example #11
0
        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (this.openFileDialog.ShowDialog() == DialogResult.OK)
            {
                this.file.Read(File.Open(openFileDialog.FileName, FileMode.Open, FileAccess.Read, FileShare.Read));

                OLVColumn nameCol = new OLVColumn("Name", string.Empty);
                nameCol.Width = 325;
                nameCol.IsEditable = false;
                nameCol.AspectGetter = delegate(object rowObject)
                {
                    if (rowObject is ErpEntry)
                    {
                        string str = ((ErpEntry)rowObject).FileName.Substring(7).Replace("/", "\\");
                        return Path.GetFileName(((ErpEntry)rowObject).FileName);//.Substring(7));
                    }
                    else if (rowObject is ErpResource)
                    {
                        return ((ErpResource)rowObject).Name;
                    }

                    return string.Empty;
                };
                this.TreeListView.Columns.Add(nameCol);

                OLVColumn fileTypeCol = new OLVColumn("File Type", "EntryType");
                fileTypeCol.Width = 150;
                this.TreeListView.Columns.Add(fileTypeCol);

                OLVColumn sizeCol = new OLVColumn("Size", "Size");
                sizeCol.Width = 100;
                sizeCol.IsEditable = false;
                this.TreeListView.Columns.Add(sizeCol);

                OLVColumn pSizeCol = new OLVColumn("Packed Size", "PackedSize");
                pSizeCol.Width = 100;
                pSizeCol.IsEditable = false;
                this.TreeListView.Columns.Add(pSizeCol);

                this.TreeListView.SetObjects(this.file.Entries);
            }
        }
Example #12
0
        /// <summary>
        /// Draw a slight colouring over our tinted column
        /// </summary>
        /// <remarks>
        /// This overlay only works when:
        /// - the list is in Details view
        /// - there is at least one row
        /// - there is a selected column (or a specified tint column)
        /// </remarks>
        /// <param name="olv"></param>
        /// <param name="g"></param>
        /// <param name="r"></param>
        public override void Draw(ObjectListView olv, Graphics g, Rectangle r)
        {
            if (olv.View != System.Windows.Forms.View.Details)
            {
                return;
            }

            if (olv.GetItemCount() == 0)
            {
                return;
            }

            OLVColumn column = this.ColumnToTint ?? olv.SelectedColumn;

            if (column == null)
            {
                return;
            }

            Point sides = NativeMethods.GetScrolledColumnSides(olv, column.Index);

            if (sides.X == -1)
            {
                return;
            }

            Rectangle columnBounds = new Rectangle(sides.X, r.Top, sides.Y - sides.X, r.Bottom);

            // Find the bottom of the last item. The tinting should extend only to there.
            OLVListItem lastItem = olv.GetLastItemInDisplayOrder();

            if (lastItem != null)
            {
                Rectangle lastItemBounds = lastItem.Bounds;
                if (!lastItemBounds.IsEmpty && lastItemBounds.Bottom < columnBounds.Bottom)
                {
                    columnBounds.Height = lastItemBounds.Bottom - columnBounds.Top;
                }
            }
            g.FillRectangle(this.tintBrush, columnBounds);
        }
Example #13
0
        public void LoadMeshUI()
        {
            this.Plugin.grnObjectListView.Columns.Clear();
            OLVColumn nameCol = new OLVColumn("Name", "Name");

            nameCol.Width      = 100;
            nameCol.IsEditable = false;
            this.Plugin.grnObjectListView.Columns.Add(nameCol);

            OLVColumn vertCountCol = new OLVColumn("Vertex Count", "Vertices.Count");

            vertCountCol.Width      = 75;
            vertCountCol.IsEditable = false;
            this.Plugin.grnObjectListView.Columns.Add(vertCountCol);

            OLVColumn faceCountCol = new OLVColumn("Face Count", "Faces.Count");

            faceCountCol.Width      = 70;
            faceCountCol.IsEditable = false;
            this.Plugin.grnObjectListView.Columns.Add(faceCountCol);
        }
Example #14
0
        public static void AddRefInColumn(this ObjectListView listView, Func <object, ulong> addressGetter, ClrDump dump)
        {
            var col = new OLVColumn("RefIn", null)
            {
                Width     = 60,
                TextAlign = HorizontalAlignment.Right
            };

            col.AspectGetter = o =>
            {
                if (o == null)
                {
                    return(null);
                }

                ulong address = addressGetter(o);
                return(address == 0 ? 0 : (object)dump.CountReferers(address));
            };
            col.AspectToStringFormat = "{0:###,###,###,##0}";
            listView.AllColumns.Add(col);
        }
Example #15
0
        public static void AddSimpleValueColumn(this ObjectListView listView, Func <object, ulong> addressGetter, ClrDump dump, Func <object, ClrType> typeGetter)
        {
            var col = new OLVColumn("Value", null)
            {
                Width = 150
            };

            col.AspectGetter = o =>
            {
                ClrType type    = typeGetter(o);
                ulong   address = addressGetter(o);
                return(dump.Eval(
                           () => type.IsPrimitive || type.IsString ? type.GetValue(address) : address
                           ));
            };
            listView.AllColumns.Add(col);
            var menuItem = new ToolStripMenuItem("Copy Value");

            listView.ContextMenuStrip.Items.Add(menuItem);
            menuItem.Click += (o, e) =>
            {
                if (listView.SelectedItem == null)
                {
                    return;
                }

                int    index       = listView.SelectedItem.Index;
                var    modelObject = listView.GetModelObject(index);
                string val         = col.GetStringValue(modelObject);
                string escapeVal   = StringHelpers.Escape(val);
                if (string.IsNullOrEmpty(escapeVal))
                {
                    Clipboard.SetText("null");
                }
                else
                {
                    Clipboard.SetText(escapeVal);
                }
            };
        }
Example #16
0
        /// <summary>
        /// Create and return an editor that is appropriate for the given value.
        /// Return null if no appropriate editor can be found.
        /// </summary>
        /// <param name="model">The model involved</param>
        /// <param name="column">The column to be edited</param>
        /// <param name="value">The value to be edited. This value may not be the exact
        /// value for the column/model combination. It could be simply representative of
        /// the appropriate type of value.</param>
        /// <returns>A Control that can edit the given type of values</returns>
        public Control GetEditor(object model, OLVColumn column, object value)
        {
            Control editor;

            // Give the first chance delegate a chance to decide
            if (firstChanceCreator != null)
            {
                editor = firstChanceCreator(model, column, value);
                if (editor != null)
                {
                    return(editor);
                }
            }

            // Try to find a creator based on the type of the value (or the column)
            var type = value == null ? column.DataType : value.GetType();

            if (type != null && creatorMap.ContainsKey(type))
            {
                editor = creatorMap[type](model, column, value);
                if (editor != null)
                {
                    return(editor);
                }
            }

            // Enums without other processing get a special editor
            if (value != null && value.GetType().IsEnum)
            {
                return(CreateEnumEditor(value.GetType()));
            }

            // Give any default creator a final chance
            if (defaultCreator != null)
            {
                return(defaultCreator(model, column, value));
            }

            return(null);
        }
Example #17
0
        public void Initialize()
        {
            this.ls_content_column_results            = new OLVColumn();
            this.ls_content_column_results.AspectName = "Score";
            this.ls_content_column_results.Text       = "Score";
            this.ls_content_column_results.UseInitialLetterForGroup = true;
            this.ls_content_column_results.Width            = 40;
            this.ls_content_column_results.TextAlign        = HorizontalAlignment.Center;
            this.ls_content_column_results.RendererDelegate = new RenderDelegate(this.ResultsRenderDelegate);

            this.ls_content_column_name      = new OLVColumn();
            this.ls_content_column_name.Text = "Name";
            this.ls_content_column_name.UseInitialLetterForGroup = true;
            this.ls_content_column_name.Width            = 300;
            this.ls_content_column_name.RendererDelegate = new RenderDelegate(this.NameRenderDelegate);

            this.OwnerDraw = true;
            this.AllColumns.Add(this.ls_content_column_name);
            this.AllColumns.Add(this.ls_content_column_results);

            this.Columns.AddRange(new ColumnHeader[] { ls_content_column_results, ls_content_column_name });

            this.Location      = new System.Drawing.Point(0, 0);
            this.TabIndex      = 0;
            this.EmptyListMsg  = "Click Start";
            this.FullRowSelect = true;
            this.MultiSelect   = false;
            this.RowHeight     = 25;
            this.ShowGroups    = false;
            ImageList il = new ImageList();

            il.ImageSize        = new Size(1, this.RowHeight);
            this.SmallImageList = il;

            this.SelectedIndexChanged += new EventHandler(BufferValidatorSummeryList_SelectionChanged);

            results = new List <IValidationResults>();

            this.SetObjects(results);
        }
 override public void Sort(OLVColumn column, SortOrder order)
 {
     if (column == listView.AllColumns.FirstOrDefault(x => x.AspectName == "CollectorNumber"))
     {
         FilteredObjectList.Sort(new CollectorNumberComparer {
             SortOrder = order
         });
     }
     else if (column == listView.AllColumns.FirstOrDefault(x => x.AspectName == "DisplayName"))
     {
         FilteredObjectList.Sort(new NameComparer {
             SortOrder = order
         });
     }
     else if (column == listView.AllColumns.FirstOrDefault(x => x.AspectName == "Type"))
     {
         FilteredObjectList.Sort(new TypeComparer {
             SortOrder = order
         });
     }
     else if (column == listView.AllColumns.FirstOrDefault(x => x.AspectName == "Set"))
     {
         FilteredObjectList.Sort(new SetComparer {
             SortOrder = order
         });
     }
     else if (column == listView.AllColumns.FirstOrDefault(x => x.AspectName == "ManaCost"))
     {
         FilteredObjectList.Sort(new ManaCostComparer {
             SortOrder = order
         });
     }
     else if (column == listView.AllColumns.FirstOrDefault(x => x.AspectName == "CopiesOwned"))
     {
         FilteredObjectList.Sort(new CopiesOwnedComparer {
             SortOrder = order
         });
     }
     RebuildIndexMap();
 }
Example #19
0
        /// <summary>
        /// Initialize the form to show the columns of the given view
        /// </summary>
        /// <param name="olv"></param>
        /// <param name="view"></param>
        protected void InitializeForm(ObjectListView olv, View view)
        {
            this.AllColumns          = olv.AllColumns;
            this.RearrangableColumns = new List <OLVColumn>(this.AllColumns);
            foreach (OLVColumn col in this.RearrangableColumns)
            {
                if (view == View.Details)
                {
                    this.MapColumnToVisible[col] = col.IsVisible;
                }
                else
                {
                    this.MapColumnToVisible[col] = col.IsTileViewColumn;
                }
            }
            this.RearrangableColumns.Sort(new SortByDisplayOrder(this));

            this.objectListView1.BooleanCheckStateGetter = delegate(Object rowObject)
            {
                return(this.MapColumnToVisible[(OLVColumn)rowObject]);
            };

            this.objectListView1.BooleanCheckStatePutter = delegate(Object rowObject, bool newValue)
            {
                // Some columns should always be shown, so ignore attempts to hide them
                OLVColumn column = (OLVColumn)rowObject;
                if (!column.CanBeHidden)
                {
                    return(true);
                }

                this.MapColumnToVisible[column] = newValue;
                EnableControls();
                return(newValue);
            };

            this.objectListView1.SetObjects(this.RearrangableColumns);
            this.EnableControls();
        }
Example #20
0
        private void FrmHomographs_Load(object sender, EventArgs e)
        {
            // Grouping by courses==========================================
            OLVColumn clm = ((OLVColumn)olvHomographs.Columns[0]);

            /* clm.GroupKeyGetter = delegate (object rowObject) {
             *   WordForm wf = (WordForm)rowObject;
             *   return wf.Title;
             * };
             *
             * clm.GroupKeyToTitleConverter = delegate (object groupKey) {
             *   return groupKey.ToString();
             * };
             * clm.Groupable = true;
             * // ==============================================================
             *
             */

            olvHomographs.SetObjects(WordForm.GetHomographsList());
            label1.Text = "Количество омографов:" + olvHomographs.Items.Count;
            olvHomographs.Refresh();
        }
Example #21
0
        /// <summary>
        /// Enable the controls on the dialog to match the current state
        /// </summary>
        protected void EnableControls()
        {
            if (this.objectListView1.SelectedIndices.Count == 0)
            {
                this.buttonMoveUp.Enabled   = false;
                this.buttonMoveDown.Enabled = false;
                this.buttonShow.Enabled     = false;
                this.buttonHide.Enabled     = false;
            }
            else
            {
                // Can't move the first row up or the last row down
                this.buttonMoveUp.Enabled   = (this.objectListView1.SelectedIndices[0] != 0);
                this.buttonMoveDown.Enabled = (this.objectListView1.SelectedIndices[0] < (this.objectListView1.GetItemCount() - 1));

                OLVColumn selectedColumn = (OLVColumn)this.objectListView1.SelectedObject;

                // Some columns cannot be hidden (and hence cannot be Shown)
                this.buttonShow.Enabled = !this.MapColumnToVisible[selectedColumn] && selectedColumn.CanBeHidden;
                this.buttonHide.Enabled = this.MapColumnToVisible[selectedColumn] && selectedColumn.CanBeHidden;
            }
        }
Example #22
0
 /// <summary>
 /// Generate aspect getters and putters for any columns that are missing them (and for which we have
 /// enough information to actually generate a getter)
 /// </summary>
 protected virtual void CreateMissingAspectGettersAndPutters()
 {
     foreach (OLVColumn x in this.ListView.AllColumns)
     {
         OLVColumn column = x; // stack based variable accessible from closures
         if (column.AspectGetter == null && !String.IsNullOrEmpty(column.AspectName))
         {
             column.AspectGetter = delegate(object row)
             {
                 // In most cases, rows will be DataRowView objects
                 DataRowView drv = row as DataRowView;
                 if (drv == null)
                 {
                     return(column.GetAspectByName(row));
                 }
                 return((drv.Row.RowState == DataRowState.Detached) ? null : drv[column.AspectName]);
             };
         }
         if (column.IsEditable && column.AspectPutter == null && !String.IsNullOrEmpty(column.AspectName))
         {
             column.AspectPutter = delegate(object row, object newValue)
             {
                 // In most cases, rows will be DataRowView objects
                 DataRowView drv = row as DataRowView;
                 if (drv == null)
                 {
                     column.PutAspectByName(row, newValue);
                 }
                 else
                 {
                     if (drv.Row.RowState != DataRowState.Detached)
                     {
                         drv[column.AspectName] = newValue;
                     }
                 }
             };
         }
     }
 }
        bool m_bNoFilter = true; // to fix tooltip bug on initial list being empty
        #endregion

        #region CTOR
        public LearnedListView()
        {
            OLVColumn olvCol = GenerateColumn(1);

            olvCol.HeaderImageKey = "rankup";
            olvCol.AspectGetter   = delegate(object sk) {
                Skill  skill    = sk as Skill;
                string szReturn = skill.CurrentRanks.ToString();
                if (skill.MaxRanks > 0)
                {
                    szReturn += "/" + skill.MaxRanks;
                }
                return(szReturn);
            };

            olvCol.Text        = "Talent Rank";
            olvCol.Width       = 100;
            this.MouseClick   += LearnedListView_OnMouseClick;
            this.ModelDropped += LearnedListView_OnModelDropped;

            ActivateFilter();
        }
Example #24
0
        private void ApplyFilter(ToolStripCheckedListBox checkedList, OLVColumn column)
        {
            if (!(column.ListView is ObjectListView olv) || olv.IsDisposed)
            {
                return;
            }

            var textBox = (checkedList.GetCurrentParent() as ToolStripDropDownMenu).Items[0] as ToolStripTextBox;

            if (!string.IsNullOrWhiteSpace(textBox.Text))
            {
                var filter = TextMatchFilter.Contains(olv, textBox.Text);
                filter.Columns                  = new[] { column };
                column.ValueBasedFilter         = filter;
                column.ValuesChosenForFiltering = new ArrayList();
                olv.UpdateColumnFiltering();
            }
            else
            {
                base.EnactFilter(checkedList, column);
            }
        }
Example #25
0
        public void SetGroupingRecord(String ColumnAspect)
        {
            OLVColumn matchColumn = null;

            if (!String.IsNullOrEmpty(ColumnAspect))
            {
                foreach (OLVColumn col in gvResults.AllColumns)
                {
                    if (col.AspectName.Equals(ColumnAspect))
                    {
                        matchColumn = col;
                    }
                }
            }

            if (matchColumn != null)
            {
                gvResults.AlwaysGroupByColumn = matchColumn;
            }

            gvResults.ShowGroups = (matchColumn != null);
        }
        private void ListView_CellToolTipShowing(object sender, ToolTipShowingEventArgs e)
        {
            string stringValue = null;

            try
            {
                OLVColumn column = e.Column ?? e.ListView.GetColumn(0);

                if (column.AspectName != null && AppManager.Instance.IsCustomEditProperty(SourceObjectType, column.AspectName))
                {
                    object objectValue = Dm.Instance.GetCustomPropertyValue(e.Model, column.AspectName, true, AppManager.Instance.TooltipTruncatedMaxItemCount, AppManager.Instance.TooltipTruncatedMaxLength);
                    stringValue = objectValue != null?objectValue.ToString() : null;

                    if (string.IsNullOrEmpty(stringValue))
                    {
                        return;
                    }
                    else
                    {
                        e.ToolTipControl.SetMaxWidth(400);
                        // Changing colour doesn't work in systems other than XP
                        e.BackColor    = Color.AliceBlue;
                        e.ForeColor    = Color.IndianRed;
                        e.AutoPopDelay = 15000;
                        e.Text         = stringValue;
                    }
                }
                else
                {
                    return;//default tooltip
                }
            }
            catch (Exception ex)
            {
                Log.LogError(ex);
                stringValue = ex.ToString();
            }
        }
        public SimpleRelationSelectorDialog()
        {
            InitializeComponent();
            this.Text = FrwCRUDRes.SimpleDictListDialog_Dict;

            ((System.ComponentModel.ISupportInitialize)(listView)).BeginInit();
            //ovl settings
            listView.EmptyListMsg     = FrwCRUDRes.List_No_Records;
            listView.EmptyListMsgFont = new Font("Tahoma", 9);//todo;
            listView.FullRowSelect    = true;
            listView.UseCompatibleStateImageBehavior = false;
            listView.View                        = System.Windows.Forms.View.Details;
            listView.UseFiltering                = true;
            listView.UseFilterIndicator          = true;
            listView.AllowColumnReorder          = true;
            listView.TriStateCheckBoxes          = false;
            listView.CellEditUseWholeCell        = false;
            listView.TintSortColumn              = true;
            listView.ShowItemToolTips            = true;
            listView.UseHotItem                  = true;
            listView.UseHyperlinks               = true;
            listView.ShowCommandMenuOnRightClick = true;
            listView.TintSortColumn              = true;
            //listView.MultiSelect = allowMultiSelect;

            OLVColumn column = null;

            column                = new OLVColumn();
            column.AspectName     = "Text";
            column.Text           = FrwCRUDRes.SimpleDictListDialog_Name;
            column.Width          = 350;
            column.FillsFreeSpace = true;
            AddColumnToList(column);

            //SourceObjects = Dm.Instance.GetDictionaryItems(DictId);

            ((System.ComponentModel.ISupportInitialize)(listView)).EndInit();
        }
Example #28
0
        private void RebuildCustomColumns()
        {
            this.customColumns = SettingsDialog.CustomColumns;

            for (int i = olvJobs.AllColumns.Count - 1; i >= 0; i--)
            {
                if (this.olvJobs.AllColumns[i].Tag != null)
                {
                    this.olvJobs.AllColumns.RemoveAt(i);
                }
            }

            // Add custom columns to list
            foreach (KeyValuePair <string, string> column in this.customColumns)
            {
                OLVColumn newCol = new OLVColumn(column.Key, "")
                {
                    Name = column.Key,
                    Tag  = column.Value
                };
                this.olvJobs.AllColumns.Add(newCol);
                newCol.AspectGetter = delegate(object x)
                {
                    if (string.IsNullOrEmpty(newCol.Tag as string))
                    {
                        return(null);
                    }

                    bool   forceEval = newCol.Name.StartsWith("!");
                    string varFind   = "{" + ((string)newCol.Tag).TrimStart('{').TrimEnd('}') + "}";

                    string value = ((ApplicationJob)x).Variables.ReplaceAllInString(varFind, DateTime.MinValue, null, !forceEval);
                    return(varFind == value ? string.Empty : value);
                };
            }

            olvJobs.RebuildColumns();
        }
Example #29
0
        private OLVColumn itemCol_RuneCharges()
        {
            var charges = new OLVColumn();
            charges.Text = "Charges";
            charges.AspectGetter = delegate (object x)
            {
                Item i = (Item)x;

                Rune r = DataReader.Runes.Where(oo => oo.ID == i.ID).FirstOrDefault();
                if (string.IsNullOrEmpty(r.Name)) return (byte)0;
                else return r.Charges;

            };
            charges.AspectToStringConverter = delegate (object x)
            {
                var i = (byte)x;

                if (i == 0) return "N/A";
                else return i.ToString();
            };

            return charges;
        }
Example #30
0
        public void TestSubItemCheckBox()
        {
            PersonDb.All[0].IsActive = true;
            PersonDb.All[1].IsActive = false;

            OLVColumn column        = this.olv.GetColumn(1);
            string    oldAspectName = column.AspectName;

            column.AspectName = "IsActive";
            column.CheckBoxes = true;

            this.olv.SetObjects(PersonDb.All);
            Assert.IsTrue(this.olv.IsSubItemChecked(PersonDb.All[0], column));
            Assert.IsFalse(this.olv.IsSubItemChecked(PersonDb.All[1], column));

            this.olv.ToggleSubItemCheckBox(PersonDb.All[0], column);
            this.olv.ToggleSubItemCheckBox(PersonDb.All[1], column);

            Assert.IsFalse(this.olv.IsSubItemChecked(PersonDb.All[0], column));
            Assert.IsTrue(this.olv.IsSubItemChecked(PersonDb.All[1], column));

            this.olv.GetColumn(1).AspectName = oldAspectName;
        }
Example #31
0
        public Form1(string[] Args)
        {
            InitializeComponent();
            this.Icon = EgoJpkArchiver.Properties.Resources.Ryder25;
            this.Text = EgoJpkArchiver.Properties.Resources.AppTitleLong + " " + EgoJpkArchiver.Properties.Resources.AppVersionShort;

            this.listView.ShowGroups = false;
            OLVColumn nameCol = new OLVColumn("Name", "Name");
            nameCol.Width = 300;
            nameCol.IsEditable = false;
            this.listView.Columns.Add(nameCol);

            OLVColumn sizeCol = new OLVColumn("Size", "Size");
            sizeCol.Width = 100;
            sizeCol.IsEditable = false;
            this.listView.Columns.Add(sizeCol);

            if (Args.Length > 0)
            {
                fileName = Args[0];
                this.ReadJpk();
            }
        }
        protected OLVColumn MakeButtonColumn(string name, string text)
        {
            //this.listView.GetColumn()
            OLVColumn column = null;

            column      = new OLVColumn();
            column.Name = name;
            column.Text = text;
            if (text != null)
            {
                column.AspectGetter = delegate(Object rowObject)
                {
                    return(text);
                };
            }

            // Renderer must be installed earlier IsButton = true
            //column.Renderer = new StaticTextColumnButtonRenderer () {StaticText = text};
            // for some strange reason, there is a background error 'System.IO.FileNotFoundException' in System.Drawing.dll

            // Tell the columns that it is going to show buttons.
            // The label that goes into the button is the Aspect that would have been
            // displayed in the cell.
            column.IsButton = true;

            // How will the button be sized? That can either be:
            //   - FixedBounds. Each button is ButtonSize in size
            //   - CellBounds. Each button is as wide as the cell, inset by CellPadding
            //   - TextBounds. Each button resizes to match the width of the text plus ButtonPadding
            column.ButtonSizing = OLVColumn.ButtonSizingMode.CellBounds;
            //column.ButtonSize = new Size(80, 26);

            // Make the buttons clickable even if the row itself is disabled
            column.EnableButtonWhenItemIsDisabled = true;
            column.TextAlign = HorizontalAlignment.Center;
            return(column);
        }
Example #33
0
 /// <summary>
 /// Generate aspect getters and putters for any columns that are missing them (and for which we have
 /// enough information to actually generate a getter)
 /// </summary>
 protected virtual void CreateMissingAspectGettersAndPutters()
 {
     for (int i = 0; i < this.Columns.Count; i++)
     {
         OLVColumn column = this.GetColumn(i);
         if (column.AspectGetter == null && !String.IsNullOrEmpty(column.AspectName))
         {
             column.AspectGetter = delegate(object row) {
                 // In most cases, rows will be DataRowView objects
                 DataRowView drv = row as DataRowView;
                 if (drv != null)
                 {
                     return(drv[column.AspectName]);
                 }
                 else
                 {
                     return(column.GetAspectByName(row));
                 }
             };
         }
         if (column.IsEditable && column.AspectPutter == null && !String.IsNullOrEmpty(column.AspectName))
         {
             column.AspectPutter = delegate(object row, object newValue) {
                 // In most cases, rows will be DataRowView objects
                 DataRowView drv = row as DataRowView;
                 if (drv != null)
                 {
                     drv[column.AspectName] = newValue;
                 }
                 else
                 {
                     column.PutAspectByName(row, newValue);
                 }
             };
         }
     }
 }
Example #34
0
        /// <summary>
        /// Do the work of making a menu that shows the clusters to the users
        /// </summary>
        /// <param name="column"></param>
        /// <param name="clusters"></param>
        /// <returns></returns>
        virtual protected ToolStripMenuItem CreateFilteringMenuItem(OLVColumn column, List <ICluster> clusters)
        {
            ToolStripCheckedListBox checkedList = new ToolStripCheckedListBox();

            checkedList.Tag = column;
            foreach (ICluster cluster in clusters)
            {
                checkedList.AddItem(cluster, column.ValuesChosenForFiltering.Contains(cluster.ClusterKey));
            }
            if (!String.IsNullOrEmpty(SELECT_ALL_LABEL))
            {
                int checkedCount = checkedList.CheckedItems.Count;
                if (checkedCount == 0)
                {
                    checkedList.AddItem(SELECT_ALL_LABEL, CheckState.Unchecked);
                }
                else
                {
                    checkedList.AddItem(SELECT_ALL_LABEL, checkedCount == clusters.Count ? CheckState.Checked : CheckState.Indeterminate);
                }
            }
            checkedList.ItemCheck += new ItemCheckEventHandler(HandleItemCheckedWrapped);

            ToolStripMenuItem clearAll = new ToolStripMenuItem(CLEAR_ALL_FILTERS_LABEL, ClearFilteringImage, delegate(object sender, EventArgs args)
            {
                this.ClearAllFilters(column);
            });
            ToolStripMenuItem apply = new ToolStripMenuItem(APPLY_LABEL, FilteringImage, delegate(object sender, EventArgs args)
            {
                this.EnactFilter(checkedList, column);
            });
            ToolStripMenuItem subMenu = new ToolStripMenuItem(FILTERING_LABEL, null, new ToolStripItem[] {
                clearAll, new ToolStripSeparator(), checkedList, apply
            });

            return(subMenu);
        }
Example #35
0
        public AttachmentsListView()
        {
            SmallImageList = new ImageList {
                ColorDepth = ColorDepth.Depth32Bit
            };

            View        = System.Windows.Forms.View.SmallIcon;
            HeaderStyle = ColumnHeaderStyle.None;
            Scrollable  = true;

            CellEditActivation = CellEditActivateMode.F2Only;

            CopySelectionOnControlC = false;

            DragSource = new VirtualFileDragSource();
            AllowDrop  = true;

            var overlay = (TextOverlay)EmptyListMsgOverlay;

            overlay.Alignment   = ContentAlignment.TopLeft;
            overlay.InsetX      = 0;
            overlay.InsetY      = 0;
            overlay.BackColor   = Color.Empty;
            overlay.BorderColor = Color.Empty;
            overlay.TextColor   = SystemColors.GrayText;

            var column = new OLVColumn
            {
                FillsFreeSpace     = true,
                AutoCompleteEditor = false,
                AspectGetter       = model => ((RowObject)model).Name,
                AspectPutter       = SetAttachmentName,
                ImageGetter        = IconImageGetter
            };

            Columns.Add(column);
        }
Example #36
0
        private void SetUpChatView()
        {
            List <OLVColumn> columns = new List <OLVColumn>();

            foreach (var key in ProjectInfo.Data.SelectedFields)
            {
                OLVColumn cl = new OLVColumn();
                cl.AspectGetter = delegate(object x)
                {
                    DynamicMessage message = (DynamicMessage)x;
                    return(message.Contents[key]);
                };
                cl.Text     = key;
                cl.WordWrap = true;


                columns.Add(cl);
            }
            suggesterView.AllColumns.Clear();
            suggesterView.AllColumns.AddRange(columns);

            foreach (var cl in suggesterView.AllColumns)
            {
                if (cl.Text != ProjectInfo.TextFieldKey)
                {
                    cl.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
                }
                else
                {
                    cl.FillsFreeSpace = true;
                }
            }

            suggesterView.RebuildColumns();
            suggesterView.Refresh();
        }
        public void Test_ModelFilter_HandlesColumnChanges()
        {
            this.olv.ExpandAll();

            OLVColumn commentColumn = new OLVColumn("Comment field", "Comments");

            this.olv.AllColumns.Add(commentColumn);
            this.olv.RebuildColumns();

            this.olv.UseFiltering = true;
            this.olv.ModelFilter  = new TextMatchFilter(this.olv, PersonDb.LastComment);

            // After filtering the list should contain the one item that matched the filter and its ancestors
            Assert.AreEqual(4, this.olv.GetItemCount());

            commentColumn.IsVisible = false;
            this.olv.RebuildColumns();
            Assert.AreEqual(0, this.olv.VirtualListSize);

            commentColumn.IsVisible = true;
            this.olv.RebuildColumns();
            Assert.AreEqual(4, this.olv.GetItemCount());
            Assert.AreEqual(PersonDb.LastComment, ((Person)this.olv.GetItem(3).RowObject).Comments);
        }
        public void TestHyperlinks()
        {
            this.olv.UseHyperlinks  = true;
            this.olv.HyperlinkStyle = new HyperlinkStyle();
            this.olv.HyperlinkStyle.Normal.ForeColor = Color.Thistle;
            this.olv.HyperlinkStyle.Normal.BackColor = Color.SpringGreen;
            this.olv.HyperlinkStyle.Normal.FontStyle = FontStyle.Bold;

            foreach (OLVColumn column in this.olv.Columns)
            {
                column.Hyperlink = (column.Index < 2);
            }

            this.olv.SetObjects(PersonDb.All);
            for (int j = 0; j < this.olv.GetItemCount(); j++)
            {
                OLVListItem item = this.olv.GetItem(j);
                //Assert.IsFalse(item.UseItemStyleForSubItems);
                for (int i = 0; i < this.olv.Columns.Count; i++)
                {
                    OLVColumn column = this.olv.GetColumn(i);
                    if (column.Hyperlink)
                    {
                        Assert.AreEqual(this.olv.HyperlinkStyle.Normal.ForeColor, item.SubItems[i].ForeColor);
                        Assert.AreEqual(this.olv.HyperlinkStyle.Normal.BackColor, item.SubItems[i].BackColor);
                        Assert.IsTrue(item.SubItems[i].Font.Bold);
                    }
                    else
                    {
                        Assert.AreEqual(this.olv.ForeColor, item.SubItems[i].ForeColor);
                        Assert.AreEqual(this.olv.BackColor, item.SubItems[i].BackColor);
                        Assert.IsFalse(item.SubItems[i].Font.Bold);
                    }
                }
            }
        }
Example #39
0
        protected override List <ICluster> Cluster(IClusteringStrategy strategy, ObjectListView listView,
                                                   OLVColumn column)
        {
            if (column is MyOLVColumn mycolumn && mycolumn.ClusterGetter != null)
            {
                var list = mycolumn.ClusterGetter.Invoke(listView.ObjectsForClustering.Cast <CapturePacket>());
                if (strategy is ClusteringStrategy cstrategy)
                {
                    foreach (var c in list)
                    {
                        string format = (c.Count == 1)
                            ? cstrategy.DisplayLabelFormatSingular
                            : cstrategy.DisplayLabelFormatPlural;
                        c.DisplayLabel = string.IsNullOrEmpty(format)
                            ? c.DisplayLabel
                            : string.Format(format, c.DisplayLabel, c.Count);
                    }
                }

                return(list);
            }

            return(base.Cluster(strategy, listView, column));
        }
Example #40
0
        /// <summary>
        /// Apply the selected values from the given list as a filter on the given column
        /// </summary>
        /// <param name="checkedList">A list in which the checked items should be used as filters</param>
        /// <param name="column">The column for which a filter should be generated</param>
        virtual protected void EnactFilter(ToolStripCheckedListBox checkedList, OLVColumn column)
        {
            ObjectListView olv = column.ListView as ObjectListView;

            if (olv == null || olv.IsDisposed)
            {
                return;
            }

            // Collect all the checked values
            ArrayList chosenValues = new ArrayList();

            foreach (object x in checkedList.CheckedItems)
            {
                ICluster cluster = x as ICluster;
                if (cluster != null)
                {
                    chosenValues.Add(cluster.ClusterKey);
                }
            }
            column.ValuesChosenForFiltering = chosenValues;

            olv.UpdateColumnFiltering();
        }
Example #41
0
        /// <summary>
        /// Uncheck the check at the given cell
        /// </summary>
        /// <param name="rowObject"></param>
        /// <param name="column"></param>
        public virtual void UncheckSubItem(object rowObject, OLVColumn column)
        {
            if (column == null || rowObject == null || !column.CheckBoxes)
                return;

            column.PutCheckState(rowObject, CheckState.Unchecked);
            this.RefreshObject(rowObject);
        }
Example #42
0
        /// <summary>
        /// Toggle the check at the check box of the given cell
        /// </summary>
        /// <param name="rowObject"></param>
        /// <param name="column"></param>
        public virtual void ToggleSubItemCheckBox(object rowObject, OLVColumn column)
        {
            CheckState currentState = column.GetCheckState(rowObject);
            CheckState newState = CalculateToggledCheckState(column, currentState);

            SubItemCheckingEventArgs args = new SubItemCheckingEventArgs(column, this.ModelToItem(rowObject), column.Index, currentState, newState);
            this.OnSubItemChecking(args);
            if (args.Canceled)
                return;

            switch (args.NewValue) {
                case CheckState.Checked:
                    this.CheckSubItem(rowObject, column);
                    break;
                case CheckState.Indeterminate:
                    this.CheckIndeterminateSubItem(rowObject, column);
                    break;
                case CheckState.Unchecked:
                    this.UncheckSubItem(rowObject, column);
                    break;
            }
        }
Example #43
0
 /// <summary>
 /// Sort the items in the list view by the values in the given column and by the given order.
 /// </summary>
 /// <param name="columnToSort">The column whose values will be used for the sorting.
 /// If null, the first column will be used.</param>
 /// <param name="order">The ordering to be used for sorting. If this is None,
 /// this.Sorting and then SortOrder.Ascending will be used</param>
 /// <remarks>If ShowGroups is true, the rows will be grouped by the given column.
 /// If AlwaysGroupsByColumn is not null, the rows will be grouped by that column,
 /// and the rows within each group will be sorted by the given column.</remarks>
 public virtual void Sort(OLVColumn columnToSort, SortOrder order)
 {
     if (this.InvokeRequired) {
         this.Invoke((MethodInvoker)delegate { this.Sort(columnToSort, order); });
     } else {
         this.DoSort(columnToSort, order);
         this.PostProcessRows();
     }
 }
Example #44
0
 /// <summary>
 /// Sort the items in the list view by the values in the given column and the last sort order
 /// </summary>
 /// <param name="columnToSort">The column whose values will be used for the sorting</param>
 public virtual void Sort(OLVColumn columnToSort)
 {
     if (this.InvokeRequired) {
         this.Invoke((MethodInvoker)delegate { this.Sort(columnToSort); });
     } else {
         this.Sort(columnToSort, this.LastSortOrder);
     }
 }
Example #45
0
        private OLVListSubItem MakeSubItem(object rowObject, OLVColumn column)
        {
            object cellValue = column.GetValue(rowObject);
            OLVListSubItem subItem = new OLVListSubItem(cellValue,
                                                        column.ValueToString(cellValue),
                                                        column.GetImage(rowObject));
            if (this.UseHyperlinks && column.Hyperlink) {
                IsHyperlinkEventArgs args = new IsHyperlinkEventArgs();
                args.ListView = this;
                args.Model = rowObject;
                args.Column = column;
                args.Text = subItem.Text;
                args.Url = subItem.Text;
                this.OnIsHyperlink(args);
                subItem.Url = args.Url;
            }

            return subItem;
        }
Example #46
0
 CheckState CalculateToggledCheckState(OLVColumn column, CheckState currentState)
 {
     switch (currentState) {
         case CheckState.Checked: return column.TriStateCheckBoxes ? CheckState.Indeterminate : CheckState.Unchecked;
         case CheckState.Indeterminate: return CheckState.Unchecked;
         case CheckState.Unchecked:
         default: return CheckState.Checked;
     }
 }
Example #47
0
        /// <summary>
        /// Put a sort indicator next to the text of the given given column
        /// </summary>
        /// <param name="columnToSort">The column to be marked</param>
        /// <param name="sortOrder">The sort order in effect on that column</param>
        protected virtual void ShowSortIndicator(OLVColumn columnToSort, SortOrder sortOrder)
        {
            int imageIndex = -1;

            if (!NativeMethods.HasBuiltinSortIndicators()) {
                // If we can't use builtin image, we have to make and then locate the index of the
                // sort indicator we want to use. SortOrder.None doesn't show an image.
                if (this.SmallImageList == null || !this.SmallImageList.Images.ContainsKey(SORT_INDICATOR_UP_KEY))
                    MakeSortIndicatorImages();

                if (sortOrder == SortOrder.Ascending)
                    imageIndex = this.SmallImageList.Images.IndexOfKey(SORT_INDICATOR_UP_KEY);
                else if (sortOrder == SortOrder.Descending)
                    imageIndex = this.SmallImageList.Images.IndexOfKey(SORT_INDICATOR_DOWN_KEY);
            }

            // Set the image for each column
            for (int i = 0; i < this.Columns.Count; i++) {
                if (columnToSort != null && i == columnToSort.Index)
                    NativeMethods.SetColumnImage(this, i, sortOrder, imageIndex);
                else
                    NativeMethods.SetColumnImage(this, i, SortOrder.None, -1);
            }
        }
Example #48
0
        /// <summary>
        /// Find the first row in the given range of rows that prefix matches the string value of the given column.
        /// </summary>
        /// <param name="text"></param>
        /// <param name="first"></param>
        /// <param name="last"></param>
        /// <param name="column"></param>
        /// <returns>The index of the matched row, or -1</returns>
        protected virtual int FindMatchInRange(string text, int first, int last, OLVColumn column)
        {
            if (first <= last) {
                for (int i = first; i <= last; i++) {
                    string data = column.GetStringValue(this.GetNthItemInDisplayOrder(i).RowObject);
                    if (data.StartsWith(text, StringComparison.CurrentCultureIgnoreCase))
                        return i;
                }
            } else {
                for (int i = first; i >= last; i--) {
                    string data = column.GetStringValue(this.GetNthItemInDisplayOrder(i).RowObject);
                    if (data.StartsWith(text, StringComparison.CurrentCultureIgnoreCase))
                        return i;
                }
            }

            return -1;
        }
Example #49
0
 /// <summary>
 /// Get the first non-null value of the given column.
 /// At most 1000 rows will be considered.
 /// </summary>
 /// <param name="column"></param>
 /// <returns>The first non-null value, or null if no non-null values were found</returns>
 internal object GetFirstNonNullValue(OLVColumn column)
 {
     for (int i = 0; i < Math.Min(this.GetItemCount(), 1000); i++) {
         object value = column.GetValue(this.GetModelObject(i));
         if (value != null)
             return value;
     }
     return null;
 }
Example #50
0
        public static void ConfigureFOLV(ref FastObjectListView FOLV, Type Cls, System.Drawing.Font Fnt, ImageList ImageList, string PrimarySortColumnName = "", SortOrder PrimarySortOrder = SortOrder.Ascending, string SecondarySortColumnName = "", SortOrder SecondarySortOrder = SortOrder.Ascending, List <string> FilterColumnList = null, Color Clr = new Color(), int RowHeight = 0, bool ShowGroups = false)
        {
            try
            {
                FOLV.AllowColumnReorder      = true;
                FOLV.CellEditActivation      = ObjectListView.CellEditActivateMode.DoubleClick;
                FOLV.CopySelectionOnControlC = true;
                FOLV.FullRowSelect           = true;
                FOLV.GridLines     = true;
                FOLV.HideSelection = false;
                FOLV.IncludeColumnHeadersInCopy = true;
                FOLV.OwnerDraw = true;
                FOLV.SelectColumnsOnRightClick          = true;
                FOLV.SelectColumnsOnRightClickBehaviour = ObjectListView.ColumnSelectBehaviour.ModelDialog;
                FOLV.SelectedColumnTint          = Color.LawnGreen;
                FOLV.ShowCommandMenuOnRightClick = true;
                FOLV.ShowFilterMenuOnRightClick  = true;
                FOLV.ShowGroups                    = false;
                FOLV.ShowImagesOnSubItems          = true;
                FOLV.ShowItemCountOnGroups         = true;
                FOLV.ShowItemToolTips              = true;
                FOLV.ShowSortIndicators            = true;
                FOLV.SortGroupItemsByPrimaryColumn = true;
                FOLV.TintSortColumn                = true;
                FOLV.UseFiltering                  = true;
                FOLV.UseHyperlinks                 = false; //may cause column save/restore error?
                FOLV.CellEditActivation            = ObjectListView.CellEditActivateMode.DoubleClick;
                FOLV.UseCellFormatEvents           = true;
                FOLV.UseNotifyPropertyChanged      = true;

                if (ImageList != null)
                {
                    FOLV.SmallImageList = ImageList;
                }

                if (Fnt != null)
                {
                    FOLV.Font = Fnt;
                }
                else
                {
                    FOLV.Font = new Font("Consolas", 8, FontStyle.Regular);
                }

                if (Clr.IsEmpty)
                {
                    FOLV.ForeColor = Clr;
                }

                PropertyInfo[] IIProps2 = Cls.GetProperties();                 //Cls.GetType().GetProperties


                // Uncomment this to see a fancy cell highlighting while editing
                EditingCellBorderDecoration EC = new EditingCellBorderDecoration(true);
                EC.UseLightbox = true;

                FOLV.AddDecoration(EC);
                FOLV.BuildList();
                int colcnt = 0;

                foreach (PropertyInfo ei in IIProps2)
                {
                    if (typeof(IEnumerable).IsAssignableFrom(ei.PropertyType) && !(ei.PropertyType.Name == "String"))
                    {
                        continue;
                    }
                    else if (ei.PropertyType.Name == "Object")
                    {
                        continue;
                    }

                    colcnt = colcnt + 1;
                    OLVColumn cl = new OLVColumn();
                    if (ImageList != null)
                    {
                        //if (FOLV.Name == "FOLV_UpdateList" && colcnt == 1)
                        //{
                        //	cl.ImageGetter = GetImageForUpdateList;
                        //}
                        //else if (FOLV.Name == "FOLV_BlocklistViewer" && ei.Name == "RegionalInternetRegistry")
                        //{
                        //	cl.ImageGetter = GetImageForBlocklistViewerRIR;
                        //}
                        //else if (FOLV.Name == "FOLV_Apps" && colcnt == 1)
                        //{
                        //	cl.ImageGetter = GetImageForProdList;
                        //}
                    }
                    //cl.AspectName = ei.Name
                    cl.UseFiltering = true;
                    cl.Searchable   = true;
                    cl.Text         = ei.Name;
                    cl.Name         = ei.Name;

                    cl.DataType   = ei.PropertyType;
                    cl.AspectName = ei.Name;

                    if (ei.PropertyType.Name == "Int64" || ei.PropertyType.Name == "Int32" || ei.PropertyType.Name == "Timespan")
                    {
                        cl.TextAlign = HorizontalAlignment.Right;
                    }

                    if (ei.Name == "UniqueID" || ei.Name == "FoundElementList")
                    {
                        cl.MinimumWidth = 0;
                        cl.MaximumWidth = 0;
                        cl.Width        = 0;
                    }
                    else
                    {
                        cl.MinimumWidth = 50;
                        //cl.MaximumWidth = 20000
                        //cl.Width = -2
                    }

                    if (ei.Name.ToLower().Contains("url"))
                    {
                        cl.Hyperlink = true;
                    }
                    //If cl.DataType = GetType(Boolean) Then
                    //    cl.CheckBoxes = True
                    //    cl.IsEditable = False
                    //End If


                    if (ei.Name.ToLower() == PrimarySortColumnName.ToLower())
                    {
                        FOLV.PrimarySortColumn = cl;
                        FOLV.PrimarySortOrder  = PrimarySortOrder;                        //SortOrder.Descending

                        //cl.ImageGetter = AddressOf GetImageFromProd
                    }
                    if (ei.Name.ToLower() == SecondarySortColumnName.ToLower())
                    {
                        FOLV.SecondarySortColumn = cl;
                        FOLV.SecondarySortOrder  = SecondarySortOrder;                        //SortOrder.Descending
                    }

                    FOLV.Columns.Add(cl);
                }


                //OLV.RebuildColumns()
                FOLV.Refresh();
                FOLV.BuildList();
                Application.DoEvents();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            finally
            {
            }
        }
Example #51
0
 /// <summary>
 /// Collect and return all the variables that influence the creation of groups
 /// </summary>
 /// <returns></returns>
 protected virtual GroupingParameters CollectGroupingParameters(OLVColumn groupByColumn, SortOrder groupByOrder,
     OLVColumn column, SortOrder order, OLVColumn secondaryColumn, SortOrder secondaryOrder)
 {
     string titleFormat = this.ShowItemCountOnGroups ? groupByColumn.GroupWithItemCountFormatOrDefault : null;
     string titleSingularFormat = this.ShowItemCountOnGroups ? groupByColumn.GroupWithItemCountSingularFormatOrDefault : null;
     GroupingParameters parms = new GroupingParameters(this, groupByColumn, groupByOrder,
         column, order, secondaryColumn, secondaryOrder,
         titleFormat, titleSingularFormat, this.SortGroupItemsByPrimaryColumn);
     return parms;
 }
        public TrackViewer()
        {
            int w = (600 / 2) - 12 - 6, h = 400 - 12 - 11;

            listView = new ObjectListView
            {
                FullRowSelect      = true,
                HeaderStyle        = ColumnHeaderStyle.Nonclickable,
                HideSelection      = false,
                Location           = new Point(12, 12),
                MultiSelect        = false,
                RowFormatter       = RowColorer,
                ShowGroups         = false,
                Size               = new Size(w, h),
                UseFiltering       = true,
                UseFilterIndicator = true
            };
            OLVColumn c1, c2, c3, c4;

            c1 = new OLVColumn(Strings.TrackViewerEvent, "Command.Label");
            c2 = new OLVColumn(Strings.TrackViewerArguments, "Command.Arguments")
            {
                UseFiltering = false
            };
            c3 = new OLVColumn(Strings.TrackViewerOffset, "Offset")
            {
                AspectToStringFormat = "0x{0:X}", UseFiltering = false
            };
            c4 = new OLVColumn(Strings.TrackViewerTicks, "Ticks")
            {
                AspectGetter = (o) => string.Join(", ", ((SongEvent)o).Ticks), UseFiltering = false
            };
            c1.Width     = c2.Width = c3.Width = 72;
            c4.Width     = 47;
            c1.Hideable  = c2.Hideable = c3.Hideable = c4.Hideable = false;
            c1.TextAlign = c2.TextAlign = c3.TextAlign = c4.TextAlign = HorizontalAlignment.Center;
            listView.AllColumns.AddRange(new OLVColumn[] { c1, c2, c3, c4 });
            listView.RebuildColumns();
            listView.ItemActivate += ListView_ItemActivate;

            var panel1 = new ThemedPanel {
                Location = new Point(306, 12), Size = new Size(w, h)
            };

            tracksBox = new ComboBox
            {
                Enabled  = false,
                Location = new Point(4, 4),
                Size     = new Size(100, 21)
            };
            tracksBox.SelectedIndexChanged += (o, e) => LoadTrack(tracksBox.SelectedIndex);
            panel1.Controls.AddRange(new Control[] { tracksBox });

            ClientSize = new Size(600, 400);
            Controls.AddRange(new Control[] { listView, panel1 });
            FormBorderStyle = FormBorderStyle.FixedDialog;
            MaximizeBox     = false;
            Text            = $"{Utils.ProgramName} ― {Strings.TrackViewerTitle}";

            UpdateTracks();
        }
Example #53
0
 /// <summary>
 /// Return a TextBox that can be used as a default cell editor.
 /// </summary>
 /// <param name="column">What column does the cell belong to?</param>
 /// <returns></returns>
 protected virtual Control MakeDefaultCellEditor(OLVColumn column)
 {
     TextBox tb = new TextBox();
     if (column.AutoCompleteEditor)
         this.ConfigureAutoComplete(tb, column);
     return tb;
 }
Example #54
0
 /// <summary>
 /// Configure the given text box to autocomplete unique values
 /// from the given column. At most 1000 rows will be considered.
 /// </summary>
 /// <param name="tb">The textbox to configure</param>
 /// <param name="column">The column used to calculate values</param>
 public void ConfigureAutoComplete(TextBox tb, OLVColumn column)
 {
     this.ConfigureAutoComplete(tb, column, 1000);
 }
Example #55
0
        private BeforeSortingEventArgs BuildBeforeSortingEventArgs(OLVColumn column, SortOrder order)
        {
            OLVColumn groupBy = this.AlwaysGroupByColumn ?? column ?? this.GetColumn(0);
            SortOrder groupByOrder = this.AlwaysGroupBySortOrder;
            if (order == SortOrder.None) {
                order = this.Sorting;
                if (order == SortOrder.None)
                    order = SortOrder.Ascending;
            }
            if (groupByOrder == SortOrder.None)
                groupByOrder = order;

            BeforeSortingEventArgs args = new BeforeSortingEventArgs(
                groupBy, groupByOrder,
                column, order,
                this.SecondarySortColumn ?? this.GetColumn(0),
                this.SecondarySortOrder == SortOrder.None ? order : this.SecondarySortOrder);
            if (column != null)
                args.Canceled = !column.Sortable;
            return args;
        }
Example #56
0
        /// <summary>
        /// Configure the given text box to autocomplete unique values
        /// from the given column. At most 1000 rows will be considered.
        /// </summary>
        /// <param name="tb">The textbox to configure</param>
        /// <param name="column">The column used to calculate values</param>
        /// <param name="maxRows">Consider only this many rows</param>
        public void ConfigureAutoComplete(TextBox tb, OLVColumn column, int maxRows)
        {
            // Don't consider more rows than we actually have
            maxRows = Math.Min(this.GetItemCount(), maxRows);

            // Reset any existing autocomplete
            tb.AutoCompleteCustomSource.Clear();

            // CONSIDER: Should we use ClusteringStrategy here?

            // Build a list of unique values, to be used as autocomplete on the editor
            Dictionary<string, bool> alreadySeen = new Dictionary<string, bool>();
            List<string> values = new List<string>();
            for (int i = 0; i < maxRows; i++) {
                string valueAsString = column.GetStringValue(this.GetModelObject(i));
                if (!String.IsNullOrEmpty(valueAsString) && !alreadySeen.ContainsKey(valueAsString)) {
                    values.Add(valueAsString);
                    alreadySeen[valueAsString] = true;
                }
            }

            tb.AutoCompleteCustomSource.AddRange(values.ToArray());
            tb.AutoCompleteSource = AutoCompleteSource.CustomSource;
            tb.AutoCompleteMode = column.AutoCompleteEditorMode;
        }
Example #57
0
        private void DoSort(OLVColumn columnToSort, SortOrder order)
        {
            // Sanity checks
            if (this.GetItemCount() == 0 || this.Columns.Count == 0)
                return;

            // Fill in default values, if the parameters don't make sense
            if (this.ShowGroups) {
                columnToSort = columnToSort ?? this.GetColumn(0);
                if (order == SortOrder.None) {
                    order = this.Sorting;
                    if (order == SortOrder.None)
                        order = SortOrder.Ascending;
                }
            }

            // Give the world a chance to fiddle with or completely avoid the sorting process
            BeforeSortingEventArgs args = this.BuildBeforeSortingEventArgs(columnToSort, order);
            this.OnBeforeSorting(args);
            if (args.Canceled)
                return;

            // Virtual lists don't preserve selection, so we have to do it specifically
            // THINK: Do we need to preserve focus too?
            IList selection = new ArrayList();
            if (this.VirtualMode)
                selection = this.SelectedObjects;

            this.ClearHotItem();

            // Finally, do the work of sorting, unless an event handler has already done the sorting for us
            if (!args.Handled) {
                // Sanity checks
                if (args.ColumnToSort != null && args.SortOrder != SortOrder.None) {
                    if (this.ShowGroups)
                        this.BuildGroups(args.ColumnToGroupBy, args.GroupByOrder, args.ColumnToSort, args.SortOrder,
                            args.SecondaryColumnToSort, args.SecondarySortOrder);
                    else if (this.CustomSorter != null)
                        this.CustomSorter(columnToSort, order);
                    else
                        this.ListViewItemSorter = new ColumnComparer(args.ColumnToSort, args.SortOrder,
                            args.SecondaryColumnToSort, args.SecondarySortOrder);
                }
            }

            if (this.ShowSortIndicators)
                this.ShowSortIndicator(args.ColumnToSort, args.SortOrder);

            this.LastSortColumn = args.ColumnToSort;
            this.LastSortOrder = args.SortOrder;

            if (selection.Count > 0)
                this.SelectedObjects = selection;

            this.RefreshHotItem();

            this.OnAfterSorting(new AfterSortingEventArgs(args));
        }
Example #58
0
        /// <summary>
        /// Find the item and column that are under the given co-ords
        /// </summary>
        /// <param name="x">X co-ord</param>
        /// <param name="y">Y co-ord</param>
        /// <param name="selectedColumn">The column under the given point</param>
        /// <returns>The item under the given point. Can be null.</returns>
        public virtual OLVListItem GetItemAt(int x, int y, out OLVColumn selectedColumn)
        {
            selectedColumn = null;
            ListViewHitTestInfo info = this.HitTest(x, y);
            if (info.Item == null)
                return null;

            if (info.SubItem != null) {
                int subItemIndex = info.Item.SubItems.IndexOf(info.SubItem);
                selectedColumn = this.GetColumn(subItemIndex);
            }

            return (OLVListItem)info.Item;
        }
Example #59
0
        /// <summary>
        /// Configure the given column to show the given property.
        /// The title and aspect name of the column are already filled in.
        /// </summary>
        /// <param name="column"></param>
        /// <param name="property"></param>
        protected virtual void ConfigureColumn(OLVColumn column, PropertyDescriptor property) {

            column.LastDisplayIndex = this.ListView.AllColumns.Count;

            // If our column is a BLOB, it could be an image, so assign a renderer to draw it.
            // CONSIDER: Is this a common enough case to warrant this code?
            if (property.PropertyType == typeof(System.Byte[]))
                column.Renderer = new ImageRenderer();
        }
Example #60
0
 /// <summary>
 /// Is there a check at the check box at the given cell
 /// </summary>
 /// <param name="rowObject"></param>
 /// <param name="column"></param>
 public virtual bool IsSubItemChecked(object rowObject, OLVColumn column)
 {
     if (column != null && rowObject != null && column.CheckBoxes)
         return (column.GetCheckState(rowObject) == CheckState.Checked);
     else
         return false;
 }