Ejemplo n.º 1
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                int count = info.OpenArray();

                IG2DPlotStyle[] array = new IG2DPlotStyle[count];
                for (int i = 0; i < count; i++)
                {
                    array[i] = (IG2DPlotStyle)info.GetValue("e", this);
                }
                info.CloseArray(count);

                if (o == null)
                {
                    return(new G2DPlotStyleCollection(array));
                }
                else
                {
                    G2DPlotStyleCollection s = (G2DPlotStyleCollection)o;
                    for (int i = count - 1; i >= 0; i--)
                    {
                        s.Add(array[i]);
                    }
                    return(s);
                }
            }
Ejemplo n.º 2
0
        /// <summary>
        /// Prepares a new substyle (one that is not already in the collection) for becoming member of the collection. The substyle will get
        /// all distributes group properties (local only) of this style collection.
        /// </summary>
        /// <param name="newSubStyle">Sub style to prepare.</param>
        /// <param name="layer"></param>
        /// <param name="pdata"></param>
        public void PrepareNewSubStyle(IG2DPlotStyle newSubStyle, IPlotArea layer, Processed2DPlotData pdata)
        {
            var externGroup = new PlotGroupStyleCollection();
            var localGroup  = new PlotGroupStyleCollection();

            // because we don't step, the order is essential only for PrepareStyles
            for (int i = 0; i < _innerList.Count; i++)
            {
                this[i].CollectLocalGroupStyles(externGroup, localGroup);
            }
            newSubStyle.CollectLocalGroupStyles(externGroup, localGroup);

            // prepare
            for (int i = 0; i < Count; i++)
            {
                this[i].PrepareGroupStyles(externGroup, localGroup, layer, pdata);
            }
            newSubStyle.PrepareGroupStyles(externGroup, localGroup, layer, pdata);

            // apply
            for (int i = 0; i < Count; i++)
            {
                this[i].ApplyGroupStyles(externGroup, localGroup);
            }
            newSubStyle.ApplyGroupStyles(externGroup, localGroup);
        }
Ejemplo n.º 3
0
        public void RemoveAt(int idx)
        {
            IG2DPlotStyle removed = this[idx];

            _innerList.RemoveAt(idx);

            EhSelfChanged(EventArgs.Empty);
        }
Ejemplo n.º 4
0
        public void ExchangeItemPositions(int pos1, int pos2)
        {
            IG2DPlotStyle item1 = this[pos1];

            _innerList[pos1] = _innerList[pos2];
            _innerList[pos2] = item1;

            EhSelfChanged(EventArgs.Empty);
        }
Ejemplo n.º 5
0
        public void Insert(int whichposition, IG2DPlotStyle toinsert)
        {
            if (toinsert != null)
            {
                _innerList.Insert(whichposition, toinsert);
                toinsert.ParentObject = this;

                EhSelfChanged(EventArgs.Empty);
            }
        }
Ejemplo n.º 6
0
        protected void Replace(IG2DPlotStyle ps, int idx, bool withReorganizationAndEvents)
        {
            if (ps != null)
            {
                _innerList[idx] = ps;
                ps.ParentObject = this;

                if (withReorganizationAndEvents)
                {
                    EhSelfChanged(EventArgs.Empty);
                }
            }
        }
Ejemplo n.º 7
0
        protected void Add(IG2DPlotStyle toadd, bool withReorganizationAndEvents)
        {
            if (toadd != null)
            {
                _innerList.Add(toadd);
                toadd.ParentObject = this;

                if (withReorganizationAndEvents)
                {
                    EhSelfChanged(EventArgs.Empty);
                }
            }
        }
Ejemplo n.º 8
0
        IMVCANController GetStyleController(IG2DPlotStyle style)
        {
            if (_styleControllerDictionary.ContainsKey(style))
            {
                return(_styleControllerDictionary[style]);
            }

            IMVCANController ct = (IMVCANController)Current.Gui.GetControllerAndControl(new object[] { style }, typeof(IMVCANController), UseDocument.Directly);

            if (ct != null)
            {
                _styleControllerDictionary.Add(style, ct);
            }

            return(ct);
        }
        public virtual void EhView_AddStyle(int[] selindices, int nstyle)
        {
            IG2DPlotStyle style    = (IG2DPlotStyle)Activator.CreateInstance(this._plotStyleTypes[nstyle]);
            IPlotArea     layer    = Main.DocumentPath.GetRootNodeImplementing <IPlotArea>(_doc);
            G2DPlotItem   plotitem = Main.DocumentPath.GetRootNodeImplementing <G2DPlotItem>(_doc);

            if (layer != null && plotitem != null)
            {
                _doc.PrepareNewSubStyle(style, layer, plotitem.GetRangesAndPoints(layer));
            }

            _tempdoc.Add(style);
            UpdateStyleList(new int[] {});

            OnCollectionChangeCommit();
        }
