Beispiel #1
0
        public static IStyleGalleryItem FindStyleGalleryItem(string string_0, string string_1, string string_2,
                                                             string string_3)
        {
            IStyleGalleryItem styleGalleryItem;
            IStyleGallery     myStyleGallery;

            try
            {
                if (File.Exists(string_1))
                {
                    string lower = Path.GetExtension(string_1).ToLower();
                    if (lower == ".style")
                    {
                        myStyleGallery = new MyStyleGallery();
                    }
                    else if (lower != ".serverstyle")
                    {
                        styleGalleryItem = null;
                        return(styleGalleryItem);
                    }
                    else
                    {
                        myStyleGallery = new ServerStyleGallery();
                        for (int i = (myStyleGallery as IStyleGalleryStorage).FileCount - 1; i >= 0; i--)
                        {
                            if (Path.GetExtension((myStyleGallery as IStyleGalleryStorage).File[i]).ToLower() !=
                                ".serverstyle")
                            {
                                (myStyleGallery as IStyleGalleryStorage).RemoveFile(
                                    (myStyleGallery as IStyleGalleryStorage).File[i]);
                            }
                        }
                    }
                    (myStyleGallery as IStyleGalleryStorage).AddFile(string_1);
                    IStyleGalleryItem styleGalleryItem1 = SymbolFind.FindStyleGalleryItem(string_0, myStyleGallery,
                                                                                          string_1, string_2, string_3);
                    myStyleGallery = null;
                    GC.Collect();
                    styleGalleryItem = styleGalleryItem1;
                }
                else
                {
                    styleGalleryItem = null;
                }
            }
            catch (Exception exception)
            {
                styleGalleryItem = null;
            }
            return(styleGalleryItem);
        }
Beispiel #2
0
 private void btnConvert_Click(object sender, EventArgs e)
 {
     if (this.listBox1.Items.Count == 0)
     {
         MessageBox.Show("请选择要转换的源符号库");
     }
     else if (this.txtDest.Text.Length == 0)
     {
         MessageBox.Show("请输入转出目录");
     }
     else
     {
         IStyleGallery  gallery;
         int            num3;
         string         str;
         SaveFileDialog dialog = new SaveFileDialog
         {
             FileName = this.txtDest.Text
         };
         Stream stream = dialog.OpenFile();
         if (stream != null)
         {
             Stream manifestResourceStream;
             int    num;
             if (!this.m_IsStyleFile)
             {
                 manifestResourceStream =
                     base.GetType()
                     .Assembly.GetManifestResourceStream(
                         "Yutai.ArcGIS.Controls.Controls.SymbolUI.template.style");
             }
             else
             {
                 manifestResourceStream =
                     base.GetType()
                     .Assembly.GetManifestResourceStream(
                         "Yutai.ArcGIS.Controls.Controls.SymbolUI.template.ServerStyle");
             }
             byte[] buffer = new byte[4096];
             while ((num = manifestResourceStream.Read(buffer, 0, 4096)) > 0)
             {
                 stream.Write(buffer, 0, num);
             }
             stream.Close();
         }
         if (this.m_IsStyleFile)
         {
             gallery = new ServerStyleGalleryClass();
             num3    = (gallery as IStyleGalleryStorage).FileCount - 1;
             while (num3 >= 0)
             {
                 str = (gallery as IStyleGalleryStorage).get_File(num3);
                 (gallery as IStyleGalleryStorage).RemoveFile(str);
                 num3--;
             }
         }
         else
         {
             gallery = new MyStyleGallery();
         }
         gallery.Clear();
         (gallery as IStyleGalleryStorage).TargetFile = this.txtDest.Text;
         foreach (object obj2 in this.listBox1.Items)
         {
             try
             {
                 IStyleGallery gallery2;
                 if (this.m_IsStyleFile)
                 {
                     gallery2 = new MyStyleGallery();
                 }
                 else
                 {
                     gallery2 = new ServerStyleGalleryClass();
                     num3     = (gallery2 as IStyleGalleryStorage).FileCount - 1;
                     while (num3 >= 0)
                     {
                         str = (gallery2 as IStyleGalleryStorage).get_File(num3);
                         (gallery2 as IStyleGalleryStorage).RemoveFile(str);
                         num3--;
                     }
                 }
                 gallery2.Clear();
                 (gallery2 as IStyleGalleryStorage).AddFile(obj2.ToString());
                 for (num3 = 0; num3 < gallery2.ClassCount; num3++)
                 {
                     string    name  = gallery2.get_Class(num3).Name;
                     IEnumBSTR mbstr = gallery2.get_Categories(name);
                     string    fileNameWithoutExtension = Path.GetFileNameWithoutExtension(obj2.ToString());
                     mbstr.Reset();
                     for (string str4 = mbstr.Next(); str4 != null; str4 = mbstr.Next())
                     {
                         IEnumStyleGalleryItem item = gallery2.get_Items(name, obj2.ToString(), str4);
                         item.Reset();
                         IStyleGalleryItem item2 = null;
                         try
                         {
                             item2 = item.Next();
                         }
                         catch
                         {
                         }
                         while (item2 != null)
                         {
                             string str6;
                             if (this.m_IsStyleFile)
                             {
                                 IStyleGalleryItem item3 = new ServerStyleGalleryItemClass();
                                 object            obj3  = item2.Item;
                                 item3.Item = obj3;
                                 string str5 = item2.Name;
                                 item3.Name = str5;
                                 if (item2.Category.Length > 0)
                                 {
                                     str6           = fileNameWithoutExtension + "_" + item2.Category;
                                     item3.Category = str6;
                                 }
                                 else
                                 {
                                     item3.Category = fileNameWithoutExtension;
                                 }
                                 try
                                 {
                                     string defaultStylePath = (gallery as IStyleGalleryStorage).DefaultStylePath;
                                     int    fileCount        = (gallery as IStyleGalleryStorage).FileCount;
                                     gallery.AddItem(item3);
                                 }
                                 catch (Exception)
                                 {
                                 }
                             }
                             else
                             {
                                 if (item2.Category.Length > 0)
                                 {
                                     str6           = fileNameWithoutExtension + "_" + item2.Category;
                                     item2.Category = str6;
                                 }
                                 else
                                 {
                                     item2.Category = fileNameWithoutExtension;
                                 }
                                 gallery.AddItem(item2);
                             }
                             try
                             {
                                 item2 = item.Next();
                             }
                             catch
                             {
                             }
                         }
                     }
                 }
                 (gallery2 as IStyleGalleryStorage).RemoveFile(obj2.ToString());
             }
             catch (Exception)
             {
             }
         }
         try
         {
             (gallery as IStyleGalleryStorage).RemoveFile(this.txtDest.Text);
         }
         catch
         {
         }
         base.Close();
     }
 }
