Пример #1
0
        /*
         * PaintShape
         */
        /// <summary>
        /// Returns the color of a given Visio shape.
        /// </summary>
        /// <param name="shape">Root shape</param>
        public static VisDefaultColors ShapeColorGet(IVShape shape)
        {
            #region Validations

            if (shape == null)
            {
                throw new ArgumentNullException(nameof(shape));
            }

            #endregion

            Cell cell = shape.get_CellsSRC((short)VisSectionIndices.visSectionObject, (short)VisRowIndices.visRowLine, (short)VisCellIndices.visLineColor);

            if (cell == null)
            {
                return(VisDefaultColors.visBlack);
            }

            string formula = cell.FormulaU;

            /*
             * Since the color is a fomula, we can't be 100% sure that a color index
             * will be placed there. Of course, we could assume that the model shapes
             * are all kosher, but that's a pretty big risk! In this case, it's best
             * to assume that if it *ISN'T* a color, then return .visTransparent.
             *
             * One of the examples of formula color is: =THEMEGUARD(THEME("Color2")) which
             * is meant to preserve the color of the shape according to the palette of
             * the current theme.
             */
            VisDefaultColors color;

            try
            {
                color = Enumerate.Parse <VisDefaultColors>(formula);
            }
            catch (ActorException)
            {
                color = VisDefaultColors.visTransparent;
            }

            return(color);
        }
Пример #2
0
        /// <summary>
        /// Loads the data for the instance from the resource manager.
        /// </summary>
        /// <param name="itemId">Item identifier.</param>
        /// <param name="args">Argument list.</param>
        /// <returns>Item data.</returns>
        /// <remarks>
        /// This method must *NOT* throw any exceptions. By design, this method must
        /// always succeed in constructing an instance of ModelResultItemData. If there
        /// is any problem during the processing, then the ModelResultItemData class
        /// should be initialized and returned but with a payload that illustrates the
        /// internal error that occurred.
        /// </remarks>
        private static ModelResultItemData LoadFromRm(string itemId, params object[] args)
        {
            #region Validations

            if (itemId == null)
            {
                throw new ArgumentNullException("itemId");
            }

            #endregion

            /*
             *
             */
            CultureInfo ic = CultureInfo.InvariantCulture;


            /*
             *
             */
            string code     = RM.GetString(string.Concat(itemId, "_Code"));
            string actor    = RM.GetString(string.Concat(itemId, "_Actor"));
            string desc     = RM.GetString(string.Concat(itemId, "_Message"));
            string itemType = RM.GetString(string.Concat(itemId, "_ItemType"));

            if (string.IsNullOrEmpty(code) == true)
            {
                return(new ModelResultItemData()
                {
                    Code = -3001,
                    Actor = "ModelResultItem.Internal",
                    Description = string.Format(ic, Resources.ResultItem_CodeNotDefined, itemId),
                    ItemType = ModelResultItemType.Error
                });
            }

            if (string.IsNullOrEmpty(actor) == true)
            {
                return(new ModelResultItemData()
                {
                    Code = -3002,
                    Actor = "ModelResultItem.Internal",
                    Description = string.Format(ic, Resources.ResultItem_ActorNotDefined, itemId),
                    ItemType = ModelResultItemType.Error
                });
            }

            if (string.IsNullOrEmpty(desc) == true)
            {
                return(new ModelResultItemData()
                {
                    Code = -3003,
                    Actor = "ModelResultItem.Internal",
                    Description = string.Format(ic, Resources.ResultItem_DescriptionNotDefined, itemId),
                    ItemType = ModelResultItemType.Error
                });
            }

            if (string.IsNullOrEmpty(itemType) == true)
            {
                return(new ModelResultItemData()
                {
                    Code = -3004,
                    Actor = "ModelResultItem.Internal",
                    Description = string.Format(ic, Resources.ResultItem_ItemTypeNotDefined, itemId),
                    ItemType = ModelResultItemType.Error
                });
            }



            /*
             *
             */
            ModelResultItemData data = new ModelResultItemData();
            data.Actor = actor;



            /*
             * .Code
             */
            try
            {
                data.Code = int.Parse(code, ic);
            }
            catch (FormatException)
            {
                return(new ModelResultItemData()
                {
                    Code = -3005,
                    Actor = "ModelResultItem.Internal",
                    Description = string.Format(ic, Resources.ResultItem_CodeNotInteger, itemId, code),
                    ItemType = ModelResultItemType.Error
                });
            }
            catch (OverflowException)
            {
                return(new ModelResultItemData()
                {
                    Code = -3006,
                    Actor = "ModelResultItem.Internal",
                    Description = string.Format(ic, Resources.ResultItem_CodeNotInteger, itemId, code),
                    ItemType = ModelResultItemType.Error
                });
            }


            /*
             * .ItemType
             */
            try
            {
                data.ItemType = Enumerate.Parse <ModelResultItemType>(itemType);
            }
            catch (ActorException)
            {
                return(new ModelResultItemData()
                {
                    Code = -3007,
                    Actor = "ModelResultItem.Internal",
                    Description = string.Format(ic, Resources.ResultItem_ItemTypeNotEnum, itemId, itemType),
                    ItemType = ModelResultItemType.Error
                });
            }


            /*
             * .Description
             */
            try
            {
                data.Description = string.Format(ic, desc, args);
            }
            catch (FormatException)
            {
                return(new ModelResultItemData()
                {
                    Code = -3008,
                    Actor = "ModelResultItem.Internal",
                    Description = string.Format(ic, Resources.ResultItem_DescriptionFormatFail, itemId, desc, args.Length),
                    ItemType = ModelResultItemType.Error
                });
            }

            return(data);
        }