Esempio n. 1
0
        protected override void OnClick()
        {
            AddLayersToMap addLayersToMap = AddLayersToMap.Current;

            addLayersToMap.B1 = this;

            ComboBox_LayerList cmbox = addLayersToMap.ComboBox_LayerList;
            // List<string> items = addLayersToMap.ComboBox_LayerList.ItemCollection;
            Dictionary <string, string> dict = cmbox.layerNameAndPath;

            if (cmbox.ItemCollection.Count > 0)
            {
                //IEnumerable<Item> items = cmbox.ItemCollection;
                foreach (var item in cmbox.ItemCollection)
                {
                    //Debug.Print(item.GetType());
                    //MessageBox.Show(item.ToString());
                    if (item.ToString() != "LayerName")
                    {
                        if (File.Exists(dict[item.ToString()]))
                        {
                            AddLayer(dict[item.ToString()]);
                        }
                    }
                }
            }

            else
            {
                GetLayers();
            }
        }
Esempio n. 2
0
        protected override void OnClick()
        {
            // ComboBox_LayerList cll = new ComboBox_LayerList();//wrong way to access current ComboBox

            // Testing get existing ComboBox object, Opening File, and Updating ComboBox. JBK 2020.07.17
            AddLayersToMap addLayersToMap = AddLayersToMap.Current;

            addLayersToMap.ComboBox_LayerList.OpenFile();
            addLayersToMap.ComboBox_LayerList.UpdateCombo();
        }
Esempio n. 3
0
        /// <summary>
        /// Combo Box constructor
        /// </summary>
        public ComboBox_LayerList()
        {
            // Testing ComboBox access. Sets this ComboBox to accessible
            //   variable in AddLayersToMaps static module. JBK - 2020.07.17
            AddLayersToMap addLayersToMap = AddLayersToMap.Current;

            if (addLayersToMap == null)
            {
                return;
            }
            addLayersToMap.ComboBox_LayerList = this;
            UpdateCombo();
        }
Esempio n. 4
0
        public void OpenFile()
        {
            string fileName = string.Empty;
            // System.Windows.Forms.OpenFileDialog OpenFileDialog = new System.Windows.Forms.OpenFileDialog();
            // OpenFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
            OpenItemDialog oid = new OpenItemDialog
            {
                // oid.BrowseFilter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";

                Title       = "Open a text file",
                Filter      = ItemFilters.textFiles,
                MultiSelect = true
            };
            bool?ok = oid.ShowDialog();

            //System.Threading.Thread.Sleep(300);


            if (ok == true)
            {
                IEnumerable <Item> selected = oid.Items;

                fileName = selected.First().Path;
                //MessageBox.Show("LayerList is updated using "+fileName);

                //pass the text file path to Button1, so it can read the file too.
                AddLayersToMap addLayersToMap = AddLayersToMap.Current;

                Button1 b1 = addLayersToMap.B1; //// get the instance of the current one, do not create a new Button1
                //Button1 b1 = new Button1();
                if (b1 != null)
                {
                    b1.FILE_NAME = fileName;
                    if (b1.Enabled == false)
                    {
                        b1.Enabled = true;
                    }
                }
                readText(fileName);
            }
            else
            {
                MessageBox.Show("No file selected");
                return;
            }
        }
Esempio n. 5
0
        /// <summary>
        /// The on comboBox selection change event.
        /// </summary>
        /// <param name="item">The newly selected combo box item</param>
        protected override void OnSelectionChange(ComboBoxItem item)
        {
            if (item == null)
            {
                return;
            }

            if (string.IsNullOrEmpty(item.Text))
            {
                return;
            }

            // TODO  Code behavior when selection changes.
            AddLayersToMap addLayersToMap = AddLayersToMap.Current;

            Button1 btn = addLayersToMap.B1 ?? new Button1();

            if (item.Text.ToUpper() != "LAYERNAME")
            {
                if (File.Exists(layerNameAndPath[item.Text]) || layerNameAndPath[item.Text].ToUpper().Contains("SERVER")) //make sure the path exists
                {
                    btn.AddLayer(layerNameAndPath[item.Text]);                                                            //get the path with dictionary key, then call AddLayer
                }
                else
                {
                    System.Windows.MessageBox.Show(string.Format("{0} doesn't exist or is not accessible", layerNameAndPath[item.Text]));
                }
            }


            //string FILE_NAME = @"C:\Work\GIS\data\shpList.txt";
            //string[] lines = File.ReadAllLines(FILE_NAME);//.Where(x =>!string.IsNullOrWhiteSpace(x));
            //foreach (string line in lines)
            //{
            //    string[] content = line.Split(',');
            //    //Add(new ComboBoxItem(content[0]));
            //    if (item.Text != "LayerName" && item.Text == content[0])
            //    {
            //        btn.AddLayer(content[1]);
            //    }
            //}
        }