Exemplo n.º 1
0
        private static void ResolveMasters(DirectedGraphLayout layout_diagram, IVisio.Application app)
        {
            // for masters that are identified by their name and stencil, go find the actual master objects by
            // loading the specified stenciles

            var documents      = app.Documents;
            var master_to_size = new Dictionary <IVisio.Master, VA.Drawing.Size>();

            // Load and cache all the masters
            var loader = new MasterLoader();

            foreach (var layout_shape in layout_diagram.Shapes)
            {
                loader.Add(layout_shape.MasterName, layout_shape.StencilName);
            }
            loader.Resolve(documents);

            // If no size was provided for the shape, then set the size based on the master
            var layoutshapes_without_size_info = layout_diagram.Shapes.Where(s => s.Size == null);

            foreach (var layoutshape in layoutshapes_without_size_info)
            {
                var master = loader.Get(layoutshape.MasterName, layoutshape.StencilName);
                var size   = MsaglRenderer.TryGetValue(master_to_size, master.VisioMaster);
                if (!size.HasValue)
                {
                    var master_bb = master.VisioMaster.GetBoundingBox(IVisio.VisBoundingBoxArgs.visBBoxUprightWH);
                    size = master_bb.Size;
                    master_to_size[master.VisioMaster] = size.Value;
                }
                layoutshape.Size = size.Value;
            }
        }
Exemplo n.º 2
0
 protected virtual void JS <T>(T caller, string snippet) where T : Control
 {
     if (MasterLoader != null)
     {
         MasterLoader.JS <T>(caller, snippet); return;
     }
     _Page().JS <T>(caller, snippet);
 }
Exemplo n.º 3
0
 protected virtual void Alert <T>(T caller, string message, string postScript = null, bool executeBeforeAlert = false) where T : Control
 {
     if (MasterLoader != null)
     {
         MasterLoader.Alert(caller, message, postScript, executeBeforeAlert); return;
     }
     _Page().Alert <T>(caller, message, postScript, executeBeforeAlert);
 }
Exemplo n.º 4
0
 public virtual void JS(string snippet)
 {
     if (MasterLoader != null)
     {
         MasterLoader.JS(snippet); return;
     }
     _Page().JS(this, snippet);
 }
Exemplo n.º 5
0
 public virtual void Alert(string message, string postScript = null, bool executeBeforeAlert = false)
 {
     if (MasterLoader != null)
     {
         MasterLoader.Alert(message, postScript, executeBeforeAlert); return;
     }
     _Page().Alert(this, message, postScript, executeBeforeAlert);
 }
Exemplo n.º 6
0
        public void プロパティと属性に対応したMasterInfoが生成される()
        {
            PropertyFactory factory = new PropertyFactory();
            var             builder = new MasterLoader(factory);
            var             info    = typeof(Hoge).GetMember(nameof(Hoge.Fugas))[0] as PropertyInfo;
            var             attr    = new PwMasterAttribute("ふが", "Fugas");

            var master = builder.AsDynamic().GetMasterinfo((info, attr)) as MasterInfo;

            master.Key.Is("Fugas");
            master.Property.Is(info);
            var collection = master.Master.IsInstanceOf <ComplicateCollectionProperty>();

            collection.ElementType.Is(typeof(Fuga));
            collection.Count.Value.Is(0);
            collection.Title.Value.Is("ふが");
            collection.ValueType.Is(typeof(Fuga[]));
        }
Exemplo n.º 7
0
        public void マスタープロパティを列挙できる()
        {
            PropertyFactory factory = new PropertyFactory();
            var             builder = new MasterLoader(factory);
            var             members = typeof(Hoge).GetMembers();

            var masters = builder.AsDynamic()
                          .GetMastersProperties(members) as IEnumerable <(PropertyInfo info, PwMasterAttribute attr)>;

            var dic = masters.ToDictionary(x => x.info.Name, x => x);

            dic.ContainsKey(nameof(Hoge.Fugas)).IsTrue();
            dic.ContainsKey(nameof(Hoge.Fuga)).IsTrue();
            dic.ContainsKey(nameof(Hoge.NotMember)).IsFalse();
            dic.ContainsKey(nameof(Hoge.Run)).IsFalse();
            dic[nameof(Hoge.Fugas)].attr.Name.Is("ふが");
            dic[nameof(Hoge.Fuga)].attr.Name.IsNull();
            dic[nameof(Hoge.Fugas)].attr.Key.Is("Fugas");
            dic[nameof(Hoge.Fuga)].attr.Key.IsNull();
        }
