public void SavingDataGridStateActionTest()
        {
            var trigger = new System.Windows.Interactivity.EventTrigger("Closed");
            var trg = new SavingDataGridStateAction();
            trigger.Actions.Add(trg);

            var w = new Window();
            Interaction.GetTriggers(w).Add(trigger);

            var dg = new DataGrid();
            dg.Name = "FDataGrid";
            var c1 = new ColumnSetting() { DisplayIndex = 0, Width = -2 };
            var c2 = new ColumnSetting() { DisplayIndex = 1, Width = 100 };
            var c3 = new ColumnSetting() { DisplayIndex = 2, Width = 200 };
            var c4 = new ColumnSetting() { DisplayIndex = 3, Width = -1 };
            var c5 = new ColumnSetting() { DisplayIndex = 4, Width = 0 };
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c1.DisplayIndex, Width = c1.Width });
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c2.DisplayIndex, Width = c2.Width });
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c3.DisplayIndex, Width = c3.Width });
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c4.DisplayIndex, Width = c4.Width });
            dg.Columns.Add(new DataGridTemplateColumn() { DisplayIndex = c5.DisplayIndex, Width = c5.Width });
            trg.Parameter = dg;

            w.ShowDialog();

            var cols = Setting.DataGridColumns;
            var c = cols[0];
            Assert.IsTrue(c1.Equals(c));
            c = cols[1];
            Assert.IsTrue(c2.Equals(c));
            c = cols[2];
            Assert.IsTrue(c3.Equals(c));
            c = cols[3];
            Assert.IsTrue(c4.Equals(c));
            c = cols[4];
            Assert.IsTrue(c5.Equals(c));

            Setting.Save();
        }
Example #2
0
        public void SavingDataGridStateActionTest()
        {
            var trigger = new System.Windows.Interactivity.EventTrigger("Closed");
            var trg     = new SavingDataGridStateAction();

            trigger.Actions.Add(trg);

            var w = new Window();

            Interaction.GetTriggers(w).Add(trigger);

            var dg = new DataGrid();

            dg.Name = "FDataGrid";
            var c1 = new ColumnSetting()
            {
                DisplayIndex = 0, Width = -2
            };
            var c2 = new ColumnSetting()
            {
                DisplayIndex = 1, Width = 100
            };
            var c3 = new ColumnSetting()
            {
                DisplayIndex = 2, Width = 200
            };
            var c4 = new ColumnSetting()
            {
                DisplayIndex = 3, Width = -1
            };
            var c5 = new ColumnSetting()
            {
                DisplayIndex = 4, Width = 0
            };

            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c1.DisplayIndex, Width = c1.Width
            });
            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c2.DisplayIndex, Width = c2.Width
            });
            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c3.DisplayIndex, Width = c3.Width
            });
            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c4.DisplayIndex, Width = c4.Width
            });
            dg.Columns.Add(new DataGridTemplateColumn()
            {
                DisplayIndex = c5.DisplayIndex, Width = c5.Width
            });
            trg.Parameter = dg;

            w.ShowDialog();

            var cols = Setting.DataGridColumns;
            var c    = cols[0];

            Assert.IsTrue(c1.Equals(c));
            c = cols[1];
            Assert.IsTrue(c2.Equals(c));
            c = cols[2];
            Assert.IsTrue(c3.Equals(c));
            c = cols[3];
            Assert.IsTrue(c4.Equals(c));
            c = cols[4];
            Assert.IsTrue(c5.Equals(c));

            Setting.Save();
        }