public void RenderControl(UXTreeItem item) { HTMLObject obj = new HTMLObject(this.project.Tools.Find(x => x.Path == "html" && x.Name == "li")); RenderCSSProperties(item, obj.CSS); obj.Container = this.currentContainer; obj.HTML = String.Format(obj.HTML, item.Text, item.Name); this.currentObject.Objects.Add(obj); this.project.Instances.Add(obj); }
/// <summary> /// Render a selectable table /// </summary> /// <param name="data"></param> public void RenderControl(UXViewSelectableDataTable data) { MasterObject mo = new MasterObject(); RenderCSSProperties(data, mo.CSS); mo.Name = data.Name + "_outer_masterObject"; mo.Width = 100; mo.Height = 100; mo.ConstraintWidth = EnumConstraint.RELATIVE; mo.ConstraintHeight = EnumConstraint.RELATIVE; mo.CountColumns = 1; mo.CountLines = 1; mo.HTMLBefore = "<div id='" + mo.Name + "_in' onmouseout='javascript:LeaveArrow();'>"; mo.HTMLAfter = "</div>"; HorizontalZone h = new HorizontalZone(); h.ConstraintWidth = EnumConstraint.RELATIVE; h.ConstraintHeight = EnumConstraint.RELATIVE; h.Width = 100; h.Height = 100; h.CountLines = 1; mo.HorizontalZones.Add(h); VerticalZone v = new VerticalZone(); v.Width = 100; v.Height = 100; data.Get("Disposition", (s, x) => { v.Disposition = Enum.Parse(typeof(Disposition), x.Value); }); v.ConstraintWidth = EnumConstraint.RELATIVE; v.ConstraintHeight = EnumConstraint.RELATIVE; v.CountLines = 1; v.CountColumns = 1; h.VerticalZones.Add(v); this.project.MasterObjects.Add(mo); HTMLObject obj = new HTMLObject(mo); obj.Container = this.currentContainer; this.currentObject.Objects.Add(obj); this.project.Instances.Add(obj); currentContainer = mo.HorizontalZones[0].VerticalZones[0].Name; RenderControl(data as UXViewDataTable); }
/// <summary> /// Render a button /// </summary> /// <param name="button">button to render</param> public void RenderControl(UXButton button) { HTMLObject obj = new HTMLObject(this.project.Tools.Find(x => x.Path == "html" && x.Name == "button")); button.Get("Width", (s, v) => { obj.Width = Convert.ToUInt32(v.Value); }); button.Get("Height", (s, v) => { obj.Height = Convert.ToUInt32(v.Value); }); button.Get("Constraint-Width", (x, y) => { EnumConstraint c; if (Enum.TryParse <EnumConstraint>(y.Value, out c)) { obj.ConstraintWidth = c; } else { obj.ConstraintWidth = EnumConstraint.AUTO; } }); button.Get("Constraint-Height", (x, y) => { EnumConstraint c; if (Enum.TryParse <EnumConstraint>(y.Value, out c)) { obj.ConstraintHeight = c; } else { obj.ConstraintHeight = EnumConstraint.AUTO; } }); RenderCSSProperties(button, obj.CSS); obj.Container = this.currentContainer; obj.HTML = String.Format(obj.HTML, button.Id, button.Text); obj.JavaScriptOnLoad.Code = String.Format(obj.JavaScriptOnLoad.Code, button.Id); this.currentObject.Objects.Add(obj); this.project.Instances.Add(obj); }
/// <summary> /// Render a label /// </summary> /// <param name="text">text to render</param> public void RenderControl(UXReadOnlyText text) { HTMLObject obj = new HTMLObject(this.project.Tools.Find(x => x.Path == "html" && x.Name == "readOnlyText")); text.Get("Width", (s, v) => { obj.Width = Convert.ToUInt32(v.Value); }); text.Get("Height", (s, v) => { obj.Height = Convert.ToUInt32(v.Value); }); text.Get("Constraint-Width", (x, y) => { EnumConstraint c; if (Enum.TryParse <EnumConstraint>(y.Value, out c)) { obj.ConstraintWidth = c; } else { obj.ConstraintWidth = EnumConstraint.AUTO; } }); text.Get("Constraint-Height", (x, y) => { EnumConstraint c; if (Enum.TryParse <EnumConstraint>(y.Value, out c)) { obj.ConstraintHeight = c; } else { obj.ConstraintHeight = EnumConstraint.AUTO; } }); RenderCSSProperties(text, obj.CSS); obj.Container = this.currentContainer; obj.HTML = String.Format(obj.HTML, text.Text); this.currentObject.Objects.Add(obj); this.project.Instances.Add(obj); }
/// <summary> /// Render an image /// </summary> /// <param name="image">image</param> public void RenderControl(UXClickableImage image) { HTMLObject obj = new HTMLObject(this.project.Tools.Find(x => x.Path == "html" && x.Name == "image")); image.Get("Width", (s, v) => { obj.Width = Convert.ToUInt32(v.Value); }); image.Get("Height", (s, v) => { obj.Height = Convert.ToUInt32(v.Value); }); image.Get("Constraint-Width", (x, y) => { EnumConstraint c; if (Enum.TryParse <EnumConstraint>(y.Value, out c)) { obj.ConstraintWidth = c; } else { obj.ConstraintWidth = EnumConstraint.AUTO; } }); image.Get("Constraint-Height", (x, y) => { EnumConstraint c; if (Enum.TryParse <EnumConstraint>(y.Value, out c)) { obj.ConstraintHeight = c; } else { obj.ConstraintHeight = EnumConstraint.AUTO; } }); RenderCSSProperties(image, obj.CSS); obj.Container = this.currentContainer; this.currentObject.Objects.Add(obj); this.project.Instances.Add(obj); }
/// <summary> /// Render a table /// </summary> /// <param name="table">table to render</param> public void RenderControl(UXTable table) { MasterObject mo = new MasterObject(); RenderCSSProperties(table, mo.CSS); mo.Name = table.Name + "_masterObject"; mo.Width = 100; mo.Height = 100; mo.ConstraintWidth = EnumConstraint.RELATIVE; mo.ConstraintHeight = EnumConstraint.RELATIVE; mo.CountColumns = Convert.ToUInt32(table.ColumnCount); mo.CountLines = Convert.ToUInt32(table.LineCount); MasterObject previousMasterObject = currentMasterObject; this.currentMasterObject = mo; dynamic previousObject = this.currentObject; this.currentObject = mo; for (int pos_line = 0; pos_line < table.LineCount; ++pos_line) { if (table.Children.ElementAt(pos_line) != null) { RenderControl(table.Children.ElementAt(pos_line)); } } this.currentObject = previousObject; this.currentMasterObject = previousMasterObject; this.project.MasterObjects.Add(mo); HTMLObject obj = new HTMLObject(mo); obj.Container = this.currentContainer; this.currentObject.Objects.Add(obj); this.project.Instances.Add(obj); }
/// <summary> /// Render a window /// </summary> /// <param name="window">window to render</param> public void RenderControl(UXWindow window) { string previous; Projects.Activate(projectName, out previous); Page p = new Page(); window.Get("Constraint-Width", (x, y) => { EnumConstraint c; if (Enum.TryParse <EnumConstraint>(y.Value, out c)) { p.ConstraintWidth = c; } else { p.ConstraintWidth = EnumConstraint.AUTO; } }); window.Get("Constraint-Height", (x, y) => { EnumConstraint c; if (Enum.TryParse <EnumConstraint>(y.Value, out c)) { p.ConstraintHeight = c; } else { p.ConstraintHeight = EnumConstraint.AUTO; } }); window.Get("Disposition", (s, v) => { p.Disposition = Enum.Parse(typeof(Disposition), v.Value); }); window.Get("Width", (x, y) => { p.Width = Convert.ToUInt32(y.Value); }); window.Get("Height", (x, y) => { p.Height = Convert.ToUInt32(y.Value); }); MasterPage mp = new MasterPage(); RenderCSSProperties(window, mp.CSS); mp.Name = "masterPage_" + window.Name; mp.Width = 100; mp.Height = 100; mp.ConstraintWidth = EnumConstraint.RELATIVE; mp.ConstraintHeight = EnumConstraint.RELATIVE; mp.CountColumns = 1; mp.CountLines = 1; mp.Meta = "<meta name='viewport' content='initial-scale=1, maximum-scale=1, user-scalable=no'/>"; HTMLTool def = this.project.Tools.Find(x => x.Path == "html" && x.Name == "default"); HTMLObject obj = new HTMLObject(def); obj.Container = "globalContainer"; mp.Objects.Add(obj); this.project.Instances.Add(obj); List <AreaSizedRectangle> rects = new List <AreaSizedRectangle>(); AreaSizedRectangle sz = new AreaSizedRectangle(0, 0, 1, 1, 0, 0); rects.Add(sz); mp.MakeZones(rects); this.project.MasterPages.Add(mp); p.MasterPageName = mp.Name; p.Name = window.FileName; currentPage = p; currentMasterPage = mp; currentContainer = mp.HorizontalZones[0].VerticalZones[0].Name; currentObject = currentPage; foreach (IUXObject child in window.Children) { RenderControl(child); } using (FileStream fs = new FileStream(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, p.Name), FileMode.Create, FileAccess.Write, FileShare.Write)) { using (StreamWriter sw = new StreamWriter(fs)) { OutputHTML o = currentPage.GenerateProduction(); sw.Write(o.HTML); sw.Close(); } fs.Close(); } Projects.Reactivate(previous); }
public async Task <QueryResult <TableModel> > GetOfferTableQuantityItemsVRO(QuantityTableSearchCretriaModel quantityTableSearchCretriaModel) { var cellsCount = 0; cellsCount = await _offerQueries.GetOfferTableQuantityItems(quantityTableSearchCretriaModel.QuantityTableId); quantityTableSearchCretriaModel.CellsCount = cellsCount; var offer = await _offerQueries.FindOfferWithStatusById(quantityTableSearchCretriaModel.OfferId); var quantityItems = await _offerQueries.GetSupplierQTableItemsForChecking(quantityTableSearchCretriaModel); QuantitiesTemplateModel lst = await _offerQueries.GetOfferQuantityItems(quantityTableSearchCretriaModel.OfferId, quantityTableSearchCretriaModel.QuantityTableId); lst.QuantitiesItems = quantityItems.Items.ToList(); if (lst == null) { lst = new QuantitiesTemplateModel(); } lst.grid = new List <string>(); lst.ActivityTemplates = new List <int> { (int)TenderActivityTamplate.OldSystemAndVRO }; foreach (var item in lst.ActivityTemplates) { FormConfigurationDTO DTOModel = new FormConfigurationDTO() { SubmitAction = "/Offer/SaveVROCheckingQuantityItem", TenderId = quantityTableSearchCretriaModel.TenderId, HasAlternative = offer.Tender.HasAlternativeOffer ?? false, ApplySelected = offer.Tender.HasAlternativeOffer ?? false, CanEditAlternative = ((_httpContextAccessor.HttpContext.User.IsInRole(RoleNames.OffersOpeningAndCheckSecretary) && (offer.Tender.TenderStatusId == (int)Enums.TenderStatus.VROFinancialCheckingOpening || offer.Tender.TenderStatusId == (int)Enums.TenderStatus.VROOffersFinancialChecking))) ? true : false, AllowEdit = false, ActivityId = 1, EncryptedOfferId = Util.Encrypt(quantityTableSearchCretriaModel.OfferId), EncryptedTenderId = Util.Encrypt(quantityTableSearchCretriaModel.TenderId), QuantityItemDtos = lst.QuantitiesItems.ToList(), YearsCount = (offer.Tender.TemplateYears ?? 0) }; ApiResponse <List <HtmlTemplateDto> > resultList = new ApiResponse <List <HtmlTemplateDto> >(); ApiResponse <HtmlTemplateDto> resultItem = new ApiResponse <HtmlTemplateDto>(); if (_httpContextAccessor.HttpContext.User.IsInRole(RoleNames.OffersOpeningAndCheckSecretary) && (offer.Tender.TenderStatusId == (int)Enums.TenderStatus.VROOffersFinancialChecking || offer.Tender.TenderStatusId == (int)Enums.TenderStatus.VROFinancialCheckingOpening)) { resultList = resultList = await _qantityTemplatesProxy.GetMonafasatSupplierForChecking(DTOModel); } else { resultList = await _qantityTemplatesProxy.GenerateSupplierReadOnlyTemplate(DTOModel); } HTMLObject obje = new HTMLObject(); ApiResponse <List <HtmlTemplateDto> > obj = new ApiResponse <List <HtmlTemplateDto> > { Data = resultList.Data }; if (obj.Data != null && obj.Data.Count > 0 && obj.Data[0] != null) { lst.grid.AddRange(obj.Data.Select(a => a.FormHtml).ToList()); obje.grid.AddRange(obj.Data.Select(a => a.FormHtml).ToList()); lst.grids.AddRange(obj.Data.GroupBy(o => new { o.FormId, o.FormName, o.TemplateName, o.FormExcellTemplate }).Select(o => new HTMLObject { FormId = o.Key.FormId, FormName = o.Key.FormName, TemplateName = o.Key.TemplateName, FormExcellTemplate = _configuration.APIConfiguration.QuantityTemplates + "/api/QuantityTable/" + o.Key.FormExcellTemplate, Javascript = o.FirstOrDefault().JsScript, gridTables = o.Select(u => new TableModel { TableHtml = u.FormHtml, TableId = u.TableId, TableName = !string.IsNullOrEmpty(u.TableName) ? u.TableName : "اسم الجدول", FormId = u.FormId, DeleteFormHtml = u.DeleteFormHtml, EditFormHtml = u.EditFormHtml, Javascript = u.JsScript }).ToList() }).ToList()); } } lst.IsReadOnly = quantityTableSearchCretriaModel.IsReadOnly; return(new QueryResult <TableModel>(lst.grids[0].gridTables.ToList(), quantityItems.TotalCount, quantityTableSearchCretriaModel.PageNumber, quantityTableSearchCretriaModel.PageSize * cellsCount)); }
private void supprimerToolStripMenuItem5_Click(object sender, EventArgs e) { TreeNode t = this.prv_currentNodeContext; if (t != null) { if (t.Tag != null) { DialogResult dr = MessageBox.Show(Translate("SuppressText"), Translate("SuppressTitle"), MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == System.Windows.Forms.DialogResult.Yes) { if (t.Tag is Library.MasterPage) { MasterPage mp = t.Tag as MasterPage; Project.CurrentProject.Remove(mp); Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); Project.CurrentProject.ReloadProject(); } else if (t.Tag is Library.MasterObject) { Project.CurrentProject.Remove(t.Tag as MasterObject); Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); Project.CurrentProject.ReloadProject(); } else if (t.Tag is Library.HTMLTool) { Library.HTMLTool tool = t.Tag as Library.HTMLTool; Project.CurrentProject.Remove(tool); Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); Project.CurrentProject.ReloadProject(); } else if (t.Tag is Library.HTMLObject) { HTMLObject obj = t.Tag as Library.HTMLObject; Project.CurrentProject.Remove(obj); Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); Project.CurrentProject.ReloadProject(); } else if (t.Tag is Library.SculptureObject) { SculptureObject sObject = t.Tag as SculptureObject; Project.CurrentProject.Remove(sObject); Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); Project.CurrentProject.ReloadProject(); } else if (t.Tag is Library.Page) { Page p = t.Tag as Library.Page; Project.CurrentProject.Remove(p); Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); Project.CurrentProject.ReloadProject(); } else if (t.Tag is Library.File) { Library.File f = t.Tag as Library.File; Project.CurrentProject.Remove(f); Project.Save(Project.CurrentProject, ConfigDirectories.GetDocumentsFolder(), AppDomain.CurrentDomain.GetData("fileName").ToString()); Project.CurrentProject.ReloadProject(); } } } } }
private void treeView1_DoubleClick(object sender, EventArgs e) { TreeNode currentSelection = this.treeView1.GetNodeAt(this.treeView1.PointToClient(MousePosition)); if (currentSelection != null) { this.treeView1.SelectedNode = currentSelection; } if (this.treeView1.SelectedNode != null) { if (this.treeView1.SelectedNode.Tag != null) { // sauvegarde selected node this.prv_currentNodeContext = this.treeView1.SelectedNode; if (this.treeView1.SelectedNode.Tag is Library.MasterPage) { Library.MasterPage mp = this.treeView1.SelectedNode.Tag as Library.MasterPage; MasterPageView window = new MasterPageView(mp.Name); window.Text = String.Format(Translate("MasterPageTitle"), mp.Name); window.FormClosed += window_FormClosed; window.MdiParent = this; window.MasterPage = mp; window.WindowState = FormWindowState.Normal; window.StartPosition = FormStartPosition.Manual; window.Top = 0; window.Left = 0; window.Show(); } else if (this.treeView1.SelectedNode.Tag is Library.MasterObject) { Library.MasterObject mo = this.treeView1.SelectedNode.Tag as Library.MasterObject; MasterObjectView window = new MasterObjectView(mo.Title); window.Text = String.Format(Translate("MasterObjectTitle"), mo.Title); window.FormClosed += window_FormClosed; window.MdiParent = this; window.MasterObject = mo; window.WindowState = FormWindowState.Normal; window.StartPosition = FormStartPosition.Manual; window.Top = 0; window.Left = 0; window.Show(); } else if (this.treeView1.SelectedNode.Tag is Library.SculptureObject) { Library.SculptureObject so = this.treeView1.SelectedNode.Tag as Library.SculptureObject; SculptureView window = new SculptureView(); window.Text = String.Format(Translate("SculptureTitle"), so.Title); window.FormClosed += window_FormClosed; window.MdiParent = this; window.SculptureObject = so; if (window.SculptureObject.Cadres.Count == 0) { window.SculptureObject.Cadres.Add(new CadreModel()); } window.CurrentCadreModel.CurrentObject = window.SculptureObject.Cadres[0]; window.WindowState = FormWindowState.Normal; window.StartPosition = FormStartPosition.Manual; window.Top = 0; window.Left = 0; window.Show(); } else if (this.treeView1.SelectedNode.Tag is Library.HTMLTool) { Library.HTMLTool t = this.treeView1.SelectedNode.Tag as Library.HTMLTool; ToolView view = new ToolView(t.Title); view.Text = String.Format(Translate("ToolTitle"), t.Title); view.FormClosed += window_FormClosed; view.MdiParent = this; view.HTMLTool = t; view.WindowState = FormWindowState.Normal; view.StartPosition = FormStartPosition.Manual; view.Top = 0; view.Left = 0; view.Show(); } else if (this.treeView1.SelectedNode.Tag is Library.HTMLObject) { HTMLObject obj = this.treeView1.SelectedNode.Tag as Library.HTMLObject; if (!String.IsNullOrEmpty(obj.MasterObjectName)) { ObjectView view = new ObjectView(obj.Title); view.Text = String.Format(Translate("ObjectTitle"), obj.Title); view.FormClosed += window_FormClosed; view.MdiParent = this; view.HTMLObject = obj; view.WindowState = FormWindowState.Normal; view.StartPosition = FormStartPosition.Manual; view.Top = 0; view.Left = 0; view.Show(); } else { SimpleObjectView view = new SimpleObjectView(obj.Title); view.Text = String.Format(Translate("ObjectTitle"), obj.Title); view.FormClosed += window_FormClosed; view.MdiParent = this; view.HTMLObject = obj; view.WindowState = FormWindowState.Normal; view.StartPosition = FormStartPosition.Manual; view.Top = 0; view.Left = 0; view.Show(); } } else if (this.treeView1.SelectedNode.Tag is Library.Page) { Page p = this.treeView1.SelectedNode.Tag as Library.Page; PageView view = new PageView(p.Name); view.Text = String.Format(Translate("PageTitle"), p.Name); view.FormClosed += window_FormClosed; view.MdiParent = this; view.Page = p; view.WindowState = FormWindowState.Normal; view.StartPosition = FormStartPosition.Manual; view.Top = 0; view.Left = 0; view.Show(); } else if (this.treeView1.SelectedNode.Tag is Library.Configuration) { ConfigView cv = new ConfigView(); cv.FormClosed += window_FormClosed; cv.Datas = (this.treeView1.SelectedNode.Tag as Library.Configuration).Elements; cv.ShowDialog(); } else if (this.treeView1.SelectedNode.Tag is List <string> ) { if (this.treeView1.SelectedNode.Name == "JavaScriptUrls") { JavaScriptUrls ju = new JavaScriptUrls(); ju.FormClosed += window_FormClosed; ju.Datas = (this.treeView1.SelectedNode.Tag as List <string>); ju.ShowDialog(); } else if (this.treeView1.SelectedNode.Name == "CSSUrls") { CSSUrls cu = new CSSUrls(); cu.FormClosed += window_FormClosed; cu.Datas = (this.treeView1.SelectedNode.Tag as List <string>); cu.ShowDialog(); } } } } }
/// <summary> /// Helper method for public static HTMLObject[] GetElementValue(string html, string element, HtmlParsingOptions options, params string[] attributes) /// </summary> private static HTMLObject[] parseUnsureAttributes(string html, string element, string[] incompleteAttributes) { #region [ create the regex ] //create the element StringBuilder regexBuilder = new StringBuilder("<"); regexBuilder.Append(element); if (incompleteAttributes.Length != 0) { regexBuilder.Append(@"\s+"); } //initiate there might be following attributes if (incompleteAttributes.Length != 0) { regexBuilder.Append("("); foreach (var s in incompleteAttributes) { regexBuilder.Append("("); regexBuilder.Append(Regex.Escape(s)); regexBuilder.Append("=\"["); regexBuilder.Append(regexPatternAllCharacters); regexBuilder.Append("]+\" *)"); regexBuilder.Append("|"); } //remove the last | regexBuilder.Remove(regexBuilder.Length - 1, 1); //min/only (not sure) amount of those attributes regexBuilder.Append("){"); regexBuilder.Append(incompleteAttributes.Length); regexBuilder.Append("}"); regexBuilder.Append(@"\s?"); } //close it and save the pattern for easy use lateron regexBuilder.Append(">"); string regexPattern = regexBuilder.ToString(); var regexPatternIgnoreCase = new Regex(regexBuilder.ToString(), RegexOptions.IgnoreCase); #endregion //Now we have the Regex which we are looking for, so we can go ahead and get that sweet seet first index if (!regexPatternIgnoreCase.IsMatch(html)) { throw new Exception("Does not contain the Element in combination with the attributes"); } //TODO: Propper exeption //get the matching attribut sentencens var matches = Regex.Matches(html, regexPattern); HTMLObject[] response = new HTMLObject[matches.Count]; int index = 0; //Now we can parse out the attributes foreach (Match match in matches) { //get the tags of that element string tagWithAttributes = match.Value; //instantiate the new objec response[index] = new HTMLObject { Tag = tagWithAttributes, Element = element }; var theObject = response[index]; //now that we have the tags with attributes it is easy to filter out the tags foreach (var passedAttribte in incompleteAttributes) { string value = Regex.Replace(tagWithAttributes, ".+" + passedAttribte + "=\"", "", RegexOptions.IgnoreCase); value = Regex.Replace(value, "\".+", "", RegexOptions.Singleline); theObject.Attributes.Add(passedAttribte, value); } string[] paramsForFunc = new string[theObject.Attributes.Count]; //now we can build an array to call the first method here to get the specific value of this tag int i = 0; foreach (var item in theObject.Attributes) { paramsForFunc[i++] = item.Key + "=\"" + item.Value + "\""; } //now we can call the main function theObject.Value = GetElementValue(html, element, paramsForFunc); index++; } //now that we are finished we can return the object return(response); }