Esempio n. 1
0
 public static Object[] Show(params WinFormItem[] items)
 {
     using (WinForm cd = new WinForm(WinFormStyle.Dialog))
     {
         cd.Add <Panel>(WinFormConfig.SinglePageForm);
         TableLayoutPanel tlpRows = cd.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;
         TableLayoutPanel p       = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells")
         {
             CellsSize = new Pair <int>(2, 1)
         });
         p.ColumnStyles[0].SizeType = SizeType.Percent;
         p.ColumnStyles[0].Width    = 38;
         p.ColumnStyles[1].SizeType = SizeType.Percent;
         p.ColumnStyles[1].Width    = 62;
         foreach (var item in items)
         {
             p.Add(item);
         }
         cd.Items["MainPanel"].LinkedControl.Add <TableLayoutPanel>(WinFormConfig.StdButtons());
         if (cd.ShowDialog() == DialogResult.OK)
         {
             cd.Save();
             return(items.Select(i => i.Value).ToArray());
         }
         else
         {
             return(items.Select(i => i.OriginalValue).ToArray());
         }
     }
 }
Esempio n. 2
0
 public static T Show <T>(string caption, T value, T resultIfCancel)
 {
     using (WinForm cd = new WinForm(WinFormStyle.Dialog))
     {
         T result;
         cd.Add <Panel>(WinFormConfig.SinglePageForm);
         TableLayoutPanel tlpRows = cd.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;
         TableLayoutPanel p       = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells")
         {
             CellsSize = new Pair <int>(2, 1)
         });
         p.Add(new WinFormItem("Item")
         {
             Caption  = caption,
             DataType = typeof(T),
             Value    = value,
         });
         cd.Items["MainPanel"].LinkedControl.Add <TableLayoutPanel>(WinFormConfig.StdButtons());
         if (cd.ShowDialog() == DialogResult.OK)
         {
             cd.Save();
             result = (T)cd.GetItem("Item").Value;
         }
         else
         {
             result = resultIfCancel;
         }
         return((T)result);
     }
 }
Esempio n. 3
0
        public void Find()
        {
            if (_cd != null)
            {
                _cd.Dispose();
            }
            _cd = new WinForm(WinFormStyle.Dialog)
            {
                Size = new Size(350, Convert.ToInt32(350 / vbo.GoldenRatio)),
                Text = "Найти..."
            };

            _cd.Add <Panel>(WinFormConfig.SinglePageForm);
            TableLayoutPanel tlpRows = _cd.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;
            TableLayoutPanel p       = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells")
            {
                CellsSize = new Pair <int>(2, 2)
            });

            p.ColumnStyles[0].SizeType = SizeType.Percent;
            p.ColumnStyles[0].Width    = 100;
            p.ColumnStyles[1].SizeType = SizeType.Absolute;
            p.ColumnStyles[1].Width    = 100;
            ComboBox cbox = p.Add <ComboBox>(new WinFormItem("SearchText")
            {
                PresentationType = typeof(ComboBox),
                DataType         = typeof(string),
                Value            = GetInitialSearchText()
            });

            cbox.Items.AddRange(_searches.ToArray());
            SetAutoComplete(cbox);
            _cd.Activated += new EventHandler((o, e) => { ((WinForm)o).GetControl <ComboBox>("SearchText").Focus(); });
            Button btn = p.Add <Button>("Find");

            btn.Text         = "Найти";
            btn.Click       += new EventHandler(Btn_Click);
            _cd.AcceptButton = btn;
            CheckBox cb = p.Add <CheckBox>(new WinFormItem("MatchCase")
            {
                Value = (_stringComparison != StringComparison.InvariantCultureIgnoreCase), DataType = typeof(bool), PresentationType = typeof(CheckBox)
            });

            cb.Text = "С учетом регистра";
            tlpRows.Add <Label>("Blank");
            _cd.Show(this);
        }
