public void EhView_MoveDownGroupStyle()
        {
            if (0 == _currentNoOfItemsThatCanHaveChilds || _currentNormalStyles[_currentNoOfItemsThatCanHaveChilds - 1].IsSelected)
            {
                return; // can not move down any more
            }
            for (int i = _currentNoOfItemsThatCanHaveChilds - 2; i >= 0; i--)
            {
                CheckableSelectableListNode selected = _currentNormalStyles[i];
                if (!selected.IsSelected)
                {
                    continue;
                }

                IPlotGroupStyle style     = _doc.GetPlotGroupStyle((Type)selected.Tag);
                Type            childtype = _doc.GetTypeOfChild(style.GetType());
                _doc.RemoveType(style.GetType()); // Removing the type so removing also the parent-child-relationship
                if (childtype == null)
                {
                    _doc.Add(style);
                }
                else
                {
                    _doc.Add(style, childtype); // Add the type, but the child type this time is the parent type
                }
                _currentNormalStyles.Exchange(i, i + 1);
            }
            // this requires the whole currentNormalStyle list to be updated
            UpdateCurrentNormalOrder();
            _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
        }
        public void EhView_RemoveNormalGroupStyle()
        {
            for (int i = _currentNormalStyles.Count - 1; i >= 0; i--)
            {
                CheckableSelectableListNode selected = _currentNormalStyles[i];
                if (!selected.IsSelected)
                {
                    continue;
                }

                _doc.RemoveType((Type)selected.Tag);

                _currentNormalStyles.RemoveAt(i);
                if (i < _currentNoOfItemsThatCanHaveChilds)
                {
                    _currentNoOfItemsThatCanHaveChilds--;
                }

                _availableNormalStyles.Add(new SelectableListNode(
                                               Current.Gui.GetUserFriendlyClassName((Type)selected.Tag),
                                               selected.Tag,
                                               true));
            }

            UpdateCurrentNormalIndentation();
            _view.InitializeAvailableNormalGroupStyles(_availableNormalStyles);
            _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
        }
        public void EhView_IndentGroupStyle()
        {
            // for all selected items: append it as child to the item upward
            int count = Math.Min(_currentNoOfItemsThatCanHaveChilds + 1, _currentNormalStyles.Count); // note: the first item that can step, but can not have childs, could also be indented, thats why 1+

            for (int i = 1; i < count; ++i)
            {
                CheckableSelectableListNode selected = _currentNormalStyles[i];
                if (!selected.IsSelected)
                {
                    continue;
                }

                if (null != _doc.GetParentTypeOf((Type)selected.Tag))
                {
                    continue; // only ident those items who dont have a parent
                }
                IPlotGroupStyle style = _doc.GetPlotGroupStyle((Type)selected.Tag);
                _doc.RemoveType(style.GetType());                       // Removing the type so removing also the parent-child-relationship
                _doc.Add(style, (Type)_currentNormalStyles[i - 1].Tag); // Add the type again, but this time without parents or childs
            }
            // this requires the whole currentNormalStyle list to be updated
            UpdateCurrentNormalOrder();
            UpdateCurrentNormalIndentation();
            _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
        }
Ejemplo n.º 4
0
        public void EhView_MoveUpGroupStyle()
        {
            if (0 == _currentStepItems || _currentNormalStyles[0].Selected)
            {
                return; // can not move up any more
            }
            for (int i = 1; i < _currentStepItems; i++)
            {
                CheckableSelectableListNode selected = _currentNormalStyles[i];
                if (!selected.Selected)
                {
                    continue;
                }

                IPlotGroupStyle style      = _doc.GetPlotGroupStyle((Type)selected.Item);
                Type            parenttype = _doc.GetParentTypeOf(style.GetType());
                _doc.RemoveType(style.GetType()); // Removing the type so removing also the parent-child-relationship
                if (parenttype == null)
                {
                    _doc.Add(style);
                }
                else
                {
                    _doc.Insert(style, parenttype); // Add the type, but parent type is this time the child type
                }
                _currentNormalStyles.Exchange(i, i - 1);
            }
            // this requires the whole currentNormalStyle list to be updated
            UpdateCurrentNormalOrder();
            _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
        }
Ejemplo n.º 5
0
        public void EhView_AddNormalGroupStyle()
        {
            SelectableListNode selected = null;

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

                IPlotGroupStyle s = (IPlotGroupStyle)Activator.CreateInstance((Type)selected.Item);
                _doc.Add(s);
                CheckableSelectableListNode node = new CheckableSelectableListNode(
                    Current.Gui.GetUserFriendlyClassName(s.GetType()),
                    s.GetType(), true, s.IsStepEnabled);
                if (s.CanHaveChilds())
                {
                    _currentNormalStyles.Insert(_currentStepItems, node);
                    _currentStepItems++;
                }
                else
                {
                    _currentNormalStyles.Add(node);
                }

                _view.InitializeAvailableNormalGroupStyles(_availableNormalStyles);
                _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
            }
        }
