Пример #1
0
        private void tsbSave_Click(object sender, EventArgs e)
        {
            string GetLayoutString(LayoutControl layout)
            {
                //删除隐藏的item,避免数据库中存储无效的item
                layout.HiddenItems.Clear();

                using (MemoryStream ms = new MemoryStream())
                    using (StreamReader sr = new StreamReader(ms))
                    {
                        layout.SaveLayoutToStream(ms);
                        ms.Position = 0;

                        return(sr.ReadToEnd());
                    }
            }

            List <ItemFormat> GetItemFormats(LayoutControl layout)
            {
                layout.HiddenItems.Clear();

                List <ItemFormat> result = new List <ItemFormat>();

                foreach (BaseLayoutItem bli in layout.Items)
                {
                    DesignLabel dl = bli as DesignLabel;
                    if (dl != null)
                    {
                        ItemFormat itemFmt = new ItemFormat();
                        itemFmt.ItemName = dl.Name;
                        itemFmt.Formats  = dl.Formats;

                        result.Add(itemFmt);
                    }
                }

                return(result);
            }

            try
            {
                if (_summaryDesign == null)
                {
                    _summaryDesign = new SummaryModuleDesign();
                }

                _summaryDesign.DBSource      = GlobalDB.DBSource;
                _summaryDesign.LayoutFormats = GetLayoutString(layoutControl1);
                _summaryDesign.ItemFormats   = GetItemFormats(layoutControl1);

                this.Close();
            }
            catch (Exception ex)
            {
                MsgBox.ShowException(ex, this);
            }
        }
Пример #2
0
        private void FillFormats(List <ItemFormat> ItemFormats)
        {
            foreach (ItemFormat itemFmt in ItemFormats)
            {
                BaseLayoutItem bli = layoutControl1.Items.FindByName(itemFmt.ItemName);

                DesignLabel dl = bli as DesignLabel;
                if (dl != null)
                {
                    dl.Formats = itemFmt.Formats;

                    dl.Formats.默认背景色 = dl.AppearanceItemCaption.BackColor;
                    dl.Formats.默认前景色 = dl.AppearanceItemCaption.ForeColor;
                }
            }
        }
Пример #3
0
        private void frmSummaryDesign_Load(object sender, EventArgs e)
        {
            layoutControl1.UnRegisterFixedItemType(typeof(SimpleLabelItem));
            layoutControl1.UnRegisterFixedItemType(typeof(SimpleSeparator));
            layoutControl1.UnRegisterFixedItemType(typeof(EmptySpaceItem));
            layoutControl1.UnRegisterFixedItemType(typeof(SplitterItem));



            layoutControl1.RegisterFixedItemType(typeof(DesignEmpty));
            layoutControl1.RegisterCustomPropertyGridWrapper(typeof(DesignEmpty), typeof(DesignEmptyPropertiesWrapper));

            layoutControl1.RegisterFixedItemType(typeof(DesignLabel));
            layoutControl1.RegisterCustomPropertyGridWrapper(typeof(DesignLabel), typeof(DesignLabelPropertiesWrapper));

            layoutControl1.RegisterFixedItemType(typeof(DesignSplitter));
            layoutControl1.RegisterCustomPropertyGridWrapper(typeof(DesignSplitter), typeof(DesignSplitterPropertiesWrapper));

            layoutControl1.ShowCustomizationForm();

            if (_summaryDesign == null)
            {
                return;
            }

            LayoutControlEx.SetLayoutString(layoutControl1, _summaryDesign.LayoutFormats);

            foreach (ItemFormat itemFmt in _summaryDesign.ItemFormats)
            {
                BaseLayoutItem bli = layoutControl1.Items.FindByName(itemFmt.ItemName);

                DesignLabel dl = bli as DesignLabel;
                if (dl != null)
                {
                    dl.Formats = itemFmt.Formats;
                }
            }
        }
Пример #4
0
        private void ReloadDictionary(Dictionary <string, object> dicts)
        {
            foreach (BaseLayoutItem bli in layoutControl1.Items)
            {
                DesignLabel dl = bli as DesignLabel;

                if (dl == null)
                {
                    continue;
                }
                if (string.IsNullOrEmpty(dl.Formats.数据项名称))
                {
                    continue;
                }

                dl.Image = null;
                dl.AppearanceItemCaption.BackColor = dl.Formats.默认背景色;
                dl.AppearanceItemCaption.ForeColor = dl.Formats.默认前景色;

                if (dicts == null)
                {
                    dl.Text = " ";

                    continue;
                }

                string showDisplay = "";

                bool isDataItem = dicts.ContainsKey(dl.Formats.数据项名称);
                if (isDataItem)
                {
                    string value = Convert.ToString(dicts[dl.Formats.数据项名称]);
                    showDisplay = value;

                    if (dl.Formats.文本格式.Count > 0)
                    {
                        int vIndex = dl.Formats.文本格式.FindIndex(T => T.数据值 == value);

                        if (vIndex >= 0)
                        {
                            DesignLabelFormatItem formatItem = dl.Formats.文本格式[vIndex];

                            dl.Image    = Img24Resource.LoadImg(formatItem.图标名称);
                            showDisplay = formatItem.显示内容;

                            if (formatItem.背景色.Name != "0")
                            {
                                dl.AppearanceItemCaption.BackColor = formatItem.背景色;
                            }

                            if (formatItem.前景色.Name != "0")
                            {
                                dl.AppearanceItemCaption.ForeColor = formatItem.前景色;
                            }
                        }
                    }
                }

                if (string.IsNullOrEmpty(showDisplay))
                {
                    showDisplay = " ";
                }
                dl.Text = showDisplay;
            }
        }