Example #1
0
        public void ListViewGroupCollection_RemoveAt_ValidIndex_Success()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            collection.Add(group);
            collection.Add(new ListViewGroup());
            collection.Add(new ListViewGroup());
            collection.Add(new ListViewGroup());

            // Remove from start.
            collection.RemoveAt(0);
            Assert.Equal(3, collection.Count);

            // Remove from middle.
            collection.RemoveAt(1);
            Assert.Equal(2, collection.Count);

            // Remove from end.
            collection.RemoveAt(1);
            Assert.Single(collection);

            // Remove only.
            collection.RemoveAt(0);
            Assert.Empty(collection);
            Assert.Null(group.ListView);
        }
        public void ListViewGroupCollection_Item_GetNoSuchString_ReturnsNull(string key)
        {
            var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group1 = new ListViewGroup();
            var group2 = new ListViewGroup();

            group2.Name = "text";
            collection.Add(group1);
            collection.Add(group2);

            Assert.Null(collection[key]);
        }
Example #3
0
        public void ListViewGroupCollection_Add_AlreadyInCollection_Nop()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group1 = new ListViewGroup();
            var group2 = new ListViewGroup();

            Assert.Equal(0, collection.Add(group1));
            Assert.Equal(1, collection.Add(group2));

            Assert.Equal(-1, collection.Add(group1));
            Assert.Equal(2, collection.Count);
        }
        public void ListViewGroupCollection_Item_GetStringExists_ReturnsExpected(string key, int expectedIndex)
        {
            var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group1 = new ListViewGroup();
            var group2 = new ListViewGroup();

            group2.Name = "text";
            collection.Add(group1);
            collection.Add(group2);

            Assert.Equal(collection[expectedIndex], collection[key]);
        }
        public void ListViewGroupCollection_Item_SetAlreadyInCollection_Nop(int index)
        {
            var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            var group1 = new ListViewGroup();
            var group2 = new ListViewGroup();

            collection.Add(group1);
            collection.Add(group2);

            collection[index] = group2;
            Assert.Same(group1, collection[0]);
        }
Example #6
0
        public void ListViewGroupCollection_Insert_SetAlreadyInCollection_Nop(int index)
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            var group1 = new ListViewGroup();
            var group2 = new ListViewGroup();

            collection.Add(group1);
            collection.Add(group2);

            collection.Insert(index, group2);
            Assert.Same(group1, collection[0]);
        }
Example #7
0
        public void ListViewGroupCollection_Add_NullGroup_ThrowsArgumentNullException()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            Assert.Throws <ArgumentNullException>("group", () => collection.Add(null));
        }
Example #8
0
        public void ListViewGroupCollection_Item_GetInvalidIndex_ThrowsArgumentOutOfRangeException(int index)
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            collection.Add(new ListViewGroup());
            Assert.Throws <ArgumentOutOfRangeException>("index", () => collection[index]);
        }
Example #9
0
        public void ListViewGroupCollection_Add_ListViewGroup_Success()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group1 = new ListViewGroup();

            Assert.Equal(0, collection.Add(group1));
            Assert.Same(group1, Assert.Single(collection));
            Assert.Same(listView, group1.ListView);

            // Add another.
            var group2 = new ListViewGroup();

            Assert.Equal(1, collection.Add(group2));
            Assert.Equal(new ListViewGroup[] { group1, group2 }, collection.Cast <ListViewGroup>());
            Assert.Same(listView, group2.ListView);
        }
        public void ListViewGroupCollection_Item_SetNoSuchString_Nop(string key)
        {
            var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group1 = new ListViewGroup();
            var group2 = new ListViewGroup();

            group2.Name = "text";
            collection.Add(group1);
            collection.Add(group2);

            var group3 = new ListViewGroup();

            collection[key] = group3;
            Assert.Same(group1, collection[0]);
            Assert.Same(group2, collection[1]);
        }
Example #11
0
        public void ListViewGroupCollection_Item_SetNull_ThrowsArgumentNullException()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            collection.Add(new ListViewGroup());
            Assert.Throws <ArgumentNullException>("value", () => collection[0] = null);
        }
Example #12
0
        public void ListViewGroupCollection_Insert_NullGroup_ThrowsArgumentNullException(int index)
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            collection.Add(new ListViewGroup());
            Assert.Throws <ArgumentNullException>("group", () => collection.Insert(index, null));
        }
