Exemple #1
0
        private ISymbol ConvertstringToSymbol(string data)
        {
            int i;

            byte[] numArray = Convert.FromBase64String(data);
            int    length   = (int)numArray.Length - 16;

            byte[] numArray1 = new byte[16];
            for (i = 0; i < 16; i++)
            {
                numArray1[i] = numArray[i];
            }
            Guid           guid          = new Guid(numArray1);
            IPersistStream persistStream = (IPersistStream)Activator.CreateInstance(Type.GetTypeFromCLSID(guid));

            byte[] numArray2 = new byte[length];
            for (i = 0; i < length; i++)
            {
                numArray2[i] = numArray[i + 16];
            }
            IMemoryBlobStream memoryBlobStreamClass = new MemoryBlobStream();

            ((IMemoryBlobStreamVariant)memoryBlobStreamClass).ImportFromVariant(numArray2);
            persistStream.Load(memoryBlobStreamClass);
            return(persistStream as ISymbol);
        }
Exemple #2
0
        public void RemoveItem(IStyleGalleryItem istyleGalleryItem_0)
        {
            Guid   guid;
            object obj;

            if (this.string_0 != "")
            {
                string str = this.method_2(istyleGalleryItem_0);
                if (str.Length != 0 && istyleGalleryItem_0.ID != -1)
                {
                    IPersistStream    item = (IPersistStream)istyleGalleryItem_0.Item;
                    IMemoryBlobStream memoryBlobStreamClass = new MemoryBlobStream();
                    (new ObjectStream()).Stream = memoryBlobStreamClass;
                    item.GetClassID(out guid);
                    item.Save(memoryBlobStreamClass, 1);
                    ((IMemoryBlobStreamVariant)memoryBlobStreamClass).ExportToVariant(out obj);
                    Array  arrays   = (Array)obj;
                    byte[] numArray = new byte[arrays.Length + 16];
                    guid.ToByteArray().CopyTo(numArray, 0);
                    arrays.CopyTo(numArray, 16);
                    obj = numArray;
                    OleDbConnection oleDbConnection =
                        new OleDbConnection(string.Concat("Provider=Microsoft.Jet.OLEDB.4.0;Data source= ",
                                                          this.string_0));
                    oleDbConnection.Open();
                    OleDbCommand d = this.method_7(str, oleDbConnection);
                    d.Parameters["ID"].Value = istyleGalleryItem_0.ID;
                    d.ExecuteNonQuery();
                    oleDbConnection.Close();
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Each BuilderItem contains a Function Raster Dataset which is used to create the thumbnail.
        /// The thumbnail is created by Nearest Neighbor resampling of the Function Raster Dataset.
        /// The resampled raster is exported as a byte array and saved Into the IMemoryBlobStreamVariant.
        /// The blob is then inserted into the Thumbnail field.
        /// </summary>
        /// <param name="mybuilderItem">Item containing the Function Dataset to be added to the Mosaic Dataset</param>
        private void Resampling(IBuilderItem mybuilderItem)
        {
            try
            {
                IFunctionRasterDataset pFuncRasterDataset = mybuilderItem.Dataset; // Get the FunctionRasterDataset from mybuilderItem
                IRasterDataset         pRasterDataset;
                pRasterDataset = (IRasterDataset)pFuncRasterDataset;               // Cast the FunctionRasterDataset to Raster Dataset
                IPropertySet thePropSet = pFuncRasterDataset.Properties;           // Get the properties of the raster Dataset
                IRaster      praster    = pRasterDataset.CreateDefaultRaster();    // Create default raster from the above raster dataset
                praster.ResampleMethod = rstResamplingTypes.RSP_NearestNeighbor;   // The raster is resampled by RSP_NearestNeighbor
                IRasterProps pRasterProps = (IRasterProps)praster;                 // Raster properties are used to update the height, width of the raster
                pRasterProps.Height = 256;
                pRasterProps.Width  = 256;

                IRasterExporter pConverter = new RasterExporterClass();                           // IRasterExporter object is used to convert the raster to byte array.
                byte[]          pBytesArr;
                pBytesArr = pConverter.ExportToBytes(praster, "TIFF");                            // Convert the resampled Raster to a Byte array
                IMemoryBlobStream        memBlobStream = new MemoryBlobStream();                  // Create new IMemoryBlobStream
                IMemoryBlobStreamVariant varBlobStream = (IMemoryBlobStreamVariant)memBlobStream; // Assign to IMemoryBlobStreamVariant
                object anObject = pBytesArr;
                varBlobStream.ImportFromVariant(anObject);                                        // IMemoryBlobStreamVariant object is assigned the byte array
                thePropSet.SetProperty("ThumbNail", memBlobStream);                               // and saved to the property "ThumbNail"
            }
            catch (Exception ex)
            {
                System.Exception myExc = new System.Exception(
                    "Error: Failed to Re-Sampled the raster.Thumbnails will not be created." + ex.Message, ex);
                throw myExc;
            }
            return;
        }
Exemple #4
0
        private void method_3(string string_1, string string_2, IList ilist_0)
        {
            int       j;
            Exception exception;

            try
            {
                OleDbConnection oleDbConnection =
                    new OleDbConnection(string.Concat("Provider=Microsoft.Jet.OLEDB.4.0;Data source= ", string_2));
                string           str = string.Concat("SELECT * FROM [", string_1, "]");
                OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(str, oleDbConnection);
                DataSet          dataSet          = new DataSet();
                oleDbDataAdapter.Fill(dataSet);
                oleDbConnection.Close();
                for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                {
                    try
                    {
                        IStyleGalleryItem myStyleGalleryItem = new MyStyleGalleryItem();
                        ((MyStyleGalleryItem)myStyleGalleryItem).ItemID = (int)dataSet.Tables[0].Rows[i]["ID"];
                        myStyleGalleryItem.Name     = (string)dataSet.Tables[0].Rows[i]["Name"];
                        myStyleGalleryItem.Category = (string)dataSet.Tables[0].Rows[i]["Category"];
                        IMemoryBlobStream memoryBlobStreamClass = new MemoryBlobStream();
                        object            item   = dataSet.Tables[0].Rows[i]["Object"];
                        Array             arrays = (Array)item;
                        int    length            = arrays.Length - 16;
                        byte[] value             = new byte[16];
                        for (j = 0; j < 16; j++)
                        {
                            value[j] = (byte)arrays.GetValue(j);
                        }
                        IPersistStream persistStream = (IPersistStream)this.method_0(new Guid(value));
                        byte[]         numArray      = new byte[length];
                        for (j = 0; j < length; j++)
                        {
                            numArray[j] = (byte)arrays.GetValue(j + 16);
                        }
                        ((IMemoryBlobStreamVariant)memoryBlobStreamClass).ImportFromVariant(numArray);
                        persistStream.Load(memoryBlobStreamClass);
                        myStyleGalleryItem.Item = persistStream;
                        ilist_0.Add(myStyleGalleryItem);
                    }
                    catch (Exception exception1)
                    {
                        exception = exception1;
                        // CErrorLog.writeErrorLog(this, exception, "");
                    }
                }
            }
            catch (Exception exception2)
            {
                exception = exception2;
                //CErrorLog.writeErrorLog(this, exception, "");
                MessageBox.Show(exception.Message);
            }
        }
        private void LoadToolbarControlItems(string filePath)
        {
            //Create a MemoryBlobStream
            IBlobStream blobStream = new MemoryBlobStream();
            //Get the IStream interface
            IStream stream = blobStream;

            //Load the stream from the file
            blobStream.LoadFromFile(filePath);
            //Load the stream into the ToolbarControl
            axToolbarControl1.LoadItems(stream);
        }
        private void SaveToolbarControlItems(string filePath)
        {
            //Create a MemoryBlobStream
            IBlobStream blobStream = new MemoryBlobStream();
            //Get the IStream interface
            IStream stream = blobStream;

            //Save the ToolbarControl into the stream
            axToolbarControl1.SaveItems(stream);
            //Save the stream to a file
            blobStream.SaveToFile(filePath);
        }
Exemple #7
0
        public static IFeatureRenderer ReadRender(string string_0)
        {
            BinaryReader binaryReader = new BinaryReader(new System.IO.FileStream(string_0, FileMode.Open));

            byte[]            numArray = binaryReader.ReadBytes(binaryReader.ReadInt32());
            IMemoryBlobStream memoryBlobStreamClass = new MemoryBlobStream();
            IObjectStream     objectStreamClass     = new ObjectStream()
            {
                Stream = memoryBlobStreamClass
            };

            ((IMemoryBlobStreamVariant)memoryBlobStreamClass).ImportFromVariant(numArray);
            IPropertySet propertySetClass = new PropertySet();

            (propertySetClass as IPersistStream).Load(objectStreamClass);
            return(propertySetClass.GetProperty("Render") as IFeatureRenderer);
        }
Exemple #8
0
        private void method_4(string string_1, string string_2, string string_3, IList ilist_0)
        {
            int j;

            try
            {
                OleDbConnection oleDbConnection =
                    new OleDbConnection(string.Concat("Provider=Microsoft.Jet.OLEDB.4.0;Data source= ", string_2));
                string[]       string1          = new string[] { "SELECT * FROM [", string_1, "] Where Category = '", string_3, "'" };
                IDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(string.Concat(string1), oleDbConnection);
                DataSet        dataSet          = new DataSet();
                oleDbDataAdapter.Fill(dataSet);
                oleDbConnection.Close();
                for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
                {
                    IStyleGalleryItem myStyleGalleryItem = new MyStyleGalleryItem();
                    ((MyStyleGalleryItem)myStyleGalleryItem).ItemID = (int)dataSet.Tables[0].Rows[i]["ID"];
                    myStyleGalleryItem.Name     = (string)dataSet.Tables[0].Rows[i]["Name"];
                    myStyleGalleryItem.Category = (string)dataSet.Tables[0].Rows[i]["Category"];
                    IMemoryBlobStream memoryBlobStreamClass = new MemoryBlobStream();
                    object            item   = dataSet.Tables[0].Rows[i]["Object"];
                    Array             arrays = (Array)item;
                    int    length            = arrays.Length - 16;
                    byte[] value             = new byte[16];
                    for (j = 0; j < 16; j++)
                    {
                        value[j] = (byte)arrays.GetValue(j);
                    }
                    IPersistStream persistStream = (IPersistStream)this.method_0(new Guid(value));
                    byte[]         numArray      = new byte[length];
                    for (j = 0; j < length; j++)
                    {
                        numArray[j] = (byte)arrays.GetValue(j + 16);
                    }
                    ((IMemoryBlobStreamVariant)memoryBlobStreamClass).ImportFromVariant(numArray);
                    persistStream.Load(memoryBlobStreamClass);
                    myStyleGalleryItem.Item = persistStream;
                    ilist_0.Add(myStyleGalleryItem);
                }
            }
            catch
            {
            }
        }
Exemple #9
0
 public override void OnClick()
 {
     if (m_DialogSaveGlobe.ShowDialog() == DialogResult.OK)
     {
         try
         {
             IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStream();
             IObjectStream     pObjectStream     = new ObjectStream();
             pObjectStream.Stream = pMemoryBlobStream;
             IPersistStream pPersistStream = m_globeHookHelper.Globe as IPersistStream;
             pPersistStream.Save(pObjectStream, 1);
             pMemoryBlobStream.SaveToFile(m_DialogSaveGlobe.FileName);
             IMapDocument mapDoc;
         }
         catch (Exception exp)
         {
             DevExpress.XtraEditors.XtraMessageBox.Show(string.Format("抱歉,保存操作出现意外错误,信息:{0}", exp.Message));
         }
     }
 }
Exemple #10
0
 public override void OnClick()
 {
     if (m_DialogSaveGlobe.ShowDialog() == DialogResult.OK)
     {
         try
         {
             IMemoryBlobStream pMemoryBlobStream = new MemoryBlobStream();
             IObjectStream pObjectStream = new ObjectStream();
             pObjectStream.Stream = pMemoryBlobStream;
             IPersistStream pPersistStream = m_globeHookHelper.Globe as IPersistStream;
             pPersistStream.Save(pObjectStream, 1);
             pMemoryBlobStream.SaveToFile(m_DialogSaveGlobe.FileName);
             IMapDocument mapDoc;
         }
         catch(Exception exp)
         {
             DevExpress.XtraEditors.XtraMessageBox.Show(string.Format("抱歉,保存操作出现意外错误,信息:{0}", exp.Message));
         }
     }
 }
Exemple #11
0
        public static void SaveRender(IFeatureRenderer ifeatureRenderer_0, string string_0)
        {
            object            obj;
            IMemoryBlobStream memoryBlobStreamClass = new MemoryBlobStream();
            IObjectStream     objectStreamClass     = new ObjectStream()
            {
                Stream = memoryBlobStreamClass
            };
            IPropertySet   propertySetClass = new PropertySet();
            IPersistStream persistStream    = propertySetClass as IPersistStream;

            propertySetClass.SetProperty("Render", ifeatureRenderer_0);
            persistStream.Save(objectStreamClass, 0);
            ((IMemoryBlobStreamVariant)memoryBlobStreamClass).ExportToVariant(out obj);
            System.IO.FileStream fileStream   = new System.IO.FileStream(string_0, FileMode.CreateNew);
            BinaryWriter         binaryWriter = new BinaryWriter(fileStream);

            binaryWriter.Write((int)((byte[])obj).Length);
            binaryWriter.Write((byte[])obj);
            binaryWriter.Close();
            fileStream.Close();
        }
Exemple #12
0
        public override void OnClick()
        {
            if (m_DialogOpenGlobe.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    IGlobe pGlobe = m_globeHookHelper.Globe;
                    IObjectStream pObjectStream = new ObjectStream();
                    IMemoryBlobStream pMemorysBlobStream = new MemoryBlobStream();
                    pMemorysBlobStream.LoadFromFile(m_DialogOpenGlobe.FileName);
                    IPersistStream pPersistStream = pGlobe as IPersistStream;
                    pObjectStream.Stream = pMemorysBlobStream;
                    pPersistStream.Load(pObjectStream);

                    m_globeHookHelper.GlobeDisplay.RefreshViewers();
                    m_globeHookHelper.ActiveViewer.Redraw(true);
                    (pGlobe as IActiveView).Refresh();
                }
                catch (Exception exp)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show(string.Format("抱歉,加载操作出现意外错误,信息:{0}", exp.Message));
                }
            }
        }
Exemple #13
0
        public override void OnClick()
        {
            if (m_DialogOpenGlobe.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    IGlobe            pGlobe             = m_globeHookHelper.Globe;
                    IObjectStream     pObjectStream      = new ObjectStream();
                    IMemoryBlobStream pMemorysBlobStream = new MemoryBlobStream();
                    pMemorysBlobStream.LoadFromFile(m_DialogOpenGlobe.FileName);
                    IPersistStream pPersistStream = pGlobe as IPersistStream;
                    pObjectStream.Stream = pMemorysBlobStream;
                    pPersistStream.Load(pObjectStream);

                    m_globeHookHelper.GlobeDisplay.RefreshViewers();
                    m_globeHookHelper.ActiveViewer.Redraw(true);
                    (pGlobe as IActiveView).Refresh();
                }
                catch (Exception exp)
                {
                    DevExpress.XtraEditors.XtraMessageBox.Show(string.Format("抱歉,加载操作出现意外错误,信息:{0}", exp.Message));
                }
            }
        }
        /// <summary>
        /// Each BuilderItem contains a Function Raster Dataset which is used to create the thumbnail.
        /// The thumbnail is created by Nearest Neighbor resampling of the Function Raster Dataset. 
        /// The resampled raster is exported as a byte array and saved Into the IMemoryBlobStreamVariant. 
        /// The blob is then inserted into the Thumbnail field.
        /// </summary>
        /// <param name="mybuilderItem">Item containing the Function Dataset to be added to the Mosaic Dataset</param>
        private void Resampling(IBuilderItem mybuilderItem)
        {
            try
            {
                IFunctionRasterDataset pFuncRasterDataset = mybuilderItem.Dataset; // Get the FunctionRasterDataset from mybuilderItem
                IRasterDataset pRasterDataset;
                pRasterDataset = (IRasterDataset)pFuncRasterDataset; // Cast the FunctionRasterDataset to Raster Dataset
                IPropertySet thePropSet = pFuncRasterDataset.Properties; // Get the properties of the raster Dataset
                IRaster praster = pRasterDataset.CreateDefaultRaster(); // Create default raster from the above raster dataset
                praster.ResampleMethod = rstResamplingTypes.RSP_NearestNeighbor; // The raster is resampled by RSP_NearestNeighbor
                IRasterProps pRasterProps = (IRasterProps)praster; // Raster properties are used to update the height, width of the raster
                pRasterProps.Height = 256;
                pRasterProps.Width = 256;

                IRasterExporter pConverter = new RasterExporterClass(); // IRasterExporter object is used to convert the raster to byte array.
                byte[] pBytesArr;
                pBytesArr = pConverter.ExportToBytes(praster, "TIFF"); // Convert the resampled Raster to a Byte array 
                IMemoryBlobStream memBlobStream = new MemoryBlobStream(); // Create new IMemoryBlobStream
                IMemoryBlobStreamVariant varBlobStream = (IMemoryBlobStreamVariant)memBlobStream; // Assign to IMemoryBlobStreamVariant
                object anObject = pBytesArr;
                varBlobStream.ImportFromVariant(anObject); // IMemoryBlobStreamVariant object is assigned the byte array
                thePropSet.SetProperty("ThumbNail", memBlobStream); // and saved to the property "ThumbNail"
            }
            catch (Exception ex)
            {
                System.Exception myExc = new System.Exception(
                    "Error: Failed to Re-Sampled the raster.Thumbnails will not be created." + ex.Message, ex);
                throw myExc;
            }
            return;

        }