Esempio n. 4
0
        public DialogResult ShowDialog(DBGridParamShowType showType)
        {
            int processed = _items.Count(item => showType == DBGridParamShowType.ShowAll || item.Visible);

            if (processed == 0)
            {
                return(DialogResult.OK);
            }

            using (WinForm cd = new WinForm(WinFormStyle.Dialog))
            {
                cd.Add <Panel>(WinFormConfig.SinglePageForm);
                TableLayoutPanel tlpRows = cd.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;
                TableLayoutPanel p       = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells")
                {
                    CellsSize = new Pair <int>(2, 1)
                });
                p.ColumnStyles[0].SizeType = SizeType.Percent;
                p.ColumnStyles[0].Width    = 38;
                p.ColumnStyles[1].SizeType = SizeType.Percent;
                p.ColumnStyles[1].Width    = 62;
                foreach (var item in _items)
                {
                    if (showType == DBGridParamShowType.ShowAll || item.Visible)
                    {
                        p.Add(item);
                    }
                }

                cd.Items["MainPanel"].LinkedControl.Add <TableLayoutPanel>(WinFormConfig.StdButtons());
                cd.Size         = new Size(450, (int)(450 / vbo.GoldenRatio));
                cd.MinimumSize  = cd.Size;
                cd.AcceptButton = null;
                if (cd.Parent != null)
                {
                    cd.StartPosition = FormStartPosition.CenterParent;
                }
                else
                {
                    cd.StartPosition = FormStartPosition.CenterScreen;
                }

                if (cd.ShowDialog() == DialogResult.OK)
                {
                    cd.Save();
                    Save2Cash();
                    return(DialogResult.OK);
                }
                else
                {
                    return(DialogResult.Cancel);
                }
            }
        }
Esempio n. 5
0
        public BaseViewForm(WinFormItem browser)
        {
            Width  = 680;
            Height = (int)(Width / vbo.GoldenRatio);
            this.Add <Panel>(WinFormConfig.SinglePageForm);
            TableLayoutPanel tp = Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;

            tp.Add(browser);
            browser.LinkedControl.Dock = DockStyle.Fill;
            var btp = GetItem("MainPanel")
                      .LinkedControl
                      .Add <TableLayoutPanel>(WinFormConfig.StdButtons());

            btp.Height = ButtonHeight + 20;
        }
Esempio n. 6
0
        protected virtual void OnLoadData()
        {
            TableLayoutPanel tlpRows = Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;
            TableLayoutPanel p       = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells")
            {
                CellsSize = new Pair <int>(2, 1)
            });

            p.ColumnStyles[0].SizeType = SizeType.Percent;
            p.ColumnStyles[0].Width    = 38;
            p.ColumnStyles[1].SizeType = SizeType.Percent;
            p.ColumnStyles[1].Width    = 62;
            foreach (var item in _schema.Attributes)
            {
                if (item.Visible)
                {
                    p.Add(Attrib2WinFormItem(item, null));
                }
            }
        }
Esempio n. 7
0
        private void InitializeComponent()
        {
            //FontManager.SetBaseFontSize(12f);
            this.SuspendLayout();
            //main
            this.Text   = Program.AppName;
            this.Icon   = ResourceManager.GetIcon("metib_logo", new Size(16, 16), Assembly.GetExecutingAssembly());
            this.Width  = 1000;
            this.Height = (int)(this.Width / vbo.GoldenRatio2);

            this.Add <Panel>(WinFormConfig.SinglePageForm);
            TableLayoutPanel tlpRows = this.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;

            tlpRows.Add <TableLayoutPanel>(
                new WinFormItem("WorkCells",
                                SetMenuBar(),
                                SetToolbar(),
                                SetGrid()
                                )
                );
            _dateStart.Value  = rth.DateStart;
            _dateFinish.Value = rth.DateFinish;
            this.ResumeLayout();
        }