Example #13
0
        public void ListViewGroupCollection_Item_SetStringExists_GetReturnsExpected(string key, int expectedIndex)
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group1 = new ListViewGroup();
            var group2 = new ListViewGroup
            {
                Name = "text"
            };

            collection.Add(group1);
            collection.Add(group2);

            var group3 = new ListViewGroup();

            collection[key] = group3;
            Assert.Same(group3, collection[expectedIndex]);
        }
        public void ListViewGroupCollection_Add_ListViewGroup_Success()
        {
            var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            collection.Add(group);
            Assert.Same(group, Assert.Single(collection));
            Assert.Same(listView, group.ListView);
        }
Example #15
0
        public void ListViewGroupCollection_Item_GetValidIndex_ReturnsExpected()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            var group = new ListViewGroup();

            collection.Add(group);
            Assert.Same(group, collection[0]);
        }
Example #16
0
        public void ListViewGroupCollection_IndexOf_Invoke_ReturnsExpected()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            collection.Add(group);

            Assert.Equal(0, collection.IndexOf(group));
            Assert.Equal(-1, collection.IndexOf(new ListViewGroup()));
            Assert.Equal(-1, collection.IndexOf(null));
        }
        //[InjectionProperty(Required = false)]
        //private ITraceWindowSource TraceSource
        //{
        //  set { _traceSource = value; }
        //}

        #endregion

        public MainForm()
            : base(true)
        {
            InitializeComponent();

            //this.SetLogoIcon();
            this.SetLogoImages(picTop, status);
            UpdateCaption();

            tslblStatusState.SetLogoForeColor();
            tslblStatusNetwork.SetLogoForeColor();

            imgServices.Images.Add(Images.OK);
            imgServices.Images.Add(Images.Error);
            imgServices.Images.Add(Images.Extension);
            imgServices.Images.Add(Images.Extension.MakeGrayscale());
            imgServices.Images.Add(Images.Find);
            imgServices.Images.Add(Images.Warning);

            lblExtensionsWarning.ImageIndex = ImageIndexWarning;
            lblMonitorWarning.ImageIndex    = ImageIndexWarning;

            ListViewGroupCollection lvgc = lvwMonitor.Groups;

            lvgc.Clear();
            foreach (MonitoringObjectCategory mt in RuntimeHelper.GetEnumElements <MonitoringObjectCategory>())
            {
                lvgc.Add(mt.ToString(), mt.GetString());
            }

            _gazprom                = null;
            _settingsForm           = null;
            _aboutForm              = null;
            _inputForm              = new InputForm();
            _stateTimer             = new ToolStripStateTimer(tslblStatusState, TimeSpan.FromSeconds(2));
            _stateTimer.DefaultText = StatusStateReady;
            _stateTimer.UpdateStateText();

            _chordHandler = new ChordKeyHandler(this);
            _actions      = new Dictionary <int, HotKeyAction>();
            _actions.Add(_chordHandler.AddChord(Keys.Control, Keys.L, Keys.F), HotKeyAction.OpenLogFolder);
            _actions.Add(_chordHandler.AddChord(Keys.Control, Keys.L, Keys.D), HotKeyAction.DeleteLogFiles);
            _actions.Add(_chordHandler.AddChord(Keys.Control, Keys.L, Keys.O), HotKeyAction.OpenLogFile);
            _actions.Add(_chordHandler.AddChord(Keys.Control, Keys.L, Keys.W), HotKeyAction.LogComment);
            _actions.Add(_chordHandler.AddChord(Keys.Control, Keys.L, Keys.R), HotKeyAction.LogRuntimeInfo);
            _actions.Add(_chordHandler.AddChord(Keys.Control, Keys.D, Keys.N), HotKeyAction.NetworkControl);
            _actions.Add(_chordHandler.AddChord(Keys.Control, Keys.S, Keys.E), HotKeyAction.ShowExtensionFilter);
            _actions.Add(_chordHandler.AddChord(Keys.Control, Keys.L, Keys.C), HotKeyAction.LogControl);
            _chordHandler.ChordPressed += OnChordPressed;

            _menuMain = null;
            //_traceSource = null;
        }
Example #18
0
        public void ListViewGroupCollection_Insert_ListViewGroup_Success()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            collection.Add(new ListViewGroup());
            collection.Insert(1, group);
            Assert.Equal(2, collection.Count);
            Assert.Same(group, collection[1]);
            Assert.Same(listView, group.ListView);
        }
Example #19
0
        public void ListViewGroupCollection_Add_StringString_Success(string key, string headerText, string expectedHeaderText)
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            collection.Add(key, headerText);

            ListViewGroup group = Assert.Single(collection.Cast <ListViewGroup>());

            Assert.Equal(key, group.Name);
            Assert.Equal(expectedHeaderText, group.Header);
        }
