Beispiel #1
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();
        }
Beispiel #2
0
        public virtual void Save(XmlDocument doc, XmlNode node, MpeParser parser, MpeControl reference)
        {
            if (doc != null && node != null)
            {
                // Type
                parser.SetValue(doc, node, "type", type.ToString());
                // Description
                string s1 = Description != null ? Description : Type.ToString();
                string s2 = (reference != null && reference.Description != null) ? reference.Description : Type.ToString();
                if (reference == null || (!s1.Equals(s2)))
                {
                    parser.SetValue(doc, node, "description", s1);
                }
                // Id
                parser.SetInt(doc, node, "id", Id);
                // Location - Absolute Positioning
                Point p = AbsoluteLocation;
                parser.SetInt(doc, node, "posX", p.X);
                parser.SetInt(doc, node, "posY", p.Y);

                // Size
                if (reference == null || reference.Width != Width)
                {
                    parser.SetInt(doc, node, "width", Width);
                }
                // Height
                if (reference == null || reference.Height != Height)
                {
                    parser.SetInt(doc, node, "height", Height);
                }
                // DiffuseColor
                if (reference == null || reference.DiffuseColor != DiffuseColor)
                {
                    parser.SetColor(doc, node, "colordiffuse", DiffuseColor);
                }
                // DimColor
                if (reference == null || reference.DimColor != DimColor)
                {
                    parser.SetColor(doc, node, "dimColor", DimColor);
                }
                // Animation
                Animation.Save(doc, node, parser);
                // Visible
                //if (Visible == false)
                //{
                parser.SetValue(doc, node, "visible", Visible);
                //}
                // Actions
                if (OnLeft > 0)
                {
                    parser.SetInt(doc, node, "onleft", OnLeft);
                }
                if (OnRight > 0)
                {
                    parser.SetInt(doc, node, "onright", OnRight);
                }
                if (OnUp > 0)
                {
                    parser.SetInt(doc, node, "onup", OnUp);
                }
                if (OnDown > 0)
                {
                    parser.SetInt(doc, node, "ondown", OnDown);
                }


                string[] keys = tags.Keys;
                for (int i = 0; i < keys.Length; i++)
                {
                    parser.SetValue(doc, node, keys[i], tags[keys[i]].Value);
                }
            }
        }