1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- using InABox.Core;
- using InABox.Wpf;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Forms;
- using static System.Windows.Forms.VisualStyles.VisualStyleElement.StartPanel;
- namespace InABox.DynamicGrid
- {
- public abstract class DynamicFormWindow : ThemableWindow
- {
- protected abstract DynamicFormDesignGrid Grid { get; }
- private DFLayoutType _type;
- public DFLayoutType Type
- {
- get => _type;
- set
- {
- _type = value;
- Width = _type == DFLayoutType.Mobile ? 600 : 1000;
- Height = 800;
- }
- }
- public DFLayout Form
- {
- get => Grid.Form;
- set => Grid.Form = value;
- }
- public IList<DigitalFormVariable> Variables
- {
- get => Grid.Variables;
- set => Grid.Variables = value;
- }
- /// <summary>
- /// Renders the form; after this is called, any changes to properties triggers a refresh.
- /// </summary>
- public void Initialize()
- {
- Grid.Initialize();
- }
- public void LoadLayout(DigitalFormLayout layout, IList<DigitalFormVariable> variables)
- {
- Variables = variables;
- var f = new DFLayout();
- if (!string.IsNullOrWhiteSpace(layout.Layout))
- {
- f.LoadLayout(layout.Layout);
- }
- else
- {
- f = new DFLayout();
- f.RowHeights.Add("Auto");
- f.ColumnWidths.AddRange(new[] { "*", "Auto" });
- }
- f.LoadVariables(variables);
- Form = f;
- }
- /*public static T LoadDigitalForm<T>(Guid id) where T : Entity, IPersistent, IRemotable, IDigitalFormInstance, new()
- {
- var result = new Client<T>().Query(
- new Filter<T>(x => x.ID).IsEqualTo(id),
- new Columns<T>(
- x => x.ID,
- x => x.Form.ID,
- x => x.Form.Description,
- x => x.FormCompleted,
- x => x.FormCompletedBy.ID,
- x => x.FormCompletedBy.UserID,
- x => x.FormData
- )
- ).Rows.FirstOrDefault()?.ToObject<T>();
- return result;
- }*/
- }
- }
|