public AttrController(string name, List <string> a) { InitializeComponent(); using (SiteGeneratorContext context = new SiteGeneratorContext()) { var linq = from t in context.HTML_ATTR where t.TAG == name.ToLower() select t; if (linq.Count() > 0) { var count = 0; foreach (var item in linq) { var linqobj = (from b in context.HTML_ATTR where b.TAG == item.TAG select b).ToArray(); if (linqobj[count].NAME_ATTR != "src") { Label label = new Label() { Content = linqobj[count].NAME_ATTR, ToolTip = linqobj[count].TAG }; text = new TextBox() { Text = a[count], DataContext = linqobj[count].NAME_ATTR }; resultquerry.Add(linqobj[count].NAME_ATTR); Attr.Children.Add(label); Attr.Children.Add(text); count++; } else { Label label = new Label() { Content = linqobj[count].NAME_ATTR, ToolTip = linqobj[count].TAG }; text = new TextBox() { Text = a[count], DataContext = linqobj[count].NAME_ATTR }; resultquerry.Add(linqobj[count].NAME_ATTR); Attr.Children.Add(label); Attr.Children.Add(text); count++; } } Button button = new Button() { Content = "Применить аттрибут" }; button.Click += Button_Click; Attr.Children.Add(button); } } }
private void SelectItem(object sender, MouseButtonEventArgs e) { TreeViewItem select = sender as TreeViewItem; SelectTreeViewItem = select; window = this; if (select.Header.ToString() == "<TEXT>") { MessageBox.Show("Текст"); } else { List <string> list = new List <string>(); var c = ((IHTMLElement)select.DataContext).tagName; using (SiteGeneratorContext context = new SiteGeneratorContext()) { var b = (from w in context.HTML_ATTR where w.TAG == c.ToLower() select w.NAME_ATTR).ToList(); if (b.Count > 0) { foreach (var item in b) { dynamic a = ((IHTMLElement)select.DataContext).getAttribute(item.ToString()); string buf = " " + a; list.Add(buf); if (list != null) { attributes.Children.Clear(); } } attributes.Children.Add(new AttrController(((IHTMLElement)select.DataContext).tagName, list)); } if (b.Count == 0) { attributes.Children.Clear(); } } Tool.Items.Clear(); Tool.Items.Add(new CssBlock((((IHTMLElement)select.DataContext).tagName))); if (select.Items.Count <= 1) { var a = select.DataContext as IHTMLElement; if (a.innerText != null) { EditInner(a.innerText); } } else { Editor.Text = ""; } } }
public string invalid(TreeViewItem items) { if (items == null) { return(""); } string html = ""; foreach (TreeViewItem item in items.Items) { if (item.Header.ToString() == "<TEXT>") { html += item.DataContext; continue; } var x = dom.createElement(((IHTMLElement)item.DataContext).tagName); string newHTML = x.outerHTML; using (SiteGeneratorContext context = new SiteGeneratorContext { }) { var attr = (from at in context.HTML_ATTR where ((IHTMLElement)item.DataContext).tagName == at.TAG select at.NAME_ATTR); foreach (var query in attr) { dynamic a = ((IHTMLElement)item.DataContext).getAttribute(query.ToString(), -1); string buf = "" + a; if (buf.Length > 0) { newHTML = newHTML.Insert(newHTML.IndexOf('>'), " " + query + "=" + '"' + a + '"'); } } } html += newHTML.Insert(newHTML.IndexOf('>') + 1, item.Items.Count <= 0 ? (((IHTMLElement)item.DataContext).innerHTML == null ? "" : ((IHTMLElement)item.DataContext).innerHTML + item.DataContext) : invalid(item)); } return(html); }
private void MenuGen(object sender, MouseButtonEventArgs e) { var a = (TreeViewItem)sender; using (var context = new SiteGeneratorContext()) { var blogs = (from t in context.HTML_GEN where t.POSITION == (((a.Header.ToString()).Remove(a.Header.ToString().Length - 1, 1)).Remove(0, 1)).ToLower() select t.TAG).ToList(); if (blogs.Count != 0) { AddElements.Items.Clear(); } foreach (var item in blogs) { MenuItem items = new MenuItem { Header = item.ToString() }; items.Click += AddElementsClick; AddElements.Items.Add(items); } } }
private void CreateProject_Click(object sender, RoutedEventArgs e) { CreateProjectPage projectPage = new CreateProjectPage(); projectPage.ShowDialog(); if (projectPage.Success) { if (Settings.Uri != null) { Toglebar(); web.Source = new Uri(Settings.Uri); System.Windows.Forms.MessageBox.Show(web.Document.ToString()); FirstInizial(); } } using (SiteGeneratorContext context = new SiteGeneratorContext()) { var linqobj = (from b in context.HTML_ATTR where b.TAG == "a" select b).ToList(); // MessageBox.Show(linqobj.Count.ToString()); } }
public CssBlock(string name) { InitializeComponent(); using (SiteGeneratorContext context = new SiteGeneratorContext()) { var linq = from t in context.CSS_HTML where t.TAG_NAME == name.ToLower() select t; if (linq.Count() > 0) { List <string> list = ReadingCss(); foreach (var item in linq) { var linqobj = (from t in context.CSS_GEN where t.PROPERTY_NAME == item.PROPERTY_NAME select t).Take(1).Single(); string buf = ""; foreach (var param in list) { if (param.Contains(linqobj.PROPERTY_NAME)) { buf = param.Remove(0, param.IndexOf(':', 0) + 1);; } } if (linqobj.TYPE_ROW == 0) { Label label = new Label() { Content = linqobj.PROPERTY_NAME, ToolTip = linqobj.DISCRIPTION_CSS }; TextBox text = new TextBox() { Text = buf, DataContext = linqobj.PROPERTY_NAME }; CssController.Children.Add(label); CssController.Children.Add(text); } else if (linqobj.TYPE_ROW == 1) { Label label = new Label() { Content = linqobj.PROPERTY_NAME, ToolTip = linqobj.DISCRIPTION_CSS }; ComboBox combo = new ComboBox() { Items = { "red", "blue", "black" }, DataContext = linqobj.PROPERTY_NAME }; CssController.Children.Add(label); CssController.Children.Add(combo); } } Button button = new Button() { Content = "Применить свойства" }; button.Click += Button_Click; CssController.Children.Add(button); } } }