예제 #1
0
        protected override void DoTest()
        {
            Assert.AreEqual(0, SkylineWindow.Document.Settings.DataSettings.Lists.Count);
            var documentSettingsDlg = ShowDialog <DocumentSettingsDlg>(SkylineWindow.ShowDocumentSettingsDialog);
            var listDesigner        = ShowDialog <ListDesigner>(documentSettingsDlg.AddList);

            RunUI(() =>
            {
                listDesigner.ListName = "Planets";
            });
            SetCellValue(listDesigner.ListPropertiesGrid, 0, 0, "Name");
            SetCellValue(listDesigner.ListPropertiesGrid, 1, 0, "Symbol");
            SetCellValue(listDesigner.ListPropertiesGrid, 2, 0, "Distance");
            SetCellValue(listDesigner.ListPropertiesGrid, 2, 1, ListPropertyType.GetAnnotationTypeName(AnnotationDef.AnnotationType.number));
            SetCellValue(listDesigner.ListPropertiesGrid, 3, 0, "Rings");
            SetCellValue(listDesigner.ListPropertiesGrid, 3, 1, ListPropertyType.GetAnnotationTypeName(AnnotationDef.AnnotationType.true_false));
            RunUI(() =>
            {
                listDesigner.IdProperty = "Name";
            });
            OkDialog(listDesigner, listDesigner.OkDialog);
            OkDialog(documentSettingsDlg, documentSettingsDlg.OkDialog);
            RunUI(() => SkylineWindow.ShowList("Planets"));
            var listGridForm = FindOpenForm <ListGridForm>();

            WaitForConditionUI(() => listGridForm.IsComplete);
            SetCellAddress(listGridForm.DataGridView, 0, 0);
            SetClipboardText(string.Join(TextUtil.SEPARATOR_TSV_STR, "Earth", "\u2641", 1.00000011, false));
            RunUI(listGridForm.DataGridView.SendPaste);
            SetCellAddress(listGridForm.DataGridView, 0, 0);
            WaitForConditionUI(() => listGridForm.IsComplete);
            var listData = SkylineWindow.Document.Settings.DataSettings.Lists.First();

            Assert.AreEqual(1, listData.RowCount);
            SetClipboardText(TextUtil.LineSeparate(
                                 string.Join(TextUtil.SEPARATOR_TSV_STR, "Mercury", "\u263F", 0.38709893, false),
                                 string.Join(TextUtil.SEPARATOR_TSV_STR, "Venus", "\u2640", 0.72333199, false),
                                 string.Join(TextUtil.SEPARATOR_TSV_STR, "Mars", "\u2642", 1.52366231, false),
                                 string.Join(TextUtil.SEPARATOR_TSV_STR, "Jupiter", "\u2643", 5.20336301, true),
                                 string.Join(TextUtil.SEPARATOR_TSV_STR, "Saturn", "\u2644", 9.53707032, true),
                                 string.Join(TextUtil.SEPARATOR_TSV_STR, "Uranus", "\u2645", 19.19126393, true),
                                 string.Join(TextUtil.SEPARATOR_TSV_STR, "Neptune", "\u2646", 30.06896348, true),
                                 string.Join(TextUtil.SEPARATOR_TSV_STR, "Pluto", "\u2647", 39.482, false)
                                 ));
            SetCellAddress(listGridForm.DataGridView, 1, 0);
            RunUI(listGridForm.DataGridView.SendPaste);
            SetCellAddress(listGridForm.DataGridView, 0, 0);
            listData = SkylineWindow.Document.Settings.DataSettings.Lists.First();
            Assert.AreEqual(9, listData.RowCount);
            SetCellAddress(listGridForm.DataGridView, 8, 0);
            var alertDlg = ShowDialog <AlertDlg>(listGridForm.DataboundGridControl.NavBar.ViewContext.Delete);

            OkDialog(alertDlg, alertDlg.ClickOk);
            SetCellAddress(listGridForm.DataGridView, 0, 0);
            listData = SkylineWindow.Document.Settings.DataSettings.Lists.First();
            Assert.AreEqual(8, listData.RowCount);
            OkDialog(listGridForm, listGridForm.Close);
            AssertEx.Serializable(SkylineWindow.Document);
        }
