コード例 #1
0
        internal void LoadStyleAndColorsXml(XmlDocument styleXml, eChartStyle fallBackStyle, XmlDocument colorsXml)
        {
            if (fallBackStyle == eChartStyle.None)
            {
                throw new ArgumentException("fallBackStyle", "fallBackStyle can't be None");
            }
            if (_chart.Style != eChartStyle.None && _chart.Style != fallBackStyle)
            {
                _chart.Style = fallBackStyle;
            }

            if (styleXml == null || styleXml.DocumentElement == null || styleXml.DocumentElement.LocalName != "chartStyle" || styleXml.DocumentElement.ChildNodes.Count != 31)
            {
                throw new ArgumentException("xml", "StyleXml is null or not in the correct format");
            }

            if (StylePart == null)
            {
                CreateStylePart(_chart.WorkSheet.Workbook._package.Package);
            }

            StyleXml = styleXml;
            StyleXml.Save(StylePart.GetStream(FileMode.CreateNew));
            Style = new ExcelChartStyle(NameSpaceManager, StyleXml.DocumentElement, this);

            if (colorsXml == null)
            {
                colorsXml = new XmlDocument();
                colorsXml.LoadXml(GetStartColorXml());
            }

            LoadColorXml(colorsXml);
            _chart.InitChartTheme((int)fallBackStyle);
        }
コード例 #2
0
        private void LoadStyleAndColors(ExcelChart chart)
        {
            if (chart.Part == null)
            {
                return;
            }
            var p = chart.WorkSheet.Workbook._package;

            foreach (var rel in chart.Part.GetRelationships())
            {
                if (rel.RelationshipType == ExcelPackage.schemaChartStyleRelationships)
                {
                    StyleUri  = UriHelper.ResolvePartUri(rel.SourceUri, rel.TargetUri);
                    StylePart = p.Package.GetPart(StyleUri);
                    StyleXml  = new XmlDocument();
                    LoadXmlSafe(StyleXml, StylePart.GetStream());
                }
                else if (rel.RelationshipType == ExcelPackage.schemaChartColorStyleRelationships)
                {
                    ColorsUri  = UriHelper.ResolvePartUri(rel.SourceUri, rel.TargetUri);
                    ColorsPart = p.Package.GetPart(ColorsUri);
                    ColorsXml  = new XmlDocument();
                    LoadXmlSafe(ColorsXml, ColorsPart.GetStream());
                }
            }
        }
コード例 #3
0
 /// <summary>
 /// Constructs a new instance of the StyleEntry class.
 /// </summary>
 /// <param name="Arrange">The arrangement</param>
 /// <param name="Part">The style part</param>
 /// <param name="Instrument">The instrument</param>
 /// <param name="ChordType">The chord family</param>
 /// <param name="Message">The message</param>
 public StyleEntry(Arrangement Arrange, StylePart Part, Instrument Instrument, ChordType ChordType, MidiMessage Message)
 {
     this.arrangement = Arrange;
     this.part        = Part;
     this.instrument  = Instrument;
     this.chordType   = ChordType;
     this.message     = Message;
 }
コード例 #4
0
 /// <summary>
 /// Creates a new HighlightingColorizer instance.
 /// Derived classes using this constructor must override the <see cref="CreateHighlighter"/> method.
 /// </summary>
 protected ThemedHighlightingColorizer()
 {
     _themeManager = AppContext.Resolve <IThemeManager>();
     _defaultStyle = new StylePart
     {
         Bold       = false,
         Italic     = false,
         Foreground = (_themeManager.CurrentTheme != null ? _themeManager.CurrentTheme.Foreground : "#000000")
     };
 }
コード例 #5
0
        /// <summary>
        /// Gets the events from the given style part
        /// </summary>
        /// <param name="IsBasic">True if Basic, False if Advanced</param>
        /// <param name="Part">Part of the style</param>
        /// <param name="Instr">Track of the part</param>
        /// <param name="CType">Chord type</param>
        /// <returns>A list of the events</returns>
        public IEnumerable <MidiMessage> this[bool IsBasic, StylePart Part, Instrument Instr, ChordType CType] {
            get {
                Dictionary <Instrument, Dictionary <StylePart, InstrumentAddress> > Source =
                    IsBasic ? this.BasicAddresses : this.AdvancedAddresses;

                InstrumentAddress addr = Source[Instr][Part];

                return(this.GetMidiMessages(addr, CType));
            }
        }
コード例 #6
0
        private void OnSelectedPartChanged()
        {
            this.SelectedArrangement = rbArrangementBasic.Checked ? Arrangement.Basic : Arrangement.Advanced;

            this.SelectedPart = (from c in this.StylePartMappings
                                 where c.Key.Checked
                                 select c.Value).ElementAt(0);

            this.SelectedInstrument  = isInstrument.SelectedInstrument;
            this.SelectedChordFamily = cfsChord.SelectedChordType;

            this.UpdateMidiEvents();
        }
コード例 #7
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            StylePart[] parts = new StylePart[] {
                StylePart.Intro,
                StylePart.Original,
                StylePart.Variation,
                StylePart.Variation2,
                StylePart.FillToVariation,
                StylePart.FillToVariation2,
                StylePart.FillToOriginal,
                StylePart.Ending
            };

            this.Part = parts[comboBox1.SelectedIndex];

            this.RenderMessages();
        }
コード例 #8
0
        /// <summary>
        /// Creates an empty style and color for chart, ready to be customized
        /// </summary>
        public void CreateEmptyStyle(eChartStyle fallBackStyle = eChartStyle.Style2)
        {
            if (fallBackStyle == eChartStyle.None)
            {
                throw new InvalidOperationException("The chart must have a style. Please set the charts Style property to a value different than None or Call LoadStyleXml with the fallBackStyle parameter");
            }

            var p  = _chart.WorkSheet.Workbook._package.Package;
            var id = CreateStylePart(p);

            StyleXml = new XmlDocument();
            StyleXml.LoadXml(GetStartStyleXml(id));
            StyleXml.Save(StylePart.GetStream());
            Style = new ExcelChartStyle(NameSpaceManager, StyleXml.DocumentElement, this);
            _chart.InitChartTheme((int)fallBackStyle);

            CreateColorXml(p);
        }