Example #1
0
 public void RestoreDefaultGridLayout()
 {
     if (_dataType != null)
     {
         _target.LoadLayout(LayoutDescriptor.makeDirectDefaultForType(_dataType));
     }
 }
Example #2
0
 public void LoadGridLayout(LayoutDescriptor descr)
 {
     if (_dataType != null)
     {
         _target.LoadLayout(descr);
     }
 }
Example #3
0
 // grid layout management
 public void SaveGridLayout()
 {
     if (_dataType != null)
     {
         _target.SaveLayout(LayoutDescriptor.makeDirectForType(_dataType));
     }
 }
Example #4
0
 public void SaveLayout(LayoutDescriptor descr)
 {
     using (Stream wr = descr.GetWriter())
     {
         if (wr != null)
         {
             SLogManager.getInstance().getClassLogger(GetType()).Debug($"Grid Save Layout: {descr.CombinePath()}");
             _view.SaveLayoutToStream(wr);
         }
     }
 }
Example #5
0
 public void LoadLayout(LayoutDescriptor descr)
 {
     using (Stream rr = descr.GetReader())
     {
         if (rr != null)
         {
             SLogManager.getInstance().getClassLogger(GetType()).Debug($"Grid Load layout: {descr.CombinePath()}");
             _view.RestoreLayoutFromStream(rr);
         }
         else
         {
             SLogManager.getInstance().getClassLogger(GetType()).Warn($"Grid layout: {descr.CombinePath()} NOT FOUND!");
         }
     }
 }
Example #6
0
        public List <LayoutDescriptor> GetLayoutsByTypeAndPrefix(Type type, string prefix)
        {
            if (Layouts == null)
            {
                return(null);
            }

            List <LayoutDescriptor> ret = new List <LayoutDescriptor>()
            {
                LayoutDescriptor.makeDirectDefaultForType(type), LayoutDescriptor.makeDirectForType(type)
            };

            var tmp = Layouts.Groups.FindAll(g => g.prefix == prefix && g.type == type.Name).FirstOrDefault();

            if (tmp != null)
            {
                ret.AddRange(tmp.Layouts.Select(e => LayoutDescriptor.makeCustomForType(type.Name, tmp.path, e)));
            }

            return(ret);
        }
Example #7
0
 public void LoadLayout(LayoutDescriptor descr)
 {
     SLogManager.getInstance().getClassLogger(GetType()).Debug("Grid Load layout");
 }
Example #8
0
 public void LoadGridLayout()
 {
     LoadGridLayout(LayoutDescriptor.makeDirectForType(_dataType));
 }
Example #9
0
        private void ConnectGrid()
        {
            if (_target != null && !_gridIsConnected && _dataType != null && _target.IsReady)
            {
                // check columns loaded
                if (_target.ColumnsCount() == 0)
                {
                    _target.PopulateColumns();
                }

                if (!_isTypeDataTable)
                {
                    PropertyInfo[] pis = _dataType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
                    foreach (PropertyInfo pi in pis)
                    {
                        applyAttributes(pi.Name);
                    }
                }
                else
                {
                    DataTable dt = base.DataSource as DataTable;
                    if (dt != null)
                    {
                        /*
                         *                      PropertyInfo[] pis = _dataType.GetProperties(BindingFlags.Instance | BindingFlags.Public);
                         *                      foreach (PropertyInfo pi in pis)
                         *                      {
                         *  string strName = pi.Name;
                         *                              if (dt.Columns[strName]	!= null)
                         *                              {
                         *                                      applyAttributes(pi.Name);
                         *                              }
                         *                      }
                         */
                        foreach (DataColumn c in dt.Columns)
                        {
                            applyAttributes(c.ColumnName);
                        }
                    }
                }
                //attach CustomRowCellEditForEditing event too
                _target.CustomRowCellEditForEditing += CustomRowCellEditForEditingHandler;
                _target.ShownEditor += EditorShownHandler;


                _target.CellValueChanged += _target_CellValueChanged;


                if (HandleCustomColumnDisplayText)
                {
                    _target.CustomColumnDisplayText += CustomColumnDisplayText;
                }

                _gridIsConnected = true;


                if (!ReferenceEquals(null, _editorsHost) && !ReferenceEquals(null, _dataType) && !ReferenceEquals(null, _target))
                {
                    _editorsHost.onGridConnected(this, new GridConnectedEventData()
                    {
                        Control = _target, DataBindingSource = this, DataType = _dataType, Kind = GridConnectedEventKind.GridConnected
                    });
                }

                // probably good place save default layout
                _target.SaveLayout(LayoutDescriptor.makeDirectDefaultForType(_dataType));
            }
        }