コード例 #1
0
        /// <summary>
        /// Remove all tab stops on the shape
        /// </summary>
        /// <param name="shape"></param>
        private static void ClearTabStops(IVisio.Shape shape)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException("shape");
            }

            int num_existing_tabstops = GetTabStopCount(shape);

            if (num_existing_tabstops < 1)
            {
                return;
            }

            var cell_tabstopcount = shape.CellsSRC[src_tabstopcount.Section, src_tabstopcount.Row, src_tabstopcount.Cell];

            cell_tabstopcount.FormulaForce = "0";

            const string formula = "0";

            var update = new VA.ShapeSheet.Update();

            for (int i = 1; i < num_existing_tabstops * 3; i++)
            {
                var src = new VA.ShapeSheet.SRC(tab_section, (short)IVisio.VisRowIndices.visRowTab,
                                                (short)i);
                update.SetFormula(src, formula);
            }

            update.Execute(shape);
        }
コード例 #2
0
        public short Render(IVisio.Shape shape)
        {
            short sec_index = GeometryHelper.AddSection(shape);
            short row_count = shape.RowCount[sec_index];

            var writer = new FormulaWriterSRC();

            var src_nofill      = new VA.ShapeSheet.SRC(sec_index, 0, ShapeSheet.SRCConstants.Geometry_NoFill.Cell);
            var src_noline      = new VA.ShapeSheet.SRC(sec_index, 0, ShapeSheet.SRCConstants.Geometry_NoLine.Cell);
            var src_noshow      = new VA.ShapeSheet.SRC(sec_index, 0, ShapeSheet.SRCConstants.Geometry_NoShow.Cell);
            var src_nosnap      = new VA.ShapeSheet.SRC(sec_index, 0, ShapeSheet.SRCConstants.Geometry_NoSnap.Cell);
            var src_noquickdrag = new VA.ShapeSheet.SRC(sec_index, 0, ShapeSheet.SRCConstants.Geometry_NoQuickDrag.Cell);

            writer.SetFormula(src_nofill, this.NoFill);
            writer.SetFormula(src_noline, this.NoLine);
            writer.SetFormula(src_noshow, this.NoShow);
            writer.SetFormula(src_nosnap, this.NoSnap);
            writer.SetFormula(src_noquickdrag, this.NoQuickDrag);

            foreach (var row in this.Rows)
            {
                row.AddTo(shape, writer, row_count, sec_index);
                row_count++;
            }

            writer.Commit(shape);
            return(0);
        }
コード例 #3
0
 public FormatPaintCell(VisioAutomation.ShapeSheet.SRC src, string name, FormatCategory category)
 {
     this.Category = category;
     this.Name     = name;
     this.SRC      = src;
     this.Formula  = null;
     this.Result   = null;
 }
コード例 #4
0
        public void VerifySRCSize()
        {
            // SRCs must be 6 bytes
            var c1 = new VisioAutomation.ShapeSheet.SRC();
            int actual_size = System.Runtime.InteropServices.Marshal.SizeOf(c1);
            Assert.AreEqual(6, actual_size);

            this.VerifyFormulaLiteralSize();
        }
コード例 #5
0
        public void VerifySRCSize()
        {
            // SRCs must be 6 bytes
            var c1          = new VisioAutomation.ShapeSheet.SRC();
            int actual_size = System.Runtime.InteropServices.Marshal.SizeOf(c1);

            Assert.AreEqual(6, actual_size);

            this.VerifyFormulaLiteralSize();
        }
コード例 #6
0
        public static void Set(IVisio.Shape shape, string name, string value, string prompt)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException("shape");
            }

            CheckValidName(name);

            if (Contains(shape, name))
            {
                string full_prop_name = GetRowName(name);

                if (value != null)
                {
                    string value_cell_name = full_prop_name;
                    var    cell            = shape.CellsU[value_cell_name];
                    string value_formula   = Convert.StringToFormulaString(value);
                    cell.FormulaU = value_formula;
                }

                if (prompt != null)
                {
                    string prompt_cell_name = full_prop_name + ".Prompt";
                    var    cell             = shape.CellsU[prompt_cell_name];
                    var    prompt_formula   = Convert.StringToFormulaString(prompt);
                    cell.FormulaU = prompt_formula;
                }
                return;
            }

            short row = shape.AddNamedRow(
                _userdefinedcell_section,
                name,
                (short)IVisio.VisRowIndices.visRowUser);

            var update = new VA.ShapeSheet.Update();

            if (value != null)
            {
                string value_formula = Convert.StringToFormulaString(value);
                var    src           = new VA.ShapeSheet.SRC(_userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserValue);
                update.SetFormula(src, value_formula);
            }

            if (prompt != null)
            {
                string prompt_formula = Convert.StringToFormulaString(prompt);
                var    src            = new VA.ShapeSheet.SRC(_userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt);
                update.SetFormula(src, prompt_formula);
            }

            update.Execute(shape);
        }
