コード例 #1
0
        private void editor_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = ((ComboBox)sender).SelectedIndex;

            if (index >= 0 && index < m_Options.Length)
            {
                m_TrackShape = m_Options[index];
                RaiseValueChanged();
            }
        }
コード例 #2
0
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                TrackShape    trackShape    = (TrackShape)value;
                TypeConverter enumConverter = TypeDescriptor.GetConverter(typeof(DashStyle));
                string        result        = String.Format("{0};{1}",
                                                            enumConverter.ConvertToString(context, culture, (DashStyle)trackShape.DashStyle),
                                                            trackShape.ShowSteps?"true":"false");
                return(result);
            }

            return(base.ConvertTo(context, culture, value, destinationType));
        }
コード例 #3
0
        private void editor_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox editor = sender as ComboBox;

            if (editor == null)
            {
                return;
            }

            if (editor.SelectedIndex < 0)
            {
                return;
            }

            value = options[editor.SelectedIndex];
            RaiseValueChanged();
        }
コード例 #4
0
        public override void ReadXML(XmlReader xmlReader)
        {
            xmlReader.ReadStartElement();
            string s = xmlReader.ReadElementContentAsString("Value", "");

            TrackShape value = TrackShape.Solid;

            try
            {
                TypeConverter trackShapeConverter = TypeDescriptor.GetConverter(typeof(TrackShape));
                value = (TrackShape)trackShapeConverter.ConvertFromString(s);
            }
            catch (Exception)
            {
                log.ErrorFormat("An error happened while parsing XML for Track shape. {0}", s);
            }

            this.value = options.IndexOf(value) >= 0 ? value : defaultValue;
            xmlReader.ReadEndElement();
        }
コード例 #5
0
        public override void ReadXML(XmlReader _xmlReader)
        {
            _xmlReader.ReadStartElement();
            string s = _xmlReader.ReadElementContentAsString("Value", "");

            TrackShape value = TrackShape.Solid;

            try
            {
                TypeConverter trackShapeConverter = TypeDescriptor.GetConverter(typeof(TrackShape));
                value = (TrackShape)trackShapeConverter.ConvertFromString(s);
            }
            catch (Exception)
            {
                // The input XML couldn't be parsed. Keep the default value.
            }

            // Restrict to the actual list of "athorized" values.
            m_TrackShape = (Array.IndexOf(m_Options, value) >= 0) ? value : TrackShape.Solid;

            _xmlReader.ReadEndElement();
        }
コード例 #6
0
        public override void ReadXML(XmlReader xmlReader)
        {
            xmlReader.ReadStartElement();
            string s = xmlReader.ReadElementContentAsString("Value", "");

            TrackShape value = TrackShape.Solid;

            try
            {
                TypeConverter trackShapeConverter = TypeDescriptor.GetConverter(typeof(TrackShape));
                value = (TrackShape)trackShapeConverter.ConvertFromString(s);
            }
            catch (Exception)
            {
                log.ErrorFormat("An error happened while parsing XML for Track shape. {0}", s);
            }

            // Restrict to the actual list of "athorized" values.
            trackShape = (Array.IndexOf(Options, value) >= 0) ? value : TrackShape.Solid;

            xmlReader.ReadEndElement();
        }
コード例 #7
0
 public StyleElementTrackShape(TrackShape _default)
 {
     m_TrackShape = (Array.IndexOf(m_Options, _default) >= 0) ? _default : TrackShape.Solid;
 }
コード例 #8
0
 public StyleElementTrackShape(TrackShape givenDefault)
 {
     trackShape = (Array.IndexOf(Options, givenDefault) >= 0) ? givenDefault : TrackShape.Solid;
 }
コード例 #9
0
        private void DoBindWrite(string targetProperty, object value)
        {
            // Check type and import value if compatible with the target prop.
            bool imported = false;

            switch (targetProperty)
            {
            case "Color":
            {
                if (value is Color)
                {
                    color    = (Color)value;
                    imported = true;
                }
                break;
            }

            case "LineSize":
            {
                if (value is int)
                {
                    lineSize = (int)value;
                    imported = true;
                }

                break;
            }

            case "LineShape":
            {
                if (value is LineShape)
                {
                    lineShape = (LineShape)value;
                    imported  = true;
                }

                break;
            }

            case "LineEnding":
            {
                if (value is LineEnding)
                {
                    lineEnding = (LineEnding)value;
                    imported   = true;
                }

                break;
            }

            case "TrackShape":
            {
                if (value is TrackShape)
                {
                    trackShape = (TrackShape)value;
                    imported   = true;
                }

                break;
            }

            case "Curved":
            {
                if (value is Boolean)
                {
                    curved   = (Boolean)value;
                    imported = true;
                }

                break;
            }

            case "Font":
            {
                if (value is int)
                {
                    // Recreate the font changing just the size.
                    string    fontName  = font.Name;
                    FontStyle fontStyle = font.Style;
                    font.Dispose();
                    font     = new Font(fontName, (int)value, fontStyle);
                    imported = true;
                }
                break;
            }

            case "Bicolor":
            {
                if (value is Color)
                {
                    bicolor.Background = (Color)value;
                    imported           = true;
                }
                break;
            }

            case "GridDivisions":
            {
                if (value is int)
                {
                    gridDivisions = (int)value;
                    imported      = true;
                }
                break;
            }

            default:
            {
                log.DebugFormat("Unknown target property \"{0}\".", targetProperty);
                break;
            }
            }

            if (imported)
            {
                if (ValueChanged != null)
                {
                    ValueChanged(null, EventArgs.Empty);
                }
            }
            else
            {
                log.DebugFormat("Could not import value \"{0}\" to property \"{1}\".", value.ToString(), targetProperty);
            }
        }
コード例 #10
0
 public bool Equals(TrackShape other)
 {
     return(DashStyle == other.DashStyle && ShowSteps == other.ShowSteps);
 }
コード例 #11
0
 public StyleElementTrackShape(TrackShape initialValue)
 {
     value = options.IndexOf(initialValue) >= 0 ? initialValue : defaultValue;
 }