public HomePage() : base(0, 0, DemoManager.Desktop.Width, DemoManager.Desktop.Height) { panelNavigation = new Panel(5, 5, DemoManager.Desktop.Width - 10, DemoManager.Desktop.Height - 10) { Background = new LinearGradientBrush(Color.Bisque, Color.Black, 0, 0, 1000, 1000, 120), Border = new Pen(Color.Black, 1) }; Children.Add(panelNavigation); header = new Panel(0, 0, panelNavigation.Width - 0, 25); header.Background = DemoManager.Bar; header.Children.Add(new Label(10, 5, DemoManager.FontCourierNew10, "Navigation") { ForeColor = Color.CornflowerBlue }); header.TouchDown += delegate(object sender, TouchEventArgs e) { TouchCapture.Capture(header); p = e.Point; }; header.TouchMove += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == header) { panelNavigation.Translate(e.Point.X - p.X, e.Point.Y - p.Y); p = e.Point; } }; header.TouchUp += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == header) TouchCapture.ReleaseCapture(); }; panelNavigation.Children.Add(header); x = margin; w = panelNavigation.Width / 2 - 2 * margin; y = header.Height + margin; step = h + margin; AddButton("Level"); AddButton("ProgressBar"); AddButton("Image"); //AddButton("Panel"); //AddButton("Checkbox"); //AddButton("Button"); //AddButton("MultiImage"); //AddButton("Label"); //AddButton("RadioButton"); //AddButton("Slider"); //AddButton("TextBlock"); //AddButton(""); //AddButton(""); //AddButton(""); //AddButton(""); //AddButton(""); //AddButton(""); }
public void CrashDemo() { Panel pnl = new Panel(0, 0, 150, 150); //Panel pnl = new Panel(0, 0, 50, 50); pnl.Background = new SolidColorBrush(Color.CornflowerBlue); int translateValue = 3; Desktop.SuspendLayout(); for (int i = 0; i < 10; i++) pnl.Children.Add(new TextBlock(10, 15 * i, 140, 20, FontRegular, "label" + i.ToString()) { ForeColor = Color.Brown }); Desktop.Children.Add(pnl); Desktop.ResumeLayout(); new Thread(delegate() { //int n = 0; while (true) { Desktop.SuspendLayout(); DateTime dt = DateTime.Now; int c = pnl.Children.Count; for (int j = 0; j < c; j++) { //dt0 = DateTime.Now; //Label lbl = (Label)Children.GetAt(j); TextBlock lbl = (TextBlock)pnl.Children[j]; //Debug.Print("Label text set"); lbl.Text = dt.Ticks.ToString(); //Thread.Sleep(10); //ts = DateTime.Now - dt0; //n++; //sum += ts; //Debug.Print("MFE: " + ts.ToString()); //Debug.Print("MFE (average): " + new TimeSpan(sum.Ticks / n).ToString()); } pnl.Translate(translateValue, translateValue); if (pnl.X + pnl.Width >= Desktop.Width - 1) pnl.X = 0; if (pnl.Y + pnl.Height >= Desktop.Height - 1) pnl.Y = 0; Desktop.ResumeLayout(); } } ).Start(); //new Thread(delegate() //{ // while (true) // { // pnl.Translate(1, 1); // if (pnl.X + pnl.Width >= desktop.Width - 1) // pnl.X = 0; // if (pnl.Y + pnl.Height >= desktop.Height - 1) // pnl.Y = 0; // //Thread.Sleep(100); // } //}).Start(); }
private void Demo() { Background = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.reWalls)) { Stretch = Stretch.Fill }; ImageBrush bar = new ImageBrush(Resources.GetBitmap(Resources.BitmapResources.Bar)); // left panel Panel panelNavigation = new Panel(10, 10, 150, 460); panelNavigation.Background = new LinearGradientBrush(Color.Bisque, Color.Black, 0, 500, 1000, 500); panelNavigation.Background.Opacity = 120; panelNavigation.Border = new Pen(Color.Black, 1); Children.Add(panelNavigation); Panel tlb = new Panel(1, 1, panelNavigation.Width - 2, 25); tlb.Background = bar; tlb.Children.Add(new Label(10, 5, fontCourierNew10, "Navigation") { ForeColor = Color.CornflowerBlue }); tlb.TouchDown += delegate(object sender, TouchEventArgs e) { TouchCapture.Capture(tlb); p = e.Point; }; tlb.TouchMove += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb) { panelNavigation.Translate(e.Point.X - p.X, e.Point.Y - p.Y); p = e.Point; } }; tlb.TouchUp += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb) TouchCapture.ReleaseCapture(); }; panelNavigation.Children.Add(tlb); //int d = 15; //int x = 0; ////int y = 5; //RadioButtonGroup rbgNavigation = new RadioButtonGroup(10, 30, 15, panelNavigation.Height - 40); //panelNavigation.Children.Add(rbgNavigation); //rbgNavigation.AddRadioButton(new RadioButton(x, 5, d, true)); //rbgNavigation.AddRadioButton(new RadioButton(x, 25, d)); //rbgNavigation.AddRadioButton(new RadioButton(x, 45, d)); //rbgNavigation.AddRadioButton(new RadioButton(x, 65, d)); //rbgNavigation.AddRadioButton(new RadioButton(x, 85, d)); //rbgNavigation.AddRadioButton(new RadioButton(x, 105, d)); //panelNavigation.Children.Add(new Label(30, 35, fontCourierNew10, "Checkboxes") { ForeColor = Color.White }); //panelNavigation.Children.Add(new Label(30, 55, fontCourierNew10, "Buttons") { ForeColor = Color.White }); int x = 5; int w = panelNavigation.Width - 2 * x; int h = 18; int y = 35; int step = h + 5; //Font fnt = fontRegular; Font fnt = fontCourierNew10; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Checkbox", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Button", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Image", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Label", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Level", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "MultiImage", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Panel", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "ProgressBar", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "RadioButton", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "Slider", Color.White) { BackgroundUnpressed = bar }); y += step; panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "TextBlock", Color.White) { BackgroundUnpressed = bar }); y += step; //panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "", Color.White) { BackgroundUnpressed = bar }); y += step; //panelNavigation.Children.Add(new Button(x, y, w, h, fnt, "", Color.White) { BackgroundUnpressed = bar }); y += step; foreach (Control ctrl in panelNavigation.Children) { if (ctrl is Button) (ctrl as Button).Click += new EventHandler(Button_Click); } // title TextBlock txtTitle = new TextBlock(200, panelNavigation.Y, 590, 60, fontTitle, "MFE graphics"); txtTitle.ForeColor = Color.CornflowerBlue; txtTitle.TextAlignment = TextAlignment.Center; txtTitle.TextVerticalAlignment = VerticalAlignment.Center; Children.Add(txtTitle); // right panel int yy = txtTitle.Height + 10; panelPresentation = new Panel(txtTitle.X, panelNavigation.Y + yy, txtTitle.Width, panelNavigation.Height - yy); panelPresentation.Background = new SolidColorBrush(Color.Black); panelPresentation.Background.Opacity = 50; panelPresentation.Border = new Pen(Color.Black, 1); Children.Add(panelPresentation); tlb2 = new Panel(1, 1, panelPresentation.Width - 2, 25); tlb2.Background = bar; tlb2.Children.Add(lblActiveDemo = new Label(10, 5, fontCourierNew10, "Presentation: [Please select control type on the left]") { ForeColor = Color.CornflowerBlue }); tlb2.TouchDown += delegate(object sender, TouchEventArgs e) { TouchCapture.Capture(tlb2); p = e.Point; }; tlb2.TouchMove += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb2) { panelPresentation.Translate(e.Point.X - p.X, e.Point.Y - p.Y); p = e.Point; } }; tlb2.TouchUp += delegate(object sender, TouchEventArgs e) { if (TouchCapture.Captured == tlb2) TouchCapture.ReleaseCapture(); }; panelPresentation.Children.Add(tlb2); }