Esempio n. 1
0
        private void CreateViews(string templatePath, out bool cancel, out bool isnewview)
        {
            View newView = this.view; isnewview = false;
            mediator.Canvas.UpdateHidePanel("Creating View...");
            using (System.Xml.XmlReader reader = System.Xml.XmlReader.Create(templatePath))
            {
                while (reader.ReadToFollowing("View"))
                {
                    do
                    {
                        XmlReader viewSubTree = reader.ReadSubtree();

                        if (reader.HasAttributes)
                        {
                            if (reader.GetAttribute("ViewId") != null)
                            {
                                newView = CreateView(reader);

                                mediator.Canvas.UpdateHidePanel(string.Format("Creating View - {0}", newView.Name));
                                string viewNamePlaceHolder = newView.Name;
                                int viewNameIncrement = 1;
                                string viewNameCandidate = viewNamePlaceHolder;

                                while (mediator.Project.Views.Contains(newView))
                                {
                                    viewNameIncrement++;
                                    viewNameCandidate = string.Format("{0}_{1}", viewNamePlaceHolder, viewNameIncrement);
                                    newView.Name = viewNameCandidate;
                                }

                                newView.Name = viewNamePlaceHolder;
                                if (mediator.Project.Views.Contains(newView))
                                {
                                    ShowTemplateFormDialog(viewNameCandidate, ref newView);
                                    isnewview = true;
                                }
                            }
                        }

                        if (newView.Name == string.Empty)
                        {
                            cancel = true; isnewview = false;
                            mediator.Canvas.HideUpdateEnd();
                            return;
                        }

                        metadata = newView.GetMetadata();

                        if (mediator.Project.Views.Contains(newView) == false)
                        {
                            metadata.InsertView(newView);
                            mediator.Project.Views.Add(newView);
                            mediator.ProjectExplorer.AddView(newView);
                            mediator.Project.LoadViews();
                            mediator.ProjectExplorer.SelectView(newView.Name);
                        }

                        while (viewSubTree.ReadToFollowing("Page"))
                        {
                            int pageId = -1;

                            do
                            {
                                if (viewSubTree.MoveToFirstAttribute())
                                {
                                    if (viewSubTree.Name == ColumnNames.PAGE_ID)
                                    {
                                        int.TryParse(reader.Value, out pageId);
                                        if (pageIdViewNamePairs.ContainsKey(pageId) == false)
                                        {
                                            pageIdViewNamePairs.Add(pageId, newView.Name);
                                        }
                                        else
                                        {

                                        }
                                    }
                                }
                            }
                            while (viewSubTree.ReadToNextSibling("Page"));
                        }

                    } while (reader.ReadToNextSibling("View"));
                }
            }
            cancel = false;
        }