Exemple #1
0
        private void _resolve_masters(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.OfType <Shape>()
                              .Where(shape => shape.Master.VisioMaster == null).ToList();

            var master_cache = new MasterCache();

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

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

            master_cache.Resolve(docs);

            foreach (var shape_node in shape_nodes)
            {
                var mref = master_cache.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.OfType <Shape>())
            {
                if (shape.Master.VisioMaster == null)
                {
                    throw new InternalAssertionException("Missing a master for a shape");
                }
            }
        }
        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.Geometry.Size>();

            // Load and cache all the masters
            var master_cache = new MasterCache();

            foreach (var layout_shape in layout_diagram.Shapes)
            {
                master_cache.Add(layout_shape.MasterName, layout_shape.StencilName);
            }
            master_cache.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 = master_cache.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;
            }
        }
Exemple #3
0
        /// <summary>
        /// Gets the cache associated with a type derived from the abstract class Model.
        /// If the cache hasn't been accessed yet, this creates one for the type.
        /// </summary>
        public static ModelCache Get(Type type)
        {
            if (MasterCache == null)
            {
                MasterCache = new Dictionary <Type, ModelCache>();
            }

            if (!MasterCache.ContainsKey(type))
            {
                MasterCache.Add(type, new ModelCache(type));
            }

            return(MasterCache[type]);
        }
        public MasterTaskManager()
        {
            _winList         = new ConcurrentDictionary <string, IWindowTask>();
            _expList         = new ConcurrentDictionary <string, IExpressionTask>();
            _workList        = new ConcurrentDictionary <string, IWorker>();
            _masterCacheList = new ConcurrentDictionary <string, byte[]>();
            _masterCache     = new MasterCache();
            _context         = new GlobalContext(new ActionBlock <ICalculateContext>(ParallelCalculate, new ExecutionDataflowBlockOptions()
            {
                MaxDegreeOfParallelism = GlobalConfig.Config.MaxDegreeOfParallelism
            }));

            LoadCache();

            _remoteInvokeThread              = new Thread(new ThreadStart(RemoteInvokeThread));
            _remoteInvokeThread.Name         = "RemoteInvokeThread";
            _remoteInvokeThread.IsBackground = true;
            _remoteInvokeThread.Start();
        }
        protected override void HandleErrors()
        {
            if (!string.IsNullOrEmpty(PXUIFieldAttribute.GetErrorOnly(MasterCache, _masterRow, _masterQtyField.Name)))
            {
                return;
            }

            PXCache detailCache = MasterCache.Graph.Caches[DetailType];

            foreach (var redirected in RedirectedSplits)
            {
                if (detailCache.Cached.OfType <object>().Contains(redirected.Key))
                {
                    if (PXDBQuantityAttribute.VerifyForDecimal <TDetailQty>(detailCache, redirected.Key) != null)
                    {
                        MasterCache.RaiseExceptionHandling(_masterQtyField.Name, _masterRow, MasterCache.GetValue(_masterRow, _masterQtyField.Name), redirected.Value);
                        break;
                    }
                }
            }
        }