示例#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 override string ToString()
 {
     if (DateString.StartsWith("BET 1 JAN"))
     {
         return("BET " + DateString.Substring(10));
     }
     else if (DateString.StartsWith("AFT 1 JAN"))
     {
         return("AFT " + DateString.Substring(10));
     }
     else
     {
         return(DateString);
     }
 }