コード例 #7
0
        public bool section_is_skippable(VA.ShapeSheet.SRC src)
        {
            bool can_skip = (src.Section == (short)IVisio.VisSectionIndices.visSectionFirst) ||
                            (src.Section == (short)IVisio.VisSectionIndices.visSectionFirstComponent) ||
                            (src.Section == (short)IVisio.VisSectionIndices.visSectionLast) ||
                            (src.Section == (short)IVisio.VisSectionIndices.visSectionInval) ||
                            (src.Section == (short)IVisio.VisSectionIndices.visSectionNone) ||
                            (src.Section == (short)IVisio.VisSectionIndices.visSectionFirst) ||
                            (src.Section == (short)IVisio.VisSectionIndices.visSectionLastComponent);

            return(can_skip);
        }
コード例 #8
0
        public static void SetTabStops(IVisio.Shape shape, IList <TabStop> stops)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException("shape");
            }

            if (stops == null)
            {
                throw new System.ArgumentNullException("stops");
            }

            ClearTabStops(shape);
            if (stops.Count < 1)
            {
                return;
            }

            const short row = 0;
            var         invariant_culture  = System.Globalization.CultureInfo.InvariantCulture;
            var         vis_tab_stop_count = (short)IVisio.VisCellIndices.visTabStopCount;
            var         tabstopcountcell   = shape.CellsSRC[tab_section, row, vis_tab_stop_count];

            tabstopcountcell.FormulaU = stops.Count.ToString(invariant_culture);

            // set the number of tab stobs allowed for the shape
            var tagtab = GetTabTagForStops(stops.Count);

            shape.RowType[tab_section, (short)IVisio.VisRowIndices.visRowTab] = (short)tagtab;

            // add tab properties for each stop
            var update = new VA.ShapeSheet.Update();

            for (int stop_index = 0; stop_index < stops.Count; stop_index++)
            {
                int i = stop_index * 3;

                var alignment = ((int)stops[stop_index].Alignment).ToString(invariant_culture);
                var position  = ((int)stops[stop_index].Position).ToString(invariant_culture);

                var src_tabpos   = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 1));
                var src_tabalign = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 2));
                var src_tabother = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 3));

                update.SetFormula(src_tabpos, position);    // tab position
                update.SetFormula(src_tabalign, alignment); // tab alignment
                update.SetFormula(src_tabother, "0");       // tab unknown
            }

            update.Execute(shape);
        }
コード例 #9
0
        private static IList <TabStop> GetTabStops(IVisio.Shape shape)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException("shape");
            }

            int num_stops = VA.Text.TextFormat.GetTabStopCount(shape);

            if (num_stops < 1)
            {
                return(new List <TabStop>(0));
            }

            const short row = 0;


            var srcs = new List <VA.ShapeSheet.SRC>(num_stops * 3);

            for (int stop_index = 0; stop_index < num_stops; stop_index++)
            {
                int i = stop_index * 3;

                var src_tabpos   = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 1));
                var src_tabalign = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 2));
                var src_tabother = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 3));

                srcs.Add(src_tabpos);
                srcs.Add(src_tabalign);
                srcs.Add(src_tabother);
            }

            var surface = new VA.Drawing.DrawingSurface(shape);


            var stream    = VA.ShapeSheet.SRC.ToStream(srcs);
            var unitcodes = srcs.Select(i => IVisio.VisUnitCodes.visNumber).ToList();
            var results   = surface.GetResults_3 <double>(stream, unitcodes);

            var stops_list = new List <TabStop>(num_stops);

            for (int stop_index = 0; stop_index < num_stops; stop_index++)
            {
                var pos   = results[(stop_index * 3) + 1];
                var align = (VA.Text.TabStopAlignment)((int)results[(stop_index * 3) + 2]);
                var ts    = new VA.Text.TabStop(pos, align);
                stops_list.Add(ts);
            }

            return(stops_list);
        }
