コード例 #1
0
        public override void Apply(bool keepSelection = false)
        {
            int lastSelectedIndex = _oListView.SelectedIndices.Count > 0 ? _oListView.SelectedIndices[0] : -1;

            base.Apply(keepSelection);

            _colors = new Stack <Color>(Constants.PhaseColors);
            _phaseColors.Clear();

            if (Scripts != null)
            {
                int[] phasemasks = Scripts.Select(p => ((SmartScript)p).event_phase_mask).Distinct().ToArray();

                if (phasemasks.Length > Constants.PhaseColors.Count)
                {
                    MessageBox.Show("There are not enough colors in the application because you are using too many different phasemasks.", "Not enough colors!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                foreach (int phasemask in phasemasks.Where(phasemask => phasemask != 0 && !_phaseColors.ContainsKey(phasemask)))
                {
                    _phaseColors.Add(phasemask, _colors.Pop());
                }

                _oListView.Refresh();
                ResizeColumns();
            }
        }
コード例 #2
0
        public void UpdatePhaseColors()
        {
            if (Scripts == null)
            {
                return;
            }

            _colors = new Stack <Color>(Constants.phaseColors);
            _phaseColors.Clear();

            if (!Settings.Default.PhaseHighlighting)
            {
                return;
            }

            int[] phaseMasks = Scripts.Select(p => ((SmartScript)p).event_phase_mask).Distinct().ToArray();

            if (phaseMasks.Length > Constants.phaseColors.Count)
            {
                MessageBox.Show("There are not enough colors in the application because you are using too many different phasemasks.", "Not enough colors!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (int phasemask in phaseMasks.Where(phasemask => phasemask != 0 && !_phaseColors.ContainsKey(phasemask)))
            {
                _phaseColors.Add(phasemask, _colors.Pop());
            }

            _oListView.Refresh();
        }
コード例 #3
0
        public static void FilterFOLV(FastObjectListView OLV, string FilterText, bool Filter)
        {
            using var cw = new Global_GUI.CursorWait();

            try
            {
                if (!string.IsNullOrEmpty(FilterText))
                {
                    if (Filter)
                    {
                        OLV.UseFiltering = true;
                    }
                    else
                    {
                        OLV.UseFiltering = false;
                    }
                    TextMatchFilter filter = TextMatchFilter.Regex(OLV, FilterText);
                    OLV.ModelFilter = filter;
                    HighlightTextRenderer renderererer = new HighlightTextRenderer(filter);
                    SolidBrush            brush        = renderererer.FillBrush as SolidBrush ?? new SolidBrush(Color.Transparent);
                    brush.Color            = System.Drawing.Color.FromArgb(100, Color.LightSeaGreen); //
                    renderererer.FillBrush = brush;
                    OLV.DefaultRenderer    = renderererer;
                    Global.SaveRegSetting("SearchText", FilterText);
                }
                else
                {
                    OLV.ModelFilter = null;
                }
                OLV.Refresh();
                //Application.DoEvents();
            }
            catch { }
        }
コード例 #4
0
        private void buttonRefresh_Click(object sender, EventArgs e)
        {
            if (Refreshing)
            {
                return;
            }
            fastOLV.Refresh();
            fastOLV.BuildList();
            Refresh();
            RefreshParserAndCodeExplorer();

            Npp.GrabFocus();
        }
コード例 #5
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
            {
            }
        }
コード例 #6
0
        public static void UpdateFOLV(FastObjectListView olv, IList objs,
                                      bool Follow = false,
                                      ColumnHeaderAutoResizeStyle ResizeColsStyle = ColumnHeaderAutoResizeStyle.None,
                                      bool FullRefresh     = false,
                                      bool UseSelected     = false,
                                      object SelectObject  = null,
                                      bool ForcedSelection = false,
                                      [CallerMemberName()] string memberName = null)
        {
            Global_GUI.InvokeIFRequired(olv, () =>
            {
                try
                {
                    int oldcnt = olv.Items.Count;

                    if (oldcnt == 0)
                    {
                        olv.EmptyListMsg = "Loading...";
                    }

                    //Debug.Print($"{DateTime.Now} - {memberName} > UpdateFOLV: {objs.Count} items, Follow={Follow}");

                    olv.Freeze();  //accessed from another thread

                    if (FullRefresh)
                    {
                        //olv.ClearCachedInfo();
                        //olv.ClearObjects();
                    }

                    if (FullRefresh || olv.Items.Count == 0)  //full refresh of new objects
                    {
                        olv.SetObjects(objs, true);
                    }
                    else
                    {
                        olv.AddObjects(objs);  //minimize list changes
                    }
                    if (olv.Items.Count > 0)
                    {
                        if (Follow)
                        {
                            if (SelectObject != null && UseSelected)
                            {
                                //use the given object as selected
                                olv.SelectedObject = SelectObject;  //olv.Items.Count - 1;
                            }
                            else if (SelectObject == null && UseSelected && olv.IsFiltering && olv.GetItemCount() > 0)
                            {
                                //use the last filtered object as the selected object
                                olv.SelectedObject = olv.FilteredObjects.Cast <object>().Last();
                            }
                            else if (!olv.IsFiltering)
                            {
                                //just use the last object given to us
                                olv.SelectedObject = objs[objs.Count - 1];  //olv.Items.Count - 1;
                            }


                            if (olv.SelectedObject != null)
                            {
                                olv.EnsureModelVisible(olv.SelectedObject);
                            }
                        }
                        else
                        {
                            //only select something if nothing is already selected
                            if (SelectObject != null && (ForcedSelection || (UseSelected && olv.SelectedObject == null)))
                            {
                                //use the given object as selected
                                olv.SelectedObject = SelectObject;  //olv.Items.Count - 1;
                                olv.EnsureModelVisible(olv.SelectedObject);
                            }
                            //else if (SelectObject == null && UseSelected && olv.IsFiltering && olv.GetItemCount() > 0)
                            //{
                            //    //use the last filtered object as the selected object
                            //    olv.SelectedObject = olv.FilteredObjects.Cast<object>().First();
                            //}
                            //else if (!olv.IsFiltering && UseSelected)
                            //{
                            //    //just use the last object given to us
                            //    olv.SelectedObject = objs[0];  //olv.Items.Count - 1;
                            //}
                        }


                        //update column size only if did not restore folv state file or forced
                        if (olv.Tag == null)
                        {
                            olv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                            olv.Tag = "resizedcols";
                        }
                        else if (ResizeColsStyle != ColumnHeaderAutoResizeStyle.None)
                        {
                            olv.AutoResizeColumns(ResizeColsStyle);
                            olv.Tag = "resizedcols";
                        }
                    }
                    else
                    {
                        olv.EmptyListMsg = "Empty";
                    }
                }
                catch (Exception ex)
                {
                    Log("Error: " + ex.Msg());
                }
                finally
                {
                    olv.Unfreeze();
                    if (FullRefresh)
                    {
                        olv.Refresh();
                    }
                }
            });
        }
コード例 #7
0
        public static void ConfigureFOLV(FastObjectListView FOLV, Type Cls,
                                         System.Drawing.Font Fnt        = null,
                                         ImageList ImageList            = null,
                                         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,
                                         bool GridLines  = true)
        {
            //Global_GUI.InvokeIFRequired(FOLV, () =>
            //{

            try
            {
                FOLV.AllowColumnReorder      = true;
                FOLV.CopySelectionOnControlC = true;
                FOLV.FullRowSelect           = true;
                FOLV.GridLines     = GridLines;
                FOLV.HideSelection = false;
                FOLV.IncludeColumnHeadersInCopy = true;
                FOLV.OwnerDraw = true;
                FOLV.SelectColumnsOnRightClick          = true;
                FOLV.SelectColumnsOnRightClickBehaviour = ObjectListView.ColumnSelectBehaviour.InlineMenu;
                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                 = true; //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;
                }

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

                //if (IIProps2.Length == 0)
                //    IIProps2 = Cls.GetFields();

                // 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;

                //for (int i = 0; i < IIProps2.Length; i++)
                //{
                //    object ei = IIProps2[i];

                //}

                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 (FOLV.SmallImageList != null)
                    {
                        if (string.Equals(FOLV.Name, "folv_history", StringComparison.OrdinalIgnoreCase))
                        {
                            if (colcnt == 1)
                            {
                                cl.ImageGetter = GetImageForHistoryList;
                            }
                            else if (ei.Name == "IsPerson")
                            {
                                cl.ImageGetter             = GetImageForHistoryListPerson;
                                cl.AspectToStringConverter = delegate(object x)
                                {
                                    return(String.Empty);
                                };
                            }
                            else if (ei.Name == "Success")
                            {
                                cl.ImageGetter             = GetImageForHistoryListSuccess;
                                cl.AspectToStringConverter = delegate(object x)
                                {
                                    return(String.Empty);
                                };
                            }
                        }
                        else if (string.Equals(FOLV.Name, "FOLV_AIServers", StringComparison.OrdinalIgnoreCase))
                        {
                            if (colcnt == 1)
                            {
                                cl.ImageGetter = GetImageForAIServerList;
                            }
                        }
                        else if (string.Equals(FOLV.Name, "FOLV_Cameras", StringComparison.OrdinalIgnoreCase))
                        {
                            if (colcnt == 1)
                            {
                                cl.ImageGetter = GetImageForCameraList;
                            }
                        }
                        //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 (cl.Name == "Func" || 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.IndexOf("url", StringComparison.OrdinalIgnoreCase) >= 0)
                    {
                        cl.Hyperlink = true;
                    }

                    if ((ei.Name.Has("percent") || ei.Name.Has("threshold") || ei.Name.Has("confidence")) && (ei.PropertyType == typeof(double) || ei.PropertyType == typeof(int) || ei.PropertyType == typeof(float)))
                    {
                        cl.AspectToStringFormat = "{0:0.#}%";
                    }

                    //if (ei.PropertyType == typeof(ThreadSafe.Boolean))
                    //{
                    //    if (FOLV.Name == "FOLV_AIServers")
                    //    {
                    //        cl.AspectGetter = delegate (object rowObject)
                    //        {
                    //            bool ret = false;
                    //            ClsURLItem obj = (ClsURLItem)rowObject;
                    //            if (ei.Name == "Enabled")
                    //            {
                    //                ret = obj.Enabled.ReadFullFence();
                    //            }
                    //            else if (ei.Name == "InUse")
                    //            {
                    //                ret = obj.InUse.ReadFullFence();
                    //            }
                    //            else
                    //            {
                    //                int test = 0;
                    //            }
                    //            return ret;
                    //        };

                    //        cl.DataType = typeof(bool);
                    //        cl.CheckBoxes = true;
                    //    }

                    //}
                    //if (ei.Name == "Enabled")
                    //{
                    //    int test = 0;
                    //}

                    //if (ei.PropertyType == typeof(Boolean))
                    //{
                    //    cl.CheckBoxes = true;
                    //    cl.IsEditable = false;
                    //}


                    if (string.Equals(ei.Name, PrimarySortColumnName, StringComparison.OrdinalIgnoreCase))
                    {
                        FOLV.PrimarySortColumn = cl;
                        FOLV.PrimarySortOrder  = PrimarySortOrder; //SortOrder.Descending

                        //cl.ImageGetter = AddressOf GetImageFromProd
                    }
                    if (string.Equals(ei.Name, SecondarySortColumnName, StringComparison.OrdinalIgnoreCase))
                    {
                        FOLV.SecondarySortColumn = cl;
                        FOLV.SecondarySortOrder  = SecondarySortOrder; //SortOrder.Descending
                    }

                    FOLV.AllColumns.Add(cl);  //Columns vs AllColumns?
                }

                //restore column state if it exists
                FOLVRestoreState(FOLV);

                //OLV.RebuildColumns()
                FOLV.Refresh();
                FOLV.BuildList();
                FOLV.RebuildColumns();

                //Application.DoEvents();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message);
            }
            finally
            {
            }

            //});
        }