//
        public void CreateWindow()
        {
            FactoryShape  factory = FactoryManager.getInstance().GetSelectedTool();
            ElementWindow model   = (ElementWindow)factory.CreateControl();

            m_Window        = (ElementWindow)model;
            model.Container = m_Canvas;

            bool[] hotSpot = { false, false };
            mSceneCanvas.Add(model);

            ElementProperty prop = FactoryActionParam.CreateParam(model);

            model.Property = prop;
            factory.PopulatePropertyList(prop);
            m_GridView.Tag       = prop;
            m_ActionWindow       = new ActionAdd(factory);
            m_ActionWindow.Model = model;
            // Assign a copy of Param.....
            m_ActionWindow.SetParam(prop);
            mHostory.ExcuteAction(m_ActionWindow);

            //mSceneCanvas.Canvas.Invalidate();
            PopulateControlList();
            ElementTracker.Instance.AttachHotSpotObserver(this);
            //m_Window.PropertyChangeObserver = this;
            model.OnSizeChanged();
        }
        //
        private void listBox1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            int          index        = m_listItems.SelectedIndex + 1;
            FactoryShape factoryShape = FactoryManager.getInstance().SelectTool(index);
            DrawElement  model        = factoryShape.CreateControl();

            ElementProperty prop   = FactoryActionParam.CreateParam(model);
            int             id     = m_Window.List.Count + 1;
            String          strVal = factoryShape.Name + factoryShape.List.Count.ToString();

            model.Property = prop;
            prop.SetValue("Name", strVal.Trim());
            prop.SetValue("Id", id.ToString());
            prop.SetValue("Location", model.Location.X.ToString() + "," + model.Location.Y.ToString());
            prop.SetValue("Text", model.Text);
            prop.SetValue("Size", model.Width.ToString() + "," + model.Height.ToString());
            //
            factoryShape.PopulatePropertyList(prop);
            m_GridView.Tag = prop;
            //
            Action action = factoryShape.CreateAddAction(model, m_Window);

            action.SetParam(prop);
            mHostory.ExcuteAction(action);
        }
        //
        static public void CopyProperty(ElementProperty propOld, ElementProperty propNew)
        {
            PropertyObject propObjOld = null;
            PropertyObject propObjNew = null;
            int            size       = propOld.List.Count;

            List <PropertyObject> listOld = new List <PropertyObject>(propOld.List.Values);
            List <PropertyObject> listNew = new List <PropertyObject>(propNew.List.Values);


            for (int i = 0; i < size; i++)
            {
                propObjNew      = listNew[i];
                propObjOld      = listOld[i];
                propObjOld.Text = propObjNew.Text;
            }
        }
        //
        public void CreateElementWindow(XmlNode node)
        {
            FactoryShape  factory = FactoryManager.getInstance().GetFactory(node.Name);
            ElementWindow model   = (ElementWindow)factory.CreateControl();

            m_Window        = (ElementWindow)model;
            model.Container = m_Canvas;

            bool[] hotSpot = { false, false };
            mSceneCanvas.Add(model);

            ElementProperty prop = FactoryActionParam.CreateParam(model);

            model.Property = prop;
            factory.PopulatePropertyList(prop);
            m_GridView.Tag = prop;

            foreach (XmlAttribute attr in node.Attributes)
            {
                prop.SetValue(attr.Name, attr.Value);
            }

            //FIXME use Factory for action...
            m_ActionWindow       = new ActionAdd(factory);
            m_ActionWindow.Model = model;
            // Assign a copy of Param.....
            m_ActionWindow.SetParam(prop);
            mHostory.ExcuteAction(m_ActionWindow);

            //mSceneCanvas.Canvas.Invalidate();
            PopulateControlList();
            ElementTracker.Instance.AttachHotSpotObserver(this);
            //m_Window.PropertyChangeObserver = this;
            model.OnSizeChanged();

            foreach (XmlNode child in node.ChildNodes)
            {
                // We only need Control elements..
                if (child.Name == "Properties")
                {
                    continue;
                }
                //
                CreateChildlement(child);
            }
        }
Exemple #5
0
        public static ElementProperty CreateParam(DrawElement obj)
        {
            ElementProperty prop = null;

            if (obj is ElementWindow)
            {
                prop = new ElementPropertyWindow();
            }
            else if (obj is ElementButton)
            {
                prop = new ElementPropertyButton();
            }
            if (prop != null)
            {
                prop.InitDefaultProperty();
            }
            return(prop);
        }
        public override int execute()
        {
            UpdatePosition();

            bool[] hotSpot = { true, true };

            if (Model is ElementWindow)
            {
                hotSpot[0] = false;
                hotSpot[1] = false;
            }

            ElementProperty.CopyProperty(Model.Property, m_ActionParam);
            //
            m_Tracker.ShowHotSpot(hotSpot[0], 1);
            m_Tracker.ShowHotSpot(hotSpot[1], 2);
            Model.Text = m_ActionParam.GetValue("Text");

            return(base.execute());
        }
        //
        public void CreateChildlement(XmlNode node)
        {
            FactoryShape factoryShape = FactoryManager.getInstance().GetFactory(node.Name);
            DrawElement  model        = factoryShape.CreateControl();

            ElementProperty prop = FactoryActionParam.CreateParam(model);

            model.Property = prop;

            foreach (XmlAttribute attr in node.Attributes)
            {
                prop.SetValue(attr.Name, attr.Value);
            }


            try
            {
                XmlNodeList propertiesNodes = node.FirstChild.ChildNodes;
                foreach (XmlNode nodeProp in propertiesNodes)
                {
                    prop.SetValue(nodeProp.Name, nodeProp.InnerText);
                }
            }
            catch (Exception e)
            {
            }



            factoryShape.PopulatePropertyList(prop);
            m_GridView.Tag = prop;
            Action action = factoryShape.CreateAddAction(model, m_Window);

            action.SetParam(prop);
            //
            mHostory.ExcuteAction(action);
        }
 //
 public void SetParam(ElementProperty param)
 {
     m_ActionParam = param;
 }