Esempio n. 8
0
        static OutputWindow()
        {
            _cd = new WinForm(WinFormStyle.Dialog)
            {
                Text = "Окно сообщений"
            };
            _cd.Add <Panel>(WinFormConfig.SinglePageForm);
            _cd.FormClosing += _cd_FormClosing;
            TableLayoutPanel tlpRows = _cd.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;

            tlpRows.Add(new WinFormItem($"LogView")
            {
                PresentationType = typeof(DataGridView),
                ControlTrigger   = (cdi, ctrl) =>
                {
                    DataGridView grid          = (ctrl as DataGridView);
                    grid.Dock                  = DockStyle.Fill;
                    grid.AllowUserToAddRows    = false;
                    grid.AllowUserToDeleteRows = false;
                    grid.AutoGenerateColumns   = false;
                    grid.VirtualMode           = true;
                    //grid.ScrollBars = ScrollBars.Both;
                    grid.RowHeadersWidth = 30;
                    int i   = grid.Columns.Add("MessageTime", "Время");
                    var col = grid.Columns[i];
                    col.DataPropertyName        = "MessageTime";
                    col.DefaultCellStyle.Format = vbo.FullDateFormat;
                    col.Width = 130;
                    i         = grid.Columns.Add("MessageSource", "Статус");
                    grid.Columns[i].DataPropertyName = "MessageSource";
                    i   = grid.Columns.Add("Message", "Описание события");
                    col = grid.Columns[i];
                    col.DataPropertyName          = "Message";
                    col.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
                    col.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                    var b            = new DataGridViewButtonColumn()
                    {
                        Name       = "BtnView",
                        HeaderText = "",
                        Text       = "***",
                        Width      = 30,
                        UseColumnTextForButtonValue = true
                    };
                    grid.Columns.Add(b);
                    grid.CellClick += Grid_CellClick;
                    _grid           = grid;
                }
            });
            _cd.Size = new Size(Convert.ToInt32(Screen.FromControl(_cd).WorkingArea.Width / vbo.GoldenRatio), Screen.FromControl(_cd).WorkingArea.Height / 3);
            _timer   = new Timer {
                Interval = 1000
            };
            _timer.Tick += (c, e) =>
            {
                int cnt = _queue.Count;
                for (; _queue.TryDequeue(out Tuple <DateTime, string, string> item);)
                {
                    _dt.Rows.Add(item.Item1, item.Item2, item.Item3);
                }
                if (cnt > 0)
                {
                    _grid.Refresh();
                    Application.DoEvents();
                }
            };
            _cd.Disposed += (c, e) =>
            {
                _timer?.Dispose();
            };
            _grid.DataSource = GetDataSource();
        }
Esempio n. 9
0
        public ActionExecuteForm(DBGrid grid, string actionID)
            : base(WinFormStyle.Dialog)
        {
            this.Add <Panel>(WinFormConfig.SinglePageForm);
            TableLayoutPanel tlpRows = this.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;
            TableLayoutPanel tp      = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells")
            {
                CellsSize = new Pair <int>(2, 1)
            });

            tp.ColumnStyles[0].SizeType = SizeType.Percent;
            tp.ColumnStyles[0].Width    = 38;
            tp.ColumnStyles[1].SizeType = SizeType.Percent;
            tp.ColumnStyles[1].Width    = 62;

            int maxWidth = 480;

            _ai       = ClientGate.GetActionInfo(actionID);
            this.Text = _ai.Name;
            foreach (var p in _ai.InterfaceParameters
                     .Where(param => param.Value.Dirrect == ParamDirrect.Input)
                     .OrderBy(param => param.Value.Position)
                     .Select(param => param.Value))
            {
                WinFormItem item = new WinFormItem(p.AttribName)
                {
                    Caption          = p.Name,
                    DataType         = MdbTypeMap.GetType(p.DataType),
                    Width            = p.DisplayWidth,
                    DataSize         = p.Width,
                    Format           = p.Format,
                    SuperForm        = p.SuperForm,
                    SuperMethod      = p.SuperMethod,
                    ConstName        = p.ConstName,
                    PresentationType = Type.GetType(p.PresentationType),
                    Value            = p.DefaultValue
                };
                if (!p.ListData.IsEmpty())
                {
                    string[] data = p.ListData.Split(',');
                    string[] text = p.ListItems.Split(',');
                    for (int i = 0; i < data.Length; i++)
                    {
                        item.Add(new WinFormItem(text[i])
                        {
                            Caption  = text[i],
                            DataType = item.DataType,
                            Value    = data[i].CastAs(item.DataType)
                        });
                    }
                    item.Mask = "lock";
                }
                switch (item.ConstName.ToLower())
                {
                case "bs_datecurrent":
                    item.Value = vbo.Date();
                    break;

                case "bs_datestart":
                    item.Value = rth.DateStart;
                    break;

                case "bs_datefinish":
                    item.Value = rth.DateFinish;
                    break;

                case "bs_username":
                    item.Value = PathHelper.UserName;
                    break;

                case "bs_selection":
                    item.Value = string.Join(",", grid.CheckedRows.Select(r => r[grid.IdColName].ToString()));
                    break;

                case "bs_objectname":
                    item.Value = grid.SchemaName;
                    break;

                default:
                    if (item.ConstName.Left(1) == "=")
                    {
                        //!!! item.Value = Evaluator.Eval(item.ConstName.Substring(1), schema);
                    }
                    else
                    {
                        //!!!
                        //string localSetting = schema[path + "ConstName"];
                        //if (localSetting.IndexOf(vbo.chrSep) > -1)
                        //	localSetting = dbs.GetSetting(localSetting);
                        //else
                        //	localSetting = dbs.GetSetting(setPath + localSetting);
                        //if (string.IsNullOrEmpty(localSetting))
                        //	localSetting = dbs.GetSetting(schema["ObjectName"] + vbo.chrSep + "Setup" + vbo.chrSep +
                        //		schema[path + "ConstName"]);
                        //if (!string.IsNullOrEmpty(localSetting))
                        //	item.Value = localSetting;
                    }
                    break;
                }
                if (item.OriginalValue == null && grid.ParentRow != null && !string.IsNullOrEmpty(p.FieldName))
                {
                    try
                    {
                        item.Value = grid.ParentRow[p.FieldName];
                    }
                    finally
                    {
                        if (vbo.IsEmpty(item.Value))
                        {
                            item.Value = null;
                        }
                    }
                }
                int width = Math.Max(p.Name.Length, p.DisplayWidth) * (int)this.Font.SizeInPoints;
                if (width > maxWidth)
                {
                    maxWidth = width;
                }
                tp.Add(item);
            }
            var btp = GetItem("MainPanel")
                      .LinkedControl
                      .Add <TableLayoutPanel>(WinFormConfig.StdButtons(OKCaption: "&Выполнить"));

            this.AcceptButton = null;
            this.Width        = maxWidth;
            this.Height       = (int)(this.Width / vbo.GoldenRatio);
            if (this.Parent != null)
            {
                this.StartPosition = FormStartPosition.CenterParent;
            }
            else
            {
                this.StartPosition = FormStartPosition.CenterScreen;
            }
        }
