コード例 #1
0
        ///--------------------------------------------------------------------------------
        /// <summary>This method applies diagram updates.</summary>
        ///--------------------------------------------------------------------------------
        public void ProcessEditDiagramPerformed(DiagramEventArgs data)
        {
            try
            {
                bool isItemMatch = false;
                if (data != null && data.Diagram != null)
                {
                    foreach (DiagramViewModel item in Diagrams)
                    {
                        if (item.Diagram.DiagramID == data.Diagram.DiagramID)
                        {
                            isItemMatch = true;
                            item.Diagram.TransformDataFromObject(data.Diagram, null, false);
                            item.OnUpdated(item, null);
                            item.ShowInTreeView();
                            break;
                        }
                    }
                    if (isItemMatch == false)
                    {
                        // add new Diagram
                        data.Diagram.Solution = Solution;

                        #region protected
                        DiagramViewModel newItem = new DiagramViewModel(data.Diagram, Entities, Solution);
                        #endregion protected

                        newItem.Updated += new EventHandler(Children_Updated);
                        Diagrams.Add(newItem);
                        Solution.DiagramList.Add(newItem.Diagram);
                        Items.Add(newItem);
                        OnUpdated(this, null);
                        newItem.ShowInTreeView();
                    }
                }
            }
            catch (Exception ex)
            {
                ShowIssue(ex.Message + ex.StackTrace);
            }
        }