/// <summary> /// Create a form to pick a data source item or group /// </summary> /// <param name="project">Project holding sample data and filters</param> /// <param name="prompt">Text to show user</param> /// <param name="previous">Optional: The path that was previously selected. This will be shown as expanded and selected if it's still valid</param> /// <param name="repeaterPath">Optional: Page-specific repeater data path. This will show the data for page 1, but the path selection will be correct for all pages</param> /// <param name="pageIndex">Optional: If given, page-specific filters will be shown</param> /// <param name="allowEmpty">If true, the pick button will be available when no item is selected</param> public PickDataSource(FileSystemProject project, string prompt, string[]?previous, string[]?repeaterPath, int?pageIndex, bool allowEmpty) { _allowEmpty = allowEmpty; InitializeComponent(); Text = prompt; // load tree from sample data var data = project.LoadSampleData(); if (data == null) { return; } // TODO: extract the logic of this to core (share with web ui and make it more testable) AddSampleData(data); AddDataFilters(project, data); if (repeaterPath != null) { AddRepeaterPath(project, data, repeaterPath); } if (pageIndex != null) { AddPageDataFilters(project, data, pageIndex !.Value); } AddPageNumbers(repeaterPath); if (allowEmpty) { pickButton !.Enabled = true; } SelectPath(previous); // pick previous source if it exists }
public EditProjectNotes(IScreenModule returnModule, FileSystemProject project) { _returnModule = returnModule; _project = project; InitializeComponent(); nameTextBox !.Text = _project.Index.Name; notesTextBox !.Text = _project.Index.Notes; fontFamilyTextBox !.Text = _project.Index.FontName?.ToString() ?? ""; fontSizeTextBox !.Text = _project.Index.BaseFontSize?.ToString() ?? ""; }
public BoxPlacer(IScreenModule returnModule, FileSystemProject project, int pageIndex) { InitializeComponent(); _returnModule = returnModule; _project = project; _pageIndex = pageIndex; _imageCache = LoadFromFile(Path.Combine(_project.BasePath, _project.Pages[_pageIndex].GetBackgroundPath())); DoubleBuffered = true; MouseWheel += ChangeZoom; }
public RepeatModePicker(IScreenModule returnModule, FileSystemProject project, int pageIndex) { InitializeComponent(); _returnModule = returnModule; _project = project; _pageIndex = pageIndex; var page = _project.Pages[_pageIndex]; repeatsCheckbox !.Checked = page.RepeatMode.Repeats; pickDataButton !.Enabled = page.RepeatMode.Repeats; if (page.RepeatMode.DataPath != null) { dataPathLabel !.Text = string.Join(".", page.RepeatMode.DataPath); } }
public EditPageMeta(IScreenModule returnModule, FileSystemProject project, int pageIndex) { _returnModule = returnModule; _project = project; _pageIndex = pageIndex; InitializeComponent(); var page = _project.Pages[pageIndex]; nameTextBox !.Text = page.Name; renderBackgroundCheckbox !.Checked = page.RenderBackground; notesTextBox !.Text = page.Notes; fontSizeTextBox !.Text = page.PageFontSize?.ToString() ?? "16"; widthTextBox !.Text = page.WidthMillimetres.ToString(CultureInfo.InvariantCulture); heightTextBox !.Text = page.HeightMillimetres.ToString(CultureInfo.InvariantCulture); }
public DisplayFormatEditor(FileSystemProject project, int pageIndex, string boxKey) { _project = project; _pageIndex = pageIndex; _boxKey = boxKey; InitializeComponent(); var box = _project.Pages[pageIndex].Boxes[boxKey]; var parameters = box.DisplayFormat?.FormatParameters ?? new Dictionary <string, string>(); FillWithEnum(formatTypeComboBox !.Items, typeof(DisplayFormatType)); var mappingType = box.DisplayFormat?.Type ?? DisplayFormatType.None; formatTypeComboBox.SelectedItem = mappingType.ToString(); var propObj = CreateTypedContainerForParams(mappingType.ToString()); MapDictionaryToProperties(parameters, propObj); formatPropertyGrid !.SelectedObject = propObj; }
public FilterEditor(IScreenModule returnModule, FileSystemProject project, string filterName, int?pageIndex) { _returnModule = returnModule; _project = project; _filterName = filterName; _pageIndex = pageIndex; InitializeComponent(); var filter = GetMappingInfo(); filterNameTextbox !.Text = _filterName; _selectedPath = filter.DataPath; dataPathLabel !.Text = string.Join(".", filter.DataPath ?? new string[0]); FillWithEnum(filterTypeComboBox !.Items, typeof(MappingType)); filterTypeComboBox.SelectedItem = filter.MappingType.ToString(); var propObj = CreateTypedContainerForParams(filter.MappingType.ToString()); MapDictionaryToProperties(filter.MappingParameters, propObj); filterPropertyGrid !.SelectedObject = propObj; }
public BoxEdit(FileSystemProject project, int pageIndex, string boxKey) { InitializeComponent(); _project = project; _pageIndex = pageIndex; _boxKey = boxKey; var box = project.Pages[pageIndex].Boxes[boxKey]; dataPathLabel !.Text = box.MappingPath == null ? "" : string.Join(".", box.MappingPath); SetupDependentCombo(project, pageIndex, boxKey, box); UpdateDisplayFormatInfo(); processOrderTextBox !.Text = box.BoxOrder?.ToString() ?? ""; fontSizeTextBox !.Text = box.BoxFontSize?.ToString() ?? ""; wrapTextCheckbox !.Checked = box.WrapText; shrinkToFitCheckbox !.Checked = box.ShrinkToFit; boxKeyTextbox !.Text = boxKey; topLeft !.Checked = box.Alignment == TextAlignment.TopLeft; topCentre !.Checked = box.Alignment == TextAlignment.TopCentre; topRight !.Checked = box.Alignment == TextAlignment.TopRight; midLeft !.Checked = box.Alignment == TextAlignment.MidlineLeft; midCentre !.Checked = box.Alignment == TextAlignment.MidlineCentre; midRight !.Checked = box.Alignment == TextAlignment.MidlineRight; bottomLeft !.Checked = box.Alignment == TextAlignment.BottomLeft; bottomCentre !.Checked = box.Alignment == TextAlignment.BottomCentre; bottomRight !.Checked = box.Alignment == TextAlignment.BottomRight; }
public MainProjectScreen(FileSystemProject project, int pageIndex) { _lastPageIndex = pageIndex; _project = project; }
private void AddRepeaterPath(FileSystemProject project, object sampleData, string[] repeaterPath) { // Get a "sample" from the data. // If it's an ArrayList, take the first item and make nodes from it. // If it's not an ArrayList, just make nodes from it // Either way, add under "Page Repeat Data" tagged:'D' var pageNode = new TreeNode { Name = "D", Text = "Page Repeat Data", Tag = "D", BackColor = Color.Linen, ForeColor = Color.Brown }; var sample = MappingActions.ApplyFilter( MappingType.None, new Dictionary <string, string>(), repeaterPath, null, project.Index.DataFilters, sampleData, null, null ); // sample should be an ArrayList. if (sample is ArrayList list && list.Count > 0) { if (list[0] == null) // invalid list { pageNode.Nodes.Add(new TreeNode { Text = "Invalid result", ForeColor = Color.Red, BackColor = Color.Pink }); } else if (list[0] is ArrayList page1) // each page has multiple rows { var sampleNodes = ReadObjectRecursive(page1, "D", "XXX").ToArray(); if (sampleNodes.Length < 1) { pageNode.Nodes.Add(new TreeNode { Text = "Sample data insufficient?", ForeColor = Color.Red, BackColor = Color.Pink }); } else { // Should be one node, with possible multiple children foreach (TreeNode?node in sampleNodes[0].Nodes) { if (node != null) { pageNode.Nodes.Add(node); } } pageNode.Expand(); // expand first node by default } } else if (list[0] is Dictionary <string, object> dict) // each page has a single compound object { var sampleNodes = ReadObjectRecursive(dict, "D", "XXX"); if (sampleNodes.Count != 1) { throw new Exception("Unexpected object result in page data ReadObjectRecursive"); } foreach (TreeNode?node in sampleNodes[0].Nodes) { if (node != null) { pageNode.Nodes.Add(node); } } pageNode.Expand(); // expand first node by default } else // single value { pageNode.Nodes.Add(new TreeNode { Text = "Invalid result", ForeColor = Color.Red, BackColor = Color.Pink }); // TODO: can I handle single values here? } }
public ProjectFiltersScreen(FileSystemProject project) { _project = project; _stateChange = StateChangePermission.Allowed; }
public PageFiltersScreen(FileSystemProject project, int pageIndex) { _project = project; _pageIndex = pageIndex; _stateChange = StateChangePermission.Allowed; }