Example #20
0
        public void ListViewGroupCollection_Contains_Invoke_ReturnsExpected()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            collection.Add(group);

            Assert.True(collection.Contains(group));
            Assert.False(collection.Contains(new ListViewGroup()));
            Assert.False(collection.Contains(null));
        }
        public void ListViewGroupCollection_Add_ListViewGroupWithHandle_Success()
        {
            var listView = new ListView();

            Assert.NotEqual(IntPtr.Zero, listView.Handle);

            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            collection.Add(group);
            Assert.Same(group, Assert.Single(collection));
            Assert.Same(listView, group.ListView);
        }
        public void ListViewGroupCollection_Item_SetValidIndex_GetReturnsExpected()
        {
            var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            collection.Add(new ListViewGroup());

            var group = new ListViewGroup();

            collection[0] = group;
            Assert.Same(group, collection[0]);
            Assert.Null(group.ListView);
        }
        public void ListViewGroupCollection_AddRange_ListViewGroupCollection_Success()
        {
            var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var otherListView = new ListView();
            ListViewGroupCollection otherCollection = listView.Groups;

            var group1 = new ListViewGroup();
            var group2 = new ListViewGroup();

            otherCollection.Add(group1);
            otherCollection.Add(group2);

            collection.AddRange(otherCollection);

            Assert.Equal(2, collection.Count);
            Assert.Same(group1, collection[0]);
            Assert.Same(group2, collection[1]);
            Assert.Equal(2, otherCollection.Count);
            Assert.Same(group1, otherCollection[0]);
            Assert.Same(group2, otherCollection[1]);
        }
Example #24
0
        public void ListViewGroupCollection_CopyTo_NonEmpty_Success()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            collection.Add(group);

            var array = new object[] { 1, 2, 3 };

            collection.CopyTo(array, 1);
            Assert.Equal(new object[] { 1, group, 3 }, array);
        }
Example #25
0
        public void ListViewGroupCollection_Item_SetListViewGroupWithHandle_Success()
        {
            using var listView = new ListView();
            Assert.NotEqual(IntPtr.Zero, listView.Handle);

            ListViewGroupCollection collection = listView.Groups;

            collection.Add(new ListViewGroup());

            var group = new ListViewGroup();

            collection[0] = group;
            Assert.Same(group, collection[0]);
            Assert.Same(listView, group.ListView);
        }
        public void ListViewGroupCollection_Add_HasItemsFromOtherListView_ThrowsArgumentException()
        {
            var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var otherListView = new ListView();

            var item  = new ListViewItem();
            var group = new ListViewGroup();

            group.Items.Add(item);
            otherListView.Items.Add(item);

            Assert.Throws <ArgumentException>(null, () => collection.Add(group));
            Assert.Empty(collection);
        }
        public void ListViewGroupCollection_Insert_ListViewGroupWithHandle_Success()
        {
            var listView = new ListView();

            Assert.NotEqual(IntPtr.Zero, listView.Handle);

            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            collection.Add(new ListViewGroup());
            collection.Insert(1, group);
            Assert.Equal(2, collection.Count);
            Assert.Same(group, collection[1]);
            Assert.Same(listView, group.ListView);
        }
Example #28
0
        public void ListViewGroupCollection_Add_ListViewGroupWithItems_Success()
        {
            using var listView = new ListView();
            var item = new ListViewItem();

            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            group.Items.Add(new ListViewItem());
            group.Items.Add(item);
            listView.Items.Add(item);

            Assert.Equal(0, collection.Add(group));
            Assert.Same(group, Assert.Single(collection));
            Assert.Same(listView, group.ListView);
        }
Example #29
0
        public void ListViewGroupCollection_Clear_Invoke_Success()
        {
            using var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;
            var group = new ListViewGroup();

            collection.Add(group);

            collection.Clear();
            Assert.Empty(collection);
            Assert.Null(group.ListView);

            // Clear again.
            collection.Clear();
            Assert.Empty(collection);
            Assert.Null(group.ListView);
        }
        public void ListViewGroupCollection_Insert_SetHasItemsFromOtherListView_Success()
        {
            var listView = new ListView();
            ListViewGroupCollection collection = listView.Groups;

            collection.Add(new ListViewGroup());
            var otherListView = new ListView();

            var item  = new ListViewItem();
            var group = new ListViewGroup();

            group.Items.Add(item);
            otherListView.Items.Add(item);

            collection.Insert(0, group);
            Assert.Same(group, collection[0]);
            Assert.Same(listView, group.ListView);
        }