Exemple #1
0
            public object Deserialize(object o, Altaxo.Serialization.Xml.IXmlDeserializationInfo info, object parent)
            {
                int count = info.OpenArray();
                var array = new IG3DPlotStyle[count];

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

                if (o == null)
                {
                    return(new G3DPlotStyleCollection(array));
                }
                else
                {
                    var s = (G3DPlotStyleCollection)o;
                    for (int i = 0; i < count; i++)
                    {
                        s.Add(array[i]);
                    }
                    return(s);
                }
            }
Exemple #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(IG3DPlotStyle newSubStyle, IPlotArea layer, Processed3DPlotData 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);
        }
Exemple #3
0
        public void Insert(int whichposition, IG3DPlotStyle toinsert)
        {
            if (toinsert != null)
            {
                _innerList.Insert(whichposition, toinsert);
                toinsert.ParentObject = this;

                EhSelfChanged(EventArgs.Empty);
            }
        }
Exemple #4
0
        protected void Replace(IG3DPlotStyle ps, int idx, bool withReorganizationAndEvents)
        {
            if (ps != null)
            {
                _innerList[idx] = ps;
                ps.ParentObject = this;

                if (withReorganizationAndEvents)
                {
                    EhSelfChanged(EventArgs.Empty);
                }
            }
        }
Exemple #5
0
        protected void Add(IG3DPlotStyle toadd, bool withReorganizationAndEvents)
        {
            if (toadd != null)
            {
                _innerList.Add(toadd);
                toadd.ParentObject = this;

                if (withReorganizationAndEvents)
                {
                    EhSelfChanged(EventArgs.Empty);
                }
            }
        }
        /// <summary>
        /// Gets the controller for a certain style instance from either the dictionary, or if not found, by creating a new instance.
        /// </summary>
        /// <param name="style"></param>
        /// <returns></returns>
        private IMVCANController GetStyleController(IG3DPlotStyle style)
        {
            if (_styleControllerDictionary.ContainsKey(style))
            {
                return(_styleControllerDictionary[style]);
            }

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

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

            return(ct);
        }
Exemple #7
0
        public virtual void EhView_AddStyle()
        {
            var sel = _singleStylesAvailable.FirstSelectedNode;

            if (null == sel)
            {
                return;
            }

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

            try
            {
                style = (IG3DPlotStyle)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 = (IG3DPlotStyle)Activator.CreateInstance((Type)sel.Tag); // try with parameterless constructor
            }
            var layer    = AbsoluteDocumentPath.GetRootNodeImplementing <IPlotArea>(_doc);
            var plotitem = AbsoluteDocumentPath.GetRootNodeImplementing <G3DPlotItem>(_doc);

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

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

            OnCollectionChangeCommit();
        }
Exemple #8
0
 public void Add(IG3DPlotStyle toadd)
 {
     Add(toadd, true);
 }