Ejemplo n.º 10
0
        void MakeAdditionalPlotStylePermanent()
        {
            IG2DPlotStyle additionalPlotStyle = _additionalPlotStyle;

            _additionalPlotStyle = null;

            if (additionalPlotStyle is LinePlotStyle)
            {
                _tempdoc.Style.Insert(1, additionalPlotStyle);
                _styleControllerList.Insert(1, _additionalPlotStyleController);
                _additionalPlotStyleController = null;
                DistributeStyleChange(1);
                _styleCollectionController.InitializeDocument(_tempdoc.Style);
            }
            else if (additionalPlotStyle is ScatterPlotStyle)
            {
                _tempdoc.Style.Insert(0, additionalPlotStyle);
                _styleControllerList.Insert(0, _additionalPlotStyleController);
                _additionalPlotStyleController = null;
                DistributeStyleChange(0);
                _styleCollectionController.InitializeDocument(_tempdoc.Style);
            }
        }
        public virtual void EhView_AddStyle()
        {
            var sel = _singleStylesAvailable.FirstSelectedNode;

            if (null == sel)
            {
                return;
            }

            var           propertyContext = Altaxo.PropertyExtensions.GetPropertyContext(_doc);
            IG2DPlotStyle style           = null;

            try
            {
                style = (IG2DPlotStyle)Activator.CreateInstance((Type)sel.Tag, propertyContext); // first try with a constructor which uses a property context
            }
            catch (System.MissingMethodException)
            {
            }

            if (null == style)                                                  // if style was not constructed
            {
                style = (IG2DPlotStyle)Activator.CreateInstance((Type)sel.Tag); // try with parameterless constructor
            }
            IPlotArea   layer    = AbsoluteDocumentPath.GetRootNodeImplementing <IPlotArea>(_doc);
            G2DPlotItem plotitem = AbsoluteDocumentPath.GetRootNodeImplementing <G2DPlotItem>(_doc);

            if (layer != null && plotitem != null)
            {
                _doc.PrepareNewSubStyle(style, layer, plotitem.GetRangesAndPoints(layer));
            }

            _currentItems.Add <IG2DPlotStyle>(new SelectableListNode(Current.Gui.GetUserFriendlyClassName(style.GetType()), style, true), (docNodeToAdd) => _doc.Add(docNodeToAdd));

            OnCollectionChangeCommit();
        }
