private void FillData(Operation operation)
        {
            DesignerItem operationItem = this.CreateItem(operation.DesignerID, "Operation", this.Height / 3, this.Width / 3, 78);

            operationItem.Content = this.GetOperationContent();
            //operationItem.BoundLogicItem = operation;
            operationItem.dispName = operation.Name;
            operationItem.Tag      = "Operation";

            ResourceDesigner.Children.Add(operationItem);
            ResourceDesigner.SetConnectorDecoratorTemplate(operationItem);
            ResourceDesigner.OperationGuid  = operationItem.ID;
            ResourceDesigner.ResourceWindow = this;

            var toolBox = new Toolbox();

            foreach (var resource in OtherResources)
            {
                var resourceItem = CreateOtherResource(resource);
                var toolBoxItem  = new ToolboxItem()
                {
                    DesignerItem = resourceItem, Content = resourceItem
                };
                toolBox.Items.Add(toolBoxItem);
            }
            otherResourcesToolbox.Content = toolBox;
            ResourceDesigner.Toolbox      = toolBox;
        }
        private void Open_Executed()
        {
            XElement root = LoadSerializedDataFromFile();

            if (root == null)
            {
                return;
            }

            ResourceDesigner.Children.Clear();
            ResourceDesigner.SelectionService.ClearSelection();

            //deserialize logic items fron xml and populate logic item list
            IEnumerable <XElement> LogicItemsXML = root.Elements("LogicItems").Elements("LogicItem");
            List <BaseLogic>       LogicItems    = new List <BaseLogic>();

            foreach (XElement itemXML in LogicItemsXML)
            {
                BaseLogic item = DeserializeLogicItem(itemXML);
                LogicItems.Add(item);
            }

            IEnumerable <XElement> DesignerItemsXML = root.Elements("DesignerItems").Elements("DesignerItem");

            foreach (XElement itemXML in DesignerItemsXML)
            {
                Guid         id   = new Guid(itemXML.Element("ID").Value);
                DesignerItem item = DeserializeDesignerItem(itemXML, id, 0, 0);
                //get logic item from logic item list
                item.BoundLogicItem = LogicItems.Find(p => p.DesignerID == item.ID);
                item.dispName       = item.BoundLogicItem.Name;
                //if (item.BoundLogicItem is BaseResource)
                ResourceDesigner.AddChild(item);
                //else
                //    ResourceDesigner.Children.Add(item);
                SetConnectorDecoratorTemplate(item);
            }


            this.InvalidateVisual();

            IEnumerable <XElement> connectionsXML = root.Elements("Connections").Elements("Connection");

            foreach (XElement connectionXML in connectionsXML)
            {
                Guid sourceID = new Guid(connectionXML.Element("SourceID").Value);
                Guid sinkID   = new Guid(connectionXML.Element("SinkID").Value);

                String sourceConnectorName = connectionXML.Element("SourceConnectorName").Value;
                String sinkConnectorName   = connectionXML.Element("SinkConnectorName").Value;

                Connector sourceConnector = GetConnector(sourceID, sourceConnectorName);
                Connector sinkConnector   = GetConnector(sinkID, sinkConnectorName);

                Connection connection = new Connection(sourceConnector, sinkConnector);
                Canvas.SetZIndex(connection, Int32.Parse(connectionXML.Element("zIndex").Value));
                ResourceDesigner.Children.Add(connection);
            }
        }
        public void UpdateResource(DesignerItem designerItem)
        {
            if (designerItem.BoundLogicItem is InformationResource)
            {
                //MessageBox.Show("UpdateResource1 : " + designerItem.BoundLogicItem.ID.ToString());
                var item           = designerItem.BoundLogicItem as InformationResource;
                var resourceWindow = new InformationWindow(item);
                resourceWindow.ShowDialog();

                if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value)
                {
                    if (Resources.Contains(item))
                    {
                        Resources.Remove(item);
                    }
                    Resources.Add(resourceWindow.InformationResource);
                    designerItem.BoundLogicItem = resourceWindow.InformationResource;
                }
                else
                {
                    ResourceDesigner.RemoveChild(designerItem);
                    //Toolbox.
                }
                return;
            }

            if (designerItem.BoundLogicItem is FinancialResource)
            {
                var item           = designerItem.BoundLogicItem as FinancialResource;
                var resourceWindow = new FinanceWindow(item);
                resourceWindow.ShowDialog();

                if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value)
                {
                    if (Resources.Contains(item))
                    {
                        Resources.Remove(item);
                    }
                    Resources.Add(resourceWindow.FinancialResource);
                    designerItem.BoundLogicItem = resourceWindow.FinancialResource;
                }
                return;
            }

            if (designerItem.BoundLogicItem is LabourForce)
            {
                var item           = designerItem.BoundLogicItem as LabourForce;
                var resourceWindow = new LabourWindow(item);
                resourceWindow.ShowDialog();

                if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value)
                {
                    if (Resources.Contains(item))
                    {
                        Resources.Remove(item);
                    }
                    Resources.Add(resourceWindow.LabourForce);
                    designerItem.BoundLogicItem = resourceWindow.LabourForce;
                }
                return;
            }

            if (designerItem.BoundLogicItem is Equipment)
            {
                var item           = designerItem.BoundLogicItem as Equipment;
                var resourceWindow = new EquipmentWindow(item);
                resourceWindow.ShowDialog();

                if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value)
                {
                    if (Resources.Contains(item))
                    {
                        Resources.Remove(item);
                    }
                    Resources.Add(resourceWindow.Equipment);
                    designerItem.BoundLogicItem = resourceWindow.Equipment;
                }
                return;
            }

            if (designerItem.BoundLogicItem is Product)
            {
                var item           = designerItem.BoundLogicItem as Product;
                var resourceWindow = new ProductWindow(item);
                resourceWindow.ShowDialog();

                if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value)
                {
                    if (Resources.Contains(item))
                    {
                        Resources.Remove(item);
                    }
                    Resources.Add(resourceWindow.Product);
                    designerItem.BoundLogicItem = resourceWindow.Product;
                }
                return;
            }

            if (designerItem.BoundLogicItem is Service)
            {
                var item           = designerItem.BoundLogicItem as Service;
                var resourceWindow = new ServiceWindow(item);
                resourceWindow.ShowDialog();

                if (resourceWindow.DialogResult.HasValue && resourceWindow.DialogResult.Value)
                {
                    if (Resources.Contains(item))
                    {
                        Resources.Remove(item);
                    }
                    Resources.Add(resourceWindow.Service);
                    designerItem.BoundLogicItem = resourceWindow.Service;
                }
                return;
            }
        }