Exemplo n.º 8
0
        public void MasterInfoをもとに参照情報を生成できる()
        {
            PropertyFactory factory = new PropertyFactory();
            var             builder = new MasterLoader(factory);
            var             info    = new MasterInfo[]
            {
                new MasterInfo("Fugas",
                               typeof(Hoge).GetMember(nameof(Hoge.Fugas))[0] as PropertyInfo,
                               new ComplicateCollectionProperty(typeof(Fuga[]), factory)),
                new MasterInfo("Fuga",
                               typeof(Hoge).GetMember(nameof(Hoge.Fuga))[0] as PropertyInfo,
                               new ClassProperty(typeof(Fuga), factory))
            };

            var repo = builder.AsDynamic()
                       .GetReferencableMasters(info as IEnumerable <MasterInfo>) as MasterRepository;

            repo.ContainsKey("Fugas").IsTrue();
            repo["Fugas"].Type.Is(typeof(Fuga));
            repo.ContainsKey("Fuga").IsFalse();
        }
Exemplo n.º 9
0
        public void サブクラス情報をロードできる()
        {
            PropertyFactory factory = new PropertyFactory();
            var             builder = new MasterLoader(factory);
            var             domain  = new Type[]
            {
                typeof(Subtyping),
                typeof(Subtype1),
                typeof(Subtype2),
                typeof(Hoge),
                typeof(Fuga),
            };

            var subtypes = builder.AsDynamic().GetSubtypes(domain) as Dictionary <Type, Type[]>;

            subtypes.ContainsKey(typeof(Subtyping)).IsTrue();
            subtypes[typeof(Subtyping)].Contains(typeof(Subtype1)).IsTrue();
            subtypes[typeof(Subtyping)].Contains(typeof(Subtype2)).IsTrue();
            subtypes.ContainsKey(typeof(Hoge)).IsFalse();
            subtypes.ContainsKey(typeof(Fuga)).IsFalse();
        }
Exemplo n.º 10
0
        private void ResolveMasters(RenderContext context)
        {
            // Find all the shapes that use masters and for which
            // a Visio master object has not been identifies yet
            var shape_nodes = this._shapes
                              .Where(shape => shape is Shape)
                              .Cast <Shape>()
                              .Where(shape => shape.Master.VisioMaster == null).ToList();

            var loader = new MasterLoader();

            foreach (var shape_node in shape_nodes)
            {
                loader.Add(shape_node.Master.MasterName, shape_node.Master.StencilName);
            }

            var application = context.VisioPage.Application;
            var docs        = application.Documents;

            loader.Resolve(docs);

            foreach (var shape_node in shape_nodes)
            {
                var mref = loader.Get(shape_node.Master.MasterName, shape_node.Master.StencilName);
                shape_node.Master.VisioMaster = mref.VisioMaster;
            }

            // Ensure that all shapes to drop are assigned a visio master object
            foreach (var shape in this._shapes.Where(s => s is Shape).Cast <Shape>())
            {
                if (shape.Master.VisioMaster == null)
                {
                    throw new InternalAssertionException("Missing a master for a shape");
                }
            }
        }
Exemplo n.º 11
0
 private CharacterMaster LoadMaster(string charaID)
 {
     return(MasterLoader.LoadCharaMaster(charaID));
 }
Exemplo n.º 12
0
    private CharacterMaster LoadMaster(string charaID)
    {
        var master = MasterLoader.LoadCharaMaster(charaID);

        return(master);
    }