Exemplo n.º 1
0
        public void BindData(int dataSourceId, int systemDataSourceId)
        {
            pnlMain.Visible        = false;
            lblMessage.Text        = "Preparing...";
            pnlPreparing.Visible   = true;
            this.ParentForm.Cursor = Cursors.WaitCursor;
            Application.DoEvents();

            List <IdpeAttribute> attributes    = new Manager().GetAttributes(dataSourceId).ToList();
            List <IdpeAttribute> sysAttributes = new Manager().GetAttributes(systemDataSourceId).Where(a => a.Name != "IsValid").ToList();

            if (sysAttributes.Count == 0)
            {
                this.ParentForm.Cursor = Cursors.Default;
                Application.DoEvents();
                ShowMessage("No system(internal) attribute found!");
                return;
            }

            List <Control> controls     = new List <Control>();
            int            count        = 1;
            bool           alternateRow = false;

            foreach (IdpeAttribute attribute in sysAttributes)
            {
                AttributeMapper attributeMapper = new AttributeMapper();
                attributeMapper.Attributes                   = attributes;
                attributeMapper.SystemAttributes             = sysAttributes;
                attributeMapper.Dock                         = System.Windows.Forms.DockStyle.Top;
                attributeMapper.Name                         = "attributeMapper" + count;
                attributeMapper.Padding                      = new System.Windows.Forms.Padding(0, 8, 0, 5);
                attributeMapper.SystemAttributeSelectedIndex = count;
                //if (alternateRow)
                //    attributeMapper.BackColors = SystemColors.ControlDark;
                controls.Add(attributeMapper);
                alternateRow = !alternateRow;
                count++;
            }

            controls.Reverse();
            pnlMain.Controls.AddRange(controls.ToArray());

            pnlMain.Visible        = true;
            pnlPreparing.Visible   = false;
            this.ParentForm.Cursor = Cursors.Default;
            Application.DoEvents();
        }
Exemplo n.º 2
0
        public bool Save(string dataSourceName)
        {
            string dynamicXamlBody = string.Empty;
            bool   allGood         = true;

            List <Control> mappers = new List <Control>(pnlMain.Controls.Cast <Control>());

            mappers.Reverse();

            foreach (Control ctl in mappers)
            {
                if (ctl is AttributeMapper)
                {
                    AttributeMapper attributeMapper = (AttributeMapper)ctl;
                    if (attributeMapper.ValidateData() == false)
                    {
                        attributeMapper.Focus();
                        allGood = false;
                    }
                    else
                    {
                        dynamicXamlBody += attributeMapper.XamlString + Environment.NewLine;
                    }
                }
            }

            if (allGood)
            {
                InputBox inputBox = new InputBox(dataSourceName + " - Map", "Enter Rule Name", "Save Rule", this.ParentForm.Icon);
                if (inputBox.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    IdpeRule rule = new IdpeRule();
                    rule.Name        = inputBox.TheInput;
                    rule.Description = inputBox.TheInput + " was created by wizard";
                    rule.Xaml        = string.Format(XamlBody, rule.Name, dynamicXamlBody);
                    new Manager().Save(rule);
                }
            }
            return(allGood);
        }