コード例 #1
0
        void View_ControlsCreated(object sender, EventArgs e)
        {
            LayoutControl layoutControl = ((LayoutControl)((DetailView)View).Control);

            layoutControl.BeginUpdate();
            try
            {
                foreach (object item in layoutControl.Items)
                {
                    if (item is LayoutControlGroup)
                    {
                        ((LayoutControlGroup)item).ExpandButtonVisible   = true;
                        ((LayoutControlGroup)item).Expanded              = true;
                        ((LayoutControlGroup)item).HeaderButtonsLocation = DevExpress.Utils.GroupElementLocation.AfterText;
                        ((LayoutControlGroup)item).ExpandOnDoubleClick   = true;
                    }
                }
            }
            finally
            {
                layoutControl.EndUpdate();
            }
        }
コード例 #2
0
ファイル: FormBuilder.cs プロジェクト: abonSerg/Clinic
        private static void SetLayoutXml(this LayoutControl layoutControl, string xml)
        {
            using (var stream = new MemoryStream())
            {
                using (var writer = new StreamWriter(stream))
                {
                    layoutControl.BeginInit();
                    layoutControl.BeginUpdate();
                    try
                    {
                        writer.Write(xml);
                        writer.Flush();
                        stream.Seek(0, SeekOrigin.Begin);

                        layoutControl.RestoreLayoutFromStream(stream);
                    }
                    finally
                    {
                        layoutControl.EndUpdate();
                        layoutControl.EndInit();
                    }
                }
            }
        }
コード例 #3
0
        public static void SetFindControlImages(GridControl grid, bool forceAlignment)
        {
            FindControl fControl = null;

            foreach (Control ctrl in grid.Controls)
            {
                fControl = ctrl as FindControl;
                if (fControl != null)
                {
                    break;
                }
            }
            if (fControl != null)
            {
                EditorButton btn = fControl.FindEdit.Properties.Buttons[0];
                btn.Kind    = XtraEditors.Controls.ButtonPredefines.Search;
                btn         = new EditorButton(ButtonPredefines.Close);
                btn.Visible = false;
                fControl.FindEdit.Properties.Buttons.Add(btn);
                fControl.FindEdit.ButtonClick += (s, e) =>
                {
                    if (!e.Button.IsDefaultButton)
                    {
                        ButtonEdit edit = s as ButtonEdit;
                        edit.Text = string.Empty;
                    }
                };
                fControl.FindEdit.EditValueChanged += (s, e) =>
                {
                    MRUEdit edit = s as MRUEdit;
                    edit.Properties.BeginUpdate();
                    try {
                        edit.Properties.Buttons[0].Visible = string.IsNullOrEmpty(edit.Text);
                        edit.Properties.Buttons[1].Visible = !string.IsNullOrEmpty(edit.Text);
                    }
                    finally {
                        edit.Properties.EndUpdate();
                    }
                };
                if (forceAlignment)
                {
                    LayoutControl lc = fControl.FindEdit.Parent as LayoutControl;
                    lc.BeginUpdate();
                    try {
                        for (int i = lc.Root.Items.Count - 1; i >= 0; i--)
                        {
                            LayoutControlItem item = lc.Root.Items[i] as LayoutControlItem;
                            if (item == null)
                            {
                                continue;
                            }
                            if (item.Visibility == XtraLayout.Utils.LayoutVisibility.Never)
                            {
                                lc.Root.Remove(item);
                            }
                            else
                            {
                                item.ControlAlignment = System.Drawing.ContentAlignment.MiddleRight;
                            }
                        }
                    }
                    finally {
                        lc.EndUpdate();
                    }
                }
            }
        }
