/// <summary> /// Try to load data from prepolated_daisy_output.xml /// </summary> /// <returns>Instnace of <see cref="PrepopulateDaisyOutput"/> class if xml file exists, otherwise - null.</returns> public static PrepopulateDaisyOutput Load() { if (!File.Exists(XmlFilePath)) { return(null); } PrepopulateDaisyOutput result = new PrepopulateDaisyOutput();; var document = new XmlDocument(); document.Load(XmlFilePath); if (document.FirstChild.ChildNodes.Count > 0) { result.OutputPath = document.FirstChild.ChildNodes[0].InnerText; } return(result); }
/// <summary> /// Function which loads the form /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DesignForm_Load(object sender, EventArgs e) { tBx_Uid.Text = GenerateId().ToString(); uId = tBx_Uid.Text; PrepopulateDaisyXml xml = new PrepopulateDaisyXml(); tBx_Creator.Text = xml.Creator; tBx_Title.Text = xml.Title; tBx_Publisher.Text = xml.Publisher; if (IsTranslateToSingleDaisy && !useAScript) { PrepopulateDaisyOutput prepopulateDaisyOutput = PrepopulateDaisyOutput.Load(); tBx_Browse.Text = prepopulateDaisyOutput != null ? prepopulateDaisyOutput.OutputPath : Path.GetDirectoryName(inputFileName); tBx_Browse.SelectionStart = 0; mLayoutPanel.Visible = false; oLayoutPanel.Visible = false; btn_OpenDetail.Visible = false; btn_OK.Location = new Point(grpBox_Properties.Width - 220, grpBox_Properties.Location.Y + grpBox_Properties.Height + 3); btn_Reset.Location = new Point(btn_OK.Location.X + btn_OK.Width + 7, btn_OK.Location.Y); btn_Cancel.Location = new Point(btn_Reset.Location.X + btn_Reset.Width + 7, btn_OK.Location.Y); } else { panel1.Visible = false; oLayoutPanel.Visible = false; mLayoutPanel.Location = new Point(panel1.Location.X, panel1.Location.Y); grpBox_Properties.Location = new Point(mLayoutPanel.Location.X, mLayoutPanel.Location.Y + 30); this.Height = this.Height - panel1.Height - oLayoutPanel.Height - btn_HideDetail.Height - 130; int tabIndex = 0; int w = 0; int h = 0; //shaby (begin): Implementing TableLayoutPannel int oTableLayoutCurrentRow = 0; int oTableLayoutCurrentColumn = 0; oTableLayoutPannel.Visible = false; oTableLayoutPannel.Name = "oTableLayoutPannel"; oTableLayoutPannel.AutoSize = true; oTableLayoutPannel.AutoSizeMode = AutoSizeMode.GrowAndShrink; //oTableLayoutPannel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; oTableLayoutPannel.TabIndex = btn_OpenDetail.TabIndex + 1; oTableLayoutPannel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); //shaby (end) : Implementing TableLayoutPannel foreach (ScriptParameter p in mParser.ParameterList) { PrepopulateDaisyOutput prepopulateDaisyOutput = PrepopulateDaisyOutput.Load(); strBrtextBox = prepopulateDaisyOutput != null ? prepopulateDaisyOutput.OutputPath : string.Empty; if (p.Name != "input" && p.ParameterDataType is PathDataType && p.IsParameterRequired) { Control c = (Control) new PathBrowserControl(p, inputFileName, mProjectDirectory, strBrtextBox); c.Anchor = AnchorStyles.Right; mLayoutPanel.Controls.Add(c); mLayoutPanel.SetFlowBreak(c, true); c.TabIndex = tabIndex++; if (w < c.Width + c.Margin.Horizontal) { w = c.Width + c.Margin.Horizontal; } h += c.Height + c.Margin.Vertical; } else if (!p.IsParameterRequired) { //TODO: added to work epub not. Should add correct procesing of this parameter. if (p.ParameterDataType is PathDataType) { continue; } Control c = p.ParameterDataType is BoolDataType ? new BoolControl(p) : p.ParameterDataType is EnumDataType ? new EnumControl(p) : p.ParameterDataType is StringDataType ? new StrUserControl(p) : (Control) new IntUserControl(p); c.Anchor = AnchorStyles.Right; oTableLayoutPannel.Controls.Add(c, oTableLayoutCurrentColumn, oTableLayoutCurrentRow); this.Controls.Add(oTableLayoutPannel); oTableLayoutCurrentRow++; } } oTableLayoutPannel.Location = new Point(btn_OpenDetail.Location.X, btn_OpenDetail.Location.Y + 5); if (oTableLayoutPannel.Width > mLayoutPanel.Width) { mLayoutPanel.Controls[0].Width = oTableLayoutPannel.Width - 3; tableLayoutPanel2.Width = oTableLayoutPannel.Width - 4; } else { oTableLayoutPannel.Controls[0].Width = mLayoutPanel.Width - 3; tableLayoutPanel2.Width = mLayoutPanel.Width - 4; } btn_OK.Location = new Point(oTableLayoutPannel.Width - 220, btn_OpenDetail.Location.Y); btn_Reset.Location = new Point(btn_OK.Location.X + btn_OK.Width + 7, btn_OpenDetail.Location.Y); btn_Cancel.Location = new Point(btn_Reset.Location.X + btn_Reset.Width + 7, btn_OpenDetail.Location.Y); } }
private void UpdatePopulateOutputXml(string outputPath) { PrepopulateDaisyOutput output = new PrepopulateDaisyOutput(outputPath); output.Save(); }