Exemplo n.º 1
0
 private void OnItemDrag(object sender, ItemDragEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         if (e.Item is TreeNode)
         {
             TreeNode node = (TreeNode)e.Item;
             if (node.Parent == controlNode && node.Tag is MpeControlType)
             {
                 MpeControlType type = (MpeControlType)node.Tag;
                 if (type != MpeControlType.Screen)
                 {
                     DoDragDrop(type, DragDropEffects.Copy);
                 }
             }
             else if (node.Parent == imageNode)
             {
                 DoDragDrop((FileInfo)node.Tag, DragDropEffects.Copy);
             }
             else
             {
                 DoDragDrop(node.Tag, DragDropEffects.Copy);
             }
         }
     }
 }
Exemplo n.º 2
0
 public MpeControl()
 {
     MpeLog.Debug("MpeControl()");
     preparing = true;
     SetStyle(ControlStyles.SupportsTransparentBackColor, true);
     SetStyle(ControlStyles.DoubleBuffer, true);
     SetStyle(ControlStyles.AllPaintingInWmPaint, true);
     SetStyle(ControlStyles.UserPaint, true);
     SetStyle(ControlStyles.ResizeRedraw, true);
     Animation                = new MpeAnimationType();
     BackColor                = Color.Transparent;
     Size                     = new Size(64, 64);
     Location                 = new Point(8, 8);
     alignment                = MpeControlAlignment.Left;
     autoSize                 = false;
     borderPen                = new Pen(Color.FromArgb(128, 255, 255, 255), 1.0f);
     borderPen.DashStyle      = DashStyle.Dash;
     controlLock              = new MpeControlLock();
     controlLock.LockChanged += new MpeControlLock.LockChangedHandler(OnLockChanged);
     description              = "";
     diffuseColor             = Color.FromArgb(255, 255, 255, 255);
     dimColor                 = Color.FromArgb(0x60ffffff);
     embedded                 = false;
     enabled                  = true;
     focused                  = false;
     id       = 0;
     masked   = false;
     modified = false;
     onLeft   = 0;
     onRight  = 0;
     onUp     = 0;
     onDown   = 0;
     padding  = new MpeControlPadding(0);
     padding.PaddingChanged += new MpeControlPadding.PaddingChangedHandler(OnPaddingChanged);
     parser           = null;
     textBrush        = new SolidBrush(Color.Black);
     type             = MpeControlType.Empty;
     visible          = "true";
     screen           = null;
     tags             = new MpeTagCollection();
     tags.TagAdded   += new MpeTagCollection.TagAddedHandler(OnTagCollectionChanged);
     tags.TagChanged += new MpeTagCollection.TagChangedHandler(OnTagCollectionChanged);
     tags.TagRemoved += new MpeTagCollection.TagRemovedHandler(OnTagCollectionChanged);
     preparing        = false;
     reference        = false;
 }
Exemplo n.º 3
0
        public void OnDragDrop(object sender, DragEventArgs e)
        {
            MpeLog.Debug("OnDragDrop()");
            if (sender == null || !(sender is MpeContainer))
            {
                MpeLog.Warn("Could not locate parent MpeContainer... Cancelling DragDrop operation.");
                return;
            }
            MpeContainer mpc = (MpeContainer)sender;

            if (e.Data.GetDataPresent(typeof(MpeControlType)))
            {
                MpeControlType type = (MpeControlType)e.Data.GetData(typeof(MpeControlType));
                MpeLog.Debug("DragDrop: " + type.ToString());
                MpeControl c = Parser.CreateControl(type);
                c.Id       = ResourceList.GenerateUniqueId();
                c.Location = mpc.PointToClient(new Point(e.X, e.Y));
                mpc.Controls.Add(c);
                c.BringToFront();
                Mask.SelectedControl = c;
                UpdatePropertyManager();
            }
            else if (e.Data.GetDataPresent(typeof(FileInfo)))
            {
                FileInfo image = (FileInfo)e.Data.GetData(typeof(FileInfo));
                MpeImage mpi   = (MpeImage)Parser.CreateControl(MpeControlType.Image);
                mpi.Id = ResourceList.GenerateUniqueId();
                mpc.Controls.Add(mpi);
                mpi.Texture  = image;
                mpi.AutoSize = true;
                mpi.Location = mpc.PointToClient(new Point(e.X, e.Y));
                mpi.BringToFront();
                Mask.SelectedControl = mpi;
                UpdatePropertyManager();
            }
            else
            {
                MpeLog.Debug("Unknown DataType... Cancelling DragDrop");
                return;
            }
            Focus();
        }