Ejemplo n.º 12
0
        void InitializeStyles()
        {
            // Clear the previous controller cache
            _additionalPlotStyle = null;
            if (_combinedScatterLineGroupController != null)
            {
                _combinedScatterLineGroupController.ChildControlChanged -= EhView_ActiveChildControlChanged;
                _combinedScatterLineGroupController = null;
            }
            _styleControllerList.Clear();


            // start to create new controllers
            if (_tempdoc.Style.Count > 0)
            {
                bool addHelperStyle = NeedsHelperStyle();
                bool useCombinedTab = UseCombinedScatterLineGroupTab();


                if (useCombinedTab)
                {
                    List <ControlViewElement> combList = new List <ControlViewElement>();

                    // create the controllers
                    IMVCANController ct1 = GetStyleController(_tempdoc.Style[0]);
                    _styleControllerList.Add(ct1);


                    if (addHelperStyle)
                    {
                        IPlotArea layer = Main.DocumentPath.GetRootNodeImplementing <IPlotArea>(_doc);
                        // add either line or scatter
                        if (_tempdoc.Style[0] is LinePlotStyle)
                        {
                            ScatterPlotStyle scatterStyle = new ScatterPlotStyle();
                            scatterStyle.ParentObject = _tempdoc.Style;
                            _tempdoc.Style.PrepareNewSubStyle(scatterStyle, layer, _doc.GetRangesAndPoints(layer));
                            _additionalPlotStyle = scatterStyle;
                            scatterStyle.Shape   = Altaxo.Graph.Gdi.Plot.Styles.XYPlotScatterStyles.Shape.NoSymbol;

                            _additionalPlotStyleController = GetStyleController(_additionalPlotStyle);
                            combList.Add(new ControlViewElement("Symbol", _additionalPlotStyleController));
                            combList.Add(new ControlViewElement("Line", ct1));
                        }
                        else
                        {
                            LinePlotStyle lineStyle = new LinePlotStyle();
                            lineStyle.ParentObject = _tempdoc.Style;
                            _tempdoc.Style.PrepareNewSubStyle(lineStyle, layer, _doc.GetRangesAndPoints(layer));
                            _additionalPlotStyle = lineStyle;
                            lineStyle.Connection = Altaxo.Graph.Gdi.Plot.Styles.XYPlotLineStyles.ConnectionStyle.NoLine;

                            _additionalPlotStyleController = GetStyleController(_additionalPlotStyle);
                            combList.Add(new ControlViewElement("Symbol", ct1));
                            combList.Add(new ControlViewElement("Line", _additionalPlotStyleController));
                        }
                    }
                    else // no helper style, i.e. second style is line style
                    {
                        // create the controllers
                        IMVCANController ct2 = GetStyleController(_tempdoc.Style[1]);
                        _styleControllerList.Add(ct2);
                        combList.Add(new ControlViewElement("Symbol", ct1));
                        combList.Add(new ControlViewElement("Line", ct2));
                    }

                    combList.Add(new ControlViewElement(string.Empty, this, this._plotGroupView));
                    _combinedScatterLineGroupController = new Common.MultiChildController(combList.ToArray(), true);
                    Current.Gui.FindAndAttachControlTo(_combinedScatterLineGroupController);
                    string title;
                    if (null != _additionalPlotStyle)
                    {
                        title = string.Format("#{0}:{1}", 1, Current.Gui.GetUserFriendlyClassName(_tempdoc.Style[0].GetType()));
                    }
                    else
                    {
                        title = "#1&&2:Symbol&&Line";
                    }
                    AddTab(title, _combinedScatterLineGroupController, _combinedScatterLineGroupController.ViewObject);
                    _combinedScatterLineGroupController.ChildControlChanged += this.EhView_ActiveChildControlChanged;
                } // if use CombinedTab

                // now the remaining styles
                int start = useCombinedTab ? (addHelperStyle ? 1 : 2) : 0;
                for (int i = start; i < _tempdoc.Style.Count; i++)
                {
                    IMVCANController ctrl = GetStyleController(_tempdoc.Style[i]);
                    _styleControllerList.Add(ctrl);
                    string title = string.Format("#{0}:{1}", (i + 1), Current.Gui.GetUserFriendlyClassName(_tempdoc.Style[i].GetType()));
                    AddTab(title, ctrl, ctrl != null ? ctrl.ViewObject : null);
                }
            }
            base.SetElements(false);
        }
    void MakeAdditionalPlotStylePermanent()
    {
      IG2DPlotStyle additionalPlotStyle = _additionalPlotStyle;
      _additionalPlotStyle = null;

      if (additionalPlotStyle is LinePlotStyle)
      {
        _tempdoc.Style.Insert(1, additionalPlotStyle);
        _styleControllerList.Insert(1, _additionalPlotStyleController);
        _additionalPlotStyleController = null;
        DistributeStyleChange(1);
        _styleCollectionController.InitializeDocument(_tempdoc.Style);
      }
      else if(additionalPlotStyle is ScatterPlotStyle)
      {
        _tempdoc.Style.Insert(0, additionalPlotStyle);
        _styleControllerList.Insert(0, _additionalPlotStyleController);
        _additionalPlotStyleController = null;
        DistributeStyleChange(0);
        _styleCollectionController.InitializeDocument(_tempdoc.Style);
      }
    }
    void InitializeStyles()
    {
      // Clear the previous controller cache
      _additionalPlotStyle = null;
      if (_combinedScatterLineGroupController != null)
      {
        _combinedScatterLineGroupController.ChildControlChanged -= EhView_ActiveChildControlChanged;
        _combinedScatterLineGroupController = null;
      }
      _styleControllerList.Clear();


      // start to create new controllers
      if (_tempdoc.Style.Count > 0)
      {
        bool addHelperStyle = NeedsHelperStyle();
        bool useCombinedTab = UseCombinedScatterLineGroupTab();


        if (useCombinedTab)
        {
          List<ControlViewElement> combList = new List<ControlViewElement>();

          // create the controllers
          IMVCANController ct1 = GetStyleController(_tempdoc.Style[0]);
          _styleControllerList.Add(ct1);


          if (addHelperStyle)
          {
            IPlotArea layer = Main.DocumentPath.GetRootNodeImplementing<IPlotArea>(_doc);
            // add either line or scatter
            if (_tempdoc.Style[0] is LinePlotStyle)
            {
              ScatterPlotStyle scatterStyle = new ScatterPlotStyle();
              scatterStyle.ParentObject = _tempdoc.Style;
              _tempdoc.Style.PrepareNewSubStyle(scatterStyle, layer, _doc.GetRangesAndPoints(layer));
              _additionalPlotStyle = scatterStyle;
              scatterStyle.Shape = Altaxo.Graph.Gdi.Plot.Styles.XYPlotScatterStyles.Shape.NoSymbol;

              _additionalPlotStyleController = GetStyleController( _additionalPlotStyle);
              combList.Add(new ControlViewElement("Symbol", _additionalPlotStyleController));
              combList.Add(new ControlViewElement("Line", ct1));
            }
            else
            {
              LinePlotStyle lineStyle = new LinePlotStyle();
              lineStyle.ParentObject = _tempdoc.Style;
              _tempdoc.Style.PrepareNewSubStyle(lineStyle, layer, _doc.GetRangesAndPoints(layer));
              _additionalPlotStyle = lineStyle;
              lineStyle.Connection = Altaxo.Graph.Gdi.Plot.Styles.XYPlotLineStyles.ConnectionStyle.NoLine;

              _additionalPlotStyleController = GetStyleController( _additionalPlotStyle );
              combList.Add(new ControlViewElement("Symbol", ct1));
              combList.Add(new ControlViewElement("Line", _additionalPlotStyleController));
            }
          }
          else // no helper style, i.e. second style is line style
          {
            // create the controllers
            IMVCANController ct2 = GetStyleController( _tempdoc.Style[1] );
            _styleControllerList.Add(ct2);
            combList.Add(new ControlViewElement("Symbol", ct1));
            combList.Add(new ControlViewElement("Line", ct2));
          }

          combList.Add(new ControlViewElement(string.Empty, this, this._plotGroupView));
          _combinedScatterLineGroupController = new Common.MultiChildController(combList.ToArray(), true);
          Current.Gui.FindAndAttachControlTo(_combinedScatterLineGroupController);
          string title;
          if(null!=_additionalPlotStyle)
            title = string.Format("#{0}:{1}", 1, Current.Gui.GetUserFriendlyClassName(_tempdoc.Style[0].GetType()));
          else
            title = "#1&&2:Symbol&&Line";
          AddTab(title, _combinedScatterLineGroupController, _combinedScatterLineGroupController.ViewObject);
          _combinedScatterLineGroupController.ChildControlChanged += this.EhView_ActiveChildControlChanged;
        } // if use CombinedTab

        // now the remaining styles
        int start = useCombinedTab ? (addHelperStyle ? 1 : 2) : 0;
        for (int i = start; i < _tempdoc.Style.Count; i++)
        {
          IMVCANController ctrl = GetStyleController( _tempdoc.Style[i] );
          _styleControllerList.Add(ctrl);
          string title = string.Format("#{0}:{1}", (i + 1),Current.Gui.GetUserFriendlyClassName(_tempdoc.Style[i].GetType()));
          AddTab(title, ctrl, ctrl != null ? ctrl.ViewObject : null);
        }
      }
      base.SetElements(false);
    }
    IMVCANController GetStyleController(IG2DPlotStyle style)
    {
      if (_styleControllerDictionary.ContainsKey(style))
        return _styleControllerDictionary[style];

      IMVCANController ct = (IMVCANController)Current.Gui.GetControllerAndControl(new object[] { style }, typeof(IMVCANController), UseDocument.Directly);

      if (ct != null)
        _styleControllerDictionary.Add(style, ct);

      return ct;
    }
Ejemplo n.º 16
0
 public void Add(IG2DPlotStyle toadd)
 {
     Add(toadd, true);
 }