Ejemplo n.º 1
0
 private void simpleButton2_Click(object sender, EventArgs e)
 {
     this.showGroup2 = !this.showGroup2;
     if (this.showGroup2)
     {
         var dragControlGroup2 = new LayoutItemDragController(
             this.lciGroup2,
             this.lciHeader2,
             DevExpress.XtraLayout.Utils.InsertLocation.After,
             DevExpress.XtraLayout.Utils.LayoutType.Vertical);
         this.lciGroup2.RestoreFromCustomization(dragControlGroup2);
         this.lciGroup1.Size           = this.sizeGroupControl2;
         this.simpleButton2.ImageIndex = 0;
     }
     else
     {
         this.lciGroup2.HideToCustomization();
         this.simpleButton2.ImageIndex = 1;
     }
 }
Ejemplo n.º 2
0
        public SearchLookUpEditEx()
        {
            base.DataBindings.CollectionChanged += DataBindings_CollectionChanged;

            this.QueryCloseUp += (object sender, CancelEventArgs e) =>
            {
                e.Cancel = preventClose;
            };
            this.Popup += delegate(object sender, EventArgs e)
            {
                ControlCollection coll = this.PopupForm.Controls;
                DevExpress.XtraGrid.Editors.SearchEditLookUpPopup form = (coll[2] as DevExpress.XtraGrid.Editors.SearchEditLookUpPopup);

                foreach (System.Windows.Forms.Control SearchPopupC in form.Controls)
                {
                    if (SearchPopupC is LayoutControl)
                    {

                        LayoutControl FormLayout = SearchPopupC as LayoutControl;
                        FormLayout.BeginUpdate();
                        System.Windows.Forms.Control findButton = FormLayout.GetControlByName("btFind");
                        if (findButton != null)
                        {
                            LayoutControlItem current = FormLayout.GetItemByControl(findButton);
                            current.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
                        }
                        ListBtn = new SimpleButton();
                        ListBtn.Size = new System.Drawing.Size(25, 45);
                        ListBtn.Text = CaptionHelper.GetLocalizedText("DialogButtons", "Go to list");
                        ListBtn.Name = "ListBtn";

                        if (FormLayout.GetControlByName("ListBtn") == null)
                        {
                            FormLayout.Controls.Add(ListBtn);
                        }

                        System.Windows.Forms.Control addButton = FormLayout.GetControlByName("btAddNew");
                        System.Windows.Forms.Control searchField = FormLayout.GetControlByName("teFind");
                        //System.Windows.Forms.Control clearValueBtn = FormLayout.GetControlByName("btClear");
                        //clearValueBtn.Visible = false;

                        if (FormLayout.Items.FindByName("ListBtn") == null)
                            FormLayout.AddItem(" ", ListBtn);

                        System.Windows.Forms.Control ListViewBtn = FormLayout.GetControlByName("ListBtn");

                        System.Windows.Forms.Control gridTable = FormLayout.Controls[10];

                        //((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).DoubleClick += (object send, EventArgs eArgs) =>
                        //{
                        //    if (((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow() != null)
                        //    {
                        //        EditValue = ((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow();
                        //        preventClose = false;
                        //        this.ClosePopup();
                        //        this.DoValidate();
                        //    }
                        //};

                        (gridTable as DevExpress.XtraGrid.GridControl).Click += (object send, EventArgs eArgs) =>
                        {
                            //    preventClose = true;
                            if (((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow() != null)
                            {
                                EditValue = ((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow();
                                preventClose = false;

                                this.DoValidate();
                            }
                        };

                        //((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).OptionsSelection.EnableAppearanceHideSelection = false;
                        //((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).FocusedRowChanged += (object send, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs eArgs) =>
                        //{
                        //    if (((DevExpress.XtraGrid.Views.Grid.GridView)send).SelectedRowsCount != 0)
                        //        clearValueBtn.Enabled = true;
                        //    else
                        //        clearValueBtn.Enabled = false;
                        //};

                        //(gridTable as DevExpress.XtraGrid.GridControl).FocusedViewChanged += (object send, DevExpress.XtraGrid.ViewFocusEventArgs eArgs) =>
                        //{
                        //    if (((DevExpress.XtraGrid.Views.Grid.GridView)((DevExpress.XtraGrid.GridControl)send).MainView).SelectedRowsCount != 0)
                        //        clearValueBtn.Enabled = true;
                        //    else
                        //        clearValueBtn.Enabled = false;
                        //};

                        if (addButton != null && searchField != null && /*clearValueBtn != null && */ListViewBtn != null && firstCreated != false)
                        {
                            //clearValueBtn.Text = CaptionHelper.GetLocalizedText("DialogButtons", "Select");
                            //clearValueBtn.Enabled = false;
                            LayoutControlItem buttonToMove = FormLayout.GetItemByControl(addButton);
                            LayoutControlItem textBoxToMove = FormLayout.GetItemByControl(searchField);
                            LayoutControlItem ListBtnTomove = FormLayout.GetItemByControl(ListViewBtn);
                            LayoutControlItem emptySpace = (LayoutControlItem)FormLayout.Items[9];
                            //LayoutControlItem clearValueBtnToMove = FormLayout.GetItemByControl(clearValueBtn);

                            LayoutItemDragController dragController = new LayoutItemDragController(buttonToMove,
            textBoxToMove, MoveType.Inside, InsertLocation.After, LayoutType.Horizontal);

                            buttonToMove.Move(dragController);

                            ListBtnTomove.SizeConstraintsType = SizeConstraintsType.Custom;
                            ListBtnTomove.Size = new Size(108, 26);
                            ListBtnTomove.MinSize = new Size(108, 26);
                            ListBtnTomove.MaxSize = new Size(108, 26);
                            ListBtnTomove.Name = "ListBtn";

                            //LayoutItemDragController thirdController = new LayoutItemDragController(clearValueBtnToMove,
                            //emptySpace, MoveType.Inside, InsertLocation.After, LayoutType.Horizontal);
                            //clearValueBtnToMove.Move(thirdController);

                            LayoutItemDragController secdragController = new LayoutItemDragController(ListBtnTomove,
                            emptySpace, MoveType.Inside, InsertLocation.After, LayoutType.Horizontal);
                            ListBtnTomove.Move(secdragController);
                            firstCreated = false;
                        }

                        if (searchFieldEmpty)
                        { addButton.Enabled = false; }

                        //clearValueBtn.Click += (object send, EventArgs args) =>
                        // {
                        //     if (((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow() != null)
                        //     {
                        //         this.EditValue = ((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow();
                        //         preventClose = false;
                        //     }
                        // };

                        searchField.TextChanged += (object send, EventArgs args) =>
                         {
                             if (((TextEdit)send).Text == string.Empty)
                             {
                                 searchFieldEmpty = true;
                                 addButton.Enabled = false;
                             }
                             else
                             {
                                 searchFieldEmpty = false;
                                 if (((DevExpress.XtraGrid.GridControl)gridTable).MainView.RowCount == 0)
                                     addButton.Enabled = true;
                                 ((DevExpress.XtraGrid.GridControl)gridTable).MainView.RowCountChanged += (object sendr, EventArgs eArgs) =>
                                 {
                                     if (((DevExpress.XtraGrid.Views.Grid.GridView)sendr).RowCount == 0)
                                         addButton.Enabled = true;
                                     else
                                         addButton.Enabled = false;
                                 };
                             }
                         };

                        ListBtn.Click += (object send, EventArgs args) =>
                        {
                            if (!ListViewDisabled)
                            {
                                ShowViewParameters svp = new ShowViewParameters();
                                IObjectSpace ObjectsListViewObjectSpace = Properties.Helper.Application.CreateObjectSpace();
                                ObjectsListView = Properties.Helper.Application.CreateListView(ObjectsListViewObjectSpace, Properties.Helper.LookupObjectTypeInfo.Type, true);

                                svp.CreatedView = ObjectsListView;
                                svp.TargetWindow = TargetWindow.NewModalWindow;
                                svp.Context = TemplateContext.View;

                                svp.CreatedView.ObjectSpace.ObjectDeleted += (object sendr, ObjectsManipulatingEventArgs eArgs) =>
                                {
                                    ((DevExpress.ExpressApp.Xpo.XPObjectSpace)sendr).Session.AfterCommitTransaction += (object sendObject, SessionManipulationEventArgs EvArgs) =>
                                    {
                                        foreach (object obj in eArgs.Objects)
                                        {
                                            if (EditValue != null)
                                            {
                                                if (obj.ToString() == EditValue.ToString())
                                                {
                                                    this.clear = true;
                                                    EditValue = null;
                                                    this.DoValidate();
                                                }
                                            }
                                        }
                                    };
                                };

                                viewCreatedHandler += (object sendr, ViewCreatedEventArgs eArgs) =>
                                {
                                    eArgs.View.ObjectSpace.ObjectDeleted += (object sendObject, DevExpress.ExpressApp.ObjectsManipulatingEventArgs EvArgs) =>
                                    {
                                        ((DevExpress.ExpressApp.Xpo.XPObjectSpace)sendObject).Session.AfterCommitTransaction += (object sendObject2, SessionManipulationEventArgs EvArgs2) =>
                                        {
                                            foreach (object obj in EvArgs.Objects)
                                            {
                                                if (EditValue != null)
                                                {
                                                    if (obj.ToString() == EditValue.ToString())
                                                    {
                                                        this.clear = true;
                                                        EditValue = null;
                                                        this.DoValidate();
                                                    }
                                                }
                                            }
                                        };
                                    };
                                    Properties.Helper.Application.ViewCreated -= viewCreatedHandler;
                                    CreatedView = eArgs.View;
                                    CreatedView.Closed += CreatedView_Closed;
                                };
                                svp.CreateAllControllers = true;
                                Properties.Helper.Application.ViewCreated += viewCreatedHandler;
                                Properties.Helper.Application.ShowViewStrategy.ShowView(svp, new ShowViewSource(null, null));

                                preventClose = false;
                                this.ClosePopup();
                            }
                            //     if (((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow() != null)
                            //     {
                            //         IObjectSpace newObjectViewObjectSpace = Properties.Helper.Application.CreateObjectSpace();
                            //         object deleting = ((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).GetFocusedRow();
                            //         if (EditValue == deleting)
                            //         {
                            //             EditValue = null;
                            //             isDeleting = true;
                            //         }
                            //         newObjectViewObjectSpace.Delete(newObjectViewObjectSpace.GetObject(deleting));
                            //         newObjectViewObjectSpace.CommitChanges();
                            //         ((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).DeleteRow(((DevExpress.XtraGrid.Views.Grid.GridView)(gridTable as DevExpress.XtraGrid.GridControl).MainView).FocusedRowHandle);
                            //         preventClose = false;
                            //     }
                        };
                        FormLayout.EndUpdate();
                    }
                }
            };
        }
Ejemplo n.º 3
0
 private void simpleButton2_Click(object sender, EventArgs e)
 {
     this.showGroup2 = !this.showGroup2;
     if (this.showGroup2)
     {
         var dragControlGroup2 = new LayoutItemDragController(
             this.lciGroup2,
             this.lciHeader2,
             DevExpress.XtraLayout.Utils.InsertLocation.After,
              DevExpress.XtraLayout.Utils.LayoutType.Vertical);
         this.lciGroup2.RestoreFromCustomization(dragControlGroup2);
         this.lciGroup1.Size = this.sizeGroupControl2;
         this.simpleButton2.ImageIndex = 0;
     }
     else
     {
         this.lciGroup2.HideToCustomization();
         this.simpleButton2.ImageIndex = 1;
     }
 }
 private void layoutControl2_DragEnter(object sender, DragEventArgs e)
 {
     dragController = null;
     ShowDragHelper();
 }
        private void layoutControl2_DragDrop(object sender, DragEventArgs e)
        {
            if (dragController != null && dragItem != null)
            {
                if (layoutControlGroup.Items.Count > 0 && dragController.LayoutType == DevExpress.XtraLayout.Utils.LayoutType.Horizontal)
                {
                    LayoutControlItem temp = layoutControl2.CalcHitInfo(new Point(e.X, e.Y)).Item as LayoutControlItem;
                    if (temp == null && layoutControlGroup.Items.Count > 0)
                        temp = layoutControlGroup.Items[layoutControlGroup.Items.Count - 1] as LayoutControlItem;
                    dragController = new LayoutItemDragController(dragItem, temp, DevExpress.XtraLayout.Utils.InsertLocation.After, DevExpress.XtraLayout.Utils.LayoutType.Vertical);
                    window.DragController = dragController;
                }
                else
                    dragController = new LayoutItemDragController(dragItem, dragController);
                if (dragItem.Owner == null || dragItem.Parent == null)
                    dragController.DragWildItem();
                else
                    dragController.Drag();

            }
            HideDragHelper();
            Cursor = Cursors.Default;
        }
 protected void UpdateDragHelper(Point p)
 {
     if (dragItem == null) return;
     p = layoutControl2.PointToClient(p);
     dragController = new LayoutItemDragController(null, layoutControl2.Root, new Point(p.X, p.Y));
     DragFrameWindow.DragController = dragController;
 }