public void FillCheckList(string checklist)
{
try
{
string[] jsons = checklist.Split(']');
string jsonCheckLists = "[" + jsons[0].Split('[')[1] + "]";
dtCheckList = JsonConvert.DeserializeObject<DataTable>(jsonCheckLists);
string path;
String exePath = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
var root = System.IO.Path.GetDirectoryName(exePath);
var newpath = root + "\\images";
ControlTemplate ct;
if (dtCheckList.Rows.Count == 0)
{
grdChecklist.Children.Clear();
grdChecklist.ColumnDefinitions.Clear();
grdChecklist.RowDefinitions.Clear();
grdChecklist.RowDefinitions.Add(new RowDefinition());
grdChecklist.ColumnDefinitions.Add(new ColumnDefinition());
grdChecklist.RowDefinitions[0].Height = new GridLength(35);
grdChecklist.ColumnDefinitions[0].Width = new GridLength(460);
Button btnNewTab = new Button();
path = newpath + "\\" + "create-a-new-tab.png";
var ib = new ImageBrush
{
ImageSource =
new BitmapImage(
new Uri(path, UriKind.Relative)
)
};
ControlTemplate template = new ControlTemplate(typeof(Button));
var image = new FrameworkElementFactory(typeof(Image));
template.VisualTree = image;
image.SetValue(Image.SourceProperty, new BitmapImage(new Uri(path)));
btnNewTab.Height = 35;
btnNewTab.Width = 460;
btnNewTab.Template = template;
btnNewTab.ToolTip = "Create A New Tab";
btnNewTab.Foreground = Brushes.White;
btnNewTab.Content = "";
btnNewTab.HorizontalAlignment = HorizontalAlignment.Left;
btnNewTab.VerticalAlignment = VerticalAlignment.Top;
btnNewTab.HorizontalContentAlignment = HorizontalAlignment.Left;
btnNewTab.VerticalContentAlignment = VerticalAlignment.Top;
Grid.SetColumn(btnNewTab, 0);
Grid.SetRow(btnNewTab, 0);
grdChecklist.Children.Add(btnNewTab);
}
else
{
int Noofchecklist = dtCheckList.Rows.Count;
grdChecklist.Children.Clear();
grdChecklist.ColumnDefinitions.Clear();
grdChecklist.RowDefinitions.Clear();
int j = 0;
for (int i = 0; i < Noofchecklist; i++)
{
grdChecklist.RowDefinitions.Add(new RowDefinition());
grdChecklist.RowDefinitions[i].Height = new GridLength(grdcheckheight);
}
for (int row = 0; row < Noofchecklist; row++)
{
if (row < dtCheckList.Rows.Count)
{
Grid grdcheck = new Grid();
grdcheck.HorizontalAlignment = HorizontalAlignment.Left;
grdcheck.VerticalAlignment = VerticalAlignment.Top;
Grid.SetColumn(grdcheck, 0);
Grid.SetRow(grdcheck, row);
grdcheck.Width = grdcheckwidth;
grdcheck.Height = grdcheckheight;
path = newpath + "\\" + "bg_grey_lftpnl.png";
var ib = new ImageBrush
{
ImageSource =
new BitmapImage(
new Uri(path, UriKind.Relative)
)
};
grdcheck.Background = ib;
for (int i = 0; i < 5; i++)
{
grdcheck.RowDefinitions.Add(new RowDefinition());
}
grdcheck.RowDefinitions[0].Height = new GridLength(2.5);
grdcheck.RowDefinitions[1].Height = new GridLength(25);
grdcheck.RowDefinitions[2].Height = new GridLength(25);
grdcheck.RowDefinitions[3].Height = new GridLength(25);
grdcheck.RowDefinitions[4].Height = new GridLength(2.5);
for (int i = 0; i < 6; i++)
{
grdcheck.ColumnDefinitions.Add(new ColumnDefinition());
}
grdcheck.ColumnDefinitions[0].Width = new GridLength(grdcheckfstcolwidth);
grdcheck.ColumnDefinitions[1].Width = new GridLength(grdchecksndcolwidth);
grdcheck.ColumnDefinitions[2].Width = new GridLength(60);
grdcheck.ColumnDefinitions[3].Width = new GridLength(60);
grdcheck.ColumnDefinitions[4].Width = new GridLength(70);
grdChecklist.Children.Add(grdcheck);
Button btnOrder = new Button();
Button btnPayment = new Button();
Button btnCheck = new Button();
Label lbltablename = new Label();
Label lblorderStatus = new Label();
Label lblclient = new Label();
Label lblserver = new Label();
Label lbltotal = new Label();
Label lblcovers = new Label();
lbltablename.Content = dtCheckList.Rows[row][3].ToString() == "" ? dtCheckList.Rows[row][2].ToString() : dtCheckList.Rows[row][3].ToString();
lbltablename.VerticalAlignment = VerticalAlignment.Top;
lbltablename.HorizontalAlignment = HorizontalAlignment.Left;
lbltablename.FontFamily = new FontFamily("Helvetica");
lbltablename.FontWeight = FontWeights.Bold;
lbltablename.FontSize = 14;
lbltablename.Foreground = Brushes.White;
Grid.SetColumn(lbltablename, 0);
Grid.SetRow(lbltablename, 1);
grdcheck.Children.Add(lbltablename);
lblserver.Content = "Server: " + (dtCheckList.Rows[row]["server"].ToString() == "" ? "Kelly Yu" :
dtCheckList.Rows[row]["server"].ToString());
lblserver.VerticalAlignment = VerticalAlignment.Top;
lblserver.HorizontalAlignment = HorizontalAlignment.Right;
lblserver.FontFamily = new FontFamily("Helvetica");
lblserver.FontWeight = FontWeights.Bold;
lblserver.FontSize = 14;
lblserver.Foreground = Brushes.White;
Grid.SetColumn(lblserver, 1);
Grid.SetRow(lblserver, 1);
grdcheck.Children.Add(lblserver);
lbltotal.Content = "Total: $ " + (dtCheckList.Rows[row]["total"].ToString() == "" ? "0.00" :
dtCheckList.Rows[row]["total"].ToString());
lbltotal.VerticalAlignment = VerticalAlignment.Top;
lbltotal.HorizontalAlignment = HorizontalAlignment.Right;
lbltotal.FontFamily = new FontFamily("Helvetica");
lbltotal.FontWeight = FontWeights.Bold;
lbltotal.FontSize = 14;
lbltotal.Foreground = Brushes.White;
Grid.SetColumn(lbltotal, 1);
Grid.SetRow(lbltotal, 2);
grdcheck.Children.Add(lbltotal);
int length = dtCheckList.Rows[row]["check_number"].ToString().Length;
lblcovers.Content = "#" + dtCheckList.Rows[row]["check_number"].ToString() + "- " +
dtCheckList.Rows[row]["check_number"].ToString().Substring(length - 4, 4) +
" | Covers: " + dtCheckList.Rows[row]["covers"].ToString();
lblcovers.VerticalAlignment = VerticalAlignment.Top;
lblcovers.HorizontalAlignment = HorizontalAlignment.Right;
lblcovers.FontFamily = new FontFamily("Helvetica");
lblcovers.FontWeight = FontWeights.Bold;
lblcovers.FontSize = 14;
lblcovers.Foreground = Brushes.White;
Grid.SetColumn(lblcovers, 1);
Grid.SetRow(lblcovers, 3);
grdcheck.Children.Add(lblcovers);
string client = dtCheckList.Rows[row]["client"].ToString();
lblclient.Content = dtCheckList.Rows[row]["client"].ToString();
lblclient.VerticalAlignment = VerticalAlignment.Top;
lblclient.HorizontalAlignment = HorizontalAlignment.Left;
lblclient.HorizontalContentAlignment = HorizontalAlignment.Left;
lblclient.VerticalContentAlignment = VerticalAlignment.Top;
lblclient.FontFamily = new FontFamily("Helvetica");
lblclient.FontWeight = FontWeights.Bold;
lblclient.FontSize = 14;
lblclient.Foreground = Brushes.White;
Grid.SetColumn(lblclient, 0);
Grid.SetRow(lblclient, 2);
grdcheck.Children.Add(lblclient);
string order_Status = dtCheckList.Rows[row][1].ToString();
lblorderStatus.Content = dtCheckList.Rows[row][1].ToString();
lblorderStatus.VerticalAlignment = VerticalAlignment.Top;
lblorderStatus.HorizontalAlignment = HorizontalAlignment.Left;
lblorderStatus.HorizontalContentAlignment = HorizontalAlignment.Left;
lblorderStatus.VerticalContentAlignment = VerticalAlignment.Top;
lblorderStatus.FontFamily = new FontFamily("Helvetica");
lblorderStatus.FontWeight = FontWeights.Bold;
lblorderStatus.FontSize = 14;
lblorderStatus.Foreground = dtCheckList.Rows[row][1].ToString() == "printed" ? Brushes.Orange : Brushes.Yellow;
Grid.SetColumn(lblorderStatus, 0);
Grid.SetRow(lblorderStatus, 3);
grdcheck.Children.Add(lblorderStatus);
if (order_Status == "printed")
{
path = newpath + "\\" + "Print.png";
ct = this.Resources["PrintTemplate"] as ControlTemplate;
}
else if (order_Status == "cancelled")
{
path = newpath + "\\" + "Cancelled.png";
ct = this.Resources["CancelledTemplate"] as ControlTemplate;
}
else if (order_Status == "closed")
{
path = newpath + "\\" + "Closed.png";
ct = this.Resources["ClosedTemplate"] as ControlTemplate;
}
else if (order_Status == "completed")
{
path = newpath + "\\" + "Completed.png";
ct = this.Resources["CompletedTemplate"] as ControlTemplate;
}
else if (order_Status == "new")
{
path = newpath + "\\" + "New.png";
ct = this.Resources["NewTemplate"] as ControlTemplate;
}
else if (order_Status == "ordered")
{
path = newpath + "\\" + "Ordered.png";
ct = this.Resources["OrderedTemplate"] as ControlTemplate;
}
else
{
path = newpath + "\\" + "New.png";
ct = this.Resources["NewTemplate"] as ControlTemplate;
}
//Image img = ct.LoadContent() as Image;
//img.Source = new BitmapImage(new Uri(path));
btnOrder.Template = ct;
btnOrder.ToolTip = "";
btnOrder.Foreground = Brushes.Black;
btnOrder.Content = "";
btnOrder.Name = "btnOrder" + j.ToString();
btnOrder.Width = 60;
btnOrder.Height = 60;
btnOrder.FontSize = 10;
btnOrder.BorderThickness = new Thickness(0, 0, 0, 0);
btnOrder.BorderBrush = Brushes.Transparent;
btnOrder.FontFamily = new FontFamily("Arial");
//btnPayment.Click += new RoutedEventHandler(btnTemp_Click);
Grid.SetColumn(btnOrder, 2);
Grid.SetRow(btnOrder, 1);
Grid.SetRowSpan(btnOrder, 3);
grdcheck.Children.Add(btnOrder);
path = newpath + "\\" + "btnbox_orange.png";
ct = this.Resources["buttonTemplate"] as ControlTemplate;
//img = ct.LoadContent() as Image;
//img.Source = new BitmapImage(new Uri(path));
path = newpath + "\\" + "btnbox_orange.png";
ib = new ImageBrush
{
ImageSource =
new BitmapImage(
new Uri(path, UriKind.Relative)
)
};
//ControlTemplate template = new ControlTemplate(typeof(Button));
//var image = new FrameworkElementFactory(typeof(Image));
//template.VisualTree = image;
//image.SetValue(Image.SourceProperty, new BitmapImage(new Uri(path)));
btnPayment.Background = ib;
//btnPayment.Template = template;
Style st = FindResource("InformButton") as Style;
btnPayment.Style = st;
btnPayment.ToolTip = "Payments";
btnPayment.Foreground = Brushes.Black;
btnPayment.Content = new TextBlock
{
Text = "Payments",
TextWrapping = TextWrapping.Wrap
};
btnPayment.Name = "btnPay" + j.ToString();
btnPayment.Width = 60;
btnPayment.Height = 60;
btnPayment.FontSize = 12;
btnPayment.FontStyle = FontStyles.Normal;
btnPayment.BorderThickness = new Thickness(0, 0, 0, 0);
btnPayment.BorderBrush = Brushes.Transparent;
btnPayment.FontFamily = new FontFamily("HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif");
//btnPayment.Click += new RoutedEventHandler(btnTemp_Click);
Grid.SetColumn(btnPayment, 3);
Grid.SetRow(btnPayment, 1);
Grid.SetRowSpan(btnPayment, 3);
grdcheck.Children.Add(btnPayment);
path = newpath + "\\" + "btnbox_orange.png";
ct = this.Resources["buttonTemplate"] as ControlTemplate;
//img = ct.LoadContent() as Image;
//img.Source = new BitmapImage(new Uri(path));
//btnCheck.Template = ct;
btnCheck.Background = ib;
st = FindResource("InformButton") as Style;
btnCheck.Style = st;
btnCheck.ToolTip = "Check Preview";
btnCheck.Content = new TextBlock
{
Text = "Check Preview",
TextWrapping = TextWrapping.Wrap
};
btnCheck.Name = "btnCheck" + j.ToString();
btnCheck.Width = 60;
btnCheck.Height = 60;
btnCheck.FontSize = 12;
btnCheck.FontStyle = FontStyles.Normal;
btnCheck.BorderThickness = new Thickness(0, 0, 0, 0);
btnCheck.BorderBrush = Brushes.Transparent;
btnCheck.FontFamily = new FontFamily("HelveticaNeue-Light,Helvetica Neue Light,Helvetica Neue,Helvetica,Arial,Lucida Grande,sans-serif");
btnCheck.HorizontalAlignment = HorizontalAlignment.Left;
btnCheck.VerticalAlignment = VerticalAlignment.Center;
btnCheck.HorizontalContentAlignment = HorizontalAlignment.Center;
btnCheck.VerticalContentAlignment = VerticalAlignment.Center;
Thickness margin = btnCheck.Margin;
margin.Right = 10;
margin.Left = 0;
margin.Top = 0;
margin.Bottom = 0;
btnCheck.Margin = margin;
//btnCheck.Click += new RoutedEventHandler(btnTemp_Click);
Grid.SetColumn(btnCheck, 4);
Grid.SetRow(btnCheck, 1);
Grid.SetRowSpan(btnCheck, 3);
grdcheck.Children.Add(btnCheck);
}
}
}
}
catch (Exception ex)
{
CustomMessageBox.Show(ex.Message);
ErrorLog.WriteErrorLog(ErrorLog.GetLogFilePath(), ex);
}
}
public void FillTableContainer(string Containerlist)
{
try
{
string[] jsons = Containerlist.Split(']');
string jsonContainerlist = "[" + jsons[0].Split('[')[1] + "]";
dtContainerlist = JsonConvert.DeserializeObject<DataTable>(jsonContainerlist);
if (dtContainerlist.Rows.Count > 0)
{
int NoofContainerlist = dtContainerlist.Rows.Count;
string path;
String exePath = System.Reflection.Assembly.GetExecutingAssembly().GetModules()[0].FullyQualifiedName;
var root = System.IO.Path.GetDirectoryName(exePath);
var newpath = root + "\\images";
int j = 0;
Grid grdTableContainer;
Button btnTable;
TextBlock tb;
Button btnResize;
#region Fill Container
for (int row = 0; row < dtContainerlist.Rows.Count; row++)
{
btnResize = new Button();
btnTable = new Button();
path = newpath + "\\Imgtb\\" + "table" + dtContainerlist.Rows[row]["image"].ToString() +
"-" + dtContainerlist.Rows[row]["color"] + ".png";
var ib = new ImageBrush
{
ImageSource =
new BitmapImage(
new Uri(path, UriKind.Relative)
)
};
ControlTemplate template = new ControlTemplate(typeof(Button));
var image = new FrameworkElementFactory(typeof(Image));
template.VisualTree = image;
image.SetValue(Image.SourceProperty, new BitmapImage(new Uri(path)));
//ControlTemplate ct;
//ct = this.Resources["buttonTemplate"] as ControlTemplate;
//Image img = ct.LoadContent() as Image;
//image.Source = new BitmapImage(new Uri(path));
//btnTable.Template = template;
canvascontainer = new Canvas();
grdTableContainer = new Grid();
grdButtons = new Grid();
if (dtContainerlist.Rows[row]["angle"].ToString() != "")
{
RotateTransform rotateTransform = new RotateTransform(double.Parse(dtContainerlist.Rows[row]["angle"].ToString()));
grdButtons.LayoutTransform = rotateTransform;
}
grdButtons.Name = "grdButtons" + row.ToString();
grdButtons.Background = ib;
grdButtons.HorizontalAlignment = HorizontalAlignment.Left;
grdButtons.VerticalAlignment = VerticalAlignment.Top;
Thickness margin = grdButtons.Margin;
margin.Left = 0;// 754 * (double.Parse(dtContainerlist.Rows[row]["tx"].ToString()) / 100);
margin.Top = 0;// 962 * (double.Parse(dtContainerlist.Rows[row]["ty"].ToString()) / 100);
grdButtons.Margin = margin;
grdButtons.Width = Int32.Parse(dtContainerlist.Rows[row]["size_x"].ToString());
grdButtons.Height = Int32.Parse(dtContainerlist.Rows[row]["size_y"].ToString());
grdTableContainer.HorizontalAlignment = HorizontalAlignment.Left;
grdTableContainer.VerticalAlignment = VerticalAlignment.Top;
margin = grdTableContainer.Margin;
margin.Left = 754 * (double.Parse(dtContainerlist.Rows[row]["tx"].ToString()) / 100);
margin.Top = 962 * (double.Parse(dtContainerlist.Rows[row]["ty"].ToString()) / 100);
grdTableContainer.Margin = margin;
grdTableContainer.Width = Int32.Parse(dtContainerlist.Rows[row]["size_x"].ToString());
grdTableContainer.Height = Int32.Parse(dtContainerlist.Rows[row]["size_y"].ToString());
tb = new TextBlock();
tb.Text = dtContainerlist.Rows[row]["table_name"].ToString();
tb.HorizontalAlignment = HorizontalAlignment.Center;
tb.VerticalAlignment = VerticalAlignment.Center;
tb.FontFamily = new FontFamily("Helvetica");
tb.FontSize = 12;
//margin = tb.Margin;
//margin.Left = 0;
//margin.Top = 40;
//tb.Margin = margin;
if (dtContainerlist.Rows[row]["angle"].ToString() != "")
{
RotateTransform rotate = new RotateTransform(-double.Parse(dtContainerlist.Rows[row]["angle"].ToString()));
tb.LayoutTransform = rotate;
}
path = newpath + "\\rotate_icon.png";
ib = new ImageBrush
{
ImageSource =
new BitmapImage(
new Uri(path, UriKind.Relative)
)
};
template = new ControlTemplate(typeof(Button));
image = new FrameworkElementFactory(typeof(Image));
template.VisualTree = image;
image.SetValue(Image.SourceProperty, new BitmapImage(new Uri(path)));
btnTable.Background = ib;
Style st = FindResource("InformButton") as Style;
btnTable.Style = st;
btnTable.ToolTip = dtContainerlist.Rows[row]["table_name"].ToString();
btnTable.Foreground = Brushes.Black;
btnTable.Content = "";// dtContainerlist.Rows[row]["table_name"].ToString();
btnTable.Name = "btnTable" + j.ToString();
//btnTable.Width = Int32.Parse(dtContainerlist.Rows[row]["size_x"].ToString());
//btnTable.Height = Int32.Parse(dtContainerlist.Rows[row]["size_y"].ToString());
btnTable.Width = 15;
btnTable.Height = 15;
btnTable.FontSize = 12;
btnTable.BorderThickness = new Thickness(0, 0, 0, 0);
btnTable.BorderBrush = Brushes.Transparent;
btnTable.FontFamily = new FontFamily("Helvetica");
btnTable.HorizontalAlignment = HorizontalAlignment.Left;
btnTable.VerticalAlignment = VerticalAlignment.Bottom;
btnTable.HorizontalContentAlignment = HorizontalAlignment.Center;
btnTable.VerticalContentAlignment = VerticalAlignment.Bottom;
//margin = btnTable.Margin;
//margin.Left = 0;
//margin.Top = 70;
//btnTable.Margin = margin;
//btnTable.MouseLeftButtonDown += new rect1_MouseLeftButtonDown(btnTemp_Click);
path = newpath + "\\drag-icon.png";
ib = new ImageBrush
{
ImageSource =
new BitmapImage(
new Uri(path, UriKind.Relative)
)
};
template = new ControlTemplate(typeof(Button));
image = new FrameworkElementFactory(typeof(Image));
template.VisualTree = image;
image.SetValue(Image.SourceProperty, new BitmapImage(new Uri(path)));
btnResize.Background = ib;
st = FindResource("InformButton") as Style;
btnResize.Style = st;
btnResize.Foreground = Brushes.Black;
btnResize.Name = "btnResize" + j.ToString();
btnResize.Width = 16;
btnResize.Height = 16;
btnResize.FontSize = 12;
btnResize.BorderThickness = new Thickness(0, 0, 0, 0);
btnResize.BorderBrush = Brushes.Transparent;
btnResize.FontFamily = new FontFamily("Helvetica");
btnResize.HorizontalAlignment = HorizontalAlignment.Right;
btnResize.VerticalAlignment = VerticalAlignment.Bottom;
btnResize.HorizontalContentAlignment = HorizontalAlignment.Right;
btnResize.VerticalContentAlignment = VerticalAlignment.Bottom;
btnResize.Cursor = Cursors.SizeNWSE;
//btnResize.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(canvascontainer_PreviewMouseLeftButtonDown);
//btnResize.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(DragFinishedMouseHandler);
margin = btnResize.Margin;
margin.Right = 0;
margin.Bottom = 0;
btnResize.Margin = margin;
Grid.SetColumn(btnTable, 0);
Grid.SetRow(btnTable, 0);
Grid.SetColumn(tb, 0);
Grid.SetRow(tb, 0);
Grid.SetColumn(btnResize, 0);
Grid.SetRow(btnResize, 0);
grdButtons.Children.Add(tb);
Grid.SetColumn(grdButtons, 0);
Grid.SetRow(grdButtons, 0);
Grid.SetColumn(canvascontainer, 0);
Grid.SetRow(canvascontainer, 0);
//Canvas.SetLeft(grdButtons, 150);
//Canvas.SetTop(grdButtons, 150);
canvascontainer.Children.Add(grdButtons);
grdTableContainer.Children.Add(canvascontainer);
grdTableContainer.Children.Add(btnTable);
grdTableContainer.Children.Add(btnResize);
grdTable.Children.Add(grdTableContainer);
}
#endregion
}
}
catch (Exception ex)
{
CustomMessageBox.Show(ex.Message);
ErrorLog.WriteErrorLog(ErrorLog.GetLogFilePath(), ex);
}
}
No comments:
Post a Comment