public ProdWnd() { InitializeComponent(); imglist = new Dictionary<string, string>(); if (Directory.Exists(ProdNum.baseDir + "\\prodpic" + StringResource.language + "\\" )) Directory.CreateDirectory(ProdNum.baseDir + "\\prodpic" + StringResource.language + "\\"); foreach (string f in Directory.GetFiles(ProdNum.baseDir + "\\prodpic\\" + StringResource.language + "\\", "*.jpg")) { FileInfo fi = new FileInfo(f); string nm = fi.Name.Remove(fi.Name.Length-4,4).Replace(' ','_'); imglist[nm] = fi.FullName; Button n = new Button(); ControlTemplate ct = this.FindResource("imgBtn") as ControlTemplate; n.Template = ct; n.Name = "ID"+nm; n.Content = nm; n.Click += ImageSelected; n.ApplyTemplate(); ImageBrush ib = ct.FindName("ImageFill",n) as ImageBrush; ib.ImageSource = new BitmapImage(new Uri(fi.FullName)); this.wrapPanel1.Children.Add(n); } }
public void TagTest2 () { Button b = new Button (); TestPanel.Children.Add (b); b.ApplyTemplate (); Enqueue (() => { TestPanel.Tag = b; TestPanel.Tag = null; Assert.IsTrue (b.Focus (), "#1"); }); EnqueueTestComplete (); }
public void ApplyTemplateTest () { Button b = new Button (); Assert.AreEqual (0, VisualTreeHelper.GetChildrenCount (b), "1"); b.ApplyTemplate (); Assert.AreEqual (0, VisualTreeHelper.GetChildrenCount (b), "2"); TestButton tb = new TestButton (); Assert.IsFalse (tb.NameFound, "3"); }
private void bucket_click(int nodeid) { App p = Application.Current as App; int last_node = curr_node_index; if (nodeid < 1) { return; } last_btn = IdToButton(last_node); curr_btn = IdToButton(nodeid); curr_node_index = nodeid; if (last_btn is Button) { last_btn.Template = this.FindResource("WeightBar") as ControlTemplate; last_btn.ApplyTemplate(); } if (curr_btn is Button) { curr_btn.Template = this.FindResource("WeightBarFocus") as ControlTemplate; curr_btn.ApplyTemplate(); } ShowStatus("loading"); //update parameter of the current node to UI. lastcall = "UpdateUI"; return; }