private bool GetToggleState(TreePath path, TableLocation Column) { try { TreeIter iter; TreeViewTable.GetIter(out iter, path); return((bool)TreeViewTable.GetValue(iter, (int)Column)); } catch { return(false); } }
public void RefreshPreview(object pos) { TableLocation loc = null; if (pos != null) { loc = new TableLocation { Column = Convert.ToInt32(ReflectionUtils.GetPropertyExCom(pos, "column")), Row = Convert.ToInt32(ReflectionUtils.GetPropertyExCom(pos, "row")) }; } Window.RefreshPreview(false, loc); }
/// <summary> /// Pops up the context menu /// </summary> /// <param name="mousePosition"></param> public void ShowContextMenu(object mousePosition) { // get the latest editor table data Window.TableData = Window.Interop.GetJsonTableData(); // incoming row data is: row 0 = header, actual rows 1 based var loc = new TableLocation(); loc.Row = Convert.ToInt32(ReflectionUtils.GetPropertyCom(mousePosition, "row")); loc.Column = Convert.ToInt32(ReflectionUtils.GetPropertyCom(mousePosition, "column")); loc.IsHeader = loc.Row < 1; // Fix up row number to 0 based if (!loc.IsHeader) { loc.Row--; } var ctx = new TableEditorContextMenu(Window, loc); ctx.ShowContextMenu(); }
public void RefreshPreview(bool dontReloadData = false, TableLocation loc = null) { if (!IsPreviewActive) { return; } if (!dontReloadData) { TableData = Interop.GetJsonTableData(); } this.PreviewTableLocation = loc; var parser = new TableParserHtml(); parser.TableData = TableData; string markdown = null; if (TableMode == "Grid Table") { markdown = parser.ToGridTableMarkdown(); } else if (TableMode == "Html Table") { markdown = parser.ToTableHtml(); } else { markdown = parser.ToPipeTableMarkdown(); } #if DEBUG var file = Path.Combine("c:\\projects\\MarkdownMonster\\MarkdownMonster", "PreviewThemes", "TableEditor.html"); var outputFile = file.Replace("TableEditor.html", "_TableEditorPreview.html"); var url = outputFile; #else var file = Path.Combine(App.InitialStartDirectory, "PreviewThemes", "TableEditor.html"); var outputFile = file.Replace("TableEditor.html", "_TableEditorPreview.html"); var url = outputFile; #endif var doc = new MarkdownDocument(); var html = doc.RenderHtml(markdown); try { string template = File.ReadAllText(file); template = template.Replace("{{Theme}}", mmApp.Configuration.PreviewTheme); template = template.Replace("{{Content}}", html); string body = StringUtils.ExtractString(template, "<body>", "</body>", returnDelimiters: true); // replace the entire body with just the HTML and remove scripts template = template.Replace(body, "<body>\n" + html + "\n</body>"); File.WriteAllText(outputFile, template); } catch { // if this fails use the template shipped } WebBrowserPreview.Navigate(url); }
public void UpdateHtmlTable(TableData data, TableLocation location) { Invoke("renderTable", BaseBrowserInterop.SerializeObject(data), BaseBrowserInterop.SerializeObject(location)); }
public async Task <IActionResult> StoreData([Bind("Id,CompanyName,Description,EMail,Website,Activated,CreatedAt,PostCode,City,Address,Country,FederalState,Telephonenumber,Password")] TableStore tableStore, IFormFile logoFile) { var storeId = User.FindFirst(ClaimTypes.NameIdentifier).Value; if (ModelState.IsValid) { //update try { var tbStore = await _context.TblStores.FirstOrDefaultAsync(x => x.Id == tableStore.Id); var logo = CreateImage(logoFile, EnumImageType.Logo); if (!(logo is null)) { var storeImages = _context.TblStores.Where(s => s.Id.ToString() == storeId).Select(s => s.Images).ToArray(); logo.Store = tbStore; if (storeImages[0].Any()) { for (int i = 0; i < storeImages[0].Count(); i++) { if (storeImages[0][i].ImageType == EnumImageType.Logo) { _context.TblImages.Remove(storeImages[0][i]); break; } } } _context.TblImages.Add(logo); } if (tbStore == null) { return(NotFound()); } if (!String.IsNullOrEmpty(tableStore.Telephonenumber)) { string outPhoneNumber; var a = ValidationHelper.ProoveValidPhoneNumber(tableStore.Telephonenumber, out outPhoneNumber); //TODO: Meldung wenn nicht passt tableStore.Telephonenumber = outPhoneNumber; } if (!String.IsNullOrEmpty(tableStore.Website)) { if (!tableStore.Website.StartsWith("http")) { tableStore.Website = $"http://{tableStore.Website}"; } } tbStore.CompanyName = tableStore.CompanyName; tbStore.Description = tableStore.Description; tbStore.EMail = tableStore.EMail; tbStore.Country = tableStore.Country; tbStore.FederalState = tableStore.FederalState; tbStore.PostCode = tableStore.PostCode; tbStore.City = tableStore.City; tbStore.Address = tableStore.Address; tbStore.Website = tableStore.Website; tbStore.Telephonenumber = tableStore.Telephonenumber; var sec = await _context.TblLocations.FirstOrDefaultAsync(a => a.StoreId == tbStore.Id); if (sec == null) { sec = new TableLocation(); sec.StoreId = tbStore.Id; _context.TblLocations.Add(sec); } sec.EMail = tbStore.EMail; sec.Address = tbStore.Address; sec.City = tbStore.City; sec.Country = tbStore.Country; sec.PostCode = tbStore.PostCode; sec.Name = tbStore.CompanyName; sec.Telephonenumber = tbStore.Telephonenumber; try { var res = GeocodeService.ConvertToGPSCoordinates(tableStore.PostCode, tableStore.City, tableStore.Address); tbStore.Longitude = res.Geometry.Location.Longitude; tbStore.Latitude = res.Geometry.Location.Latitude; } catch (Exception e) { } sec.Latitude = tbStore.Latitude; sec.Longitude = tbStore.Longitude; if (!string.IsNullOrWhiteSpace(tableStore.Password)) { tbStore.Password = PasswordHelper.CumputeHash(tableStore.Password); } await _context.SaveChangesAsync(); TempData.Add("message", "Daten erfolgreich gespeichert"); return(RedirectToAction(nameof(StoreData))); } catch (DbUpdateConcurrencyException) { ViewData.Add("message", "Daten konnten nicht gespeichert werden"); return(View(tableStore)); //if (!TableStoreExists(store.Id)) //{ // return NotFound(); //} //else //{ // throw; //} } } return(View(tableStore)); }
public TableEditorContextMenu(TableEditorHtml window, TableLocation tableLocation) { Window = window; TableLocation = tableLocation; Model = mmApp.Model; }