public override void Dispose(bool isDisposing)
        {
            _parent = null;
            _availableTransfoStyles = null;
            _availableNormalStyles  = null;
            _currentNormalStyles    = null;
            _availableUpdateModes   = null;
            _currentTransfoStyle    = null;

            base.Dispose(isDisposing);
        }
Exemple #2
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();
        }
        protected override void Initialize(bool initData)
        {
            base.Initialize(initData);

            if (initData)
            {
                // 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 : (ICoordinateTransformingGroupStyle)_doc.CoordinateTransformingStyle.Clone();
                _availableTransfoStyles = new SelectableListNodeList
                {
                    new SelectableListNode("None", null, null == _currentTransfoStyle)
                };
                types = ReflectionService.GetNonAbstractSubclassesOf(typeof(ICoordinateTransformingGroupStyle));
                foreach (Type t in types)
                {
                    Type currentStyleType = _currentTransfoStyle == null ? null : _currentTransfoStyle.GetType();
                    ICoordinateTransformingGroupStyle style;
                    if (t == currentStyleType)
                    {
                        style = _currentTransfoStyle;
                    }
                    else
                    {
                        style = (ICoordinateTransformingGroupStyle)Activator.CreateInstance(t);
                    }

                    _availableTransfoStyles.Add(new SelectableListNode(Current.Gui.GetUserFriendlyClassName(t), style, t == currentStyleType));
                }

                // Normal Styles
                _availableNormalStyles = new SelectableListNodeList();
                if (_parent != null) // if possible, collect only those styles that are applicable
                {
                    var 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));
                        }
                    }
                }

                var list = _doc.GetOrderedListOfItems(ComparePlotGroupStyles);
                _currentNormalStyles = new CheckableSelectableListNodeList();
                _currentNoOfItemsThatCanHaveChilds = 0;
                foreach (var item in list)
                {
                    if (item.CanCarryOver)
                    {
                        ++_currentNoOfItemsThatCanHaveChilds;
                    }

                    var node = new MyListNode(Current.Gui.GetUserFriendlyClassName(item.GetType()), item.GetType(), false, item.IsStepEnabled, item.CanStep);

                    _currentNormalStyles.Add(node);
                }
                UpdateCurrentNormalIndentation();
            }

            if (_view != null)
            {
                _view.InitializeAvailableCoordinateTransformingGroupStyles(_availableTransfoStyles);
                _view.InitializeAvailableNormalGroupStyles(_availableNormalStyles);
                _view.InitializeCurrentNormalGroupStyles(_currentNormalStyles);
                _view.InitializeUpdateMode(_availableUpdateModes, _doc.InheritFromParentGroups, _doc.DistributeToChildGroups);
            }
        }
    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();
    }
Exemple #5
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);
      }
    }
Exemple #7
0
 /// <summary>
 /// Sets the items of a list box with <see cref="CheckableSelectableListNode"/> items. We presume here that the ListBox has an appropriate DataTemplate, thus only the ItemsSource
 /// property of the ListBox is set with the data.
 /// </summary>
 /// <param name="view">ListBox to set.</param>
 /// <param name="data">The data to set for the ListBox.</param>
 public static void Initialize(ListBox view, CheckableSelectableListNodeList data)
 {
     view.ItemsSource = data;
 }