private void Panel1_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.IsDown && e.Key == Key.D && Keyboard.Modifiers == ModifierKeys.Control)
            {
                CElement el = getSelectedElement();
                if (el != null)
                {
                    CElement nw = el.Clone();
                    nw.ID = UniqueID++;
                    nw.setLeft(nw.getLeft() + 10);
                    nw.setTop(nw.getTop() + 10);
                    elements.Add(nw);
                    WElement cnw = addElementControl(nw);
                    Panel.SetZIndex(cnw, panel1.zindex++);
                    SetSelectedElement(cnw.ElementID);

                    lwElementList.Items.Add(nw);

                    for (int i = 0; i < lwElementList.Items.Count; i++)
                    {
                        if (((CElement)lwElementList.Items[i]).ID == cnw.ElementID)
                        {
                            lwElementList.SelectedIndex = i;
                            break;
                        }
                    }
                }
            }
        }
        public void updateElementControl(int ID)
        {
            WElement ct = getElementControl(ID);
            CElement el = elements.getID(ID);

            if (ct == null || el == null)
            {
                return;
            }

            ct.Width  = el.getWidth();
            ct.Height = el.getHeight();
            Canvas.SetLeft(ct, el.getLeft());
            Canvas.SetTop(ct, el.getTop());
            ct.Source = el.getImage();
        }
        public WElement addElementControl(CElement item)
        {
            WElement pc = new WElement();

            pc.ElementID = item.ID;
            Canvas.SetLeft(pc, item.getLeft());
            Canvas.SetTop(pc, item.getTop());
            pc.Stretch = Stretch.Fill;

            try
            {
                pc.Width  = item.getWidth();
                pc.Height = item.getHeight();
            }
            catch (Exception)
            {
            }
            pc.Source      = item.getImage();
            pc.ElementName = item.Name;
            pc.Tip         = item.Type == "Text" ? WElement.ETip.Text : WElement.ETip.Icon;
            if (item.Properties.exist("Size"))
            {
                pc.Size = Convert.ToInt32(item.Properties.getVal("Size").ToString());
            }
            else
            {
                pc.Size = 10;
            }
            if (item.Properties.exist("Color"))
            {
                pc.TColor = item.Properties.getVal("Color").ToString();
            }

            panel1.Children.Add(pc);

            return(pc);
        }