protected void DoAddInterface()
    {
      if (m_AddSelector.ShowDialog() == DialogResult.Cancel) return;

      ProjectVectorItem item = null;
      if (m_AddSelector.radioAttribute.Checked)
      {
        item = new ProjectAttribute();
        item.Name = GetNextName("Att"); item.Valid = false;
      }
      else if (m_AddSelector.radioCalculation.Checked)
      {
        item = new ProjectCalculation();
        item.Name = GetNextName("Calc"); item.Valid = false;
      }
      else if (m_AddSelector.radioLabel.Checked)
      {
        item = new ProjectText();
        item.Name = GetNextName("Label");
      }
      else if (m_AddSelector.radioPageBreak.Checked)
      {
        item = new ProjectPage();
        item.Name = GetNextName("Page");
      }

      if (lstProjectVector.SelectedItems.Count == 0)
        lstProjectVector.Items.Add(item.LVI);
      else
        lstProjectVector.Items.Insert(lstProjectVector.SelectedIndices[0], item.LVI);

      lstProjectVector.SelectedItems.Clear();
      item.Changed += new EventHandler(item_Changed);
      item.LVI.Selected = true;
    }
Example #2
0
 public static ProjectText Parse(Match m)
 {
   ProjectText ret = new ProjectText();
   ret.Value = m.Groups["Value"].Value;
   return ret;
 }
    /* Logic: We are going to look through the source list, and break it into sub lists.
     * We will start with a list of preserved items. And the reordered items will be the item
     * which exactly follows the corresponding list 
     * */
    public List<ProjectVectorItem> Sort(List<ProjectVectorItem> Source)
    {
      //New Code:
      ProjectSpecie.CachePhase = true;
      List<ProjectVectorItem> PreservedItems = new List<ProjectVectorItem>();
      List<List<ProjectVectorItem>> ReOrderedItems = new List<List<ProjectVectorItem>>();

      List<ProjectVectorItem> currentReorder = new List<ProjectVectorItem>();
      ReOrderedItems.Add(currentReorder);
      foreach (ProjectVectorItem pvi in Source)
      {
        if (m_bByPhase && IsPhaseLabel(pvi.Value) && pvi is ProjectText)
          continue;
        else if ((m_bPreservePageAndLabelLocations &&
            (pvi is ProjectText || pvi is ProjectPage)) ||
            (m_bPreserveCalculationLocations &&
            (pvi is ProjectCalculation)))
        {
          PreservedItems.Add(pvi);
          ReOrderedItems.Add(currentReorder = new List<ProjectVectorItem>());
        }
        else
          currentReorder.Add(pvi);
      }
      ProjectSpecie.SortByPhase = m_bByPhase;
      ProjectSpecie.PhaseOrder = m_PhaseOrder;
      foreach (List<ProjectVectorItem> lst in ReOrderedItems)
        lst.Sort(new Comparison<ProjectVectorItem>(SimpleComparison));

      List<ProjectVectorItem> intermediate = new List<ProjectVectorItem>(Source.Count);
      for (int i = 0; i < PreservedItems.Count; i++)
      {
        intermediate.AddRange(ReOrderedItems[i]);
        intermediate.Add(PreservedItems[i]);
      }
      intermediate.AddRange(ReOrderedItems[ReOrderedItems.Count - 1]);

      List<ProjectVectorItem> ret = new List<ProjectVectorItem>();

      Phase lastPhase = (Phase)(-1);
      foreach (ProjectVectorItem pvi in intermediate)
      {
        if (m_bByPhase && pvi is ProjectText &&
            IsPhaseLabel(pvi.Value))
          continue; //Don't add these labels.
        if (m_bByPhase && pvi is ProjectSpecie && ((ProjectSpecie)pvi).Phase != lastPhase)
        {
          lastPhase = ((ProjectSpecie)pvi).Phase;
          ProjectText txt = new ProjectText();
          txt.Value = lastPhase.ToString();
          ret.Add(txt);
        }
        if (m_bPreservePageAndLabelLocations || !(pvi is ProjectPage))
          ret.Add(pvi);
      }

      ProjectSpecie.CachePhase = false;

      return ret;
    }