public void EhView_AddNormalGroupStyle()
        {
            SelectableListNode selected = null;

            foreach (SelectableListNode node in _availableNormalStyles)
            {
                if (node.IsSelected)
                {
                    selected = node;
                    break;
                }
            }
            if (null != selected)
            {
                _availableNormalStyles.Remove(selected);

                var s = (IPlotGroupStyle)Activator.CreateInstance((Type)selected.Tag);
                _doc.Add(s);
                var node = new MyListNode(
                    Current.Gui.GetUserFriendlyClassName(s.GetType()),
                    s.GetType(), true, s.IsStepEnabled, s.CanStep);
                if (s.CanCarryOver)
                {
                    _currentNormalStyles.Insert(_currentNoOfItemsThatCanHaveChilds, node);
                    _currentNoOfItemsThatCanHaveChilds++;
                }
                else
                {
                    _currentNormalStyles.Add(node);
                }

                _view.InitializeAvailableNormalGroupStyles(_availableNormalStyles);
                _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
            }
        }
Ejemplo n.º 2
0
        void Initialize(bool initDoc)
        {
            if (initDoc)
            {
                // available Update modes
                _availableUpdateModes = new SelectableListNodeList();
                foreach (object obj in Enum.GetValues(typeof(PlotGroupStrictness)))
                {
                    _availableUpdateModes.Add(new SelectableListNode(obj.ToString(), obj, ((PlotGroupStrictness)obj) == PlotGroupStrictness.Normal));
                }

                Type[] types;
                // Transfo-Styles
                _currentTransfoStyle    = _doc.CoordinateTransformingStyle == null ? null : _doc.CoordinateTransformingStyle.GetType();
                _availableTransfoStyles = new SelectableListNodeList();
                _availableTransfoStyles.Add(new SelectableListNode("None", null, null == _currentTransfoStyle));
                types = ReflectionService.GetNonAbstractSubclassesOf(typeof(ICoordinateTransformingGroupStyle));
                foreach (Type t in types)
                {
                    _availableTransfoStyles.Add(new SelectableListNode(Current.Gui.GetUserFriendlyClassName(t), t, t == _currentTransfoStyle));
                }

                // Normal Styles
                _availableNormalStyles = new SelectableListNodeList();
                if (_parent != null) // if possible, collect only those styles that are applicable
                {
                    PlotGroupStyleCollection avstyles = new PlotGroupStyleCollection();
                    _parent.CollectStyles(avstyles);
                    foreach (IPlotGroupStyle style in avstyles)
                    {
                        if (!_doc.ContainsType(style.GetType()))
                        {
                            _availableNormalStyles.Add(new SelectableListNode(Current.Gui.GetUserFriendlyClassName(style.GetType()), style.GetType(), false));
                        }
                    }
                }
                else // or else, find all available styles
                {
                    types = ReflectionService.GetNonAbstractSubclassesOf(typeof(IPlotGroupStyle));
                    foreach (Type t in types)
                    {
                        if (!_doc.ContainsType(t))
                        {
                            _availableNormalStyles.Add(new SelectableListNode(Current.Gui.GetUserFriendlyClassName(t), t, false));
                        }
                    }
                }

                _currentNormalStyles = new CheckableSelectableListNodeList();
                _currentStepItems    = 0;
                // first those items that have no childs
                foreach (IPlotGroupStyle s in _doc)
                {
                    CheckableSelectableListNode node = new CheckableSelectableListNode(Current.Gui.GetUserFriendlyClassName(s.GetType()), s.GetType(), false, false);

                    if (s.CanHaveChilds())
                    {
                        node.Checked = s.IsStepEnabled;
                        _currentNormalStyles.Insert(_currentStepItems, node);
                        _currentStepItems++;
                    }
                    else
                    {
                        node.Checked = s.IsStepEnabled;
                        _currentNormalStyles.Add(node);
                    }
                }

                UpdateCurrentNormalOrder(); // bring the items in the right order
            }
            if (_view != null)
            {
                _view.InitializeAvailableCoordinateTransformingGroupStyles(_availableTransfoStyles);
                _view.InitializeAvailableNormalGroupStyles(_availableNormalStyles);
                _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
                _view.InitializeUpdateMode(_availableUpdateModes, _doc.InheritFromParentGroups, _doc.DistributeToChildGroups);
            }
        }
    void Initialize(bool initDoc)
    {
      if (initDoc)
      {
        // available Update modes
        _availableUpdateModes = new SelectableListNodeList();
        foreach (object obj in Enum.GetValues(typeof(PlotGroupStrictness)))
          _availableUpdateModes.Add(new SelectableListNode(obj.ToString(), obj, ((PlotGroupStrictness)obj) == PlotGroupStrictness.Normal));

        Type[] types;
        // Transfo-Styles
        _currentTransfoStyle = _doc.CoordinateTransformingStyle == null ? null : _doc.CoordinateTransformingStyle.GetType();
        _availableTransfoStyles = new SelectableListNodeList();
        _availableTransfoStyles.Add(new SelectableListNode("None",null,null==_currentTransfoStyle));
         types = ReflectionService.GetNonAbstractSubclassesOf(typeof(ICoordinateTransformingGroupStyle));
        foreach (Type t in types)
        {
            _availableTransfoStyles.Add(new SelectableListNode(Current.Gui.GetUserFriendlyClassName(t), t, t==_currentTransfoStyle));
        }

        // Normal Styles
        _availableNormalStyles = new SelectableListNodeList();
        if (_parent != null) // if possible, collect only those styles that are applicable
        {
          PlotGroupStyleCollection avstyles = new PlotGroupStyleCollection();
          _parent.CollectStyles(avstyles);
          foreach(IPlotGroupStyle style in avstyles)
          {
            if(!_doc.ContainsType(style.GetType()))
            _availableNormalStyles.Add(new SelectableListNode(Current.Gui.GetUserFriendlyClassName(style.GetType()),style.GetType(),false));
          }
        }
        else // or else, find all available styles
        {
          types = ReflectionService.GetNonAbstractSubclassesOf(typeof(IPlotGroupStyle));
          foreach (Type t in types)
          {
            if (!_doc.ContainsType(t))
              _availableNormalStyles.Add(new SelectableListNode(Current.Gui.GetUserFriendlyClassName(t), t, false));
          }
        }

        _currentNormalStyles = new CheckableSelectableListNodeList();
        _currentStepItems = 0;
          // first those items that have no childs
        foreach (IPlotGroupStyle s in _doc)
        {
          CheckableSelectableListNode node = new CheckableSelectableListNode(Current.Gui.GetUserFriendlyClassName(s.GetType()), s.GetType(), false, false);

          if (s.CanHaveChilds())
          {
            node.Checked = s.IsStepEnabled;
            _currentNormalStyles.Insert(_currentStepItems, node);
            _currentStepItems++;
          }
          else
          {
            node.Checked = s.IsStepEnabled;
            _currentNormalStyles.Add(node);
          }
        }
        
       UpdateCurrentNormalOrder(); // bring the items in the right order
      }
      if (_view != null)
      {
        _view.InitializeAvailableCoordinateTransformingGroupStyles(_availableTransfoStyles);
        _view.InitializeAvailableNormalGroupStyles(_availableNormalStyles);
        _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
        _view.InitializeUpdateMode(_availableUpdateModes, _doc.InheritFromParentGroups, _doc.DistributeToChildGroups);
      }
    }