コード例 #10
0
        private void Update(short section_index, short row_index, FormulaWriterSRC writer)
        {
            var x_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_X.Cell);
            var y_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_Y.Cell);
            var a_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_A.Cell);
            var b_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_B.Cell);
            var c_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_C.Cell);
            var d_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_D.Cell);
            var e_src = new VA.ShapeSheet.SRC(section_index, row_index, ShapeSheet.SRCConstants.Geometry_E.Cell);

            writer.SetFormula(x_src, this.X);
            writer.SetFormula(y_src, this.Y);
            writer.SetFormula(a_src, this.A);
            writer.SetFormula(b_src, this.B);
            writer.SetFormula(c_src, this.C);
            writer.SetFormula(d_src, this.D);
            writer.SetFormula(e_src, this.E);
        }
コード例 #11
0
        public void SetFormula(short id, VA.ShapeSheet.SRC src, string formula)
        {
            var sidsrc = new VA.ShapeSheet.SIDSRC(id, src);

            this.update.SetFormula(sidsrc, formula);
        }
コード例 #12
0
        public void Add(FormatCategory category, string name, VA.ShapeSheet.SRC src)
        {
            var format_cell = new FormatPaintCell(src, name, category);

            this.Cells.Add(format_cell);
        }
コード例 #13
0
        public void SRCSizeIs6Bytes()
        {
            var c1 = new VA.ShapeSheet.SRC();

            Assert.AreEqual(6, System.Runtime.InteropServices.Marshal.SizeOf(c1));
        }
コード例 #14
0
        public static void Set(IVisio.Shape shape, string name, string value, string prompt)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException("shape");
            }

            CheckValidName(name);

            if (Contains(shape, name))
            {
                string full_prop_name = GetRowName(name);

                if (value != null)
                {
                    string value_cell_name = full_prop_name;
                    var cell = shape.CellsU[value_cell_name];
                    string value_formula = Convert.StringToFormulaString(value);
                    cell.FormulaU = value_formula;
                }

                if (prompt != null)
                {
                    string prompt_cell_name = full_prop_name+".Prompt";
                    var cell = shape.CellsU[prompt_cell_name];
                    var prompt_formula = Convert.StringToFormulaString(prompt);
                    cell.FormulaU = prompt_formula;
                }
                return;
            }

            short row = shape.AddNamedRow(
                _userdefinedcell_section,
                name,
                (short)IVisio.VisRowIndices.visRowUser);

            var update = new VA.ShapeSheet.Update();

            if (value != null)
            {
                string value_formula = Convert.StringToFormulaString(value);
                var src = new VA.ShapeSheet.SRC(_userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserValue);
                update.SetFormula(src, value_formula);
            }

            if (prompt != null)
            {
                string prompt_formula = Convert.StringToFormulaString(prompt);
                var src = new VA.ShapeSheet.SRC(_userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt);
                update.SetFormula(src, prompt_formula);
            }

            update.Execute(shape);
        }
コード例 #15
0
 public void SRCSizeIs6Bytes()
 {
     var c1 = new VA.ShapeSheet.SRC();
     Assert.AreEqual(6, System.Runtime.InteropServices.Marshal.SizeOf(c1));
 }
コード例 #16
0
        /// <summary>
        /// Remove all tab stops on the shape
        /// </summary>
        /// <param name="shape"></param>
        private static void ClearTabStops(IVisio.Shape shape)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException("shape");
            }

            int num_existing_tabstops = GetTabStopCount(shape);

            if (num_existing_tabstops < 1)
            {
                return;
            }

            var cell_tabstopcount = shape.CellsSRC[src_tabstopcount.Section, src_tabstopcount.Row, src_tabstopcount.Cell];
            cell_tabstopcount.FormulaForce = "0";

            const string formula = "0";

            var update = new VA.ShapeSheet.Update();
            for (int i = 1; i < num_existing_tabstops * 3; i++)
            {
                var src = new VA.ShapeSheet.SRC(tab_section, (short)IVisio.VisRowIndices.visRowTab,
                                                (short)i);
                update.SetFormula(src, formula);
            }

            update.Execute(shape);
        }
