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);
            }
        }
Example #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);
            }
        }