Exemplo n.º 1
0
        public void AddScript(SmartScript script, bool listViewOnly = false, bool selectNewItem = false)
        {
            base.AddScript(script, listViewOnly, selectNewItem);

            //TODO: Fix me
            //if (Settings.Default.PhaseHighlighting && script.event_phase_mask != 0)
            //{
            //    if (!_phaseColors.ContainsKey(script.event_phase_mask))
            //    {
            //        if (_colors.Count == 0)
            //        {
            //            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 -1;
            //        }

            //        _phaseColors.Add(script.event_phase_mask, _colors.Pop());
            //    }

            //    newItem.BackColor = _phaseColors[script.event_phase_mask];
            //}

            ListView.SelectObject(script);
            _oListView.Select();
            _oListView.EnsureModelVisible(script);
        }
Exemplo n.º 2
0
        public void AddScript(SmartScript script, bool listViewOnly = false, bool selectNewItem = false)
        {
            base.AddScript(script, listViewOnly, selectNewItem);

            if (Settings.Default.PhaseHighlighting && script.event_phase_mask != 0)
            {
                if (!_phaseColors.ContainsKey(script.event_phase_mask))
                {
                    if (_colors.Count == 0)
                    {
                        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;
                    }

                    _phaseColors.Add(script.event_phase_mask, _colors.Pop());
                }

                _oListView.Refresh();
                ResizeColumns();
            }

            ListView.HideSelection = false;
            ListView.Focus();
            ListView.SelectObject(script);
            _oListView.Select();
            _oListView.SelectObject(script);
            _oListView.EnsureModelVisible(script);
        }
Exemplo n.º 3
0
        public static void EnsureSelectionIsVisible(this FastObjectListView list)
        {
            if (list.InvokeRequired)
            {
                list.Invoke((Action)(() =>
                {
                    list.EnsureSelectionIsVisible();
                }));
                return;
            }
            var obj = list.SelectedObject;

            if (obj != null)
            {
                list.EnsureModelVisible(obj);
            }
        }
Exemplo n.º 4
0
        public static void UpdateFOLV_add(FastObjectListView olv, ICollection Collection, bool ResizeCols = false, bool Follow = false)
        {
            Global_GUI.InvokeIFRequired(olv, () =>
            {
                try
                {
                    if (olv.Items.Count == 0)
                    {
                        olv.EmptyListMsg = "Loading...";
                    }

                    olv.Freeze();

                    olv.UpdateObjects(Collection);

                    if (olv.Items.Count > 0)
                    {
                        if (Follow)
                        {
                            olv.SelectedIndex = 0;                              //olv.Items.Count - 1;
                            olv.EnsureModelVisible(olv.SelectedObject);
                        }

                        //update column size only if did not restore folv state file or forced
                        if (olv.Tag == null || ResizeCols)
                        {
                            olv.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent);
                            olv.Tag = "resizedcols";
                        }
                    }
                    else
                    {
                        olv.EmptyListMsg = "Empty";
                    }
                }
                catch (Exception ex)
                {
                    Global.Log("Error: " + Global.ExMsg(ex));
                }
                finally
                {
                    olv.Unfreeze();
                }
            });
        }
Exemplo n.º 5
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();
                    }
                }
            });
        }