예제 #2
0
        protected override void DoTest()
        {
            const string listName     = "MyList";
            var          listDesigner = ShowDialog <ListDesigner>(SkylineWindow.AddListDefinition);

            RunUI(() => listDesigner.ListName = listName);
            SetCellValue(listDesigner.ListPropertiesGrid, 0, 0, "Name");
            SetCellValue(listDesigner.ListPropertiesGrid, 1, 0, "X");
            SetCellValue(listDesigner.ListPropertiesGrid, 1, 1, ListPropertyType.GetAnnotationTypeName(AnnotationDef.AnnotationType.number));
            SetCellValue(listDesigner.ListPropertiesGrid, 2, 0, "Y");
            SetCellValue(listDesigner.ListPropertiesGrid, 2, 1, ListPropertyType.GetAnnotationTypeName(AnnotationDef.AnnotationType.number));
            RunUI(() => listDesigner.ListPropertiesGrid.CurrentCell = listDesigner.ListPropertiesGrid.Rows[0].Cells[0]);
            OkDialog(listDesigner, listDesigner.OkDialog);
            RunUI(() => SkylineWindow.ShowList(listName));
            var listGrid = FindOpenForm <ListGridForm>();

            WaitForCondition(() => listGrid.IsComplete);
            // Add some values to the "Name" and "X" columns
            SetClipboardText(TextUtil.LineSeparate("A\t-4", "B\t2", "C\t0", "D\t3", "E\t-3"));
            RunUI(() =>
            {
                listGrid.DataGridView.CurrentCell = listGrid.DataGridView.Rows[0].Cells[0];
                listGrid.DataGridView.SendPaste();
                listGrid.DataGridView.CurrentCell = listGrid.DataGridView.Rows[0].Cells[0];
            });
            WaitForCondition(() => listGrid.IsComplete);
            Assert.AreEqual("ABCDE", GetNameValues(listGrid.DataGridView));

            // Press the "Cluster" button and see that the order changes
            RunUI(() => listGrid.DataboundGridControl.NavBar.ClusterSplitButton.PerformButtonClick());
            WaitForCondition(() => listGrid.IsComplete);
            Assert.AreEqual("AECBD", GetNameValues(listGrid.DataGridView));

            // Press the "Cluster" button again and the order goes back to the original
            RunUI(() => listGrid.DataboundGridControl.NavBar.ClusterSplitButton.PerformButtonClick());
            WaitForCondition(() => listGrid.IsComplete);
            Assert.AreEqual("ABCDE", GetNameValues(listGrid.DataGridView));

            // Add some numbers to the "Y" column
            SetClipboardText(TextUtil.LineSeparate("1", "1", "0", "3", "3"));
            RunUI(() =>
            {
                listGrid.DataGridView.CurrentCell = listGrid.DataGridView.Rows[0].Cells[2];
                listGrid.DataGridView.SendPaste();
                listGrid.DataGridView.CurrentCell = listGrid.DataGridView.Rows[0].Cells[0];
            });
            // Press the Cluster button
            RunUI(() => listGrid.DataboundGridControl.NavBar.ClusterSplitButton.PerformButtonClick());
            WaitForCondition(() => listGrid.IsComplete);
            Assert.AreEqual("BDCAE", GetNameValues(listGrid.DataGridView));

            // set to city block distance metric, which will change the clustering of the items
            var clusteringEditor = ShowDialog <ClusteringEditor>(listGrid.NavBar.ShowClusteringEditor);

            RunUI(() =>
            {
                Assert.AreEqual(ClusterMetricType.EUCLIDEAN, clusteringEditor.DistanceMetric);
                clusteringEditor.DistanceMetric = ClusterMetricType.MANHATTAN;
            });
            OkDialog(clusteringEditor, () => clusteringEditor.DialogResult = DialogResult.OK);
            WaitForCondition(() => listGrid.IsComplete);
            Assert.AreEqual("AEDBC", GetNameValues(listGrid.DataGridView));

            const string reportName = "ListClusteringReport";

            RunDlg <ViewEditor>(listGrid.NavBar.CustomizeView, viewEditor =>
            {
                viewEditor.ViewName = reportName;
                viewEditor.OkDialog();
            });

            WaitForCondition(() => listGrid.IsComplete);
            Assert.AreEqual("AEDBC", GetNameValues(listGrid.DataGridView));
            RunDlg <NameLayoutForm>(listGrid.NavBar.RememberCurrentLayout, nameLayoutForm =>
            {
                nameLayoutForm.LayoutName = "MyLayout";
                nameLayoutForm.OkDialog();
            });

            RunDlg <DocumentSettingsDlg>(SkylineWindow.ShowDocumentSettingsDialog, documentSettingsDlg =>
            {
                documentSettingsDlg.SelectTab(DocumentSettingsDlg.TABS.reports);
                documentSettingsDlg.ChooseViewsControl.CheckedViews =
                    new[] { PersistedViews.MainGroup.Id.ViewName(reportName) };
                documentSettingsDlg.OkDialog();
            });
            RunUI(() => SkylineWindow.SaveDocument(Path.Combine(TestContext.TestDir, "ListClusteringTest.sky")));
            AssertEx.Serializable(SkylineWindow.Document);
            OkDialog(listGrid, listGrid.Close);
        }