Beispiel #3
0
 private void btnConvert_Click(object sender, EventArgs e)
 {
     if (this.txtOrigin.Text.Length == 0)
     {
         MessageBox.Show("请选择要转换的源符号库");
     }
     else if (this.txtDest.Text.Length == 0)
     {
         MessageBox.Show("请输入目的符号库");
     }
     else
     {
         SaveFileDialog dialog = new SaveFileDialog
         {
             FileName = this.txtDest.Text
         };
         Stream stream = dialog.OpenFile();
         if (stream != null)
         {
             Stream        manifestResourceStream;
             int           num;
             IStyleGallery gallery;
             IStyleGallery gallery2;
             int           num3;
             if (this.m_IsStyleFile)
             {
                 manifestResourceStream =
                     base.GetType()
                     .Assembly.GetManifestResourceStream("Yutai.ArcGIS.Controls.SymbolUI.template.style");
             }
             else
             {
                 manifestResourceStream =
                     base.GetType()
                     .Assembly.GetManifestResourceStream(
                         "Yutai.ArcGIS.Controls.SymbolUI.template.ServerStyle");
             }
             byte[] buffer = new byte[4096];
             while ((num = manifestResourceStream.Read(buffer, 0, 4096)) > 0)
             {
                 stream.Write(buffer, 0, num);
             }
             stream.Close();
             if (this.m_IsStyleFile)
             {
                 gallery  = new ServerStyleGalleryClass();
                 gallery2 = new MyStyleGallery();
             }
             else
             {
                 gallery  = new MyStyleGallery();
                 gallery2 = new ServerStyleGalleryClass();
                 for (num3 = (gallery2 as IStyleGalleryStorage).FileCount - 1; num3 >= 0; num3--)
                 {
                     string path = (gallery2 as IStyleGalleryStorage).get_File(num3);
                     (gallery2 as IStyleGalleryStorage).RemoveFile(path);
                 }
             }
             (gallery as IStyleGalleryStorage).AddFile(this.txtOrigin.Text);
             (gallery2 as IStyleGalleryStorage).AddFile(this.txtDest.Text);
             for (num3 = 0; num3 < gallery.ClassCount; num3++)
             {
                 string name = gallery.get_Class(num3).Name;
                 IEnumStyleGalleryItem item = gallery.get_Items(name, this.txtOrigin.Text, "");
                 item.Reset();
                 for (IStyleGalleryItem item2 = item.Next(); item2 != null; item2 = item.Next())
                 {
                     gallery2.AddItem(item2);
                 }
             }
         }
     }
 }
