コード例 #1
0
        private static void ldc_MappingReload(object sender, EventArgs e)
        {
            LabeledDataControl       ldc = sender as LabeledDataControl;
            IBindingDataValueControl bc  = ldc.Control as IBindingDataValueControl;

            bc.ReloadData();
        }
コード例 #2
0
        private LabeledDataControl AddDataControl(IDesignerHost h, GridColumnInfo info)
        {
            //IDataControl dc = ControlFactory.GetDataControl(columnInfo);
            //Control control = dc as Control;
            //if (control == null)
            //{
            //    throw new ArgumentException("IDataControl should be System.Windows.Forms.Control!");
            //}
            //m_parentForm.Controls.Add(control);

            Control ic = null;

            foreach (string s in ControlsName.DataControlsTypeName)
            {
                if (s.LastIndexOf(info.DataControlType, StringComparison.OrdinalIgnoreCase) != -1)
                {
                    ic = (Control)h.CreateComponent(Feng.Utils.ReflectionHelper.GetTypeFromName(s));
                    break;
                }
            }

            if (ic == null)
            {
                throw new InvalidOperationException("Invalid ControlType of " + info.DataControlType);
            }
            LabeledDataControl control = (LabeledDataControl)h.CreateComponent(typeof(LabeledDataControl));

            MyLabel lbl = (MyLabel)h.CreateComponent(typeof(MyLabel));

            lbl.Text = info.Caption;

            control.Controls.Add(lbl);
            control.Controls.Add(ic);
            control.Label   = lbl;
            control.Control = ic;

            IDataControl dc = control as IDataControl;

            dc.Caption      = info.Caption;
            dc.PropertyName = info.PropertyName;
            dc.Navigator    = info.Navigator;
            //dc.Index = info.SeqNo;
            dc.Name = info.GridColumnName;

            control.ResetLayout();

            m_parentForm.Controls.Add(control);

            return(control);
        }
コード例 #3
0
        private static void ldc_MappingEdited(object sender, EventArgs e)
        {
            LabeledDataControl ldc             = sender as LabeledDataControl;
            INameValueMappingBindingControl bc = ldc.Control as INameValueMappingBindingControl;

            if (!string.IsNullOrEmpty(bc.NameValueMappingName) &&
                !bc.NameValueMappingName.StartsWith("EnumType"))
            {
                NameValueMappingInfo info = ADInfoBll.Instance.GetNameValueMappingInfo(bc.NameValueMappingName);
                if (info != null && info.EditAction != null)
                {
                    ServiceProvider.GetService <IApplication>().ExecuteAction(info.EditAction.Name);
                }
                else
                {
                    ServiceProvider.GetService <IMessageBox>().ShowWarning("无对应编辑窗口,请在配置信息中配置!");
                }
            }
        }
コード例 #4
0
        internal static void DisposeDataControls(IDataControl[] dataControlsBuffer)
        {
            if (dataControlsBuffer != null)
            {
                foreach (IDataControl dc in dataControlsBuffer)
                {
                    LabeledDataControl ldc = dc as LabeledDataControl;
                    if (ldc != null)
                    {
                        INameValueMappingBindingControl bc = ldc.Control as INameValueMappingBindingControl;
                        if (bc != null && !string.IsNullOrEmpty(bc.NameValueMappingName) &&
                            !bc.NameValueMappingName.StartsWith("EnumType"))
                        {
                            ldc.MappingEdited -= new EventHandler(ldc_MappingEdited);
                            ldc.MappingReload -= new EventHandler(ldc_MappingReload);
                        }
                    }
                }

                dataControlsBuffer = null;
            }
        }
コード例 #5
0
        internal static void InternalCreateDataControls(IDisplayManager dm, IControlManager cm, string gridName, IArchiveDetailFormAuto parent, ToolTip toolTip)
        {
            // 创建数据控件
            IList <GridColumnInfo> infos = ADInfoBll.Instance.GetGridColumnInfos(gridName);

            if (infos != null)
            {
                Dictionary <string, IDataControl> nowControls = new Dictionary <string, IDataControl>();
                GetSubControls(nowControls, parent as Control);

                List <Control> addControls = new List <Control>();
                if (infos.Count > 0)
                {
                    foreach (GridColumnInfo info in infos)
                    {
                        IDataControl dc;
                        if (!nowControls.ContainsKey(info.GridColumnName))
                        {
                            if (string.IsNullOrEmpty(info.DataControlType))
                            {
                                continue;
                            }

                            // SetDataControls in GetDataControl();
                            dc = Feng.Windows.Utils.ControlFactory.GetDataControl(info, dm.Name);
                            if (dc != null)
                            {
                                addControls.Add(dc as Control);
                            }
                        }
                        else
                        {
                            dc           = nowControls[info.GridColumnName];
                            dc.Available = true;

                            Feng.Windows.Utils.ControlFactory.SetDataControls(dc as Control, info, dm.Name);
                        }

                        // not process Editable and Insertable in here, should be in DataManger.SetState()
                        //dc.SetState(m_cm.State);

                        dm.DataControls.Add(dc);
                        dc.AvailableChanged -= new EventHandler(dc_AvailableChanged);
                        dc.AvailableChanged += new EventHandler(dc_AvailableChanged);

                        LabeledDataControl ldc = dc as LabeledDataControl;
                        if (ldc != null)
                        {
                            if (toolTip != null)
                            {
                                toolTip.SetToolTip(ldc.Label, string.IsNullOrEmpty(info.Help) ? info.Caption : info.Help);
                            }

                            INameValueMappingBindingControl bc = ldc.Control as INameValueMappingBindingControl;
                            if (bc != null && !string.IsNullOrEmpty(bc.NameValueMappingName) &&
                                !bc.NameValueMappingName.StartsWith("EnumType"))
                            {
                                ldc.MappingEdited -= new EventHandler(ldc_MappingEdited);
                                ldc.MappingReload -= new EventHandler(ldc_MappingReload);
                                ldc.MappingEdited += new EventHandler(ldc_MappingEdited);
                                ldc.MappingReload += new EventHandler(ldc_MappingReload);
                            }
                        }
                    }

                    parent.AddControls(addControls.ToArray());
                }
                else
                {
                    // 没有GridColumnInfo
                    foreach (IDataControl dc in nowControls.Values)
                    {
                        dc.AvailableChanged -= new EventHandler(dc_AvailableChanged);
                        dc.AvailableChanged += new EventHandler(dc_AvailableChanged);

                        //AddControl(dc as Control);
                        dc.Available = true;
                        dm.DataControls.Add(dc);
                    }
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// Initialize
        /// </summary>
        /// <param name="component"></param>
        public override void Initialize(IComponent component)
        {
            base.Initialize(component);

            // Record instance of control we're designing
            LabeledDataControl container = component as LabeledDataControl;

            if (container == null)
            {
                throw new ArgumentException("component is not LabeledDataControl");
            }

            if (container != null)
            {
                m_owner = container;
                // Hook up events
                IComponentChangeService c = (IComponentChangeService)GetService(typeof(IComponentChangeService));
                c.ComponentRemoving += new ComponentEventHandler(OnComponentRemoving);
            }
        }