Beispiel #1
0
        private static SelectOption GetSelectOptionFromFile()//读取文件中保存的选择设置
        {
            SelectOption result  = null;
            string       optFile = Application.StartupPath + SYSTEM_SELECTOPTION_FILE;
            Stream       stream;

            if (File.Exists(optFile))
            {
                XmlSerializer ser = new XmlSerializer(typeof(SelectOption));
                stream = new FileStream(optFile, FileMode.Open);
                try
                {
                    SelectOption tmp = (SelectOption)ser.Deserialize(stream);
                    result = tmp;
                }
                catch (Exception ex)
                {
                    MessageBox.Show("SelectionOption反序列化出错!" + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
                }
                finally
                {
                    if (stream != null)
                    {
                        stream.Close();
                    }
                }
            }
            return(result);
        }
Beispiel #2
0
        public static SelectionEnvironmentClass System_Selection_Environment(IActiveView activeView)
        {
            if (m_System_Selection_Option == null)
            {
                m_System_Selection_Option = SelectOption.GetSelectOption();
            }
            if (m_System_SelectionEnvironment == null)
            {
                m_System_SelectionEnvironment = new SelectionEnvironmentClass();
            }

            double tol = PublicFunction.ConvertPixelsToMapUnits(activeView, m_System_Selection_Option.Tolerate);

            m_System_SelectionEnvironment.PointSearchDistance  = tol;
            m_System_SelectionEnvironment.LinearSearchDistance = tol;
            m_System_SelectionEnvironment.AreaSearchDistance   = tol;

            m_System_SelectionEnvironment.PointSelectionMethod  = (esriSpatialRelEnum)m_System_Selection_Option.SelectRelection;
            m_System_SelectionEnvironment.LinearSelectionMethod = (esriSpatialRelEnum)m_System_Selection_Option.SelectRelection;
            m_System_SelectionEnvironment.AreaSelectionMethod   = (esriSpatialRelEnum)m_System_Selection_Option.SelectRelection;

            m_System_SelectionEnvironment.ClearInvisibleLayers = m_System_Selection_Option.ClearInVisible;
            m_System_SelectionEnvironment.CombinationMethod    = (esriSelectionResultEnum)m_System_Selection_Option.ResultMethod;
            m_System_SelectionEnvironment.DefaultColor         = PublicFunction.GetSelectionColor(m_System_Selection_Option.DefaultColorRGB);
            m_System_SelectionEnvironment.SearchTolerance      = (int)tol;
            m_System_SelectionEnvironment.ShowSelectionWarning = m_System_Selection_Option.ShowWarning;
            m_System_SelectionEnvironment.WarningThreshold     = m_System_Selection_Option.WarningThreshold;
            return(m_System_SelectionEnvironment);
        }
Beispiel #3
0
 /// <summary>
 /// 可以保存的选择参数
 /// </summary>
 /// <returns></returns>
 public static SelectOption System_Selection_Option()
 {
     if (m_System_Selection_Option == null)
     {
         m_System_Selection_Option = SelectOption.GetSelectOption();
     }
     return(m_System_Selection_Option);
 }
Beispiel #4
0
        public static string SYSTEM_SELECTOPTION_FILE = @"\..\option\SelOpt.xml"; //修改 袁怀月 2007-09-29

        public static SelectOption GetSelectOption()
        {
            SelectOption result = GetSelectOptionFromFile();

            if (result == null)
            {
                result = new SelectOption();
                result.SelectRelection  = 1;
                result.ClearInVisible   = true;
                result.Tolerate         = 3;
                result.DefaultColorRGB  = -12517377;
                result.ShowWarning      = true;
                result.WarningThreshold = 2000;
            }
            result.ResultMethod = 0;
            return(result);
        }
Beispiel #5
0
 public static bool SaveSelectOption(SelectOption selOpt)
 {
     try
     {
         string        optFile = Application.StartupPath + SYSTEM_SELECTOPTION_FILE;
         XmlSerializer ser     = new XmlSerializer(typeof(SelectOption));
         if (!Directory.Exists(Path.GetDirectoryName(optFile)))
         {
             Directory.CreateDirectory(Path.GetDirectoryName(optFile));
         }
         Stream stream = new FileStream(optFile, FileMode.Create);
         ser.Serialize(stream, selOpt);
         stream.Close();
         return(true);
     }
     catch (Exception ex)
     {
         MessageBox.Show("SelectionOption序列化出错!" + "\r\n" + ex.Message + "\r\n" + ex.StackTrace);
         return(false);
     }
 }