Exemplo n.º 4
0
 public MpeControl(MpeControl control) : this()
 {
     MpeLog.Debug("MpeControl(control)");
     preparing                = true;
     Size                     = control.Size;
     Location                 = control.Location;
     alignment                = control.alignment;
     autoSize                 = control.autoSize;
     borderPen                = control.borderPen;
     controlLock              = new MpeControlLock(control.controlLock);
     controlLock.LockChanged += new MpeControlLock.LockChangedHandler(OnLockChanged);
     description              = control.description;
     diffuseColor             = control.diffuseColor;
     dimColor                 = control.dimColor;
     animation                = control.animation;
     embedded                 = control.embedded;
     enabled                  = control.enabled;
     focused                  = control.focused;
     id       = control.id;
     masked   = control.masked;
     modified = control.modified;
     onLeft   = control.onLeft;
     onRight  = control.onRight;
     onUp     = control.onUp;
     onDown   = control.onDown;
     padding  = new MpeControlPadding(control.padding);
     padding.PaddingChanged += new MpeControlPadding.PaddingChangedHandler(OnPaddingChanged);
     parser           = control.parser;
     textBrush        = (SolidBrush)control.textBrush.Clone();
     type             = control.type;
     visible          = control.visible;
     screen           = control.screen;
     tags             = new MpeTagCollection(control.tags);
     tags.TagAdded   += new MpeTagCollection.TagAddedHandler(OnTagCollectionChanged);
     tags.TagChanged += new MpeTagCollection.TagChangedHandler(OnTagCollectionChanged);
     tags.TagRemoved += new MpeTagCollection.TagRemovedHandler(OnTagCollectionChanged);
     preparing        = false;
 }
Exemplo n.º 5
0
        public override void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeGroup.Load()");
            base.Load(iterator, parser);
            this.parser = parser;
            //Animation = parser.GetAnimation(iterator, "animation", Animation);
            //tags.Remove("animation");

            // Mpe Specific Tags
            bool firstLoad = false;

            if (parser.GetString(iterator, "mpe/layout", null) == null)
            {
                MpeLog.Debug("This is a group that has never been opened with MPE!");
                firstLoad = true;
                Left      = 0;
                Top       = 0;
            }
            LayoutStyle = parser.GetLayout(iterator, "mpe/layout", LayoutStyle);
            Spring      = parser.GetBoolean(iterator, "mpe/spring", Spring);
            Spacing     = parser.GetInt(iterator, "mpe/spacing", Spacing);
            Padding     = parser.GetPadding(iterator, "mpe/padding", Padding);
            // Child Controls
            XPathNodeIterator i = iterator.Current.Select("control");
            bool firstControl   = true;
            int  x = int.MaxValue;
            int  y = int.MaxValue;
            int  r = 0;
            int  b = 0;

            while (i.MoveNext())
            {
                XPathNodeIterator typeIterator = i.Current.SelectChildren("type", "");
                if (typeIterator.MoveNext())
                {
                    MpeControlType ctype = MpeControlType.Create(typeIterator.Current.Value);
                    if (firstControl && ctype == MpeControlType.Image)
                    {
                        firstControl = false;
                        backImage.Load(i, parser);
                    }
                    else
                    {
                        MpeControl c = parser.CreateControl(ctype);
                        Controls.Add(c);
                        c.Load(i, parser);
                        c.BringToFront();
                        if (firstLoad)
                        {
                            if (c.Left < x)
                            {
                                x = c.Left;
                            }
                            if (c.Top < y)
                            {
                                y = c.Top;
                            }
                            if ((c.Left + c.Width) > r)
                            {
                                r = c.Left + c.Width;
                            }
                            if ((c.Top + c.Height) > b)
                            {
                                b = c.Top + c.Height;
                            }
                        }
                    }
                }
            }
            if (firstLoad)
            {
                MpeLog.Info("x=" + x + " y=" + y);
                Left = x - 4;
                Top  = y - 4;
                for (int a = 0; a < Controls.Count; a++)
                {
                    if (Controls[a] is MpeControl)
                    {
                        Controls[a].Left -= x - 4;
                        Controls[a].Top  -= y - 4;
                    }
                }
                Width  = r - x + 8;
                Height = b - y + 8;
            }

            if (Spring)
            {
                Width  = parser.GetInt(iterator, "width", Width);
                Height = parser.GetInt(iterator, "height", Height);
            }
            Modified = false;
        }
