예제 #1
0
        public override void OnRefresh()
        {
            base.OnRefresh();

            AllowCheckedEvent = false;

            // get a list of all possible dates from datasource
            DataProcessor Processor        = new DataProcessor();
            List <string> DefaultFileNames = new List <string>();

            UIUtility.OutputFileUtility.GetOutputFiles(Controller, Controller.Selection, DefaultFileNames);
            Processor.DefaultOutputFileNames = DefaultFileNames;

            XmlDocument Doc = new XmlDocument();

            Doc.LoadXml(Controller.ApsimData.Find(NodePath).FullXML());
            DataTable DepthData = Processor.GoFindChildDataTable(Doc.DocumentElement);

            // get a list of currently selected dates.
            List <string> SelectedDates = XmlHelper.Values(Data, "Date");

            // Convert all dd/mm/yyyy dates in XML to date strings formatted according to current
            // locale.
            for (int i = 0; i < SelectedDates.Count; i++)
            {
                try
                {
                    DateTime d = DateTime.ParseExact(SelectedDates[i], "d/M/yyyy", null);
                    SelectedDates[i] = d.ToShortDateString();
                }
                catch (Exception)
                {
                    SelectedDates[i] = "";
                }
            }

            DateList.Items.Clear();
            if (DepthData != null)
            {
                List <string> DateStrings = DataTableUtility.GetDistinctValues(DepthData, "Date");
                foreach (string DateString in DateStrings)
                {
                    string St         = DateString.Substring(0, DateString.IndexOf(' '));
                    int    Indx       = DateList.Items.Add(St);
                    bool   IsSelected = SelectedDates.IndexOf(St) != -1;
                    DateList.SetItemChecked(Indx, IsSelected);
                }
            }
            AllowCheckedEvent = true;
        }
예제 #2
0
    public bool GroupByTitle(DataView Data)
    {
        // -------------------------------------------------
        // Used by the data processors to group the Data
        // into 'series'. The 'title' column is used to
        // group the data. This method is called repeatedly
        // until it returns false.
        // e.g.
        //    col1   col2   col3    title
        //      10      ?     20    TestFile1
        //      11      5     21    TestFile1
        //       ?      6     22    TestFile1
        //     100     10    120    TestFile2
        //     112     25    121    TestFile2
        //     116     46    122    TestFile2
        // A first call to this method with this data will
        // return all data for title = TestFile1. A second
        // call will return all data for title = TestFile2.
        // A third call will return false.
        // -------------------------------------------------

        if (Data.RowFilter == "")
        {
            TitleFilters      = DataTableUtility.GetDistinctValues(Data.Table, "title");
            TitleFilterNumber = 0;
        }
        else
        {
            TitleFilterNumber++;
            if (TitleFilterNumber >= TitleFilters.Count)
            {
                Data.RowFilter = "";
                return(false);
            }
        }
        if (TitleFilters.Count == 0)
        {
            return(false);
        }

        Data.RowFilter = "Title = '" + TitleFilters[TitleFilterNumber] + "'";
        return(true);
    }