Esempio n. 1
0
        /// <summary>
        /// Called when we want to edit the value of a property.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="provider"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            edSvc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if (edSvc != null)
            {
                UI.Actions.SoundAction soundAction = context.Instance as UI.Actions.SoundAction;
                if (soundAction != null)
                {
                    ListBox listBox = new ListBox();
                    foreach (UI.Resources.SoundInfo sound in soundAction.Scene.Sounds)
                    {
                        listBox.Items.Add(sound);
                    }

                    listBox.SelectedItem          = soundAction.Scene.GetSoundInfo((int)value);
                    listBox.SelectedIndexChanged += ((s, e) => { edSvc.CloseDropDown(); });

                    edSvc.DropDownControl(listBox);

                    return(listBox.SelectedItem != null ? (listBox.SelectedItem as UI.Resources.SoundInfo).ID : -1);
                }
            }

            return(value);
        }
Esempio n. 2
0
        /// <summary>
        /// Converts the font count to its string representation
        /// </summary>
        /// <param name="context"></param>
        /// <param name="culture"></param>
        /// <param name="value"></param>
        /// <param name="destinationType"></param>
        /// <returns></returns>
        public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
        {
            if (destinationType == typeof(string))
            {
                UI.Actions.SoundAction soundAction = context.Instance as UI.Actions.SoundAction;
                if (soundAction != null)
                {
                    UI.Resources.SoundInfo sound = soundAction.Scene.GetSoundInfo(soundAction.Sound);
                    if (sound != null)
                    {
                        return(sound.Name);
                    }
                }
            }

            return("None");
        }