Exemplo n.º 1
0
        /// <summary>
        /// 加载系统符号样式
        /// </summary>
        /// <param name="symbologyCtrl">符号显示控件</param>
        /// <param name="symbologyStyle">符号样式</param>
        /// <param name="subFolder"></param>
        public static void LoadSymbolStyle(AxSymbologyControl symbologyCtrl, esriSymbologyStyleClass symbologyStyle,
                                           string subFolder = @"Symbol\StyleSymbol\ESRI.ServerStyle")
        {
            symbologyCtrl.Clear();
            string styleFilePath = string.Format(@"{0}\{1}", Application.StartupPath, subFolder);

            //载入系统符号库
            symbologyCtrl.LoadStyleFile(styleFilePath);
            symbologyCtrl.StyleClass = symbologyStyle;
            ISymbologyStyleClass pSymStyleClass = symbologyCtrl.GetStyleClass(symbologyCtrl.StyleClass);

            pSymStyleClass.GetItem(0);
            pSymStyleClass.UnselectItem();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Add the style file.
 /// </summary>
 /// <param name="axSymbologyControl1">The ax symbology control1.</param>
 /// <param name="sDestPath">The s dest path.</param>
 public static void AddStyleFile(AxSymbologyControl axSymbologyControl1, string sDestPath)
 {
     System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
     openFileDialog.CheckPathExists  = true;
     openFileDialog.CheckFileExists  = true;
     openFileDialog.RestoreDirectory = true;
     openFileDialog.Multiselect      = false;
     openFileDialog.Filter           = "(style)|*.SeverStyle";
     if (openFileDialog.ShowDialog(EnviVars.instance.MainForm) == System.Windows.Forms.DialogResult.OK)
     {
         string fileName = System.IO.Path.GetFileName(openFileDialog.FileName);
         string text     = System.IO.Path.Combine(sDestPath, fileName);
         axSymbologyControl1.Clear();
         if (File.Exists(text))
         {
             string   fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(openFileDialog.FileName);
             string   extension = System.IO.Path.GetExtension(openFileDialog.FileName);
             string[] files     = Directory.GetFiles(sDestPath, fileNameWithoutExtension + "." + extension);
             int      num       = 1;
             string[] array     = files;
             for (int i = 0; i < array.Length; i++)
             {
                 string path = array[i];
                 string fileNameWithoutExtension2 = System.IO.Path.GetFileNameWithoutExtension(path);
                 int    num2  = 0;
                 string text2 = fileNameWithoutExtension2.Substring(fileNameWithoutExtension.Length);
                 if (!string.IsNullOrEmpty(text2) && int.TryParse(text2, out num2) && num2 > num)
                 {
                     num = num2 + 1;
                 }
             }
             text = System.IO.Path.Combine(sDestPath, fileNameWithoutExtension + num + extension);
         }
         File.Copy(openFileDialog.FileName, text, true);
         axSymbologyControl1.LoadStyleFile(openFileDialog.FileName);
         axSymbologyControl1.Refresh();
     }
 }