private void lstControls_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                if (lstThemeSections.SelectedItem == null)
                {
                    return;
                }

                _currentThemeSection = (ThemeSection)lstThemeSections.SelectedItem;

                foreach (var sampleControl in _currentThemeSection.Controls)
                {
                    foreach (var control in sampleControl.Controls)
                    {
                        if (control is Label)
                        {
                            ((Label)control).BorderStyle = BorderStyle.Fixed3D;
                        }
                        else if (control is Panel)
                        {
                            ((Panel)control).BorderStyle = BorderStyle.FixedSingle;
                        }
                    }
                }

                DisplaySelectedThemeSection(_currentThemeSection);
            }
            catch (Exception ex)
            {
                ExceptionHandler("Error selecting theme property", ex);
            }
        }
示例#2
0
        public void Opendynamiclayers(List <string> layers, string section)
        {
            foreach (ThemeSection themesection in profilethemeview.themesections)
            {
                CheckBox _themebox = _layerswindow.layeritems.FirstOrDefault(x => x.themesection == themesection).checkbox;
                _themebox.IsChecked = true;
                _themebox.IsChecked = false;
            }
            _layerswindow.layeritems.FirstOrDefault(x => (x.themesection != null) && (x.themesection.name.Contains(section))).checkbox.IsChecked = true;
            ThemeSection _initsec = profilethemeview.themesections.FirstOrDefault(x => x.name.Contains(section));

            holder.settitle(_initsec.name);
            foreach (string st in _initsec.layernames)
            {
                CheckBox _box = _layerswindow.layeritems.FirstOrDefault(x => (null != x.themelayer) && (x.themelayer.layernames.Contains(st))).checkbox;
                _box.IsChecked = true;
                _box.IsChecked = false;
            }

            foreach (string st in layers)
            {
                try
                {
                    CheckBox _box = _layerswindow.layeritems.FirstOrDefault(x => (null != x.themelayer) && x.themelayer.layernames.Contains(st)).checkbox;
                    _box.IsChecked = true;
                }
                catch (Exception ex)
                {
                }
            }
        }
        protected virtual void DisplaySelectedThemeSection(ThemeSection themeSection)
        {
            try
            {
                lblControlName.Text = themeSection.Name;

                var controlFont = themeSection.Controls.FirstOrDefault().Font;
                lblControlFont.Text = $"Name: {controlFont.Name}  Size: {controlFont.Size}  Style: {controlFont.Style.ToString()}";

                Color foreColor = themeSection.Controls.FirstOrDefault().ForeColor;
                picForeColor.BackColor = foreColor;
                lblForeColor.Text      = foreColor.ToString();

                Color backColor = themeSection.Controls.FirstOrDefault().BackColor;
                picBackColor.BackColor = backColor;
                lblBackColor.Text      = backColor.ToString();

                foreach (var control in themeSection.Controls)
                {
                    if (control is Label)
                    {
                        ((Label)control).BorderStyle = BorderStyle.None;
                    }
                    else if (control is Panel)
                    {
                        ((Panel)control).BorderStyle = BorderStyle.Fixed3D;
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionHandler("Error displaying selected control", ex);
            }
        }
 private void SampleView_ControlSelected(object sender, Control e)
 {
     try
     {
         ThemeSection selectedThemeSection = _themeSections.FirstOrDefault(c => c.Controls.Contains(e));
         if (selectedThemeSection != null)
         {
             lstThemeSections.SelectedItem = selectedThemeSection;
         }
     }
     catch (Exception ex)
     {
         ExceptionHandler("Error selecting theme property from control", ex);
     }
 }
示例#5
0
        private ThemeSection[] FireEvent(string name, string viewFile, string content, TModel model)
        {
            var themeSections = new ThemeSection[] { };

            var themeSection = new ThemeSection()
            {
                Name         = name,
                Content      = content,
                Model        = Model,
                ViewFileName = viewFile,
                Language     = CurrentLanguage,
                ViewBag      = ViewBag,
                ViewContext  = ViewContext,
                HttpContext  = Context,
                TempData     = TempData,
                User         = User,
                Path         = Path
            };

            try
            {
                if (_mediator == null)
                {
                    _mediator = (IMediator)ViewContext.HttpContext.RequestServices.GetService(typeof(IMediator));
                }

                themeSections = _mediator.SendAll(new OnThemeSectionRender(themeSection)).Result;
            }
            catch (Exception ex)
            {
                //If this event does not have any handler then this send will throw an exception. We can ignore this exception.
                _Logger.LogError(ex.Message, ex);
            }

            return(themeSections);
        }
示例#6
0
        void initlayerwindow(object sender, EventArgs e)
        {
            _layersWindow = new LayersWindow(profilethemeview, _view.map.Layers);
            //_layersWindow.Owner = App.Current.MainWindow;
            _layersWindow.Title = _view.eMap.MapID + ":图层";

            // Two ways to use delegate
            //_layersWindow.Closed += delegate { _layersWindow = null; };
            //_layersWindow.Closed += delegate(object o, EventArgs args) { _layersWindow = null; };

            // Use lamda function
            //_layersWindow.Closed += (o, args) =>
            //{
            //    _layersWindow = null;
            //};

            _layersWindow.OffLayerCheckBoxClick += (o, args) =>
            {
                if (args.Item.themelayer != null)
                {
                    ThemeLayer _tl = args.Item.themelayer;
                    foreach (string st in _tl.layernames)
                    {
                        Layer layer = _view.map.Layers.FirstOrDefault(x => x.ID == st);
                        if (layer != null)
                        {
                            layer.IsVisible = false;
                        }
                    }
                    Layer _layer = _view.map.Layers.FirstOrDefault(x => x.ID == _tl.tpkname + ".tpk");
                    if (_layer != null)
                    {
                        _layer.IsVisible = false;
                    }
                }
                else if (args.Item.themesection != null)
                {
                    ThemeSection _ts = args.Item.themesection;
                    foreach (string st in _ts.layernames)
                    {
                        Layer layer = _view.map.Layers.FirstOrDefault(x => x.ID == st);
                        if (layer != null)
                        {
                            layer.IsVisible = false;
                        }
                    }
                }
            };
            _layersWindow.OnLayerCheckBoxClick += (o, args) =>
            {
                if (args.Item.themelayer != null)
                {
                    ThemeLayer _tl = args.Item.themelayer;
                    foreach (string st in _tl.layernames)
                    {
                        Layer layer = _view.map.Layers.FirstOrDefault(x => x.ID == st);
                        if (layer != null)
                        {
                            layer.IsVisible = true;
                        }
                    }
                    Layer _layer = _view.map.Layers.FirstOrDefault(x => x.ID == _tl.tpkname + ".tpk");
                    if (_layer != null)
                    {
                        _layer.IsVisible = true;
                    }
                }
            };
            _view._layerswindow    = _layersWindow;
            _view.profilethemeview = profilethemeview;
            initshowlayer();

            // Globals.mainFrame.viewLoaded+=initshowlayer;
            Globals.mainFrame.viewLoaded -= initlayerwindow;
        }
示例#7
0
        public void Loadcsvfile()
        {
            try
            {
                string exeLocation       = System.IO.Directory.GetCurrentDirectory();
                string csvDestnationPath = "c:\\LaoYingData\\theme";

                if (!Directory.Exists(csvDestnationPath))
                {
                    return;
                }
                //第一列是TPK文件,第二列是geodatabse文件,第三列是图层名
                //加载剖面主题图信息
                foreach (string fp in profilethemelist)
                {
                    ThemeSection _themesection = new ThemeSection();
                    _themesection.name = fp;

                    string       exeDestnationPath = csvDestnationPath + "\\" + fp + ".csv";
                    StreamReader sr = new StreamReader(exeDestnationPath, Encoding.Default);
                    String       line;
                    ThemeLayer   themelayer = new ThemeLayer();
                    while ((line = sr.ReadLine()) != null)
                    {
                        if (line.Length == 0)
                        {
                            continue;
                        }
                        string[] str = line.Split(',');
                        if ((str[0] != null) && (str[0] != ""))
                        {
                            ThemeLayer _themelayer = _themesection.themelayers.FirstOrDefault(x => x.tpkname == str[0]);
                            if (_themelayer == null)
                            {
                                _themelayer         = new ThemeLayer();
                                _themelayer.tpkname = str[0];
                                if ((str[2] != null) && (str[2] != ""))
                                {
                                    _themelayer.layernames.Add(str[2]);
                                }
                                _themesection.themelayers.Add(_themelayer);
                            }
                            else
                            {
                                if ((str[2] != null) && (str[2] != ""))
                                {
                                    _themelayer.layernames.Add(str[2]);
                                }
                            }
                            if (str[0].Contains("无tpk"))
                            {
                                _themesection.layernames.Add(str[2]);
                            }
                        }

                        //Add a new relationship between a geofile and a layer
                        if ((str[2] != null) && (str[2] != "") && (str[1] != "") && (null != str[1]))
                        {
                            if (!LayerToGeofile.ContainsKey(str[2]))
                            {
                                LayerToGeofile.Add(str[2], str[1]);
                            }
                        }
                    }
                    profilethemeview.themesections.Add(_themesection);
                }
            }
            catch (Exception ex)
            {
            }
        }