Пример #1
0
        public void SetResult(
            IList <IVisio.Shape> target_shapes,
            IList <ShapeSheet.SRC> srcs,
            IList <string> results, IVisio.VisGetSetArgs flags)
        {
            this.Client.Application.AssertApplicationAvailable();
            this.Client.Document.AssertDocumentAvailable();

            var shapes = this.GetTargetShapes(target_shapes);

            if (shapes.Count < 1)
            {
                this.Client.WriteVerbose("SetResult: Zero Shapes. Not performing Operation");
                return;
            }

            if (srcs == null)
            {
                throw new System.ArgumentNullException(nameof(srcs));
            }

            if (results == null)
            {
                throw new System.ArgumentNullException(nameof(results));
            }

            if (results.Any(f => f == null))
            {
                this.Client.WriteVerbose("SetResult: One of the Input Results is a NULL value");
                throw new System.ArgumentException("results contains a null value", nameof(results));
            }

            this.Client.WriteVerbose("SetResult: src count= {0} and result count = {1}", srcs.Count, results.Count);

            if (results.Count != srcs.Count)
            {
                string msg = $"Must have the same number of srcs ({srcs.Count}) and results ({results.Count})";
                throw new System.ArgumentException(msg, nameof(results));
            }

            var shapeids = shapes.Select(s => s.ID).ToList();

            int num_results = results.Count;
            var update      = new ShapeSheet.Update(shapes.Count * num_results);

            update.BlastGuards  = ((short)flags & (short)IVisio.VisGetSetArgs.visSetBlastGuards) != 0;
            update.TestCircular = ((short)flags & (short)IVisio.VisGetSetArgs.visSetTestCircular) != 0;

            foreach (var shapeid in shapeids)
            {
                for (int i = 0; i < num_results; i++)
                {
                    var src    = srcs[i];
                    var result = results[i];
                    update.SetResult((short)shapeid, src, result, IVisio.VisUnitCodes.visNumber);
                }
            }

            var surface     = this.Client.ShapeSheet.GetShapeSheetSurface();
            var application = this.Client.Application.Get();

            using (var undoscope = this.Client.Application.NewUndoScope("Set ShapeSheet Result"))
            {
                update.Execute(surface);
            }
        }