Ejemplo n.º 1
0
        static PolygonFactory()
        {
            List <Exception> exceptions           = new List <Exception>();
            String           absoluteAssemblyPath = Assembly.GetExecutingAssembly().Location;

            if (_FACTORY == null)
            {
                try
                {
                    Assembly archAssembly = Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(absoluteAssemblyPath), "GpcDotNet.IA64.dll"));

                    Type t = archAssembly.GetType("Gpc.PolygonFactoryImpl");
                    if (t != null && typeof(PolygonFactory).IsAssignableFrom(t))
                    {
                        _FACTORY = (PolygonFactory)Activator.CreateInstance(t);
                    }
                }
                catch (Exception e) { exceptions.Add(e); }
            }

            if (_FACTORY == null)
            {
                try
                {
                    Assembly archAssembly = Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(absoluteAssemblyPath), "GpcDotNet.AMD64.dll"));

                    Type t = archAssembly.GetType("Gpc.PolygonFactoryImpl");
                    if (t != null && typeof(PolygonFactory).IsAssignableFrom(t))
                    {
                        _FACTORY = (PolygonFactory)Activator.CreateInstance(t);
                    }
                }
                catch (Exception e) { exceptions.Add(e); }
            }

            if (_FACTORY == null)
            {
                try
                {
                    Assembly archAssembly = Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(absoluteAssemblyPath), "GpcDotNet.IA32.dll"));

                    Type t = archAssembly.GetType("Gpc.PolygonFactoryImpl");
                    if (t != null && typeof(PolygonFactory).IsAssignableFrom(t))
                    {
                        _FACTORY = (PolygonFactory)Activator.CreateInstance(t);
                    }
                }
                catch (Exception e) { exceptions.Add(e); }
            }

            if (_FACTORY == null)
            {
                String msg = "Unable to load a native library for GPC.";
                foreach (Exception e in exceptions)
                {
                    msg += " {" + e.GetType().Name + ": " + e.Message + "}";
                }
                throw new Exception(msg);
            }
        }
Ejemplo n.º 2
0
        private void btnAddPoly_Click(object sender, EventArgs e)
        {
            if (ofdPolygon.ShowDialog(this) == DialogResult.Cancel)
            {
                return;
            }

            using (Stream input = ofdPolygon.OpenFile())
            {
                PolygonWrapper wrapper = new PolygonWrapper(ofdPolygon.FileName, PolygonFactory.Read(new StreamReader(input, Encoding.ASCII), true));
                lbPolygons.Items.Add(wrapper);
                _UpdatePictureBox();
            }
        }