예제 #1
0
        public static int ConvertToInt(object objValue)
        {
            int result = 0;

            if (!CommonAPI.IsNullValue(objValue))
            {
                int.TryParse(objValue.ToString(), out result);
            }
            return(result);
        }
예제 #2
0
        public static string ConvertToString(object objValue)
        {
            string result = "";

            if (!CommonAPI.IsNullValue(objValue))
            {
                result = objValue.ToString();
            }
            return(result);
        }
예제 #3
0
        /// <summary>
        /// Converts to double.
        /// </summary>
        /// <param name="objValue">The object value.</param>
        /// <returns>System.Double.</returns>
        public static double ConvertToDouble(object objValue)
        {
            double result = -1.0;

            if (!CommonAPI.IsNullValue(objValue))
            {
                double.TryParse(objValue.ToString(), out result);
            }
            return(result);
        }
예제 #4
0
        /// <summary>
        /// Previews the item.
        /// </summary>
        /// <param name="Symbol">The symbol.</param>
        /// <param name="Width">The width.</param>
        /// <param name="Height">The height.</param>
        /// <returns>System.Drawing.Bitmap.</returns>
        public static System.Drawing.Bitmap PreviewItem(ISymbol Symbol, int Width, int Height)
        {
            if (Symbol == null)
            {
                return(null);
            }
            System.Drawing.Bitmap   bitmap   = new System.Drawing.Bitmap(Width, Height);
            System.Drawing.Graphics graphics = System.Drawing.Graphics.FromImage(bitmap);
            graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
            double    resolution = (double)graphics.DpiY;
            IEnvelope envelope   = new EnvelopeClass();

            envelope.PutCoords(0.0, 0.0, (double)bitmap.Width, (double)bitmap.Height);
            tagRECT tagRECT = default(tagRECT);

            tagRECT.bottom = bitmap.Height;
            tagRECT.left   = 0;
            tagRECT.right  = bitmap.Width;
            tagRECT.top    = 0;
            IDisplayTransformation displayTransformation = new DisplayTransformationClass();

            displayTransformation.VisibleBounds = envelope;
            displayTransformation.Bounds        = envelope;
            displayTransformation.set_DeviceFrame(ref tagRECT);
            displayTransformation.Resolution = resolution;
            System.IntPtr hdc = graphics.GetHdc();
            int           hDC = hdc.ToInt32();

            Symbol.SetupDC(hDC, displayTransformation);
            IGeometry symbolGeometry = CommonAPI.GetSymbolGeometry(Symbol, envelope);

            Symbol.Draw(symbolGeometry);
            Symbol.ResetDC();
            graphics.ReleaseHdc(hdc);
            graphics.Dispose();
            return(bitmap);
        }