Exemplo n.º 6
0
        public override void Load(XPathNodeIterator iterator, MpeParser parser)
        {
            MpeLog.Debug("MpeScreen.Load()");
            this.parser = parser;
            XPathNodeIterator i = null;

            if (iterator == null)
            {
                throw new MpeParserException("The given iterator is invalid.");
            }
            if (iterator.Current.Name == "controls")
            {
                Width      = parser.GetInt(iterator, "skin/width", Width);
                Height     = parser.GetInt(iterator, "skin/height", Height);
                ScreenSize = MpeScreenSize.FromResolution(Width, Height);
                i          = iterator.Current.Select("control[type='image']");
                if (i.MoveNext())
                {
                    backImage.Load(i, parser);
                }
                Id = 0;
            }
            else if (iterator.Current.Name == "window")
            {
                string stype = parser.GetString(iterator, "type", "");
                if (stype == MpeScreenType.Dialog.ToString().ToLower())
                {
                    screenType = MpeScreenType.Dialog;
                }
                else if (stype == MpeScreenType.OnScreenDisplay.ToString().ToLower())
                {
                    screenType = MpeScreenType.OnScreenDisplay;
                }
                else
                {
                    screenType = MpeScreenType.Window;
                }

                Id             = parser.GetInt(iterator, "id", Id);
                AllowOverlay   = parser.GetBoolean(iterator, "allowoverlay", AllowOverlay);
                AutohideTopbar = parser.GetBoolean(iterator, "autohidetopbar", AutohideTopbar);
                DefaultControl = parser.GetInt(iterator, "defaultcontrol", DefaultControl);

                if (screenType == MpeScreenType.Dialog)
                {
                    // Initialize the default screen
                    MpeScreen defaultScreen = (MpeScreen)parser.GetControl(MpeControlType.Screen);
                    if (defaultScreen == null)
                    {
                        throw new MpeParserException("Reference screen was never initialized and loaded");
                    }
                    TextureBack = defaultScreen.TextureBack;
                    Size        = defaultScreen.Size;
                    AllowDrop   = false;
                    // First create the dialog group

                    MpeGroup dialog = (MpeGroup)parser.CreateControl(MpeControlType.Group);
                    dialog.Id          = DialogGroupId;
                    dialog.LayoutStyle = MpeLayoutStyle.Grid;
                    dialog.Parser      = Parser;
                    Controls.Add(dialog);

                    // Add all the controls
                    i = iterator.Current.Select("controls/control");
                    bool first = true;
                    while (i.MoveNext())
                    {
                        string s = parser.GetString(i, "type", "");
                        if (first && s == MpeControlType.Image.ToString())
                        {
                            first = false;
                            dialog.TextureBackImage.Load(i, parser);
                            dialog.Size     = dialog.TextureBackImage.Size;
                            dialog.Location = dialog.TextureBackImage.Location;
                        }
                        else
                        {
                            XPathNodeIterator typeIterator = i.Current.SelectChildren("type", "");
                            if (typeIterator.MoveNext())
                            {
                                MpeControlType type = MpeControlType.Create(typeIterator.Current.Value);
                                MpeControl     c    = parser.CreateControl(type);
                                dialog.Controls.Add(c);
                                c.Load(i, parser);
                                c.BringToFront();
                            }
                        }
                    }
                }
                else
                {
                    AllowDrop = true;
                    i         = iterator.Current.Select("controls/control");
                    bool first = true;
                    while (i.MoveNext())
                    {
                        string s = parser.GetString(i, "type", "");
                        if (first && s == MpeControlType.Image.ToString())
                        {
                            backImage.Load(i, parser);
                        }
                        else
                        {
                            XPathNodeIterator typeIterator = i.Current.SelectChildren("type", "");
                            if (typeIterator.MoveNext())
                            {
                                MpeControlType type = MpeControlType.Create(typeIterator.Current.Value);
                                MpeControl     c    = parser.CreateControl(type);
                                Controls.Add(c);
                                c.Load(i, parser);
                                c.BringToFront();
                            }
                        }
                        first = false;
                    }
                }
            }
            Modified = false;
        }