コード例 #4
0
ファイル: GridLayoutBuilderUI.cs プロジェクト: dvmu/MyRapid
        private void InitializeQuery()
        {
            List <Sys_Schema> sys_Schemas = InitializeField();

            if (gds.SelectedIndex < 0)
            {
                return;
            }
            GroupControl grid;

            if (gds.EditValue != null && gds.EditValue.GetType() == typeof(GroupControl))
            {
                grid = (GroupControl)gds.EditValue;
                LayoutControl eLayoutControl = (LayoutControl)iDesignerHost.CreateComponent(typeof(LayoutControl), "lyc");
                grid.Controls.Add(eLayoutControl);
                eLayoutControl.BeginUpdate();
                LayoutControlGroup eLayoutControlGroup = new LayoutControlGroup();
                eLayoutControlGroup.BeginUpdate();
                eLayoutControl.Dock     = System.Windows.Forms.DockStyle.Fill;
                eLayoutControl.Location = new System.Drawing.Point(2, 21);
                eLayoutControl.Name     = "eLayoutControl";
                eLayoutControl.Root     = eLayoutControlGroup;
                eLayoutControl.Size     = new System.Drawing.Size(1000, 500);
                eLayoutControl.TabIndex = 0;
                eLayoutControl.Text     = "QueryLayout";
                eLayoutControlGroup.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
                eLayoutControlGroup.GroupBordersVisible         = false;
                eLayoutControlGroup.Size        = new Size(1000, 500);
                eLayoutControlGroup.Location    = new Point(0, 0);
                eLayoutControlGroup.Name        = "eLayoutControlGroup";
                eLayoutControlGroup.TextVisible = false;
                List <BaseLayoutItem> baseLayoutItems = new List <BaseLayoutItem>();
                int curLeft = 0;
                int curTop  = 0;
                foreach (Sys_Schema sys_Schema in sys_Schemas)
                {
                    try
                    {
                        string   gn       = string.Format("f{0}", sys_Schema.FieldName);
                        BaseEdit baseEdit = null;
                        if (sys_Schema.SqlDbType.Equals("bit"))
                        {
                            baseEdit      = (CheckEdit)iDesignerHost.CreateComponent(typeof(CheckEdit), gn);
                            baseEdit.Text = string.Empty;
                        }
                        else if (sys_Schema.SqlDbType.Equals("datetime"))
                        {
                            baseEdit = (DateEdit)iDesignerHost.CreateComponent(typeof(DateEdit), gn);
                        }
                        else
                        {
                            baseEdit = (TextEdit)iDesignerHost.CreateComponent(typeof(TextEdit), gn);
                        }
                        baseEdit.Width = 250;
                        baseEdit.Properties.Appearance.Options.UseTextOptions = true;
                        LayoutControlItem eLayoutControlItem = new LayoutControlItem();
                        eLayoutControlItem.Location = new System.Drawing.Point(curLeft, curTop);
                        eLayoutControlItem.Name     = "oli_" + sys_Schema.FieldName;
                        eLayoutControlItem.Text     = sys_Schema.Description;
                        eLayoutControlItem.Size     = new Size(baseEdit.Width, baseEdit.Height);
                        eLayoutControlItem.Control  = baseEdit;
                        baseLayoutItems.Add(eLayoutControlItem);
                        curLeft += baseEdit.Width;
                        if (curLeft >= eLayoutControlGroup.Width)
                        {
                            curLeft = 0;
                            curTop += baseEdit.Height;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
                if (curLeft < eLayoutControlGroup.Width && curLeft > 0)
                {
                    EmptySpaceItem emptySpaceItem = new EmptySpaceItem();
                    emptySpaceItem.AllowHotTrack = false;
                    emptySpaceItem.Location      = new System.Drawing.Point(curLeft, curTop);
                    emptySpaceItem.Name          = "oli_Space";
                    emptySpaceItem.Size          = new System.Drawing.Size(eLayoutControlGroup.Width - curLeft, 24);
                    baseLayoutItems.Add(emptySpaceItem);
                }
                EmptySpaceItem emptyBottom = new EmptySpaceItem();
                emptyBottom.AllowHotTrack = false;
                emptyBottom.Location      = new System.Drawing.Point(0, curTop + 24);
                emptyBottom.Name          = "oli_Space";
                emptyBottom.Size          = new System.Drawing.Size(eLayoutControlGroup.Width, 24);
                baseLayoutItems.Add(emptyBottom);
                eLayoutControlGroup.Items.AddRange(baseLayoutItems.ToArray());
                eLayoutControlGroup.EndUpdate();
                eLayoutControl.EndUpdate();
            }
        }
コード例 #5
0
 public void ValidateLayout()
 {
     LayoutControl.Validate();
     LayoutControl.BeginUpdate();
     LayoutControl.EndUpdate();
 }
コード例 #6
0
ファイル: InitializeLayout.cs プロジェクト: dvmu/MyRapid
        private void InitializeQuery()
        {
            try
            {
                if (this.QueryControl == null)
                {
                    return;
                }
                this.QueryControl.DoubleClick += QueryAutoClear;
                this.QueryControl.Controls.Clear();
                this.Width = 1024;
                this.QueryControl.Width = 1024;
                LayoutControl eLayoutControl = new LayoutControl();
                eLayoutControl.BeginUpdate();
                eLayoutControl.AllowCustomization = false;
                LayoutControlGroup eLayoutControlGroup = new LayoutControlGroup();
                eLayoutControl.Dock     = System.Windows.Forms.DockStyle.Fill;
                eLayoutControl.Location = new System.Drawing.Point(2, 21);
                eLayoutControl.Name     = "eLayoutControl";
                eLayoutControl.Root     = eLayoutControlGroup;
                eLayoutControl.Size     = new System.Drawing.Size(1000, 90);
                eLayoutControl.TabIndex = 0;
                eLayoutControl.Text     = "QueryLayout";
                eLayoutControlGroup.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.True;
                eLayoutControlGroup.GroupBordersVisible         = false;
                eLayoutControlGroup.Location    = new Point(0, 0);
                eLayoutControlGroup.Name        = "eLayoutControlGroup";
                eLayoutControlGroup.Size        = new Size(1000, 90);
                eLayoutControlGroup.TextVisible = false;
                this.QueryControl.Controls.Add(eLayoutControl);
                List <BaseLayoutItem> baseLayoutItems = new List <BaseLayoutItem>();
                List <string>         baseControls    = new List <string>();
                int curLeft = 0;
                int curTop  = 0;
                foreach (Sys_Bind sys_Bind in BindList.Where(b => b.Bind_Name.StartsWith("@") &&
                                                             !string.IsNullOrEmpty(b.Bind_Field) &&
                                                             !b.Bind_Field.Contains(".") &&
                                                             WorkSetList.Find(w => w.WorkSet_Id == b.Bind_WorkSet &&
                                                                              (w.WorkSet_Type == (int)Sys_WorkSet_Type.Submit ||
                                                                               w.WorkSet_Type == (int)Sys_WorkSet_Type.Grid ||
                                                                               w.WorkSet_Type == (int)Sys_WorkSet_Type.Tree)) != null).OrderBy(b => b.Bind_Sort))
                {
                    if (baseControls.Contains(sys_Bind.Bind_Field))
                    {
                        continue;
                    }
                    baseControls.Add(sys_Bind.Bind_Field);
                    sys_Bind.Bind_Type = 0; //查询字段
                    //界面已有控件不再生成
                    Control[] Controls = this.Controls.Find(sys_Bind.Bind_Field, true);
                    if (Controls.Length > 0)
                    {
                        if (!string.IsNullOrEmpty(sys_Bind.Bind_Popup))
                        {
                            BaseEdit cBaseEdit = (BaseEdit)Controls[0];
                            InitializeBaseEdit(sys_Bind, cBaseEdit);
                        }
                        continue;
                    }
                    BaseEdit baseEdit = InitializeBaseEdit(sys_Bind, null);
                    baseEdit.Name = sys_Bind.Bind_Field;
                    if (!string.IsNullOrEmpty(sys_Bind.Bind_Default))
                    {
                        object obj = sys_Bind.Bind_Default;
                        if (obj.ToString().StartsWith("wk:"))
                        {
                            obj = BaseService.Get(obj.ToString().Replace("wk:", ""), null);
                        }
                        ReflectionHelper.SetProperty(baseEdit, string.IsNullOrEmpty(sys_Bind.Bind_Property) ? "EditValue" : sys_Bind.Bind_Property, obj);
                        //baseEdit.EditValue = sys_Bind.Bind_Default;
                        if (baseEdit.GetType().Equals(typeof(CheckEdit)))
                        {
                            CheckEdit chkEdit = (CheckEdit)baseEdit;
                            chkEdit.Text    = string.Empty;
                            chkEdit.Checked = obj.ToBoolEx();
                        }
                    }


                    if (baseEdit.GetType().Equals(typeof(CheckedComboBoxEdit)))
                    {
                        CheckedComboBoxEdit chkComboBox = (CheckedComboBoxEdit)baseEdit;
                        chkComboBox.RefreshEditValue();
                    }
                    baseEdit.EnterMoveNextControl = true;
                    baseEdit.Width = (int)Math.Round(eLayoutControlGroup.Width * (sys_Bind.Bind_Width / 100.00));
                    baseEdit.Properties.Appearance.Options.UseTextOptions = true;
                    baseEdit.Properties.Appearance.TextOptions.HAlignment = (DevExpress.Utils.HorzAlignment)sys_Bind.Bind_TextAlignment;
                    if (sys_Bind.Bind_ForeColor < 0)
                    {
                        baseEdit.ForeColor = Color.FromArgb(sys_Bind.Bind_ForeColor);
                    }
                    if (sys_Bind.Bind_BackColor < 0)
                    {
                        baseEdit.BackColor = Color.FromArgb(sys_Bind.Bind_BackColor);
                    }
                    if (sys_Bind.Bind_BorderColor < 0)
                    {
                        baseEdit.Properties.Appearance.Options.UseBorderColor = true;
                        baseEdit.Properties.Appearance.BorderColor            = Color.FromArgb(sys_Bind.Bind_BorderColor);
                        baseEdit.BorderStyle = BorderStyles.Simple;
                    }
                    baseEdit.ToolTip         = sys_Bind.Bind_ToolTip;
                    baseEdit.ReadOnly        = sys_Bind.Bind_ReadOnly;
                    baseEdit.Visible         = sys_Bind.Bind_Visible;
                    baseEdit.GotFocus       += Control_GotFocus;
                    eLayoutControl.GotFocus += Control_GotFocus;
                    LayoutControlItem eLayoutControlItem = new LayoutControlItem();
                    eLayoutControlItem.Location = new System.Drawing.Point(curLeft, curTop);
                    curLeft += baseEdit.Width;
                    if (curLeft >= eLayoutControlGroup.Width)
                    {
                        curLeft = 0;
                        curTop += baseEdit.Height;
                    }
                    //eLayoutControlItem.Width = (int)Math.Round(eLayoutControl.Width * (sys_Bind.Bind_Width / 100.00));
                    eLayoutControlItem.AppearanceItemCaption.TextOptions.HAlignment = (DevExpress.Utils.HorzAlignment)sys_Bind.Bind_TitleAlignment;
                    eLayoutControlItem.Name       = "oli_" + sys_Bind.Bind_Name;
                    eLayoutControlItem.Text       = sys_Bind.Bind_Nick;
                    eLayoutControlItem.Size       = new Size(baseEdit.Width, baseEdit.Height);
                    eLayoutControlItem.Control    = baseEdit;
                    eLayoutControlItem.Visibility = sys_Bind.Bind_Visible ? DevExpress.XtraLayout.Utils.LayoutVisibility.Always : DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                    baseLayoutItems.Add(eLayoutControlItem);
                }
                if (curLeft < eLayoutControlGroup.Width && curLeft > 0)
                {
                    EmptySpaceItem emptySpaceItem = new EmptySpaceItem();
                    emptySpaceItem.AllowHotTrack = false;
                    emptySpaceItem.Location      = new System.Drawing.Point(curLeft, curTop);
                    emptySpaceItem.Name          = "oli_Space";
                    emptySpaceItem.Size          = new System.Drawing.Size(eLayoutControlGroup.Width - curLeft, 24);
                    baseLayoutItems.Add(emptySpaceItem);
                }
                eLayoutControlGroup.Items.AddRange(baseLayoutItems.ToArray());
                eLayoutControl.EndUpdate();
            }
            catch (Exception ex)
            {
                SharedFunc.RaiseError(ex);
            }
        }