Exemplo n.º 1
0
        public void DisplayEditor(JobsEditor _js, string xmlText, bool _isEditMode)
        {
            js = _js;
            isEditMode = _isEditMode;

            try
            {
                this.SuspendLayout();

                Clear();
                ResizeEditor();

                if (!xmlText.Equals(String.Empty))
                {
                    xdoc = new XmlDocument();
                    xdoc.LoadXml(xmlText);

                    string moduleType = xdoc.FirstChild.Attributes["moduleType"].Value;

                    int row = 0;
                    foreach (XmlNode node in xdoc.FirstChild.Attributes)
                    {
                        tableLayoutPanel1.RowCount = row + 1;

                        TableLayoutPanelCellPosition posLeft = new TableLayoutPanelCellPosition(0, row);
                        Label l = new Label();
                        l.Text = node.Name;
                        l.TextAlign = ContentAlignment.MiddleLeft;
                        l.Width = Convert.ToInt32(tableLayoutPanel1.ColumnStyles[0].Width);
                        tableLayoutPanel1.SetCellPosition(l, posLeft);
                        tableLayoutPanel1.Controls.Add(l);

                        if (moduleType.Equals("DataTableJoiner") && node.Name.Equals("OutputColumns"))
                        {
                            Panel p = new Panel();
                            p.Height = 140;
                            p.Width = Convert.ToInt32(tableLayoutPanel1.Width - tableLayoutPanel1.ColumnStyles[0].Width) - 28;

                            string[] list = node.InnerXml.Split(';');

                            TableLayoutPanelCellPosition posRight = new TableLayoutPanelCellPosition(1, row);
                            el = new EditableList();
                            el.ListBox.DataSource = list;
                            el.Enabled = protectedFields.Contains(node.Name.ToLower()) ? false : true;
                            if (isEditMode)
                                el.TextChanged += new EventHandler(XmlNodeTextChanged);
                            el.Width = p.Width - 180;
                            el.Height = 140;
                            el.Top = 0;
                            el.Left = 0;

                            Button bAdd = new Button();
                            bAdd.Text = "Add";
                            bAdd.Top = 10;
                            bAdd.Left = p.Width - 150;
                            bAdd.Click += new EventHandler(bAdd_Click);

                            Button bRemove = new Button();
                            bRemove.Text = "Remove";
                            bRemove.Top = 50;
                            bRemove.Left = p.Width - 150;
                            bRemove.Click += new EventHandler(bRemove_Click);                                

                            p.Controls.AddRange(new Control[] { el, bAdd, bRemove });
                            tableLayoutPanel1.SetCellPosition(p, posRight);
                            tableLayoutPanel1.Controls.Add(p);

                        }
                        else
                        {

                            TableLayoutPanelCellPosition posRight = new TableLayoutPanelCellPosition(1, row);
                            TextBox t = new TextBox();
                            t.Multiline = true;
                            t.WordWrap = true;
                            t.Text = node.InnerXml;
                            t.Enabled = protectedFields.Contains(node.Name.ToLower()) ? false : true;
                            if (isEditMode)
                                t.TextChanged += new EventHandler(XmlNodeTextChanged);
                            t.Width = Convert.ToInt32(tableLayoutPanel1.Width - tableLayoutPanel1.ColumnStyles[0].Width) - 8;
                            t.Height = Convert.ToInt32(t.Height * (1.0 + (Math.Truncate(t.TextLength / 60.0))));
                            tableLayoutPanel1.SetCellPosition(t, posRight);
                            tableLayoutPanel1.Controls.Add(t);

                        }
                        row++;
                    }
                }
                this.Visible = true;
                tableLayoutPanel1.Visible = true;
                SetSaveVisibility();

                EnableUpdateButton(isEditMode);
                isDirty = false;
            }
            catch (Exception ex)
            {
                Console.Write(ex);
            }
            finally
            {
                this.ResumeLayout();
            }
        }
Exemplo n.º 2
0
        public static void NewJobEditor(string jobName)
        {
            try
            {
                JobsEditor jobEditor = null;
                if (FormsManagerProxy.DataViewerControls.ContainsKey("JobsEditorCtl"))
                {
                    jobEditor = (JobsEditor)FormsManagerProxy.DataViewerControls["JobsEditorCtl"];
                    FormsManagerProxy.DataViewerControls.Remove("JobsEditorCtl");
                    if (jobEditor != null)
                    {
                        if (jobEditor.cc != null)
                        {
                            ((ControlContainer)jobEditor.cc).Close();
                            jobEditor.cc = null;
                        }
                        jobEditor = null;
                    }
                }

                jobEditor = new JobsEditor(jobName);
                jobEditor.cc = new ControlContainer(jobEditor, "Job Editor", mf);
                FormsManagerProxy.DataViewerControls.Add("JobsEditorCtl", jobEditor);
                jobEditor.cc.Show();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error encountered.  Please contact support.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                log.Error(ex);
            }
            finally
            {
            }
        }