Beispiel #1
0
        static void serializer_UnknownElement(object sender, XmlElementEventArgs e)
        {
            // We changed from "ActionLists" to "MainChannelFrames"
            if (e.Element.Name == "ActionLists")
            {
                GUIAnimation guiAnimation = e.ObjectBeingDeserialized as GUIAnimation;
                guiAnimation.MainChannelFrames.Clear();

                foreach (XmlNode actionsListsNode in e.Element.ChildNodes)
                {
                    if (actionsListsNode.Name != "ActionList")
                    {
                        continue;
                    }

                    MainChannelFrame mcf = new MainChannelFrame();
                    mcf.Frame = uint.Parse(actionsListsNode.Attributes["Frame"].Value);
                    guiAnimation.MainChannelFrames.Add(mcf);

                    foreach (XmlNode actionListNode in actionsListsNode.ChildNodes)
                    {
                        if (actionListNode.Name != "Actions")
                        {
                            continue;
                        }

                        foreach (XmlNode actionsNode in actionListNode.ChildNodes)
                        {
                            Actions.Action action = null;

                            if (actionsNode.Name == "SoundAction")
                            {
                                Actions.SoundAction soundAction = new Actions.SoundAction();
                                soundAction.Sound  = int.Parse(actionsNode.Attributes["Sound"].Value);
                                soundAction.Volume = uint.Parse(actionsNode["Volume"].InnerText);

                                action = soundAction;
                            }
                            else if (actionsNode.Name == "MessageAction")
                            {
                                Actions.MessageAction messageAction = new Actions.MessageAction();
                                messageAction.Message = int.Parse(actionsNode.Attributes["Message"].Value);

                                action = messageAction;
                            }

                            if (action != null)
                            {
                                mcf.Actions.Add(action);
                            }
                        }
                    }
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Called when we want to edit the value of a property.  Shows the ActionsEditor form.
        /// </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)
            {
                List <Otter.UI.Actions.Action> actions = value as List <Otter.UI.Actions.Action>;

                if (actions == null)
                {
                    return(value);
                }

                GUIScene scene = null;

                GUIControl control = context.Instance as GUIControl;
                if (control != null)
                {
                    scene = control.Scene;
                }

                MainChannelFrame mainChannelFrame = context.Instance as MainChannelFrame;
                if (mainChannelFrame != null)
                {
                    scene = mainChannelFrame.Animation.Scene;
                }

                if (scene == null)
                {
                    return(value);
                }

                ActionsEditor actionsEditor = new ActionsEditor(scene);
                actionsEditor.Actions = actions;

                if (actionsEditor.ShowDialog() == DialogResult.OK)
                {
                    if (control != null)
                    {
                        return(actionsEditor.Actions);
                    }

                    NotifyingList <Otter.UI.Actions.Action> list = new NotifyingList <UI.Actions.Action>();
                    list.AddRange(actionsEditor.Actions);

                    return(list);
                }

                return(actions);
            }

            return(value);
        }