예제 #1
0
        private static void SetOtherViewAsDefault(IPatternSchema pattern, IViewSchema viewSchema)
        {
            var otherViewSchema = pattern.Views.ToList <INamedElementSchema>()
                                  .OrderBy(v => v.Name)
                                  .FirstOrDefault(v => v.Id != ((INamedElementSchema)viewSchema).Id);

            if (otherViewSchema != null)
            {
                SetDefaultView(pattern, otherViewSchema.Id);
            }
        }
예제 #2
0
        private void DeleteViewDiagram(IItemContainer parentItem, IViewSchema viewSchema)
        {
            var path      = GetDiagramFileName(parentItem, viewSchema);
            var childItem = parentItem.Items.FirstOrDefault(i => i.PhysicalPath == path);

            if (childItem != null)
            {
                VsHelper.CheckOut(childItem.PhysicalPath);
                childItem.As <EnvDTE.ProjectItem>().Remove();
            }
        }
예제 #3
0
        /// <summary>
        /// Selects (activates) the current diagram.
        /// </summary>
        public static void SelectViewDiagram(string patternModelFilePath, IViewSchema view)
        {
            Guard.NotNullOrEmpty(() => patternModelFilePath, patternModelFilePath);
            Guard.NotNull(() => view, view);

            var docData = NuPattern.Modeling.Windows.WindowExtensions.GetDesignerData(patternModelFilePath);

            var docview = docData.DocViews.First() as SingleDiagramDocView;
            var diagram = docData.Store.GetDiagramForView(view as ViewSchema);
            if (docview != null && diagram != null)
            {
                docview.Diagram = diagram;
                view.Pattern.CurrentDiagramId = diagram.Id.ToString();
            }
        }
예제 #4
0
        /// <summary>
        /// Selects (activates) the current diagram.
        /// </summary>
        public static void SelectViewDiagram(string patternModelFilePath, IViewSchema view)
        {
            Guard.NotNullOrEmpty(() => patternModelFilePath, patternModelFilePath);
            Guard.NotNull(() => view, view);

            var docData = NuPattern.Modeling.Windows.WindowExtensions.GetDesignerData(patternModelFilePath);

            var docview = docData.DocViews.First() as SingleDiagramDocView;
            var diagram = docData.Store.GetDiagramForView(view as ViewSchema);

            if (docview != null && diagram != null)
            {
                docview.Diagram = diagram;
                view.Pattern.CurrentDiagramId = diagram.Id.ToString();
            }
        }
예제 #5
0
        /// <summary>
        /// Creates a new view in the current pattern.
        /// </summary>
        public static IViewSchema CreateNewViewDiagram(this IPatternModelSchema patternModel, ModelingDocData docData, string name)
        {
            Guard.NotNull(() => patternModel, patternModel);
            Guard.NotNull(() => docData, docData);
            Guard.NotNull(() => name, name);

            // Create a new diagram
            var diagramId = PatternModelDocHelper.CreateNewViewDiagram(patternModel as PatternModelSchema, docData);

            // Create a new view
            IViewSchema view = null;

            if (diagramId != Guid.Empty)
            {
                view = patternModel.Pattern.CreateViewSchema(vw =>
                {
                    ((INamedElementSchema)vw).Name = name;
                    vw.DiagramId = diagramId.ToString();
                });
            }

            return(view);
        }
예제 #6
0
        private static void SetOtherViewAsDefault(IPatternSchema pattern, IViewSchema viewSchema)
        {
            var otherViewSchema = pattern.Views.ToList<INamedElementSchema>()
                .OrderBy(v => v.Name)
                .FirstOrDefault(v => v.Id != ((INamedElementSchema)viewSchema).Id);

            if (otherViewSchema != null)
            {
                SetDefaultView(pattern, otherViewSchema.Id);
            }
        }
예제 #7
0
 private static string GetDiagramFileName(IItemContainer parentItem, IViewSchema viewSchema)
 {
     return(System.IO.Path.Combine(
                System.IO.Path.GetDirectoryName(parentItem.PhysicalPath),
                string.Concat(viewSchema.DiagramId, ViewSchemaHelper.PatternModelFileExtension, ViewSchemaHelper.PatternModelDiagramFileExtension)));
 }
예제 #8
0
        private void DeleteViewDiagram(IItemContainer parentItem, IViewSchema viewSchema)
        {
            var path = GetDiagramFileName(parentItem, viewSchema);
            var childItem = parentItem.Items.FirstOrDefault(i => i.PhysicalPath == path);

            if (childItem != null)
            {
                VsHelper.CheckOut(childItem.PhysicalPath);
                childItem.As<EnvDTE.ProjectItem>().Remove();
            }
        }
예제 #9
0
 private static string GetDiagramFileName(IItemContainer parentItem, IViewSchema viewSchema)
 {
     return System.IO.Path.Combine(
         System.IO.Path.GetDirectoryName(parentItem.PhysicalPath),
         string.Concat(viewSchema.DiagramId, ViewSchemaHelper.PatternModelFileExtension, ViewSchemaHelper.PatternModelDiagramFileExtension));
 }