Ejemplo n.º 1
0
        protected void LoadGridLayout(GridControl grd)
        {
            string stateLayoutPath = string.Format("{0}\\{1}", Application.StartupPath, UiUtility.StateConfigPath);
            string formFileName    = string.Format("{0}\\{1}.xml", stateLayoutPath, this.Name);

            if (File.Exists(formFileName))
            {
                FormConfigState formState = UiUtility.DeserializeObject <FormConfigState>(formFileName);
                if (formState != null)
                {
                    string[] grdArr = Regex.Split(formState.GridControl, @",");
                    int      index  = Array.IndexOf(grdArr, grd.Name);

                    if (index >= 0)
                    {
                        string[] lastViewArr = Regex.Split(formState.LastDefaultView, @",");
                        this.LoadGridLayoutMultipleView(this.Name, grd, lastViewArr[index]);
                    }
                }
            }

            //this.LoadGridLayoutMultipleView(this.Name, grd);
            //all to list;
            if (this.lstGridControl == null)
            {
                this.lstGridControl = new List <GridControl>();
            }

            this.lstGridControl.Add(grd);
        }
Ejemplo n.º 2
0
        //protected void SaveGridLayout(string formName, BaseView view)
        //{
        //    string stateLayoutPath = UiUtility.StateConfigPath;
        //    string formFileName = string.Empty;
        //    string filename = string.Format("{0}\\{1}_{2}.xml", stateLayoutPath, formName, view.Name);

        //    //Check Exist Directory
        //    if (!Directory.Exists("GridLayout"))
        //    {
        //        Directory.CreateDirectory("GridLayout");
        //    }

        //    using (FileStream stream = new FileStream(filename, FileMode.Create))
        //    {
        //        view.SaveLayoutToStream(stream, DevExpress.Utils.OptionsLayoutBase.FullLayout);
        //        stream.Close();
        //    }
        //}

        //protected void LoadGridLayout(string formName, BaseView view)
        //{
        //    string stateLayoutPath = UiUtility.StateConfigPath;
        //    string filename = string.Format("{0}\\{1}_{2}.xml", stateLayoutPath, formName, view.Name);
        //    if (File.Exists(filename))
        //    {
        //        view.RestoreLayoutFromXml(filename, DevExpress.Utils.OptionsLayoutBase.FullLayout);
        //    }
        //}

        //test
        protected void LoadFormLayout()
        {
            string stateLayoutPath = string.Format("{0}\\{1}", Application.StartupPath, UiUtility.StateConfigPath);
            string formFileName    = string.Format("{0}\\{1}.xml", stateLayoutPath, this.Name);

            FormConfigState formState = null;

            if (File.Exists(formFileName))
            {
                try
                {
                    formState = UiUtility.DeserializeObject <FormConfigState>(formFileName);
                }
                catch (Exception ex)
                {
                    formState = null;
                }

                if (formState != null)
                {
                    if (!formState.FormSize.IsEmpty)
                    {
                        this.Size = formState.FormSize;
                    }
                    if (!formState.FormLocation.IsEmpty)
                    {
                        this.Location = formState.FormLocation;
                    }
                }
            }
        }
Ejemplo n.º 3
0
        protected override void OnClosed(EventArgs e)
        {
            #region Create XML Layout

            string        formFileName    = string.Empty;
            string        stateLayoutPath = string.Format("{0}\\{1}", Application.StartupPath, UiUtility.StateConfigPath);
            List <string> gridControlArr  = new List <string>();
            List <string> lastViewArr     = new List <string>();


            if (this.lstGridControl != null)
            {
                foreach (GridControl grd in this.lstGridControl)
                {
                    gridControlArr.Add(grd.Name);
                    lastViewArr.Add(grd.MainView.GetType().Name);

                    this.SaveGridLayoutMultipleView(this.Name, grd);
                }

                this.lstGridControl.Clear();
                this.lstGridControl = null;
            }

            //Check Exist Directory
            if (!Directory.Exists(stateLayoutPath))
            {
                Directory.CreateDirectory(stateLayoutPath);
            }

            FormConfigState formState = new FormConfigState {
                FormName = this.Name, GridControl = string.Join(",", gridControlArr.ToArray()), LastDefaultView = string.Join(",", lastViewArr.ToArray()), FormSize = this.Size, FormLocation = this.Location
            };

            formFileName = string.Format("{0}\\{1}.xml", stateLayoutPath, this.Name);
            UiUtility.SerializeObject(formState, formFileName);

            #endregion

            #region Application Idle Dispose

            //if (this.applicationIdle1.IsRunning)
            //{
            //    this.applicationIdle1.Stop();
            //}

            //this.applicationIdle1.Dispose();

            #endregion

            if (this.processDialog != null)
            {
                this.processDialog = null;
            }

            this.Controls.Clear();

            base.OnClosed(e);
        }