Ejemplo n.º 6
0
        void InitializeCheckedListBox(CheckedListBox box, CheckableSelectableListNodeList list)
        {
            box.BeginUpdate();
            box.Items.Clear();
            for (int i = 0; i < list.Count; i++)
            {
                CheckableSelectableListNode node = list[i];

                box.Items.Add(node, node.Checked);
                if (node.Selected)
                {
                    box.SelectedIndices.Add(i);
                }
            }

            box.EndUpdate();
        }
        /// <summary>
        /// This updates the list, presuming that the number of items has not changed.
        /// </summary>
        private void UpdateCurrentNormalOrder()
        {
            // if possible, we try to maintain the order in the list in which the items
            // appear

            if (0 == _currentNoOfItemsThatCanHaveChilds)
            {
                return; // then there is nothing to do now
            }
            IPlotGroupStyle previousStyle = null;
            IPlotGroupStyle style         = null;

            for (int i = 0; i < _currentNoOfItemsThatCanHaveChilds; i++, previousStyle = style)
            {
                CheckableSelectableListNode node = _currentNormalStyles[i];
                style = _doc.GetPlotGroupStyle((Type)node.Tag);

                if (previousStyle != null)
                {
                    Type prevchildtype = _doc.GetTypeOfChild(previousStyle.GetType());
                    if (prevchildtype != null)
                    {
                        if (prevchildtype != style.GetType())
                        {
                            int pi = _currentNormalStyles.IndexOfObject(prevchildtype);
                            _currentNormalStyles.Exchange(i, pi);
                        }
                        continue;
                    }
                }

                Type parenttype = _doc.GetParentTypeOf(style.GetType());
                if (parenttype != null &&
                    (previousStyle == null || previousStyle.GetType() != parenttype))
                {
                    int pi = _currentNormalStyles.IndexOfObject(parenttype);
                    _currentNormalStyles.Exchange(i, pi);
                }
            }
            UpdateCurrentNormalIndentation();
        }
Ejemplo n.º 8
0
        public void EhView_UnindentGroupStyle()
        {
            // make sure that all the selected items are not child of another item
            for (int i = _currentNormalStyles.Count - 1; i >= 0; i--)
            {
                CheckableSelectableListNode selected = _currentNormalStyles[i];
                if (!selected.Selected)
                {
                    continue;
                }

                if (null != _doc.GetParentTypeOf((Type)selected.Item))
                {
                    IPlotGroupStyle style = _doc.GetPlotGroupStyle((Type)selected.Item);
                    _doc.RemoveType(style.GetType()); // Removing the type so removing also the parent-child-relationship
                    _doc.Add(style);                  // Add the type again, but this time without parents or childs
                }
            }

            // this requires the whole currentNormalStyle list to be updated
            UpdateCurrentNormalOrder();
            _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
        }
Ejemplo n.º 9
0
        public void EhView_IndentGroupStyle()
        {
            // for all selected items: append it as child to the item upward

            for (int i = 1; i < _currentStepItems; i++)
            {
                CheckableSelectableListNode selected = _currentNormalStyles[i];
                if (!selected.Selected)
                {
                    continue;
                }

                if (null != _doc.GetParentTypeOf((Type)selected.Item))
                {
                    continue; // only ident those items who dont have a parent
                }
                IPlotGroupStyle style = _doc.GetPlotGroupStyle((Type)selected.Item);
                _doc.RemoveType(style.GetType());                        // Removing the type so removing also the parent-child-relationship
                _doc.Add(style, (Type)_currentNormalStyles[i - 1].Item); // Add the type again, but this time without parents or childs
            }
            // this requires the whole currentNormalStyle list to be updated
            UpdateCurrentNormalOrder();
            _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
        }
Ejemplo n.º 10
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);
      }
    }
    public void EhView_AddNormalGroupStyle()
    {
      SelectableListNode selected = null;
      foreach (SelectableListNode node in _availableNormalStyles)
      {
        if (node.Selected)
        {
          selected = node;
          break;
        }
      }
      if (null != selected)
      {
        _availableNormalStyles.Remove(selected);

        IPlotGroupStyle s = (IPlotGroupStyle)Activator.CreateInstance((Type)selected.Item);
        _doc.Add(s);
        CheckableSelectableListNode node = new CheckableSelectableListNode(
          Current.Gui.GetUserFriendlyClassName(s.GetType()),
          s.GetType(), true, s.IsStepEnabled);
        if (s.CanHaveChilds())
        {
          _currentNormalStyles.Insert(_currentStepItems, node);
          _currentStepItems++;
        }
        else
        {
          _currentNormalStyles.Add(node);
        }

        _view.InitializeAvailableNormalGroupStyles(_availableNormalStyles);
        _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
      }
    }