/// <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(nameof(shape));
            }

            int num_existing_tabstops = GetTabStopCount(shape);

            if (num_existing_tabstops < 1)
            {
                return;
            }

            var cell_tabstopcount = shape.CellsSRC[ShapeSheet.SRCConstants.Tabs_StopCount.Section, ShapeSheet.SRCConstants.Tabs_StopCount.Row, ShapeSheet.SRCConstants.Tabs_StopCount.Cell];

            cell_tabstopcount.FormulaForce = "0";

            const string formula = "0";

            var writer = new FormulaWriterSRC();

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

            writer.Commit(shape);
        }
        /// <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(nameof(shape));
            }

            int num_existing_tabstops = TextFormat.GetTabStopCount(shape);

            if (num_existing_tabstops < 1)
            {
                return;
            }

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

            cell_tabstopcount.FormulaForce = "0";

            const string formula = "0";

            var update = new ShapeSheet.Update();

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

            update.Execute(shape);
        }
 public FormatPaintCell(ShapeSheet.SRC src, string name, FormatCategory category)
 {
     this.Category = category;
     this.Name     = name;
     this.SRC      = src;
     this.Formula  = null;
     this.Result   = null;
 }
Exemple #4
0
        public ColumnQuery AddCell(ShapeSheet.SRC src, string name)
        {
            if (name == null)
            {
                throw new System.ArgumentNullException(nameof(name));
            }

            var col = this.Cells.Add(src, name);

            return(col);
        }
        public static void SetTabStops(IVisio.Shape shape, IList <TabStop> stops)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            if (stops == null)
            {
                throw new System.ArgumentNullException(nameof(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 writer = new FormulaWriterSRC();

            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 ShapeSheet.SRC(tab_section, row, (short)(i + 1));
                var src_tabalign = new ShapeSheet.SRC(tab_section, row, (short)(i + 2));
                var src_tabother = new ShapeSheet.SRC(tab_section, row, (short)(i + 3));

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

            writer.Commit(shape);
        }
        private static IList <TabStop> GetTabStops(IVisio.Shape shape)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            int num_stops = TextFormat.GetTabStopCount(shape);

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

            const short row = 0;


            var srcs = new List <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 ShapeSheet.SRC(TextFormat.tab_section, row, (short)(i + 1));
                var src_tabalign = new ShapeSheet.SRC(TextFormat.tab_section, row, (short)(i + 2));
                var src_tabother = new ShapeSheet.SRC(TextFormat.tab_section, row, (short)(i + 3));

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

            var surface = new ShapeSheet.ShapeSheetSurface(shape);


            var stream    = ShapeSheet.SRC.ToStream(srcs);
            var unitcodes = srcs.Select(i => IVisio.VisUnitCodes.visNumber).ToList();
            var results   = surface.GetResults_SRC <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 = (TabStopAlignment)((int)results[(stop_index * 3) + 2]);
                var ts    = new TabStop(pos, align);
                stops_list.Add(ts);
            }

            return(stops_list);
        }
        public static void Set(IVisio.Shape shape, string name, ShapeSheet.FormulaLiteral value, ShapeSheet.FormulaLiteral prompt)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            UserDefinedCellsHelper.CheckValidName(name);

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

                if (value.HasValue)
                {
                    string value_cell_name = full_prop_name;
                    var cell = shape.CellsU[value_cell_name];
                    cell.FormulaU = value.Encode();                    
                }

                if (prompt.HasValue)
                {
                    string prompt_cell_name = full_prop_name+".Prompt";
                    var cell = shape.CellsU[prompt_cell_name];
                    cell.FormulaU = prompt.Encode();                                        
                }
                return;
            }

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

            var update = new ShapeSheet.Update();

            if (value.HasValue)
            {
                var src = new ShapeSheet.SRC(UserDefinedCellsHelper._userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserValue);
                update.SetFormula(src, value.Encode());
            }

            if (prompt.HasValue)
            {
                var src = new ShapeSheet.SRC(UserDefinedCellsHelper._userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt);
                update.SetFormula(src, prompt.Encode());
            }

            update.Execute(shape);
        }
        public static void Set(IVisio.Shape shape, string name, ShapeSheet.FormulaLiteral value, ShapeSheet.FormulaLiteral prompt)
        {
            if (shape == null)
            {
                throw new System.ArgumentNullException(nameof(shape));
            }

            UserDefinedCellHelper.CheckValidName(name);

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

                if (value.HasValue)
                {
                    string value_cell_name = full_prop_name;
                    var    cell            = shape.CellsU[value_cell_name];
                    cell.FormulaU = value.Encode();
                }

                if (prompt.HasValue)
                {
                    string prompt_cell_name = full_prop_name + ".Prompt";
                    var    cell             = shape.CellsU[prompt_cell_name];
                    cell.FormulaU = prompt.Encode();
                }
                return;
            }

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

            var writer = new FormulaWriterSRC();

            if (value.HasValue)
            {
                var src = new ShapeSheet.SRC(UserDefinedCellHelper._userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserValue);
                writer.SetFormula(src, value.Encode());
            }

            if (prompt.HasValue)
            {
                var src = new ShapeSheet.SRC(UserDefinedCellHelper._userdefinedcell_section, row, (short)IVisio.VisCellIndices.visUserPrompt);
                writer.SetFormula(src, prompt.Encode());
            }

            writer.Commit(shape);
        }
Exemple #9
0
        internal ColumnQuery Add(ShapeSheet.SRC src, string name)
        {
            check_deplicate_src(src);
            string norm_name = this.normalize_name(name);

            check_duplicate_column_name(norm_name);

            int ordinal = this._items.Count;
            var col     = new ColumnQuery(ordinal, src, norm_name);

            this._items.Add(col);

            this._dic_columns[norm_name] = col;
            this._src_set.Add(src);
            return(col);
        }
 public SRCFormulaPair(ShapeSheet.SRC src, ShapeSheet.FormulaLiteral formula)
 {
     this.SRC     = src;
     this.Formula = formula;
 }
 internal ColumnQuery(int ordinal, ShapeSheet.SRC src, string name) :
     base(ordinal, name)
 {
     this.SRC = src;
 }
 protected SRCFormulaPair newpair(ShapeSheet.SRC src, ShapeSheet.FormulaLiteral formula)
 {
     return(new SRCFormulaPair(src, formula));
 }
Exemple #13
0
        public void Add(ShapeSheet.SRC src, FormatCategory category, string name)
        {
            var format_cell = new FormatPaintCell(src, name, category);

            this.Cells.Add(format_cell);
        }
Exemple #14
0
        public void SetResult(short id, ShapeSheet.SRC src, string result)
        {
            var sidsrc = new ShapeSheet.SIDSRC(id, src);

            this.update.SetResult(sidsrc, result, IVisio.VisUnitCodes.visNumber);
        }
Exemple #15
0
        public void SetFormula(short id, ShapeSheet.SRC src, string formula)
        {
            var sidsrc = new ShapeSheet.SIDSRC(id, src);

            this.update.SetFormula(sidsrc, formula);
        }
Exemple #16
0
        public void SetFormulaIgnoreNull(short id, ShapeSheet.SRC src, ShapeSheet.FormulaLiteral formula)
        {
            var sidsrc = new VA.ShapeSheet.SIDSRC(id, src);

            this._SetFormulaIgnoreNull(StreamType.SIDSRC, sidsrc, formula);
        }