Esempio n. 10
0
        public void Replace()
        {
            //Object[] values = InputBox.Show(new WinFormItem("DateOper") { Caption = "Дата операции", DataType = typeof(DateTime), Value = vbo.Date() },
            //	new WinFormItem("Amount") { Caption = "Сумма", DataType = typeof(decimal), Value = 1000000, Format = vbo.CurrencyFormat });

            if (_cd != null)
            {
                _cd.Dispose();
            }
            _cd = new WinForm(WinFormStyle.Dialog)
            {
                Size = new Size(350, Convert.ToInt32(350 / vbo.GoldenRatio)),
                Text = "Найти..."
            };

            _cd.Add <Panel>(WinFormConfig.SinglePageForm);
            TableLayoutPanel tlpRows = _cd.Items["FormRowsPanel"].LinkedControl as TableLayoutPanel;
            TableLayoutPanel p       = tlpRows.Add <TableLayoutPanel>(new WinFormItem("WorkCells")
            {
                CellsSize = new Pair <int>(2, 3)
            });

            p.ColumnStyles[0].SizeType = SizeType.Percent;
            p.ColumnStyles[0].Width    = 100;
            p.ColumnStyles[1].SizeType = SizeType.Absolute;
            p.ColumnStyles[1].Width    = 100;

            ComboBox cbox = p.Add <ComboBox>(new WinFormItem("SearchText")
            {
                PresentationType = typeof(ComboBox),
                DataType         = typeof(string),
                Value            = GetInitialSearchText(),
                CellAddress      = new Pair <int>(0, 0)
            });

            cbox.Items.AddRange(_searches.ToArray());
            SetAutoComplete(cbox);
            _cd.Activated += new EventHandler((o, e) => { ((WinForm)o).GetControl <ComboBox>("SearchText").Focus(); });

            cbox = p.Add <ComboBox>(new WinFormItem("ReplaceText")
            {
                PresentationType = typeof(ComboBox),
                DataType         = typeof(string),
                Value            = _replaceText,
                CellAddress      = new Pair <int>(0, 1)
            });
            cbox.Items.AddRange(_replaces.ToArray());
            SetAutoComplete(cbox);

            CheckBox cb = p.Add <CheckBox>(new WinFormItem("MatchCase")
            {
                Value            = (_stringComparison != StringComparison.InvariantCultureIgnoreCase),
                DataType         = typeof(bool),
                PresentationType = typeof(CheckBox),
                CellAddress      = new Pair <int>(0, 2)
            });

            cb.Text = "С учетом регистра";

            Button btn = p.Add <Button>("Find");

            btn.Text         = "Найти";
            btn.Click       += new EventHandler(Btn_Click);
            _cd.AcceptButton = btn;

            btn        = p.Add <Button>("Replace");
            btn.Text   = "Заменить";
            btn.Click += new EventHandler(Btn_Click);

            btn        = p.Add <Button>("ReplaceAll");
            btn.Text   = "Заменить все";
            btn.Click += new EventHandler(Btn_Click);
            tlpRows.Add <Label>("Blank");

            _cd.Show(this);
        }