Beispiel #4
0
 private void btnConvert_Click(object sender, EventArgs e)
 {
     if (this.listBox1.Items.Count == 0)
     {
         MessageBox.Show("请选择要转换的源符号库");
     }
     else if (this.txtDest.Text.Length == 0)
     {
         MessageBox.Show("请输入转出目录");
     }
     else
     {
         this.Cursor = Cursors.WaitCursor;
         foreach (object obj2 in this.listBox1.Items)
         {
             try
             {
                 string         path   = obj2.ToString();
                 SaveFileDialog dialog = new SaveFileDialog();
                 string         str2   = ".style";
                 if (this.m_IsStyleFile)
                 {
                     str2 = ".ServerStyle";
                 }
                 string str3 = Path.Combine(this.txtDest.Text, Path.GetFileNameWithoutExtension(path) + str2);
                 if (File.Exists(str3))
                 {
                     File.Delete(str3);
                 }
                 dialog.FileName = str3;
                 Stream stream = dialog.OpenFile();
                 if (stream != null)
                 {
                     Stream        manifestResourceStream;
                     int           num;
                     IStyleGallery gallery;
                     IStyleGallery gallery2;
                     int           num3;
                     string        str4;
                     if (!this.m_IsStyleFile)
                     {
                         manifestResourceStream =
                             base.GetType()
                             .Assembly.GetManifestResourceStream(
                                 "Yutai.ArcGIS.Controls.Controls.SymbolUI.template.style");
                     }
                     else
                     {
                         manifestResourceStream =
                             base.GetType()
                             .Assembly.GetManifestResourceStream(
                                 "Yutai.ArcGIS.Controls.Controls.SymbolUI.template.ServerStyle");
                     }
                     byte[] buffer = new byte[4096];
                     while ((num = manifestResourceStream.Read(buffer, 0, 4096)) > 0)
                     {
                         stream.Write(buffer, 0, num);
                     }
                     stream.Close();
                     if (this.m_IsStyleFile)
                     {
                         gallery  = new MyStyleGallery();
                         gallery2 = new ServerStyleGalleryClass();
                         num3     = (gallery2 as IStyleGalleryStorage).FileCount - 1;
                         while (num3 >= 0)
                         {
                             str4 = (gallery2 as IStyleGalleryStorage).get_File(num3);
                             (gallery2 as IStyleGalleryStorage).RemoveFile(str4);
                             num3--;
                         }
                     }
                     else
                     {
                         gallery  = new ServerStyleGalleryClass();
                         gallery2 = new MyStyleGallery();
                         num3     = (gallery as IStyleGalleryStorage).FileCount - 1;
                         while (num3 >= 0)
                         {
                             str4 = (gallery as IStyleGalleryStorage).get_File(num3);
                             (gallery as IStyleGalleryStorage).RemoveFile(str4);
                             num3--;
                         }
                     }
                     gallery.Clear();
                     gallery2.Clear();
                     (gallery as IStyleGalleryStorage).AddFile(path);
                     (gallery2 as IStyleGalleryStorage).TargetFile = str3;
                     for (num3 = 0; num3 < gallery.ClassCount; num3++)
                     {
                         string    name  = gallery.get_Class(num3).Name;
                         IEnumBSTR mbstr = gallery.get_Categories(name);
                         mbstr.Reset();
                         for (string str6 = mbstr.Next(); str6 != null; str6 = mbstr.Next())
                         {
                             IEnumStyleGalleryItem item = gallery.get_Items(name, path, str6);
                             item.Reset();
                             IStyleGalleryItem item2 = null;
                             try
                             {
                                 item2 = item.Next();
                             }
                             catch
                             {
                             }
                             while (item2 != null)
                             {
                                 if (this.m_IsStyleFile)
                                 {
                                     IStyleGalleryItem item3 = new ServerStyleGalleryItemClass();
                                     object            obj3  = item2.Item;
                                     item3.Item = obj3;
                                     string str7 = item2.Name;
                                     item3.Name = str7;
                                     string category = item2.Category;
                                     item3.Category = category;
                                     gallery2.AddItem(item3);
                                 }
                                 else
                                 {
                                     gallery2.AddItem(item2);
                                 }
                                 try
                                 {
                                     item2 = item.Next();
                                 }
                                 catch
                                 {
                                 }
                             }
                         }
                     }
                     (gallery as IStyleGalleryStorage).RemoveFile(path);
                     (gallery2 as IStyleGalleryStorage).RemoveFile(str3);
                 }
             }
             catch (Exception)
             {
             }
         }
         this.Cursor = Cursors.Default;
         base.Close();
     }
 }