@page "/"
@using Newtonsoft.Json
@using Syncfusion.Blazor.Buttons
@using Syncfusion.Blazor.Inputs
@using Syncfusion.Blazor.Navigations
@using Syncfusion.Blazor.Grids
@using Syncfusion.Blazor.Gantt
@using System.Dynamic
@using Syncfusion.Blazor.Charts
@using Syncfusion.Blazor
@using System.Text
@using System.Net
@using System.IO
@using System.Data
@using Newtonsoft.Json.Linq
@inject IJSRuntime JS
Index
Hello, world!
Welcome to your new app.
@*
@Token
*@
@*
{SelectedTab = 0;}">
Login
{SelectedTab = 1;}">
Grid
{SelectedTab = 2;}">
Gantt
{SelectedTab = 3;}">
Chart
*@
@*
*@
@code {
private SfSignature signature;
private SfButton saveButton;
private SfButton clearButton;
private bool saveDisabled = true;
private bool clearDisabled = true;
private void OnChange()
{
clearDisabled = false;
saveDisabled = false;
}
//无法保存成base64,保存图片也是保存到本地
private async void onSave()
{
await signature.SaveAsync();
clearDisabled = true;
}
private async Task onClear()
{
await signature.ClearAsync();
saveDisabled = true;
}
private SfGrid sfGrid { get; set; }
private void OnDrop(Microsoft.AspNetCore.Components.Web.DragEventArgs args)
{
}
public void Select(SelectingEventArgs args)
{
if(args.IsSwiped)
{
args.Cancel = true;
}
}
private void OnDrag(Syncfusion.Blazor.Navigations.DragEventArgs args)
{
args.Cancel = true;
}
private List countries = new List { "South Korea", "India", "Germany", "Italy", "Russia" };
private Random randomNum = new Random();
public List MedalDetails { get; set; } = new List();
private string UserName { get; set; } = "";
private string Password { get; set; } = "";
private Boolean DisableTab { get; set; } = false;
private Boolean Disabled { get; set; } = true;
private int SelectedTab { get; set; } = 2;
public List Orders { get; set; }
private string id { get;set;}
protected async override Task OnAfterRenderAsync(bool firstRender)
{
GetTempDatas(DtOri.Copy());
}
private DataTable DtOri = new DataTable();
protected override void OnInitialized()
{
DataTable dt = new DataTable();
dt.Columns.Add("X");
dt.Columns.Add("Y");
dt.Rows.Add("South Korea",20);
dt.Rows.Add("Germany",50);
dt.Rows.Add("Italy",70);
dt.Rows.Add("India",40);
dt.Rows.Add("Russia",80);
DtOri = dt.Copy();
GetTempDatas(DtOri.Copy());
//id = Guid.NewGuid().ToString();
//Orders = Enumerable.Range(1, 6).Select(x => new Order()
// {
// OrderID = 1000 + x,
// CustomerID = (new string[] { "ALFKI", "ANANTR", "ANTON", "BLONP", "BOLID" })[new Random().Next(5)],
// Freight = 2.1 * x,
// OrderDate = DateTime.Now.AddDays(-x),
// }).ToList();
//TaskCollection = GetTaskCollection();
//MedalDetails = Enumerable.Range(0, 5).Select((x) =>
//{
// dynamic d = new ExpandoObject();
// d.X = countries[x];
// d.Y = randomNum.Next(20, 80);
// return d;
//}).Cast().ToList();
}
private void GetTempDatas(DataTable dt)
{
MedalDetails = new List();
for (int i = 0; i < dt.Rows.Count; i++)
{
dynamic d = new ExpandoObject();
((IDictionary)d)["X"] = dt.Rows[i]["X"].ToString();
((IDictionary)d)["Y"] = dt.Rows[i]["Y"].ToString();
MedalDetails.Add(d);
}
}
private void OnClicked()
{
//if (this.UserName == "" && this.Password == "")
//{
// Console.WriteLine("clicked");
//}
//else if (this.UserName == "")
//{
// Console.WriteLine("Enter the username");
//}
//else if (this.Password == "")
//{
// Console.WriteLine("Enter the password");
//}
//else if (this.UserName.Length < 4)
//{
// Console.WriteLine("Username must be minimum 4 characters");
//}
//else
//{
// this.UserName = "";
// this.Password = "";
// this.DisableTab = false;
// this.Disabled = true;
// this.SelectedTab = 1;
//}
}
public class Order
{
public int? OrderID { get; set; }
public string CustomerID { get; set; }
public DateTime? OrderDate { get; set; }
public double? Freight { get; set; }
}
public List TaskCollection { get; set; } = new List();
//实体类,最终绑到Gantt图上的数据类型
public class TaskData
{
public int TaskId { get; set; } = 0;
public string? ParentId { get; set; }
public string TaskName { get; set; } = "";
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public string Duration { get; set; }
public int? Progress { get; set; }
public List SubTasks { get; set; } = new List();
public string RowId { get; set; } = "";
public string? Dependency { get; set; }
public string? Comment { get; set; }
public string? UDField1 { get; set; }
public string? UDField2 { get; set; }
public string? UDField3 { get; set; }
public int DataPos { get; set; }
}
public static List GetTaskCollection()
{
List Tasks = new List() {
new TaskData() {
TaskId = 1,
TaskName = "Project initiation",
StartDate = new DateTime(2019, 04, 02),
EndDate = new DateTime(2019, 04, 21),
SubTasks = (new List () {
new TaskData() {
TaskId = 2,
TaskName = "Identify Site location",
StartDate = new DateTime(2019, 04, 02),
Duration = "0",
Progress = 30,
},
new TaskData() {
TaskId = 3,
TaskName = "Perform soil test",
StartDate = new DateTime(2019, 04, 02),
Duration = "4",
Progress = 40,
},
new TaskData() {
TaskId = 4,
TaskName = "Soil test approval",
StartDate = new DateTime(2019, 04, 02),
Duration = "0",
Progress = 30
},
})
},
new TaskData() {
TaskId = 5,
TaskName = "Project estimation",
StartDate = new DateTime(2019, 04, 02),
EndDate = new DateTime(2019, 04, 21),
SubTasks = (new List () {
new TaskData() {
TaskId = 6,
TaskName = "Develop floor plan for estimation",
StartDate = new DateTime(2019, 04, 04),
Duration = "3",
Progress = 30,
},
new TaskData() {
TaskId = 7,
TaskName = "List materials",
StartDate = new DateTime(2019, 04, 04),
Duration = "3",
Progress = 40
},
new TaskData() {
TaskId = 8,
TaskName = "Estimation approval",
StartDate = new DateTime(2019, 04, 04),
Duration = "0",
Progress = 30,
}
})
}
};
return Tasks;
}
}