예제 #1
0
        private void trvExtensions_AfterSelect(object sender, TreeViewEventArgs e)
        {
            if (_edSvc.IsNew)
            {
                return;
            }

            var ext  = e.Node.Tag as IFeatureSourceExtension;
            var join = e.Node.Tag as IAttributeRelation;
            var calc = e.Node.Tag as ICalculatedProperty;

            if (ext != null)
            {
                var ctl = new ExtendedClassSettings(_fs, GetAllClassNames(), ext);
                ctl.Dock = DockStyle.Fill;
                //If editing to something valid, update the toolbar
                ctl.ResourceChanged += (s, evt) =>
                {
                    btnNewJoin.Enabled = btnNewCalculation.Enabled = IsValidExtension(ext);
                };

                splitContainer1.Panel2.Controls.Clear();
                splitContainer1.Panel2.Controls.Add(ctl);
                btnDelete.Enabled = true;

                btnNewCalculation.Enabled = btnNewJoin.Enabled = IsValidExtension(ext);
            }
            else if (join != null)
            {
                ext = e.Node.Parent.Tag as IFeatureSourceExtension;
                if (ext != null)
                {
                    if (ext.FeatureClass != null)
                    {
                        //NOTE: The feature source id here may be session based, but this is still okay
                        //as we're only giving context (the primary class to join on) for the secondary join UI.
                        //This feature source id is never written into the actual document
                        var ctl = new JoinSettings(_fs.ResourceID, ext.FeatureClass, join);
                        ctl.Bind(_edSvc);
                        ctl.Dock = DockStyle.Fill;
                        splitContainer1.Panel2.Controls.Clear();
                        splitContainer1.Panel2.Controls.Add(ctl);
                        btnDelete.Enabled = true;
                    }
                }
            }
            else if (calc != null)
            {
                ext = e.Node.Parent.Tag as IFeatureSourceExtension;
                if (ext != null)
                {
                    ClassDefinition cls = _edSvc.CurrentConnection.FeatureService.GetClassDefinition(_fs.ResourceID, ext.FeatureClass); //TODO: Cache?
                    if (cls != null)
                    {
                        var ctl = new CalculationSettings(_edSvc, cls, _fs, calc);
                        ctl.Dock = DockStyle.Fill;
                        splitContainer1.Panel2.Controls.Clear();
                        splitContainer1.Panel2.Controls.Add(ctl);
                        btnDelete.Enabled = true;
                    }
                }
            }
            else
            {
                splitContainer1.Panel2.Controls.Clear();
            }
        }