コード例 #17
0
 public ColorItem(string name, VA.ShapeSheet.SRC src)
 {
     this.Name    = name;
     this.SRC     = src;
     this.Formula = null;
 }
コード例 #18
0
        public static void SetTabStops(IVisio.Shape shape, IList<TabStop> stops)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException("shape");
            }

            if (stops == null)
            {
                throw new System.ArgumentNullException("stops");
            }

            ClearTabStops(shape);
            if (stops.Count < 1)
            {
                return;
            }

            const short row = 0;
            var invariant_culture = System.Globalization.CultureInfo.InvariantCulture;
            var vis_tab_stop_count = (short)IVisio.VisCellIndices.visTabStopCount;
            var tabstopcountcell = shape.CellsSRC[tab_section, row, vis_tab_stop_count];
            tabstopcountcell.FormulaU = stops.Count.ToString(invariant_culture);

            // set the number of tab stobs allowed for the shape
            var tagtab = GetTabTagForStops(stops.Count);
            shape.RowType[tab_section, (short)IVisio.VisRowIndices.visRowTab] = (short)tagtab;

            // add tab properties for each stop
            var update = new VA.ShapeSheet.Update();
            for (int stop_index = 0; stop_index < stops.Count; stop_index++)
            {
                int i = stop_index * 3;

                var alignment = ((int)stops[stop_index].Alignment).ToString(invariant_culture);
                var position = ((int)stops[stop_index].Position).ToString(invariant_culture);

                var src_tabpos = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 1));
                var src_tabalign = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 2));
                var src_tabother = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 3));

                update.SetFormula(src_tabpos, position); // tab position
                update.SetFormula(src_tabalign, alignment); // tab alignment
                update.SetFormula(src_tabother, "0"); // tab unknown
            }

            update.Execute(shape);
        }
コード例 #19
0
        private static IList<TabStop> GetTabStops(IVisio.Shape shape)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException("shape");
            }

            int num_stops = VA.Text.TextFormat.GetTabStopCount(shape);

            if (num_stops < 1)
            {
                return new List<TabStop>(0);
            }

            const short row = 0;

            var srcs = new List<VA.ShapeSheet.SRC>(num_stops*3);
            for (int stop_index = 0; stop_index < num_stops; stop_index++)
            {
                int i = stop_index * 3;

                var src_tabpos = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 1));
                var src_tabalign = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 2));
                var src_tabother = new VA.ShapeSheet.SRC(tab_section, row, (short)(i + 3));

                srcs.Add(src_tabpos);
                srcs.Add(src_tabalign );
                srcs.Add(src_tabother);
            }

            var surface = new VA.Drawing.DrawingSurface(shape);

            var stream = VA.ShapeSheet.SRC.ToStream(srcs);
            var unitcodes = srcs.Select(i => IVisio.VisUnitCodes.visNumber).ToList();
            var results = surface.GetResults_3<double>(stream, unitcodes);

            var stops_list = new List<TabStop>(num_stops);
            for (int stop_index = 0; stop_index < num_stops; stop_index++)
            {
                var pos = results[(stop_index*3) + 1];
                var align = (VA.Text.TabStopAlignment) ((int)results[(stop_index*3) + 2]);
                var ts = new VA.Text.TabStop(pos, align);
                stops_list.Add(ts);
            }

            return stops_list;
        }
コード例 #20
0
ファイル: SubQuery.cs プロジェクト: MikeJonny/VisioAutomation
        public ColumnSubQuery AddCell(VisioAutomation.ShapeSheet.SRC src, string name)
        {
            var col = this.Columns.Add(src.Cell, name);

            return(col);
        }
コード例 #21
0
        public void SetResult(short id, VA.ShapeSheet.SRC src, string result)
        {
            var sidsrc = new VA.ShapeSheet.SIDSRC(id, src);

            this.update.SetResult(sidsrc, result, IVisio.VisUnitCodes.visNumber);
        }