Example #1
0
        /// <summary>Creates the UI elements for the given HTML node and HTML view.</summary>
        /// <param name="node">The HTML node.</param>
        /// <param name="htmlView">The HTML view.</param>
        /// <returns>The UI elements.</returns>
        public DependencyObject[] CreateControls(HtmlNode node, IHtmlView htmlView)
        {
            var controls = new List<Grid>();
            foreach (var child in node.Children.OfType<HtmlTagNode>().Where(c => c.Name == "li"))
            {
                var grid = new Grid();
                grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(20)});
                grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

                var textBlock = CreateBulletSymbol(htmlView);
                                grid.Children.Add(textBlock);
                Grid.SetColumn(textBlock, 0);

                var panel = new StackPanel();

                child.WrapWithHtmlTag();
                foreach (var c in child.GetChildControls(htmlView).OfType<UIElement>())
                {
                    var frameworkElement = c as FrameworkElement;
                    if (frameworkElement != null)
                        frameworkElement.HorizontalAlignment = HorizontalAlignment.Stretch;

                    panel.Children.Add(c);
                }

                grid.Children.Add(panel);
                Grid.SetColumn(panel, 1);

                controls.Add(grid);
            }

            AdjustMargins(htmlView, controls);
            return controls.OfType<DependencyObject>().ToArray();
        }
 private void layout(StackPanel panel)
 {
     for (int i = 0; i < 8; i++)
     {
         panel.Children.Add(new Digital()
         {
             Digit = 10,
             Height = 50,
             Margin = new Thickness(5)
         });
     }
     DispatcherTimer timer = new DispatcherTimer()
     {
         Interval = TimeSpan.FromMilliseconds(250)
     };
     timer.Tick += (object sender, object e) =>
     {
         string time = DateTime.Now.ToString("HH:mm:ss");
         for (int i = 0; i < 8; i++)
         {
             string interval = time[i].ToString();
             ((Digital)panel.Children[i]).Digit =
             interval == ":" ? 11 : int.Parse(interval);
         }
     };
     timer.Start();
 }
Example #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label"></param>
        /// <param name="property"></param>
        public ComboBoxEditorBase(PropertyLabel label, PropertyItem property)
            : base(property)
        {
            currentValue = property.Value;
              property.PropertyChanged += property_PropertyChanged;
              property.ValueError += property_ValueError;

              cbo = new ComboBox
              {
            Visibility = Visibility.Collapsed,
            Margin = new Thickness(0),
            VerticalAlignment = VerticalAlignment.Center,
            HorizontalAlignment = HorizontalAlignment.Stretch
              };

              cbo.DropDownOpened += cbo_DropDownOpened;
              cbo.LostFocus += cbo_LostFocus;

              this.InitializeCombo();

              pnl = new StackPanel();
              pnl.Children.Add(cbo);

              this.ShowTextBox();

              this.Content = pnl;
        }
Example #4
0
 private static UIElement r_11_dtMethod(UIElement parent)
 {
     // e_69 element
     Border e_69 = new Border();
     e_69.Parent = parent;
     e_69.Name = "e_69";
     e_69.Background = new SolidColorBrush(new ColorW(0, 0, 255, 255));
     // e_70 element
     StackPanel e_70 = new StackPanel();
     e_69.Child = e_70;
     e_70.Name = "e_70";
     // e_71 element
     TextBlock e_71 = new TextBlock();
     e_70.Children.Add(e_71);
     e_71.Name = "e_71";
     e_71.HorizontalAlignment = HorizontalAlignment.Center;
     e_71.VerticalAlignment = VerticalAlignment.Center;
     Binding binding_e_71_Text = new Binding("TextData");
     e_71.SetBinding(TextBlock.TextProperty, binding_e_71_Text);
     // e_72 element
     Button e_72 = new Button();
     e_70.Children.Add(e_72);
     e_72.Name = "e_72";
     e_72.Content = "Hide Window";
     Binding binding_e_72_Command = new Binding("HideCommand");
     e_72.SetBinding(Button.CommandProperty, binding_e_72_Command);
     return e_69;
 }
        private void showPopup2_Click(object sender, RoutedEventArgs e)
        {
            if (p.IsOpen == true)
                return;
            Border border = new Border();
            border.BorderBrush = new SolidColorBrush(Colors.White);
            border.BorderThickness = new Thickness(2.0);

            StackPanel panel1 = new StackPanel();

            Button button1 = new Button();
            button1.Content = "Close";
            button1.Margin = new Thickness(5.0);
            button1.Click += new RoutedEventHandler(button1_Click);
            TextBlock textblock1 = new TextBlock();
            textblock1.Text = "Premi il pulsante Close";
            textblock1.Margin = new Thickness(5.0);
            panel1.Children.Add(textblock1);
            panel1.Children.Add(button1);
            border.Child = panel1;

            p = new Popup();
            // Imposta la proprietà Child con il border che è il contenitore principale che contiene a sua volta uno stackpanel, un textblock ed un button.
            p.Child = border;
            //imposta la posizione del popup
            p.VerticalOffset = 100;
            p.HorizontalOffset = 50;

            // apre il popup
            p.IsOpen = true;
        }
Example #6
0
 private static UIElement e_23_Col3_ct_dtMethod(UIElement parent)
 {
     // e_25 element
     StackPanel e_25 = new StackPanel();
     e_25.Parent = parent;
     e_25.Name = "e_25";
     // e_26 element
     TextBlock e_26 = new TextBlock();
     e_25.Children.Add(e_26);
     e_26.Name = "e_26";
     Binding binding_e_26_Text = new Binding("Text");
     e_26.SetBinding(TextBlock.TextProperty, binding_e_26_Text);
     // e_27 element
     StackPanel e_27 = new StackPanel();
     e_25.Children.Add(e_27);
     e_27.Name = "e_27";
     e_27.Orientation = Orientation.Horizontal;
     // e_28 element
     TextBlock e_28 = new TextBlock();
     e_27.Children.Add(e_28);
     e_28.Name = "e_28";
     Binding binding_e_28_Text = new Binding("Boolean");
     e_28.SetBinding(TextBlock.TextProperty, binding_e_28_Text);
     // e_29 element
     TextBlock e_29 = new TextBlock();
     e_27.Children.Add(e_29);
     e_29.Name = "e_29";
     Binding binding_e_29_Text = new Binding("Number");
     e_29.SetBinding(TextBlock.TextProperty, binding_e_29_Text);
     return e_25;
 }
Example #7
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="label"></param>
        /// <param name="property"></param>
        public DateTimeEditor(PropertyLabel label, PropertyItem property)
            : base(property)
        {
            currentValue = property.Value;
              property.PropertyChanged += property_PropertyChanged;
              property.ValueError += property_ValueError;

              contentPanel = new StackPanel();
              this.Content = contentPanel;

              datePicker = new DatePicker
              {
            Visibility = Visibility.Visible,
            Margin = new Thickness(0),
            VerticalAlignment = VerticalAlignment.Center,
            HorizontalAlignment = HorizontalAlignment.Stretch
              };

              datePicker.CalendarOpened += dtp_CalendarOpened;
              datePicker.CalendarClosed += dtp_CalendarClosed;
              datePicker.LostFocus += dtp_LostFocus;
              contentPanel.Children.Add(datePicker);
              datePicker.Focus();

              this.ShowTextBox();
        }
Example #8
0
 private static UIElement e_28_Col3_ct_dtMethod(UIElement parent)
 {
     // e_30 element
     StackPanel e_30 = new StackPanel();
     e_30.Parent = parent;
     e_30.Name = "e_30";
     // e_31 element
     TextBlock e_31 = new TextBlock();
     e_30.Children.Add(e_31);
     e_31.Name = "e_31";
     Binding binding_e_31_Text = new Binding("Text");
     e_31.SetBinding(TextBlock.TextProperty, binding_e_31_Text);
     // e_32 element
     StackPanel e_32 = new StackPanel();
     e_30.Children.Add(e_32);
     e_32.Name = "e_32";
     e_32.Orientation = Orientation.Horizontal;
     // e_33 element
     TextBlock e_33 = new TextBlock();
     e_32.Children.Add(e_33);
     e_33.Name = "e_33";
     Binding binding_e_33_Text = new Binding("Boolean");
     e_33.SetBinding(TextBlock.TextProperty, binding_e_33_Text);
     // e_34 element
     TextBlock e_34 = new TextBlock();
     e_32.Children.Add(e_34);
     e_34.Name = "e_34";
     Binding binding_e_34_Text = new Binding("Number");
     e_34.SetBinding(TextBlock.TextProperty, binding_e_34_Text);
     return e_30;
 }
 private void layout(ref Grid grid)
 {
     grid.Children.Clear();
     spins = 0;
     List<int> values = Enumerable.Range(0, 36).ToList();
     StackPanel panel = new StackPanel();
     pocket = new Grid()
     {
         Height = 220,
         Width = 220,
         HorizontalAlignment = HorizontalAlignment.Center
     };
     ComboBox combobox = new ComboBox()
     {
         Margin = new Thickness(10),
         HorizontalAlignment = HorizontalAlignment.Center
     };
     combobox.ItemsSource = values;
     combobox.SelectedIndex = 0;
     combobox.SelectionChanged += (object sender, SelectionChangedEventArgs e) =>
     {
         pickValue = (int)((ComboBox)combobox).SelectedValue;
     };
     panel.Children.Add(pocket);
     panel.Children.Add(combobox);
     grid.Children.Add(panel);
 }
Example #10
0
 override void OnApplyTemplate()
 {            
     base.OnApplyTemplate();
     LayoutRoot = GetTemplateChild(LayoutRootName) as StackPanel;
     if (ItemsCount > 0)
         OnItemsCountChanged(ItemsCount);
 }
Example #11
0
 public BrushEditor(PropertyLabel label, PropertyItem property)
     : base(property)
 {
     currentValue = property.Value;
       property.PropertyChanged += property_PropertyChanged;
       property.ValueError += property_ValueError;
       contentPanel = new StackPanel();
       this.Content = contentPanel;
       ShowTextBox();
 }
Example #12
0
	// Use this for initialization
	void Start () {
        var frame = FindObjectOfType<Frame>();

        var sp = new StackPanel();
        sp.HorizontalAlignment = FirstWave.Unity.Gui.Enums.HorizontalAlignment.Center;
        sp.VerticalAlignment = FirstWave.Unity.Gui.Enums.VerticalAlignment.Top;

        sp.AddChild(new TextBlock("This is the second scene."));

        frame.AddControl(sp);
	}
            public ActionControlModel(ActionControl control, StackPanel parent, Level level, Obstacle obs)
            {
                mControlParent = control;
                mLevel = level;
                mSwitch = obs;
                mParent = parent;

                mData = new Half_Caked.KeyValuePair<Guid, int>(obs.Guid, 0);
                mTarget= Obstacles[0];
                mTarget.Actions.Add(mData);
            }
Example #14
0
        public FleuxSettingsPivotItem()
        {
            this.Title = "fleux";
            var items = new StackPanel();

            items.AddElement(this.CreateItem("kinetic scrolling", "physics inertia 2x"));
            items.AddElement(this.CreateItem("haptic feedback", "tap on items marked for feedback"));
            items.AddElement(this.CreateItem("background on panorama", "enabled"));
            items.AddElement(this.CreateItem("shadowed transitions", "enabled"));

            this.Body = items;
        }
    public void Run(RhinoDoc _doc, bool refresh = true)
    {
        doc = _doc;

        //Rhino.Display.DisplayPipeline.DrawForeground +=

        // make dialog to stop iteration
        window = new Window
        {
            Title = "stop loop",
            Width = 100,
            Height = 50
        };

        StackPanel stack_panel = new StackPanel();

        Button stop_button = new Button();
        stop_button.Content = "stop";
        stop_button.Click += Abort;

        stack_panel.Children.Add(stop_button);
        window.Content = stack_panel;

        new System.Windows.Interop.WindowInteropHelper(window).Owner = Rhino.RhinoApp.MainWindowHandle();
        window.Show();

        // iteration starts here
        DateTime time_start = DateTime.Now;

        Setup(); // frame_no

        while (is_Running)
        {

            if (refresh) Refresh();

            frame_no++;
            Draw();

            doc.Views.Redraw();
            RhinoApp.Wait();
        }

        Finish();

        TimeSpan duration = DateTime.Now - time_start;

        double frames_per_second = Math.Truncate(frame_no / duration.TotalSeconds * 100.0) / 100.0;
        RhinoApp.WriteLine("fps: " + frames_per_second);

        frame_no = 0;
    }
        protected override void OnApplyTemplate()
#endif
        {
            base.OnApplyTemplate();

            LayoutRoot = base.GetTemplateChild("LayoutRoot") as Grid;
            CaptionsBorder = base.GetTemplateChild("CaptionsBorder") as Border;
            CaptionsRoot = base.GetTemplateChild("CaptionsRoot") as Grid;
            CaptionsPanel = base.GetTemplateChild("captionsPanel") as StackPanel;

            isTemplateApplied = true;

            UpdateSize();
        }
 private void InitializeComponent() {
     // e_0 element
     this.e_0 = new Grid();
     this.Content = this.e_0;
     this.e_0.Name = "e_0";
     // e_1 element
     this.e_1 = new StackPanel();
     this.e_0.Children.Add(this.e_1);
     this.e_1.Name = "e_1";
     this.e_1.Height = 457F;
     this.e_1.Width = 90F;
     this.e_1.Margin = new Thickness(23F, 20F, 0F, -177F);
     this.e_1.HorizontalAlignment = HorizontalAlignment.Left;
     this.e_1.VerticalAlignment = VerticalAlignment.Top;
     // txtSysID element
     this.txtSysID = new TextBlock();
     this.e_1.Children.Add(this.txtSysID);
     this.txtSysID.Name = "txtSysID";
     this.txtSysID.Margin = new Thickness(0F, 5F, 0F, 5F);
     this.txtSysID.TextWrapping = TextWrapping.Wrap;
     Binding binding_txtSysID_Text = new Binding("SystemNumber");
     this.txtSysID.SetBinding(TextBlock.TextProperty, binding_txtSysID_Text);
     // txtNumPlanets element
     this.txtNumPlanets = new TextBlock();
     this.e_1.Children.Add(this.txtNumPlanets);
     this.txtNumPlanets.Name = "txtNumPlanets";
     this.txtNumPlanets.Margin = new Thickness(0F, 5F, 0F, 5F);
     this.txtNumPlanets.TextWrapping = TextWrapping.Wrap;
     Binding binding_txtNumPlanets_Text = new Binding("NumberPlanets");
     this.txtNumPlanets.SetBinding(TextBlock.TextProperty, binding_txtNumPlanets_Text);
     // txtOwner element
     this.txtOwner = new TextBlock();
     this.e_1.Children.Add(this.txtOwner);
     this.txtOwner.Name = "txtOwner";
     this.txtOwner.Margin = new Thickness(0F, 5F, 0F, 5F);
     this.txtOwner.TextWrapping = TextWrapping.Wrap;
     Binding binding_txtOwner_Text = new Binding("OwnedBy");
     this.txtOwner.SetBinding(TextBlock.TextProperty, binding_txtOwner_Text);
     // comboPlanets element
     this.comboPlanets = new ComboBox();
     this.e_1.Children.Add(this.comboPlanets);
     this.comboPlanets.Name = "comboPlanets";
     this.comboPlanets.ItemsSource = Get_comboPlanets_Items();
     this.comboPlanets.SelectedIndex = 1;
     FontManager.Instance.AddFont("Segoe UI", 12F, FontStyle.Regular, "Segoe_UI_9_Regular");
 }
Example #18
0
		public DependencyObject[] Generate(HtmlNode node, IHtmlTextBlock textBlock)
		{
			var list = new List<Grid>();
			foreach (var child in node.Children.Where(c => c.Value == "li"))
			{
				var grid = new Grid();
				grid.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
				grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });

				var tb = new TextBlock();
				tb.Foreground = textBlock.Foreground;
				tb.FontSize = textBlock.FontSize;
				tb.FontFamily = textBlock.FontFamily;
				tb.Margin = new Thickness();
				tb.Text = "• ";

				grid.Children.Add(tb);
				Grid.SetColumn(tb, 0);

				var panel = new StackPanel();

				child.ToHtmlBlock();
				foreach (var c in child.GetLeaves(textBlock).OfType<UIElement>())
				{
					var frameworkElement = c as FrameworkElement;
					if (frameworkElement != null)
						frameworkElement.HorizontalAlignment = HorizontalAlignment.Stretch;
					panel.Children.Add(c);
				}

				grid.Children.Add(panel);
				Grid.SetColumn(panel, 1);

				list.Add(grid);
			}

			var first = list.FirstOrDefault();
			if (first != null)
				first.Margin = new Thickness(0, textBlock.ParagraphMargin, 0, 0);

			var last = list.LastOrDefault();
			if (last != null)
				last.Margin = new Thickness(0, 0, 0, textBlock.ParagraphMargin);

			return list.OfType<DependencyObject>().ToArray();
		}
Example #19
0
        public void InitializeGui(GuiManager gui)
        {
            menuOptions = new StackPanel();
            menuOptions.HorizontalAlignment = HorizontalAlignment.Left;
            menuOptions.VerticalAlignment = VerticalAlignment.Center;
            menuOptions.Margin = new Thickness(100, 40, 0, 0);
            menuOptions.Width = 176;
            menuOptions.Height = 400;
            menuOptions.Spacing.Bottom = 32;
            gui.Elements.Add(menuOptions);

            for (int i = 0; i < 5; i++)
            {
                menuOptions.Children.Add(GetMenuOption(i));
            }

            gui.UpdateLayout();
        }
 public keySelectWindow(KeyActionClass ka, Boolean editable = true)
 {
     keyAction = ka;
     InitializeComponent();
     foreach (String act in keyAction.actionList)
     {
         StackPanel sp = new StackPanel();
         sp.Orientation = Orientation.Horizontal;
         Label lbl = new Label();
         lbl.Content = act;
         lbl.Width = actionLbl.Width;
         sp.Children.Add(lbl);
         if (editable)
         {
             ComboBox cb = new ComboBox();
             cb.Name = act;
             cb.Width = keyLbl.Width;
             cb.SelectionChanged += actionKeyChanged;
             loadKeyItems(cb);
             setSelected(cb, act);
             sp.Children.Add(cb);
         }
         else
         {
             lbl = new Label();
             String k = keyAction.getKey(act);
             if (k == null)
                 lbl.Content = "Not set";
             else
                 lbl.Content = act;
             lbl.Width = actionLbl.Width;
             sp.Children.Add(lbl);
         }
         keyStackPanel.Children.Add(sp);
     }
     fixSource = true;
     if (!editable)
     //    buttonStack.Visibility = Visibility.Visible;
     //else
     {
         buttonStack.Visibility = Visibility.Hidden;
         buttonStack.Height = 0;
     }
 }
Example #21
0
 public void Draw(ref StackPanel Stack)
 {
     Stack.Children.Clear();
     foreach (int number in numbers())
     {
         Canvas container = new Canvas();
         Ellipse ball = new Ellipse();
         TextBlock text = new TextBlock();
         container.Margin = new Thickness(2);
         container.Width = 48;
         container.Height = 48;
         ball.Width = container.Width;
         ball.Height = container.Height;
         ball.Stroke = new SolidColorBrush(Colors.Black);
         if (number >= 1 && number <= 9)
         {
             ball.Fill = new SolidColorBrush(Colors.White);
         }
         else if (number >= 10 && number <= 19)
         {
             ball.Fill = new SolidColorBrush(Color.FromArgb(255, 112, 200, 236));
         }
         else if (number >= 20 && number <= 29)
         {
             ball.Fill = new SolidColorBrush(Colors.Magenta);
         }
         else if (number >= 30 && number <= 39)
         {
             ball.Fill = new SolidColorBrush(Color.FromArgb(255, 112, 255, 0));
         }
         else if (number >= 40 && number <= 49)
         {
             ball.Fill = new SolidColorBrush(Colors.Yellow);
         }
         container.Children.Add(ball);
         text.Foreground = new SolidColorBrush(Colors.Black);
         text.FontSize = 16;
         text.Text = number.ToString();
         text.Margin = new Thickness(16, 12, 16, 12);
         container.Children.Add(text);
         Stack.Children.Add(container);
     }
 }
Example #22
0
        public void InitializeGui(GuiManager gui)
        {
            this.gui = gui;

            panel = new Panel();
            panel.HorizontalAlignment = HorizontalAlignment.Left;
            panel.VerticalAlignment = VerticalAlignment.Top;
            panel.Width = Context.View.Area.Width;
            panel.Height = Context.View.Area.Height;
            gui.Elements.Add(panel);

            menuOptions = new StackPanel();
            menuOptions.HorizontalAlignment = HorizontalAlignment.Left;
            menuOptions.VerticalAlignment = VerticalAlignment.Center;
            menuOptions.Margin = new Thickness(100, 40, 0, 0);
            menuOptions.Width = 176;
            menuOptions.Height = 400;
            menuOptions.Spacing.Bottom = 32;
            panel.Children.Add(menuOptions);

            // Add the address textbox to the stackpanel
            var textBoxInfo = new TextBoxInfo()
            {
                MaxLength = 100,
                SpriteFont = Context.Resources.Fonts["Global.Normal"],
                Background = Context.Resources.Textures["MainMenu.TextBox"]
            };
            textBoxIp = new TextBox("", textBoxInfo);
            textBoxIp.HorizontalAlignment = HorizontalAlignment.Left;
            textBoxIp.VerticalAlignment = VerticalAlignment.Top;
            textBoxIp.Width = 220;
            textBoxIp.Text = "";
            textBoxIp.EnterKeyDown += textBoxIp_EnterKeyDown;
            menuOptions.Children.Add(textBoxIp);

            for (int i = 0; i < 2; i++)
            {
                menuOptions.Children.Add(GetMenuOption(i));
            }

            gui.UpdateLayout();
        }
Example #23
0
 public void DrawTesting(ref StackPanel Stack, ref List<int> l)
 {
     Stack.Children.Clear();
     foreach (int number in l)
     {
         Canvas container = new Canvas();
         Ellipse ball = new Ellipse();
         TextBlock text = new TextBlock();
         container.Margin = new Thickness(2);
         container.Width = 62;
         container.Height = 62;
         ball.Width = container.Width;
         ball.Height = container.Height;
         if (number >= 1 && number <= 9)
         {
             ball.Fill = new SolidColorBrush(Colors.Red);
         }
         else if (number >= 10 && number <= 19)
         {
             ball.Fill = new SolidColorBrush(Colors.Yellow);
         }
         else if (number >= 20 && number <= 29)
         {
             ball.Fill = new SolidColorBrush(Colors.Magenta);
         }
         else if (number >= 30 && number <= 39)
         {
             ball.Fill = new SolidColorBrush(Colors.Green);
         }
         else
         {
             ball.Fill = new SolidColorBrush(Colors.Blue);
         }
         container.Children.Add(ball);
         text.Foreground = new SolidColorBrush(Colors.Black);
         text.FontSize = 18;
         text.Text = number.ToString();
         text.Margin = new Thickness(15);
         container.Children.Add(text);
         Stack.Children.Add(container);
     }
 }
 private void InitializeComponent()
 {
     // e_0 element
     this.e_0 = new Border();
     this.Content = this.e_0;
     this.e_0.Name = "e_0";
     this.e_0.BorderBrush = new SolidColorBrush(new ColorW(0, 0, 0, 255));
     this.e_0.BorderThickness = new Thickness(3F, 3F, 3F, 3F);
     // e_1 element
     this.e_1 = new StackPanel();
     this.e_0.Child = this.e_1;
     this.e_1.Name = "e_1";
     this.e_1.Background = new SolidColorBrush(new ColorW(112, 128, 144, 255));
     this.e_1.Orientation = Orientation.Vertical;
     // e_2 element
     this.e_2 = new TextBlock();
     this.e_1.Children.Add(this.e_2);
     this.e_2.Name = "e_2";
     this.e_2.Text = "I am a user control!";
     // e_3 element
     this.e_3 = new StackPanel();
     this.e_1.Children.Add(this.e_3);
     this.e_3.Name = "e_3";
     this.e_3.Orientation = Orientation.Horizontal;
     // e_4 element
     this.e_4 = new TextBlock();
     this.e_3.Children.Add(this.e_4);
     this.e_4.Name = "e_4";
     this.e_4.Text = "User name:";
     // e_5 element
     this.e_5 = new TextBlock();
     this.e_3.Children.Add(this.e_5);
     this.e_5.Name = "e_5";
     Binding binding_e_5_Text = new Binding("Name");
     this.e_5.SetBinding(TextBlock.TextProperty, binding_e_5_Text);
     // e_6 element
     this.e_6 = new Border();
     this.e_1.Children.Add(this.e_6);
     this.e_6.Name = "e_6";
     this.e_6.Background = new SolidColorBrush(new ColorW(255, 0, 0, 255));
     FontManager.Instance.AddFont("Kootenay", 12F, FontStyle.Regular, "Kootenay_9_Regular");
 }
Example #25
0
 private void InitializeComponent()
 {
     this.FontFamily = new FontFamily("Kootenay");
     this.FontSize = 12F;
     InitializeElementResources(this);
     // e_0 element
     this.e_0 = new StackPanel();
     this.Content = this.e_0;
     this.e_0.Name = "e_0";
     // e_1 element
     this.e_1 = new TextBlock();
     this.e_0.Children.Add(this.e_1);
     this.e_1.Name = "e_1";
     this.e_1.Text = "Hello World";
     // e_2 element
     this.e_2 = new Button();
     this.e_0.Children.Add(this.e_2);
     this.e_2.Name = "e_2";
     this.e_2.Content = "Click Me";
     Binding binding_e_2_Command = new Binding("ButtonCommand");
     this.e_2.SetBinding(Button.CommandProperty, binding_e_2_Command);
     // e_3 element
     this.e_3 = new TextBlock();
     this.e_0.Children.Add(this.e_3);
     this.e_3.Name = "e_3";
     Binding binding_e_3_Text = new Binding("NumberOfClicks");
     binding_e_3_Text.FallbackValue = "0";
     this.e_3.SetBinding(TextBlock.TextProperty, binding_e_3_Text);
     // e_4 element
     this.e_4 = new DataGrid();
     this.e_0.Children.Add(this.e_4);
     this.e_4.Name = "e_4";
     Binding binding_e_4_ItemsSource = new Binding("DataGridData");
     this.e_4.SetBinding(DataGrid.ItemsSourceProperty, binding_e_4_ItemsSource);
     // TheFooBarUserControl element
     this.TheFooBarUserControl = new FooBarUserControl();
     this.e_0.Children.Add(this.TheFooBarUserControl);
     this.TheFooBarUserControl.Name = "TheFooBarUserControl";
     FontManager.Instance.AddFont("Kootenay", 12F, FontStyle.Regular, "Kootenay_9_Regular");
 }
Example #26
0
    public override void Build(IProduct product)
    {
        var panel = new StackPanel {Orientation = Orientation.Vertical, Margin = new Thickness(0, 0, 0, 0)};
        var infoPanel = new StackPanel {Orientation = Orientation.Horizontal, Margin = new Thickness(10, 0, 5, 0)};
        var purchasePanel = new StackPanel {Orientation = Orientation.Vertical, Margin = new Thickness(0, 0, 0, 0)};

        if (!HasProperty("Count")) {
            _boundValues.Add("Count", new ProductProperty<uint>("Count", product.Count) {HideGUILabel = true});
        }

        infoPanel.Children.Add(new Label {Content = "Brand: "});
        QuickBind(infoPanel.Children, GetPropertyView("Brand"));

        infoPanel.Children.Add(new Label { Content = "Size: " });
        QuickBind(infoPanel.Children, GetPropertyView("Size"));

        infoPanel.Children.Add(new Label { Content = "Number of Jackets: " });
        QuickBind(infoPanel.Children, GetPropertyView("Count"));

        purchasePanel.Children.Add(new Label { Content = "Cost: " });
        QuickBind(purchasePanel.Children, GetPropertyView("Cost"));

        purchasePanel.Children.Add(new Label { Content = "Purchaser: " });
        QuickBind(purchasePanel.Children, GetPropertyView("Purchaser"));

        purchasePanel.Children.Add(new Label { Content = "Date of Purchase: " });
        QuickBind(purchasePanel.Children, GetPropertyView("Purchase Date"));

        var infoBox = new GroupBox { Header = "Jacket Information", Content = infoPanel };
        var purchaseBox = new GroupBox { Header = "Purchase Information", Content = purchasePanel };

        panel.Children.Add(infoBox);
        panel.Children.Add(purchaseBox);

        _gui = panel;
    }
Example #27
0
        // Setting panel for DES Algorithm
        #region SYMETRIC_ALG_INTERFACE
        private void AlgDraw(ref StackPanel sP, int panel)
        {
            switch (panel)
            {
            case 0:
                sP.Margin = new Thickness(20, 0, 0, 0);
                dynamic keyField;
                if (Encryption.algParams[0] == 0)
                {
                    keyField = new Button()
                    {
                        Style   = Resources["GenerateButton"] as Style,
                        Margin  = new Thickness(0, 5, 0, 5),
                        Width   = 347,
                        Content = "Згенерувати ключ"
                    };
                    keyField.AddHandler(Button.ClickEvent, new RoutedEventHandler(GenerateRng));
                }
                else
                {
                    keyField = new PasswordBox()
                    {
                        Style  = Resources["MainPasswordBox"] as Style,
                        Width  = 347,
                        Margin = new Thickness(0, 5, 0, 5)
                    };
                    keyField.AddHandler(PasswordBox.LostFocusEvent, new RoutedEventHandler(GeneratePass));
                }
                sP.Children.Add(keyField);
                break;

            case 1:
                sP.Margin = new Thickness(20, 0, 0, 0);
                var rngType = new RadioButton()
                {
                    Width     = 330,
                    Style     = Resources["MainRadioButton"] as Style,
                    Margin    = new Thickness(0, 5, 0, 0),
                    GroupName = "keyType",
                    IsChecked = Encryption.algParams[0] == 0 ? true : false
                };
                rngType.AddHandler(RadioButton.CheckedEvent, new RoutedEventHandler(KeyTypeRng));
                var rngTypeText = new TextBlock()
                {
                    Style = Resources["TextBlock"] as Style,
                    Text  = "Ключ з криптографічного генератора псевдовипадкових послідовностей"
                };

                var passType = new RadioButton()
                {
                    Width     = 330,
                    Style     = Resources["MainRadioButton"] as Style,
                    Margin    = new Thickness(0, 10, 0, 10),
                    GroupName = "keyType",
                    IsChecked = Encryption.algParams[0] == 1 ? true : false
                };
                passType.AddHandler(RadioButton.CheckedEvent, new RoutedEventHandler(KeyTypePass));
                var passTypeText = new TextBlock()
                {
                    Style = Resources["TextBlock"] as Style,
                    Text  = "Ключ генерується розширенням паролю"
                };
                rngType.Content  = rngTypeText;
                passType.Content = passTypeText;
                sP.Children.Add(rngType);
                sP.Children.Add(passType);
                break;

            case 2:
                sP.Margin = new Thickness(20, 0, 0, 0);
                var elements = new UIElement[3, 2]
                {
                    { new Label()
                      {
                          Style = Resources["ParamLabel"] as Style, Content = "Розмір блока (біт):"
                      }, Element(0) },
                    { new Label()
                      {
                          Style = Resources["ParamLabel"] as Style, Content = "Довжина ключа (біт):"
                      }, Element(1) },
                    { new Label()
                      {
                          Style = Resources["ParamLabel"] as Style, Content = "Кількість раундів:"
                      }, Element(2) }
                };
                for (int i = 0; i < elements.GetLength(0); i++)
                {
                    var wPc = new WrapPanel();
                    wPc.Children.Add(elements[i, 0]);
                    wPc.Children.Add(elements[i, 1]);
                    sP.Children.Add(wPc);
                }
                break;
            }
        }
Example #28
0
 private void InitializUIElements()
 {
     this.stackPanel        = new StackPanel();
     this.stackPanel.Width  = this.width;
     this.stackPanel.Height = this.height;
 }
        void loadField()
        {
            StackPanel st = new StackPanel();

            txbStateId           = new Xceed.Wpf.Toolkit.WatermarkTextBox();
            txbStateId.Width     = 200;
            txbStateId.Margin    = new Thickness(0, 10, 0, 10);
            txbStateId.Watermark = "State ID";
            st.Children.Add(txbStateId);
            txbCountryId           = new Xceed.Wpf.Toolkit.WatermarkTextBox();
            txbCountryId.Width     = 200;
            txbCountryId.Watermark = "Country ID";
            txbCountryId.Margin    = new Thickness(0, 10, 0, 10);
            st.Children.Add(txbCountryId);
            txbStateCode           = new Xceed.Wpf.Toolkit.WatermarkTextBox();
            txbStateCode.Width     = 200;
            txbStateCode.Watermark = "State Code";
            txbStateCode.Margin    = new Thickness(0, 10, 0, 10);
            st.Children.Add(txbStateCode);

            txbStateName           = new Xceed.Wpf.Toolkit.WatermarkTextBox();
            txbStateName.Width     = 200;
            txbStateName.Margin    = new Thickness(0, 10, 0, 10);
            txbStateName.Watermark = "State Name";
            st.Children.Add(txbStateName);
            txbSTDCode           = new Xceed.Wpf.Toolkit.WatermarkTextBox();
            txbSTDCode.Width     = 200;
            txbSTDCode.Watermark = "STD Code";
            txbSTDCode.Margin    = new Thickness(0, 10, 0, 10);
            st.Children.Add(txbSTDCode);
            txbCountryName           = new Xceed.Wpf.Toolkit.WatermarkTextBox();
            txbCountryName.Width     = 200;
            txbCountryName.Watermark = "State Code";
            txbCountryName.Margin    = new Thickness(0, 10, 0, 10);
            st.Children.Add(txbCountryName);

            StackPanel stpanal = new StackPanel();

            stpanal.Orientation         = Orientation.Horizontal;
            stpanal.Margin              = new Thickness(20);
            stpanal.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            Button bt = new Button();

            bt.Name   = "btnSubmit";
            bt.Click += bt_Click;
            bt.Style  = Application.Current.FindResource("MetroButtonSubmit") as Style;

            // bt.Margin = new Thickness(0, 10, 0, 10);
            bt.Margin = new Thickness(0, 0, 10, 0);
            Button btcncle = new Button();

            btcncle.Style = Application.Current.FindResource("MetroButtonClose") as Style;

            btcncle.Margin = new Thickness(30, 0, 0, 0);
            stpanal.Children.Add(bt);
            stpanal.Children.Add(btcncle);

            st.Children.Add(stpanal);


            grdField.Children.Add(st);
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            //add stackpanel with text boxes and remove button
            TextBox tbTaxa = new TextBox();

            tbTaxa.AcceptsReturn = true;
            Thickness m1 = tbTaxa.Margin;

            m1.Left       = 10;
            tbTaxa.Margin = m1;
            tbTaxa.Width  = 100;
            tbTaxa.Height = 30;
            Thickness m3 = tbTaxa.Padding;

            m3.Left           = 20;
            m3.Bottom         = 20;
            tbTaxa.FontSize   = 14;
            tbTaxa.Foreground = new SolidColorBrush(Colors.Orange);
            tbTaxa.Background = new SolidColorBrush(Colors.Black);
            // tbTaxa.Padding = 15;
            TaxaText.Add(tbTaxa);


            ///////////////////////////padding
            TextBox tbData = new TextBox();

            tbData.AcceptsReturn = true;
            Thickness m2 = tbData.Margin;

            m2.Left       = 10;
            tbData.Margin = m2;
            Thickness m4 = tbData.Padding;

            m4.Left             = 20;
            m4.Bottom           = 50;
            tbData.Width        = 300;
            tbData.Height       = 150;
            tbData.FontSize     = 14;
            tbData.Background   = new SolidColorBrush(Colors.LightGray);
            tbData.TextWrapping = TextWrapping.Wrap;
            DataText.Add(tbData);

            Button btnRemove = new Button();

            btnRemove.Content             = "Remove";
            btnRemove.IsEnabled           = true;
            btnRemove.HorizontalAlignment = HorizontalAlignment.Right;
            btnRemove.Click += btnRemove_Click;
            //       < Button x: Name = "button" Content = "Next" IsEnabled = "True" HorizontalAlignment = "Right" Click = "btnValidate_Click" />


            StackPanel s = new StackPanel();

            s.Orientation         = Orientation.Horizontal;
            s.HorizontalAlignment = HorizontalAlignment.Center;
            s.Children.Add(tbTaxa);
            s.Children.Add(tbData);
            s.Children.Add(btnRemove);
            // s.Children.Add();
            //need to add remove button for each row then add button at the bottim
            SeqFrame.Children.Add(s);

            ScrollSeq.Content = SeqFrame;
            //add textboxes to list above so they can be validated
        }
Example #31
0
        private void GGpio_Dbl_click(object sender, MouseButtonEventArgs e)
        {
            if (changeEnable)
            {
                Gpio       gpio = e.Source as Gpio;
                StackPanel stp  = gpio.Parent as StackPanel;



                if (stp.Uid == "in")
                {
                    gpio.GpIn = gpioData.inputs[int.Parse(gpio.Uid)];
                    WindowSetIn setIn = new WindowSetIn(gpio);
                    setIn.ShowDialog();
                }

                else
                {
                    gpio.GpOut = gpioData.outputs[int.Parse(gpio.Uid)];
                    WindowSetOut setOut = new WindowSetOut(gpio);
                    setOut.ShowDialog();
                }
            }
            else if (handControlEnable)
            {
                Gpio gpio = e.Source as Gpio;
                if (gpio.Name.Contains("In"))
                {
                    return;
                }
                StackPanel stp = gpio.Parent as StackPanel;
                int        pom = int.Parse(gpio.Uid);
                if (stp.Uid == "in")
                {
                    if (VSTUPY[pom] == 0)
                    {
                        VSTUPY[pom] = 1;
                        comBluetooth.send("M-I-" + int.Parse(gpio.Uid) + "-1 \n");
                    }

                    else
                    {
                        VSTUPY[pom] = 0;
                        comBluetooth.send("M-I-" + int.Parse(gpio.Uid) + "-0 \n");
                    }
                }
                else if (stp.Uid == "out")
                {
                    if (VYSTUPY[pom] == 0)
                    {
                        VYSTUPY[pom] = 1;
                        comBluetooth.send("M-O-" + int.Parse(gpio.Uid) + "-1 \n");
                    }

                    else
                    {
                        VYSTUPY[pom] = 0;
                        comBluetooth.send("M-O-" + int.Parse(gpio.Uid) + "-0 \n");
                    }
                }
            }
        }
Example #32
0
        /// <summary>
        /// Create box with rounded corner, nice looking with informataion about user.
        /// </summary>
        /// <param name="comment">User object.</param>
        /// <param name="isPink">Set background color pink if true else set blue.</param>
        /// <param name="OnClick">RoutedEventHandler which defines action on click user box.</param>
        /// <returns>Grid with information about user.</returns>
        public static Grid CreateUserContentGrid(User user, string comment, string joke, bool isPink, RoutedEventHandler OnClick)
        {
            var userGrid = new Grid
            {
                Margin = new Thickness(0, 0, 0, 20)
            };

            userGrid.RowDefinitions.Add(new RowDefinition());
            userGrid.ColumnDefinitions.Add(new ColumnDefinition());

            var userButton = new Button
            {
                Width       = 350,
                Background  = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250)),
                BorderBrush = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250)),
                Margin      = new Thickness(10),
                Cursor      = Cursors.Hand
            };

            userButton.Click += OnClick;

            var userRectangle = new Rectangle
            {
                Width   = 350,
                RadiusX = 10,
                RadiusY = 10
            };

            userRectangle.Effect = new DropShadowEffect
            {
                Color = new Color {
                    A = 255, R = 222, G = 222, B = 222
                },
                ShadowDepth = 1,
                BlurRadius  = 20
            };
            if (isPink)
            {
                userRectangle.Fill = new SolidColorBrush(Color.FromArgb(80, 177, 101, 240));
            }
            else
            {
                userRectangle.Fill = new SolidColorBrush(Color.FromArgb(80, 112, 172, 250));
            }


            userGrid.Children.Add(userRectangle);

            var userStackPanel = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Background          = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250))
            };

            TextBlock nicknameTextBlock = new TextBlock
            {
                TextWrapping = TextWrapping.WrapWithOverflow,
                Text         = "NICKNAME:   " + user.Nickname,
                Margin       = new Thickness(10, 5, 10, 5),
                FontSize     = 18,
                MaxWidth     = 330,
                Width        = 330,
                Background   = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250))
            };

            TextBlock NameTextBlock = new TextBlock
            {
                TextWrapping = TextWrapping.WrapWithOverflow,
                Text         = user.Name + " " + user.Surname,
                MaxWidth     = 330,
                Width        = 330,
                FontSize     = 16,
                Margin       = new Thickness(10, 5, 10, 5),
                Background   = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250))
            };

            TextBlock EmailTextBlock = new TextBlock
            {
                TextWrapping = TextWrapping.WrapWithOverflow,
                Text         = "E-MAIL:   " + user.Email,
                MaxWidth     = 330,
                Width        = 330,
                FontSize     = 16,
                Margin       = new Thickness(10, 5, 10, 20),
                Background   = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250))
            };

            TextBlock LastCommentLabelTextBlock = new TextBlock
            {
                TextWrapping = TextWrapping.WrapWithOverflow,
                Text         = "OSTATNI KOMENTARZ:",
                MaxWidth     = 300,
                Width        = 300,
                FontSize     = 14,
                Margin       = new Thickness(10, 10, 10, 0),
                Background   = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250))
            };

            TextBlock LastCommentTextBlock = new TextBlock
            {
                TextWrapping = TextWrapping.WrapWithOverflow,
                Text         = comment,
                MaxWidth     = 300,
                Width        = 300,
                FontSize     = 12,
                Margin       = new Thickness(10),
                Padding      = new Thickness(5),
                Background   = new SolidColorBrush(Color.FromArgb(180, 255, 255, 255))
            };


            TextBlock LastJokeLabelTextBlock = new TextBlock
            {
                TextWrapping = TextWrapping.WrapWithOverflow,
                Text         = "OSTATNI DOWCIP:",
                Width        = 300,
                MaxWidth     = 300,
                FontSize     = 14,
                Margin       = new Thickness(10, 10, 10, 0),
                Background   = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250))
            };

            TextBlock LastJokeTextBlock = new TextBlock
            {
                TextWrapping = TextWrapping.WrapWithOverflow,
                Text         = joke,
                Width        = 300,
                MaxWidth     = 300,
                FontSize     = 12,
                Margin       = new Thickness(10),
                Padding      = new Thickness(5),
                Background   = new SolidColorBrush(Color.FromArgb(180, 255, 255, 255))
            };

            userStackPanel.Children.Add(nicknameTextBlock);
            userStackPanel.Children.Add(NameTextBlock);
            userStackPanel.Children.Add(EmailTextBlock);
            userStackPanel.Children.Add(LastCommentLabelTextBlock);
            userStackPanel.Children.Add(LastCommentTextBlock);
            userStackPanel.Children.Add(LastJokeLabelTextBlock);
            userStackPanel.Children.Add(LastJokeTextBlock);

            userButton.Content = userStackPanel;
            userGrid.Children.Add(userButton);
            return(userGrid);
        }
        public void DynamicText(List <String> x)
        {
            this.InitializeComponent();
            numOfTaxaPanels = x.Count;//reference main obj and however many taxa were previously entered
            TaxaText        = new List <TextBox>();
            DataText        = new List <TextBox>();
            for (int i = 0; i < numOfTaxaPanels; i++)// starts at 1 b/c the first stackpanel is already displayed
            {
                TextBox tbTaxa = new TextBox();
                tbTaxa.Name          = "taxa" + i;
                tbTaxa.AcceptsReturn = true;
                Thickness m1 = tbTaxa.Margin;
                m1.Left       = 10;
                tbTaxa.Margin = m1;
                tbTaxa.Width  = 100;
                tbTaxa.Height = 30;
                Thickness m3 = tbTaxa.Padding;
                m3.Left           = 20;
                m3.Bottom         = 20;
                tbTaxa.Text       = x[i];
                tbTaxa.FontSize   = 14;
                tbTaxa.Foreground = new SolidColorBrush(Colors.Orange);
                tbTaxa.Background = new SolidColorBrush(Colors.Black);
                // tbTaxa.Padding = 15;
                TaxaText.Add(tbTaxa);


                ///////////////////////////padding
                TextBox tbData = new TextBox();
                tbData.Name          = "data" + i;
                tbData.AcceptsReturn = true;
                Thickness m2 = tbData.Margin;
                m2.Left       = 10;
                tbData.Margin = m2;
                Thickness m4 = tbData.Padding;
                m4.Left             = 20;
                m4.Bottom           = 50;
                tbData.Width        = 300;
                tbData.Height       = 150;
                tbData.FontSize     = 14;
                tbData.Background   = new SolidColorBrush(Colors.LightGray);
                tbData.TextWrapping = TextWrapping.Wrap;
                DataText.Add(tbData);

                Button btnRemove = new Button();
                btnRemove.Content             = "Remove";
                btnRemove.IsEnabled           = true;
                btnRemove.HorizontalAlignment = HorizontalAlignment.Right;
                btnRemove.Click += btnRemove_Click;
                //       < Button x: Name = "button" Content = "Next" IsEnabled = "True" HorizontalAlignment = "Right" Click = "btnValidate_Click" />


                StackPanel s = new StackPanel();
                s.Name                = "SequencePanel" + i;
                s.Orientation         = Orientation.Horizontal;
                s.HorizontalAlignment = HorizontalAlignment.Center;
                s.Children.Add(tbTaxa);
                s.Children.Add(tbData);
                s.Children.Add(btnRemove);
                // s.Children.Add();
                //need to add remove button for each row then add button at the bottim
                SeqFrame.Children.Add(s);
            }
            ScrollSeq.Content = SeqFrame;
        }
Example #34
0
 /// <summary>
 /// 向指定的堆栈面板中添加自定义形式的控件元素
 /// </summary>
 /// <param name="textBlock">自定义内容的控件 ,基于 UIElement 的都可以</param>
 /// <param name="stackPanel">指定的堆栈面板</param>
 public static void AddString2StackPanel(UIElement textBlock, StackPanel stackPanel)
 {
     stackPanel.Children.Add(textBlock);
 }
Example #35
0
        /// <summary>
        /// Create box with rounded corner, nice looking with informataion about comment.
        /// </summary>
        /// <param name="comment">Comment object.</param>
        /// <param name="isPink">Set background color pink if true else set blue.</param>
        /// <param name="OnClick">RoutedEventHandler which defines action on click comment box.</param>
        /// <returns>Grid with information about comment.</returns>
        public static Grid CreateCommentContentGrid(Comment comment, bool isPink, RoutedEventHandler OnClick)
        {
            var jokeGrid = new Grid
            {
                Margin = new Thickness(0, 0, 0, 10)
            };

            jokeGrid.RowDefinitions.Add(new RowDefinition());
            jokeGrid.ColumnDefinitions.Add(new ColumnDefinition());

            var jokeButton = new Button
            {
                Width       = 350,
                Background  = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250)),
                BorderBrush = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250)),
                Margin      = new Thickness(10),
                Cursor      = Cursors.Hand
            };

            jokeButton.Click += OnClick;

            var jokeRectangle = new Rectangle
            {
                Width   = 350,
                RadiusX = 10,
                RadiusY = 10
            };

            jokeRectangle.Effect = new DropShadowEffect
            {
                Color = new Color {
                    A = 255, R = 222, G = 222, B = 222
                },
                ShadowDepth = 1,
                BlurRadius  = 20
            };
            if (isPink)
            {
                jokeRectangle.Fill = new SolidColorBrush(Color.FromArgb(80, 177, 101, 240));
            }
            else
            {
                jokeRectangle.Fill = new SolidColorBrush(Color.FromArgb(80, 112, 172, 250));
            }


            jokeGrid.Children.Add(jokeRectangle);

            var jokeStackPanel = new StackPanel
            {
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment   = VerticalAlignment.Top,
                Background          = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250))
            };

            TextBlock dateTextBlock = new TextBlock
            {
                TextWrapping = TextWrapping.WrapWithOverflow,
                Text         = comment.CreatedDate.ToString(),
                Margin       = new Thickness(10, 5, 10, 5),
                FontSize     = 12,
                Width        = 330,
                Background   = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250))
            };

            TextBlock contentTextBlock = new TextBlock
            {
                TextWrapping = TextWrapping.WrapWithOverflow,
                Text         = comment.Content,
                Width        = 330,
                FontSize     = 14,
                Margin       = new Thickness(10, 5, 10, 5),
                Background   = new SolidColorBrush(Color.FromArgb(0, 112, 172, 250))
            };

            jokeStackPanel.Children.Add(contentTextBlock);
            jokeStackPanel.Children.Add(dateTextBlock);

            jokeButton.Content = jokeStackPanel;
            jokeGrid.Children.Add(jokeButton);
            return(jokeGrid);
        }
        public virtual void CoerceInputTextOnLostFocus()
        {
            NumericUpDown nud = new NumericUpDown { Maximum = 100, Minimum = 0, Value = 50 };
            TextBox part = null;
            TextBox other = new TextBox();

            StackPanel panel = new StackPanel();
            panel.Children.Add(nud);
            panel.Children.Add(other);

            TestAsync(
                100,
                panel,
                () => part = nud.GetVisualDescendents().OfType<TextBox>().FirstOrDefault(),
                () => Assert.IsNotNull(part, "Could not find TextBox template part!"),
                () => part.Focus(),
                () => part.Text = "999",
                () => other.Focus(),
                () => Assert.AreEqual(100, nud.Value, "NumericUpDown did not coerce the value to 100!"));
        }
        public virtual void SelectionInactiveOnLostFocus()
        {
            StackPanel root = new StackPanel();
            TreeView view = new TreeView();
            TreeViewItem item = new TreeViewItem { Header = "Item" };
            view.Items.Add(item);
            Button other = new Button { Content = "Button" };
            root.Children.Add(view);
            root.Children.Add(other);

            TestAsync(
                root,
                () => Assert.IsFalse(item.IsSelected, "Item should not be selected initially!"),
                () => Assert.IsFalse(item.IsSelectionActive, "Item should not have inactive selection initially!"),
                () => item.Focus(),
                () => Assert.IsTrue(item.IsSelected, "Item should be selected after focus!"),
                () => Assert.IsTrue(item.IsSelectionActive, "Item should not have inactive selection after focus!"),
                () => other.Focus(),
                () => Assert.IsTrue(item.IsSelected, "Item should be selected after focusing another element!"),
                () => Assert.IsFalse(item.IsSelectionActive, "Item should have an inactive selection after focusing another element!"));
        }
Example #38
0
        private bool CheckMoveBlack(Button button1, Button button2)
        {
            CheckerBoard currentBoard = GetCurrentBoard();
            List <Move>  jumpMoves    = currentBoard.checkJumps("Black");

            if (jumpMoves.Count > 0)
            {
                bool invalid = true;
                foreach (Move move in jumpMoves)
                {
                    if (currentMove.Equals(move))
                    {
                        invalid = false;
                    }
                }
                if (invalid)
                {
                    displayError("Jump must be taken");
                    currentMove.piece1 = null;
                    currentMove.piece2 = null;
                    Console.WriteLine("False");
                    return(false);
                }
            }

            if (button1.Name.Contains("Black"))
            {
                if (button1.Name.Contains("King"))
                {
                    if ((currentMove.isAdjacent("King")) && (!button2.Name.Contains("Black")) && (!button2.Name.Contains("Red")))
                    {
                        return(true);
                    }
                    Piece middlePiece = currentMove.checkJump("King");
                    if ((middlePiece != null) && (!button2.Name.Contains("Black")) && (!button2.Name.Contains("Red")))
                    {
                        StackPanel middleStackPanel = (StackPanel)GetGridElement(CheckersGrid, middlePiece.Row, middlePiece.Column);
                        Button     middleButton     = (Button)middleStackPanel.Children[0];
                        if (middleButton.Name.Contains("Red"))
                        {
                            CheckersGrid.Children.Remove(middleStackPanel);
                            addBlackButton(middlePiece);
                            return(true);
                        }
                    }
                }
                else
                {
                    if ((currentMove.isAdjacent("Black")) && (!button2.Name.Contains("Black")) && (!button2.Name.Contains("Red")))
                    {
                        return(true);
                    }
                    Piece middlePiece = currentMove.checkJump("Black");
                    if ((middlePiece != null) && (!button2.Name.Contains("Black")) && (!button2.Name.Contains("Red")))
                    {
                        StackPanel middleStackPanel = (StackPanel)GetGridElement(CheckersGrid, middlePiece.Row, middlePiece.Column);
                        Button     middleButton     = (Button)middleStackPanel.Children[0];
                        if (middleButton.Name.Contains("Red"))
                        {
                            CheckersGrid.Children.Remove(middleStackPanel);
                            addBlackButton(middlePiece);
                            return(true);
                        }
                    }
                }
            }
            currentMove = null;
            displayError("Invalid Move. Try Again.");
            return(false);
        }
Example #39
0
 /// <summary>
 /// 移除堆栈面板的最后一个元素
 /// </summary>
 /// <param name="stackPanel">需要进行移除的面板</param>
 public static void RemoveLastChild(StackPanel stackPanel)
 {
     RemoveChildrenAt(stackPanel, stackPanel.Children.Count - 1);
 }
Example #40
0
        /// <summary>
        /// Opens a <see cref="ContentDialog"/> for the user to enter a URL
        /// </summary>
        /// <param name="button">The <see cref="ToolbarButton"/> invoked</param>
        public async void OpenLinkCreator(ToolbarButton button)
        {
            var selection = button.Model.Editor.Document.Selection;

            var labelBox = new RichEditBox
            {
                PlaceholderText = "WCT_TextToolbar_LabelLabel".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls.Core/Resources"),
#if !HAS_UNO
                Margin = new Thickness(0, 0, 0, 5),
#endif
                AcceptsReturn = false
            };
            var linkBox = new TextBox
            {
                PlaceholderText = "WCT_TextToolbar_UrlLabel".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls.Core/Resources")
            };

            CheckBox relativeBox = null;

            var contentPanel = new StackPanel
            {
                Children =
                {
#if !HAS_UNO
                    labelBox,
#endif
                    linkBox
                }
            };

            if (Model.UseURIChecker)
            {
                relativeBox = new CheckBox
                {
                    Content = "WCT_TextToolbar_RelativeLabel".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls.Core/Resources")
                };
                contentPanel.Children.Add(relativeBox);
            }

            labelBox.Document.SetDefaultCharacterFormat(selection.CharacterFormat);
            selection.GetText(Windows.UI.Text.TextGetOptions.FormatRtf, out string labeltext);
            labelBox.Document.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, labeltext);

            var contentDialog = new ContentDialog
            {
                Title               = "WCT_TextToolbar_CreateLinkLabel".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls.Core/Resources"),
                Content             = contentPanel,
                PrimaryButtonText   = "WCT_TextToolbar_OkLabel".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls.Core/Resources"),
                SecondaryButtonText = "WCT_TextToolbar_CancelLabel".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls.Core/Resources")
            };

            if (ControlHelpers.IsXamlRootAvailable && button.XamlRoot != null)
            {
                contentDialog.XamlRoot = button.XamlRoot;
            }

            var result = await contentDialog.ShowAsync();

            if (result == ContentDialogResult.Primary)
            {
                labelBox.Document.GetText(Windows.UI.Text.TextGetOptions.None, out string labelText);
                labelBox.Document.GetText(Windows.UI.Text.TextGetOptions.FormatRtf, out string formattedlabelText);

                string linkInvalidLabel = "WCT_TextToolbar_LinkInvalidLabel".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls.Core/Resources");
                string okLabel          = "WCT_TextToolbar_OkLabel".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls.Core/Resources");
                string warningLabel     = "WCT_TextToolbar_WarningLabel".GetLocalized("Microsoft.Toolkit.Uwp.UI.Controls.Core/Resources");
                string linkText         = linkBox.Text.Trim();

                if (string.IsNullOrWhiteSpace(linkText))
                {
                    ShowContentDialog(warningLabel, linkInvalidLabel, okLabel, button);
                    return;
                }

                if (Model.UseURIChecker && !string.IsNullOrWhiteSpace(linkText))
                {
                    var wellFormed = Uri.IsWellFormedUriString(linkText, relativeBox?.IsChecked == true ? UriKind.RelativeOrAbsolute : UriKind.Absolute);
                    if (!wellFormed)
                    {
                        ShowContentDialog(warningLabel, linkInvalidLabel, okLabel, button);
                        return;
                    }
                }

                Model.Formatter.ButtonActions.FormatLink(button, labelText.Trim(), formattedlabelText.Trim(), linkText);
            }
        }
Example #41
0
        public Items()
        {
            this.InitializeComponent();

            //start displaying the items records
            Query q = new Query();

            q.GetExtra("SELECT item_name,item_cost,quantity_left,quantity_consumed,date_time,_added_by FROM items");
            q.Records();
            int   items_row = q.CountRows();
            Query item_id   = new Query();

            item_id.Get("items");
            item_id.Records();
            //AMOUNT OF COLUMN DEFINITIONS
            int    col_num = Convert.ToInt32(items_r.ColumnDefinitions.Count);
            Filter f       = new Filter();

            //  RowDefinition[] rd = new RowDefinition[q.CountRows()];
            // RowDefinition rd;

            bool check_records = q.CheckRecords();

            //STACKPANEL TO HOLD THE ROWS
            // StackPanel parent_row_panel;
            //WE'RE ADDING +1 CAUSE THERE'S ALREADY A ROW DEFINED WHICH IT'S VALUE WOULD BE ZERO
            //SO IF WE DONT INCREMENT IT, IT STARTS WITH 0, WHICH MIGHT BE A BAD IDEA :(.
            //int i = 0;
            //now check the number of rows
            //keep adding rows as long as it doesn't exceed the row limit from the stupid database.

            int i = 0;

            if (check_records)
            {
                for (i = 0; i < (items_row); i++)
                {
                    RowDefinition rd = new RowDefinition();
                    //rd.Height = new GridLength(50);
                    items_r.RowDefinitions.Add(rd);

                    /*
                     * COLUMN DEFINITION
                     * CREATE COLUMNS ACCORDING TO THE PARENT COLUMN OF THE FIRST ROW, WHICH IS col_num.
                     */

                    //////////////////////////////////
                    int k = 0;
                    for (k = 0; k < col_num; k++)
                    {
                        ColumnDefinition cd = new ColumnDefinition();
                        //cd.Width = new GridLength();
                        //cd.MinWidth = 150;

                        items_r.ColumnDefinitions.Add(cd);

                        //reset column def so that when it starts looping the for again, it creates a new set of column definition
                        //column_def = 0;


                        //////////////////////////////////////////////////////////
                        Border border = new Border();

                        TextBlock n = new TextBlock();
                        n.FontSize = 17.3;

                        n.Foreground = new SolidColorBrush(Color.FromArgb(180, 0, 0, 0));


                        ///////////////////////////////////////
                        //stackpanel
                        StackPanel pa = new StackPanel();
                        // pa.Style = new Style();
                        //StackPanel m_pa = new StackPanel();
                        // m_pa.Name = "p";// + i.ToString();
                        StackPanel row_holder = new StackPanel();
                        //row_holder.Orientation = new Orientation();
                        // Orientation orie = row_holder1.Orientation;

                        //add
                        //pa.
                        pa.Children.Add(n);
                        pa.Margin = new Thickness(10);
                        //pa.MaxWidth = 115;
                        pa.HorizontalAlignment = HorizontalAlignment.Center;
                        //border.Style = new Windows.UI.Xaml.Style();
                        //border.Style.TargetType = typeof(Border);
                        border.BorderThickness = new Thickness(0, 0, 0, 1);
                        border.BorderBrush     = new SolidColorBrush(Color.FromArgb(50, 0, 0, 0));
                        //calculate odd and even ish
                        int calc = i % 2;
                        //border.MaxWidth = 115;
                        // border.MinHeight = 61;
                        border.Child = pa;
                        row_holder.Children.Add(border);



                        int calcu = col_num - k;
                        //CHECK WHAT TO INPUT

                        if (calcu == 1)
                        {//LAST VALUE
                        }
                        else if (k == 2 || k == 3)
                        {
                            if (q.Results[i, k] == "0")
                            {
                                n.Text = "None";
                            }
                            else
                            {
                                n.Text = f.Numbers(Convert.ToInt32(q.Results[i, k]));
                            }
                        }
                        else if (k == 4)
                        {
                            n.Text = f.Date(q.Results[i, k], "dd/MM/yyyy");
                        }
                        else if (calcu == 2)
                        {//second to the last value, add added by
                            Query inner_q = new Query();
                            inner_q.Get("staffs", "WHERE staff_id ='" + q.Results[i, 5] + "'");
                            if (inner_q.CheckRecords() == true)
                            {
                                inner_q.Record();
                                string person = "";
                                if ((App.Current as App).User_token.ToString() == inner_q.Result[0])
                                {
                                    person = "You";
                                }
                                else
                                {
                                    person = inner_q.Result[1];
                                }

                                n.Text = person;
                            }
                            else
                            {
                                n.Text = "Not Available";
                            }
                        }
                        else
                        {
                            n.Text = q.Results[i, k];
                        }
                        //TextBlock



                        //////////////OPTION
                        StackPanel option_panel  = new StackPanel();
                        Border     option_border = new Border();
                        //////////////////////////////////////////////////////

                        ////FOR CHANGING THE ROW BACKGROUND.
                        if (calc == 1)
                        {
                            border.Background        = new SolidColorBrush(Color.FromArgb(250, 215, 215, 215));
                            option_border.Background = new SolidColorBrush(Color.FromArgb(250, 215, 215, 215));
                        }
                        else
                        {
                            border.Background        = new SolidColorBrush(Color.FromArgb(250, 236, 254, 251));
                            option_border.Background = new SolidColorBrush(Color.FromArgb(250, 226, 246, 241));
                        }

                        //DETERMINE WHEN TO ADD THE OPTION STUFF

                        if (calcu == 1)
                        {//CREATE THE OPTIONS STUFF
                            StackPanel option_inner_panel = new StackPanel();
                            //TO MAKE THINGS EASY JARE,LOOP IT THROUGH THE ARRAY
                            string[] stuff_text  = { "Edit", "Delete" };
                            string[] stuff_image = { "", "" };
                            HyperlinkButton[,] link = new HyperlinkButton[items_row, stuff_text.Length];
                            int reduce = i;
                            if (i == items_row)
                            {
                                reduce = i - 1;
                            }

                            for (int t = 0; t < stuff_text.Length; t++)
                            {
                                option_border.BorderThickness = new Thickness(0, 0, 0, 1);
                                option_border.BorderBrush     = new SolidColorBrush(Color.FromArgb(50, 0, 0, 0));
                                TextBlock option_txt = new TextBlock();
                                option_txt.Text              = stuff_text[t];
                                option_txt.Foreground        = new SolidColorBrush(Color.FromArgb(150, 0, 0, 0));
                                option_txt.FontSize          = 15;
                                option_txt.Margin            = new Thickness(10, 0, 0, 0);
                                option_txt.VerticalAlignment = VerticalAlignment.Center;
                                // Button button = new Button();
                                link[i, t] = new HyperlinkButton();

                                //HyperlinkButton[] link = new HyperlinkButton[tests_row];
                                link[i, t].Content = option_txt.Text;
                                // link.Click = RoutedEventHandler.Combine(sender, RoutedEventArgs e);
                                //button.ClickMode = ClickMode.Hover;
                                //CLICK EVENT
                                int reduce_t = t;
                                if (t == stuff_text.Length)
                                {
                                    reduce_t = t - 1;
                                }
                                //link[i].Click += new RoutedEventHandler(EditRecord_Click("E",));
                                link[i, t].Click += (s, e) =>
                                {
                                    if ((string)link[reduce, reduce_t].Content == stuff_text[0])
                                    {//IT's edit
                                        tracker = new EditTracker("items", "item_id", item_id.Results[(reduce), 0]);
                                        //track the row.
                                        tracker.Track();

                                        Auth auth = new Auth();
                                        if (auth.CheckOwner("Items", "item_id", item_id.Results[reduce, 0]) != true)
                                        {
                                            PopUp p = new PopUp("Sorry, You can't edit Item " + tracker.TrackResult[1] + "'s record cause you didn't add the record");
                                        }

                                        else
                                        {
                                            if (!Editing.IsOpen)
                                            {
                                                //OPEN
                                                this.Frame.Opacity = .4;

                                                //this.Opacity = .4;
                                                parent.IsEnabled = false;
                                                //SET THE EDIT TRACKER
                                                //I DID (i-1) BECAUSE IT WAS INCREASE BY ONE, THEREFORE OUT OF BOUND ISH.
                                                this.i_id         = tracker.TrackResult[0];//set the id to the global var, so that we know what to edit.
                                                i_name_e.Text     = tracker.TrackResult[1];
                                                i_cost_e.Text     = tracker.TrackResult[2];
                                                i_quantity_e.Text = tracker.TrackResult[3];

                                                Editing.IsOpen = true;
                                            }
                                        }
                                    }
                                    else if ((string)link[reduce, reduce_t].Content == stuff_text[1])
                                    {//it's the delete.
                                        tracker = new EditTracker("items", "item_id", item_id.Results[(reduce), 0]);
                                        //track the row
                                        tracker.Track();

                                        Auth auth = new Auth();
                                        if (auth.CheckOwner("Items", "item_id", item_id.Results[reduce, 0]) != true)
                                        {
                                            PopUp p = new PopUp("Sorry, You can't delete this item's record cause you didn't add the record");
                                        }
                                        else
                                        {
                                            this.Frame.Opacity = .4;

                                            //this.Opacity = .4;
                                            parent.IsEnabled = false;

                                            Messages msg = new Messages();
                                            msg.Confirm("Are you sure you want to delete this item's record?");
                                            msg.p_container.IsOpen = true;
                                            parent_grid.Children.Add(msg.p_container);

                                            msg.TrueBtn.Click += (z, x) =>
                                            {
                                                //CALL THE DELETE QUERY
                                                Query que = new Query();
                                                que.successMessage = "Item " + tracker.TrackResult[1] + " with id(" + tracker.TrackResult[0] + ") has been deleted.";

                                                que.Remove("Items", "Where item_id = '" + item_id.Results[(reduce), 0] + "'");
                                                this.Frame.Opacity = 1;

                                                this.Frame.Navigate(typeof(Items), null);
                                            };

                                            msg.FalseBtn.Click += (z, x) =>
                                            {
                                                this.Frame.Opacity = 1;

                                                parent.IsEnabled = true;
                                            };
                                        }
                                    }
                                };

                                ////ADDING
                                option_inner_panel.Children.Add(link[i, t]);
                            }
                            option_panel.Children.Add(option_inner_panel);
                            option_inner_panel.Orientation = Orientation.Horizontal;
                            option_panel.VerticalAlignment = VerticalAlignment.Center;
                            option_border.Child            = option_panel;
                            Grid.SetColumn(option_border, k);
                            Grid.SetRow(option_border, i + 1);
                            items_r.Children.Add(option_border);
                        }

                        else
                        {
                            Grid.SetRow(row_holder, i + 1);

                            Grid.SetColumn(row_holder, k);
                            items_r.Children.Add(row_holder);
                        }
                    }
                }
            }
            else
            {
                //NO RECORD
                Messages msg = new Messages();
                msg.Note("No items record available.");
                items_r.Children.Add(msg._b_Container);
                RowDefinition rd = new RowDefinition();
                // rd.Height = new GridLength(50);
                items_r.RowDefinitions.Add(rd);
                Grid.SetColumnSpan(msg._b_Container, col_num);
                Grid.SetColumn(msg._b_Container, 0);
                Grid.SetRow(msg._b_Container, 1);
            }
        }
Example #42
0
                static void ApplySizeLimit(StackPanel quickInfoPanel)
                {
                    if (quickInfoPanel == null)
                    {
                        return;
                    }
                    var docPanel        = quickInfoPanel.Children[0].GetFirstVisualChild <WrapPanel>().GetParent <StackPanel>();
                    var docPanelHandled = docPanel == null;                     // don't process docPanel if it is not found

                    foreach (var item in quickInfoPanel.Children)
                    {
                        var o = item as DependencyObject;
                        if (o == null)
                        {
                            continue;
                        }
                        var cp = o.GetFirstVisualChild <ContentPresenter>();
                        if (cp == null)
                        {
                            continue;
                        }
                        var c = cp.Content;
                        if (c is Overrider || c is IInteractiveQuickInfoContent /* don't hack interactive content */)
                        {
                            continue;
                        }
                        if (docPanel == c || docPanelHandled == false && cp.GetFirstVisualChild <StackPanel>(i => i == docPanel) != null)
                        {
                            cp.LimitSize();
                            if (Config.Instance.QuickInfoXmlDocExtraHeight > 0 && Config.Instance.QuickInfoMaxHeight > 0)
                            {
                                cp.MaxHeight += Config.Instance.QuickInfoXmlDocExtraHeight;
                            }
                            foreach (var r in docPanel.Children)
                            {
                                (r as ThemedTipDocument)?.ApplySizeLimit();
                            }
                            c               = cp.Content;
                            cp.Content      = null;
                            cp.Content      = ((DependencyObject)c).Scrollable();
                            docPanelHandled = true;
                            continue;
                        }
                        else if (c is StackPanel s)
                        {
                            MakeChildrenScrollable(s);
                            continue;
                        }
                        (c as ThemedTipDocument)?.ApplySizeLimit();
                        if (c is ScrollViewer)
                        {
                            continue;
                        }
                        var v = c as IWpfTextView;                         // snippet tooltip, some other default tooltip
                        if (v != null)
                        {
                            // use the custom control to enable selection
                            cp.Content = new ThemedTipText {
                                Text = v.TextSnapshot.GetText()
                            }.Scrollable().LimitSize();
                            //v.VisualElement.LimitSize();
                            //v.Options.SetOptionValue(DefaultTextViewHostOptions.VerticalScrollBarName, true);
                            //v.Options.SetOptionValue(DefaultTextViewOptions.WordWrapStyleName, WordWrapStyles.WordWrap);
                            //v.Options.SetOptionValue(DefaultTextViewOptions.AutoScrollName, true);
                            continue;
                        }
                        o = c as DependencyObject;
                        if (o == null)
                        {
                            var s = c as string;
                            if (s != null)
                            {
                                cp.Content = new ThemedTipText {
                                    Text = s
                                }.Scrollable();
                            }
                            continue;
                        }
                        if (cp.Content is ItemsControl items && items.GetType().Name == "WpfToolTipItemsControl")
                        {
                            try {
                                MakeChildrenScrollable(items);
                                continue;
                            }
                            catch (InvalidOperationException) {
                                // ignore
#if DEBUG
                                throw;
#endif
                            }
                        }
                        cp.Content = null;
                        cp.Content = o.Scrollable();
                    }
                }
        private void btnValidate_Click(object sender, RoutedEventArgs e)
        {
            List <TextBox> taxaErrors   = new List <TextBox>();
            List <String>  stringErrors = new List <String>();



            for (int i = 0; i < TaxaText.Count; i++)
            {
                TaxaText[i].Background = new SolidColorBrush(Colors.Black);
                DataText[i].Background = new SolidColorBrush(Colors.LightGray);
                TextBox matrixBox = DataText[i];
                if (string.IsNullOrEmpty(TaxaText[i].Text))
                {
                    taxaErrors.Add(TaxaText[i]);
                    stringErrors.Add("Empty input value.");
                    TaxaText[i].Background = new SolidColorBrush(Colors.LightSalmon);
                }
                if (string.IsNullOrEmpty(matrixBox.Text))
                {
                    taxaErrors.Add(matrixBox);
                    stringErrors.Add("Empty input value.");
                    DataText[i].Background = new SolidColorBrush(Colors.LightSalmon);
                }
                else if (matrixBox.Text.Length != charLength)
                {
                    stringErrors.Add("Matrix doesn't have " + charLength + " characters.");
                    DataText[i].Background = new SolidColorBrush(Colors.LightSalmon);
                }
                //else if (App.f.C.dataSelection == 1)
                //{
                //    // List<char> charList = new List<char> { 'G', 'g', 'A', 'a', 'T', 't', 'C', 'c', App.f.C.gapChar, App.f.C.missingChar };
                //    string error;
                //    string seqchars = App.f.C.SequenceChars;
                //    for (int x = 0; x < matrixBox.Text.Length; x++)
                //    {
                //        if (!seqchars.Contains(matrixBox.Text[x]))
                //        {
                //            error = "Protein Matrix contains obscure characters. Only ";// or the chosen gap and missing characters permitted.");
                //            for(int r=0; r< seqchars.Length; r++)
                //            {
                //                error += seqchars[r] + ", ";
                //            }
                //            error += "or the chosen gap and missing characters permitted.";
                //            stringErrors.Add(error);
                //            error = "";
                //            DataText[i].Background = new SolidColorBrush(Colors.LightSalmon);
                //            break;
                //        }
                //    }

                //}
                //else if (App.f.C.dataSelection == 2)
                //{
                //    string error;
                //    string morphchars = App.f.C.MorphChars;
                //    for (int x = 0; x < matrixBox.Text.Length; x++)
                //    {
                //        if (!morphchars.Contains(matrixBox.Text[x]))
                //        {
                //            error = "Protein Matrix contains obscure characters. Only ";// or the chosen gap and missing characters permitted.");
                //            for (int r = 0; r < morphchars.Length; r++)
                //            {
                //                error += morphchars[r] + ", ";
                //            }
                //            error += "or the chosen gap and missing characters permitted.";
                //            stringErrors.Add(error);
                //            error = "";
                //            DataText[i].Background = new SolidColorBrush(Colors.LightSalmon);
                //            break;
                //        }
                //    }

                //}
                //else if (App.f.C.dataSelection  ==3)
                //{
                //    List<char> charList = new List<char> { 'G', 'g', 'A', 'a', 'T', 't', 'C', 'c', App.f.C.gapChar, App.f.C.missingChar };
                //    for(int x=0; x< matrixBox.Text.Length; x++)
                //    {
                //        if(!charList.Contains(matrixBox.Text[x]))
                //        {
                //            stringErrors.Add("Protein Matrix contains obscure characters. Only G,A,T,C or the chosen gap and missing characters permitted.");
                //            DataText[i].Background = new SolidColorBrush(Colors.LightSalmon);
                //            break;
                //        }
                //    }

                //}
            }
            if (stringErrors.Count > 0)
            {
                TextBox ErrorText = new TextBox();
                ErrorText.Name         = "errors";
                ErrorText.Width        = 300;
                ErrorText.Height       = 300;
                ErrorText.FontSize     = 12;
                ErrorText.TextWrapping = TextWrapping.Wrap;
                ErrorText.Background   = new SolidColorBrush(Colors.Gainsboro);
                ErrorText.Text         = "The following " + taxaErrors.Count + " errors must be fixed before you can continue: " + System.Environment.NewLine;
                for (int i = 0; i < stringErrors.Count; i++)
                {
                    ErrorText.Text += stringErrors[i] + System.Environment.NewLine;
                }
                StackPanel s = new StackPanel();
                s.Orientation         = Orientation.Horizontal;
                s.HorizontalAlignment = HorizontalAlignment.Center;
                s.Children.Add(ErrorText);
                ScrollError.Content = s;
            }
            else
            {
                //add to nexus  //add data to general nexus file and pass tp Page3.xaml
                //  App.f.C = new Seq();
                List <String> TaxaStrings = new List <String>();
                List <String> DataStrings = new List <String>();

                App.f.C.sequences = new List <Sequence>();
                foreach (TextBox s in TaxaText)
                {
                    TaxaStrings.Add(s.Text);
                }
                foreach (TextBox s in DataText)
                {
                    DataStrings.Add(s.Text);
                }
                for (int i = 0; i < numOfTaxaPanels; i++)
                {
                    App.f.C.sequences.Add(new Sequence(TaxaStrings[i], DataStrings[i]));
                }
                this.Frame.Navigate(typeof(Page3));
            }


            //NavigationService nav = NavigationService.GetNavigationService(this);
            //nav.Navigate(new Page3());
        }
Example #44
0
                void FixQuickInfo(StackPanel infoPanel)
                {
                    var titlePanel = infoPanel.GetFirstVisualChild <WrapPanel>();

                    if (titlePanel == null)
                    {
                        return;
                    }
                    var doc = titlePanel.GetParent <StackPanel>();

                    if (doc == null)
                    {
                        return;
                    }
                    var v16_1orLater = titlePanel.GetParent <ItemsControl>().GetParent <ItemsControl>() != null;

                    titlePanel.HorizontalAlignment = HorizontalAlignment.Stretch;
                    doc.HorizontalAlignment        = HorizontalAlignment.Stretch;

                    var icon      = infoPanel.GetFirstVisualChild <CrispImage>();
                    var signature = infoPanel.GetFirstVisualChild <TextBlock>();

                    // beautify the title panel
                    if (Config.Instance.QuickInfoOptions.MatchFlags(QuickInfoOptions.AlternativeStyle))
                    {
                        if (icon != null)
                        {
                            infoPanel.GetParent <Border>().Background = new VisualBrush(CreateEnlargedIcon(icon))
                            {
                                Opacity    = 0.3,
                                AlignmentX = AlignmentX.Right,
                                AlignmentY = AlignmentY.Bottom,
                                TileMode   = TileMode.None,
                                Stretch    = Stretch.None
                            };
                            icon.Visibility = Visibility.Collapsed;
                        }
                        if (signature != null)
                        {
                            var list = (IList)signature.Inlines;
                            for (var i = 0; i < list.Count; i++)
                            {
                                if (list[i] is Hyperlink link)
                                {
                                    var r = link.Inlines.FirstInline as Run;
                                    if (r != null)
                                    {
                                        list[i] = new Run {
                                            Text = r.Text, Foreground = r.Foreground, Background = r.Background
                                        };
                                    }
                                }
                            }
                        }
                        var c = infoPanel.GetParent <Border>();
                        c.Margin          = __DocPanelBorderMargin;
                        c.Padding         = __DocPanelBorderPadding;
                        c.MinHeight       = 50;
                        titlePanel.Margin = __TitlePanelMargin;
                    }

                    #region Override documentation
                    // https://github.com/dotnet/roslyn/blob/version-3.0.0/src/Features/Core/Portable/QuickInfo/CommonSemanticQuickInfoProvider.cs
                    // replace the default XML doc
                    // sequence of items in default XML Doc panel:
                    // 1. summary
                    // 2. generic type parameter
                    // 3. anonymous types
                    // 4. availability warning
                    // 5. usage
                    // 6. exception
                    // 7. captured variables
                    var items = doc.IsItemsHost ? (IList)doc.GetParent <ItemsControl>().Items : doc.Children;
                    if (KeepBuiltInXmlDoc == false)
                    {
                        ClearDefaultDocumentationItems(doc, v16_1orLater, items);
                    }
                    if (DocElement != null)
                    {
                        OverrideDocElement(doc, v16_1orLater, items);
                    }
                    if (ExceptionDoc != null)
                    {
                        OverrideExceptionDocElement(doc, v16_1orLater, items);
                    }
                    #endregion

                    if (icon != null && signature != null)
                    {
                        // apply click and go feature
                        if (ClickAndGoSymbol != null)
                        {
                            QuickInfoOverrider.ApplyClickAndGo(ClickAndGoSymbol, TextBuffer, signature, QuickInfoSession);
                        }
                        // fix the width of the signature part to prevent it from falling down to the next row
                        if (Config.Instance.QuickInfoMaxWidth >= 100)
                        {
                            signature.MaxWidth = Config.Instance.QuickInfoMaxWidth - icon.Width - 30;
                        }
                    }
                }
Example #45
0
        public FunkyWindow()
        {
            Settings_Funky.LoadFunkyConfiguration();

            Owner         = App.Current.MainWindow;
            Title         = "Funky Settings -- " + Bot.Character.Account.CurrentHeroName;
            SizeToContent = SizeToContent.WidthAndHeight;
            ResizeMode    = ResizeMode.CanMinimize;
            Background    = Brushes.Black;
            Foreground    = Brushes.PaleGoldenrod;
            //this.Width=600;
            //this.Height=600;

            ListBox LBWindowContent = new ListBox
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
            };

            Menu Menu_Settings = new Menu
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
            };
            MenuItem Menu_Defaults = new MenuItem
            {
                Header   = "Settings",
                Height   = 25,
                FontSize = 12,
            };
            MenuItem Menu_Default_Open = new MenuItem
            {
                Header   = "Open File..",
                Height   = 25,
                FontSize = 12,
            };

            Menu_Default_Open.Click += DefaultMenuLoadProfileClicked;
            Menu_Defaults.Items.Add(Menu_Default_Open);
            MenuItem Menu_Default_Leveling = new MenuItem
            {
                Header   = "Use Default Leveling",
                Height   = 25,
                FontSize = 12,
            };

            Menu_Default_Leveling.Click += DefaultMenuLevelingClicked;
            Menu_Defaults.Items.Add(Menu_Default_Leveling);
            MenuItem Menu_ViewSettingFile = new MenuItem
            {
                Header   = "Open Settings File",
                Height   = 25,
                FontSize = 12,
            };

            Menu_ViewSettingFile.Click += DefaultOpenSettingsFileClicked;
            Menu_Defaults.Items.Add(Menu_ViewSettingFile);

            Menu_Settings.Items.Add(Menu_Defaults);
            LBWindowContent.Items.Add(Menu_Settings);

            TabControl tabControl1 = new TabControl
            {
                Width  = 600,
                Height = 600,
                HorizontalAlignment        = HorizontalAlignment.Stretch,
                VerticalAlignment          = VerticalAlignment.Stretch,
                VerticalContentAlignment   = VerticalAlignment.Stretch,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                FontSize = 12,
            };

            LBWindowContent.Items.Add(tabControl1);

            #region Combat
            //Character
            TabItem CombatSettingsTabItem = new TabItem();
            CombatSettingsTabItem.Header = "Combat";

            tabControl1.Items.Add(CombatSettingsTabItem);
            CombatTabControl = new TabControl
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment   = VerticalAlignment.Stretch,
            };

            InitCombatControls();

            InitClusteringControls();

            InitGroupingControls();

            InitAvoidanceControls();

            InitFleeingControls();

            InitPlayerClassControls();



            CombatSettingsTabItem.Content = CombatTabControl;
            #endregion


            #region Targeting
            TabItem TargetTabItem = new TabItem();
            TargetTabItem.Header = "Targeting";
            tabControl1.Items.Add(TargetTabItem);

            tcTargeting = new TabControl
            {
                Height    = 600,
                Width     = 600,
                Focusable = false,
            };

            InitTargetingGeneralControls();
            InitTargetRangeControls();
            InitLOSMovementControls();

            TargetTabItem.Content = tcTargeting;

            #endregion


            #region General
            tcGeneral = new TabControl
            {
                Width  = 600,
                Height = 600,
            };

            TabItem GeneralSettingsTabItem = new TabItem();
            GeneralSettingsTabItem.Header = "General";
            tabControl1.Items.Add(GeneralSettingsTabItem);

            InitGeneralControls();

            GeneralSettingsTabItem.Content = tcGeneral;
            #endregion


            #region Items


            TabItem CustomSettingsTabItem = new TabItem();
            CustomSettingsTabItem.Header = "Items";
            tabControl1.Items.Add(CustomSettingsTabItem);

            tcItems = new TabControl
            {
                Width  = 600,
                Height = 600
            };

            InitItemRulesControls();
            InitLootPickUpControls();
            InitItemScoringControls();

            CustomSettingsTabItem.Content = tcItems;
            #endregion


            TabItem AdvancedTabItem = new TabItem();
            AdvancedTabItem.Header = "Advanced";
            tabControl1.Items.Add(AdvancedTabItem);
            ListBox lbAdvancedContent = new ListBox();

            #region Debug Logging
            StackPanel SPLoggingOptions    = new StackPanel();
            TextBlock  Logging_Text_Header = new TextBlock
            {
                Text                = "Debug Output Options",
                FontSize            = 12,
                Background          = Brushes.LightSeaGreen,
                TextAlignment       = TextAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Stretch,
            };
            SPLoggingOptions.Children.Add(Logging_Text_Header);

            CheckBox CBDebugStatusBar = new CheckBox
            {
                Content   = "Enable Debug Status Bar",
                Width     = 300,
                Height    = 20,
                IsChecked = Bot.Settings.Debug.DebugStatusBar,
            };
            CBDebugStatusBar.Checked   += DebugStatusBarChecked;
            CBDebugStatusBar.Unchecked += DebugStatusBarChecked;
            SPLoggingOptions.Children.Add(CBDebugStatusBar);


            TextBlock Logging_FunkyLogLevels_Header = new TextBlock
            {
                Text                = "Funky Logging Options",
                FontSize            = 12,
                Background          = Brushes.MediumSeaGreen,
                TextAlignment       = TextAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Stretch,
            };

            StackPanel panelFunkyLogFlags = new StackPanel
            {
                Orientation       = Orientation.Vertical,
                VerticalAlignment = VerticalAlignment.Stretch,
            };
            panelFunkyLogFlags.Children.Add(Logging_FunkyLogLevels_Header);

            var LogLevels = Enum.GetValues(typeof(LogLevel));
            Logger.GetLogLevelName fRetrieveNames = s => Enum.GetName(typeof(LogLevel), s);

            CBLogLevels = new CheckBox[LogLevels.Length - 2];
            int  counter = 0;
            bool noFlags = Bot.Settings.Debug.FunkyLogFlags.Equals(LogLevel.None);
            foreach (var logLevel in LogLevels)
            {
                LogLevel thisloglevel = (LogLevel)logLevel;
                if (thisloglevel.Equals(LogLevel.None) || thisloglevel.Equals(LogLevel.All))
                {
                    continue;
                }

                string loglevelName = fRetrieveNames(logLevel);
                CBLogLevels[counter] = new CheckBox
                {
                    Name      = loglevelName,
                    Content   = loglevelName,
                    IsChecked = !noFlags?Bot.Settings.Debug.FunkyLogFlags.HasFlag(thisloglevel) : false,
                };
                CBLogLevels[counter].Checked   += FunkyLogLevelChanged;
                CBLogLevels[counter].Unchecked += FunkyLogLevelChanged;

                panelFunkyLogFlags.Children.Add(CBLogLevels[counter]);
                counter++;
            }

            StackPanel  StackPanelLogLevelComboBoxes = new StackPanel();
            RadioButton cbLogLevelNone = new RadioButton
            {
                Name    = "LogLevelNone",
                Content = "None",
            };
            cbLogLevelNone.Checked += FunkyLogLevelComboBoxSelected;
            RadioButton cbLogLevelAll = new RadioButton
            {
                Name    = "LogLevelAll",
                Content = "All",
            };
            cbLogLevelAll.Checked += FunkyLogLevelComboBoxSelected;

            StackPanelLogLevelComboBoxes.Children.Add(cbLogLevelNone);
            StackPanelLogLevelComboBoxes.Children.Add(cbLogLevelAll);
            panelFunkyLogFlags.Children.Add(StackPanelLogLevelComboBoxes);

            SPLoggingOptions.Children.Add(panelFunkyLogFlags);

            lbAdvancedContent.Items.Add(SPLoggingOptions);
            #endregion



            CheckBox CBSkipAhead = new CheckBox
            {
                Content   = "Skip Ahead Feature (TrinityMoveTo/Explore)",
                Width     = 300,
                Height    = 20,
                IsChecked = Bot.Settings.Debug.SkipAhead,
            };
            CBSkipAhead.Checked   += SkipAheadChecked;
            CBSkipAhead.Unchecked += SkipAheadChecked;
            lbAdvancedContent.Items.Add(CBSkipAhead);


            //CheckBox CBLineOfSightBehavior = new CheckBox
            //{
            //    Content = "Enable Line-Of-Sight Behavior",
            //    Width = 300,
            //    Height = 20,
            //    IsChecked = Bot.Settings.Plugin.EnableLineOfSightBehavior,
            //};
            //CBLineOfSightBehavior.Checked += LineOfSightBehaviorChecked;
            //CBLineOfSightBehavior.Unchecked += LineOfSightBehaviorChecked;
            //lbAdvancedContent.Items.Add(CBLineOfSightBehavior);

            AdvancedTabItem.Content = lbAdvancedContent;

            TabItem MiscTabItem = new TabItem();
            MiscTabItem.Header = "Misc";
            tabControl1.Items.Add(MiscTabItem);
            ListBox lbMiscContent = new ListBox();
            try
            {
                GameStats cur = Bot.Game.CurrentGameStats;
                lbMiscContent.Items.Add("\r\n== CURRENT GAME SUMMARY ==");
                lbMiscContent.Items.Add(String.Format("Total Profiles:{0}\r\nDeaths:{1} TotalTime:{2} TotalGold:{3} TotalXP:{4}\r\n{5}",
                                                      cur.Profiles.Count, cur.TotalDeaths, cur.TotalTimeRunning.ToString(@"hh\ \h\ mm\ \m\ ss\ \s"), cur.TotalGold, cur.TotalXP, cur.TotalLootTracker.ToString()));

                if (Bot.Game.CurrentGameStats.Profiles.Count > 0)
                {
                    lbMiscContent.Items.Add("\r\n== PROFILES ==");
                    foreach (var item in Bot.Game.CurrentGameStats.Profiles)
                    {
                        lbMiscContent.Items.Add(String.Format("{0}\r\nDeaths:{1} TotalTime:{2} TotalGold:{3} TotalXP:{4}\r\n{5}",
                                                              item.ProfileName, item.DeathCount, item.TotalTimeSpan.ToString(@"hh\ \h\ mm\ \m\ ss\ \s"), item.TotalGold, item.TotalXP, item.LootTracker.ToString()));
                    }
                }


                TotalStats all = Bot.Game.TrackingStats;
                lbMiscContent.Items.Add("\r\n== CURRENT GAME SUMMARY ==");
                lbMiscContent.Items.Add(String.Format("Total Games:{0} -- Total Unique Profiles:{1}\r\nDeaths:{2} TotalTime:{3} TotalGold:{4} TotalXP:{5}\r\n{6}",
                                                      all.GameCount, all.Profiles.Count, all.TotalDeaths, all.TotalTimeRunning.ToString(@"hh\ \h\ mm\ \m\ ss\ \s"), all.TotalGold, all.TotalXP, all.TotalLootTracker.ToString()));
            }
            catch
            {
                lbMiscContent.Items.Add("Exception Handled");
            }

            MiscTabItem.Content = lbMiscContent;



            TabItem DebuggingTabItem = new TabItem
            {
                Header = "Debug",
                VerticalContentAlignment = VerticalAlignment.Stretch,
                VerticalAlignment        = VerticalAlignment.Stretch,
            };
            tabControl1.Items.Add(DebuggingTabItem);
            DockPanel DockPanel_Debug = new DockPanel
            {
                LastChildFill = true,
                FlowDirection = FlowDirection.LeftToRight,
            };


            Button btnObjects_Debug = new Button
            {
                Content  = "Object Cache",
                FontSize = 10,
                Width    = 80,
                Height   = 25,
                Name     = "Objects",
            };
            btnObjects_Debug.Click += DebugButtonClicked;
            Button btnObstacles_Debug = new Button
            {
                Content  = "Obstacle Cache",
                Width    = 80,
                FontSize = 10,
                Height   = 25,
                Name     = "Obstacles",
            };
            btnObstacles_Debug.Click += DebugButtonClicked;
            Button btnSNO_Debug = new Button
            {
                Content  = "SNO Cache",
                FontSize = 10,
                Width    = 80,
                Height   = 25,
                Name     = "SNO",
            };
            btnSNO_Debug.Click += DebugButtonClicked;
            Button btnAbility_Debug = new Button
            {
                Content  = "Ability Cache",
                FontSize = 10,
                Width    = 80,
                Height   = 25,
                Name     = "Ability",
            };
            btnAbility_Debug.Click += DebugButtonClicked;
            Button btnMGP_Debug = new Button
            {
                Content = "MGP Details",
                Width   = 150,
                Height  = 25,
                Name    = "MGP",
            };
            btnMGP_Debug.Click += DebugButtonClicked;
            Button btnCharacterCache_Debug = new Button
            {
                Content  = "Character",
                FontSize = 10,
                Width    = 80,
                Height   = 25,
                Name     = "CHARACTER",
            };
            btnCharacterCache_Debug.Click += DebugButtonClicked;
            Button btnTargetMovement_Debug = new Button
            {
                Content  = "TargetMove",
                FontSize = 10,
                Width    = 80,
                Height   = 25,
                Name     = "TargetMove",
            };
            btnTargetMovement_Debug.Click += DebugButtonClicked;
            Button btnCombatCache_Debug = new Button
            {
                Content  = "CombatCache",
                FontSize = 10,
                Width    = 80,
                Height   = 25,
                Name     = "CombatCache",
            };
            btnCombatCache_Debug.Click += DebugButtonClicked;
            Button btnTEST_Debug = new Button
            {
                Content  = "Test",
                FontSize = 10,
                Width    = 80,
                Height   = 25,
                Name     = "TEST",
            };
            btnTEST_Debug.Click += DebugButtonClicked;



            StackPanel StackPanel_DebugButtons = new StackPanel
            {
                Height = 40,
                HorizontalAlignment = HorizontalAlignment.Stretch,
                FlowDirection       = FlowDirection.LeftToRight,
                Orientation         = Orientation.Horizontal,
                VerticalAlignment   = VerticalAlignment.Top,
            };
            StackPanel_DebugButtons.Children.Add(btnObjects_Debug);
            StackPanel_DebugButtons.Children.Add(btnObstacles_Debug);
            StackPanel_DebugButtons.Children.Add(btnSNO_Debug);
            StackPanel_DebugButtons.Children.Add(btnAbility_Debug);
            StackPanel_DebugButtons.Children.Add(btnCharacterCache_Debug);
            StackPanel_DebugButtons.Children.Add(btnCombatCache_Debug);
            StackPanel_DebugButtons.Children.Add(btnTEST_Debug);

            //StackPanel_DebugButtons.Children.Add(btnGPC_Debug);

            DockPanel.SetDock(StackPanel_DebugButtons, Dock.Top);
            DockPanel_Debug.Children.Add(StackPanel_DebugButtons);

            LBDebug = new ListBox
            {
                SelectionMode              = SelectionMode.Extended,
                HorizontalAlignment        = HorizontalAlignment.Stretch,
                VerticalAlignment          = VerticalAlignment.Stretch,
                VerticalContentAlignment   = VerticalAlignment.Stretch,
                HorizontalContentAlignment = HorizontalAlignment.Stretch,
                FontSize    = 10,
                FontStretch = FontStretches.SemiCondensed,
                Background  = Brushes.Black,
                Foreground  = Brushes.GhostWhite,
            };

            DockPanel_Debug.Children.Add(LBDebug);

            DebuggingTabItem.Content = DockPanel_Debug;


            AddChild(LBWindowContent);
        }
Example #46
0
                void OverrideDiagnosticInfo(StackPanel panel)
                {
                    var infoPanel = panel.Children[1].GetFirstVisualChild <ItemsControl>()?.GetFirstVisualChild <StackPanel>();

                    if (infoPanel == null)
                    {
                        // try the first item (symbol title may be absent)
                        infoPanel = panel.Children[0].GetFirstVisualChild <ItemsControl>()?.GetFirstVisualChild <StackPanel>();
                        if (infoPanel?.GetFirstVisualChild <WrapPanel>()?.GetFirstVisualChild <Image>() != null)
                        {
                            return;
                        }
                    }
                    if (infoPanel == null)
                    {
                        return;
                    }
                    foreach (var item in infoPanel.Children)
                    {
                        var cp = (item as UIElement).GetFirstVisualChild <TextBlock>();
                        if (cp == null)
                        {
                            continue;
                        }
                        cp.LimitSize();
                        if (Diagnostics != null && Diagnostics.Count > 0)
                        {
                            var t = cp.GetText();
                            var d = Diagnostics.FirstOrDefault(i => i.GetMessage() == t);
                            if (d != null)
                            {
                                cp.UseDummyToolTip();
                                cp.Tag = d;
                                cp.SetGlyph(ThemeHelper.GetImage(GetGlyphForSeverity(d.Severity)));
                                cp.ToolTipOpening += ShowToolTipForDiagnostics;
                            }
                        }
                        else
                        {
                            cp.SetGlyph(ThemeHelper.GetImage(KnownImageIds.StatusInformation));
                        }
                        TextEditorWrapper.CreateFor(cp);
                    }

                    int GetGlyphForSeverity(DiagnosticSeverity severity)
                    {
                        switch (severity)
                        {
                        case DiagnosticSeverity.Warning: return(KnownImageIds.StatusWarning);

                        case DiagnosticSeverity.Error: return(KnownImageIds.StatusError);

                        case DiagnosticSeverity.Hidden: return(KnownImageIds.StatusHidden);

                        default: return(KnownImageIds.StatusInformation);
                        }
                    }

                    void ShowToolTipForDiagnostics(object sender, ToolTipEventArgs e)
                    {
                        var t   = sender as TextBlock;
                        var d   = t.Tag as Diagnostic;
                        var tip = new ThemedToolTip();

                        tip.Title.Append(d.Descriptor.Category + " (" + d.Id + ")", true);
                        tip.Content.Append(d.Descriptor.Title.ToString());
                        if (String.IsNullOrEmpty(d.Descriptor.HelpLinkUri) == false)
                        {
                            tip.Content.AppendLine().Append("Help: " + d.Descriptor.HelpLinkUri);
                        }
                        if (d.IsSuppressed)
                        {
                            tip.Content.AppendLine().Append("Suppressed");
                        }
                        if (d.IsWarningAsError)
                        {
                            tip.Content.AppendLine().Append("Content as error");
                        }
                        t.ToolTip         = tip;
                        t.ToolTipOpening -= ShowToolTipForDiagnostics;
                    }
                }
Example #47
0
        private async void ButtonReconstruct_OnClick(object sender, RoutedEventArgs e)
        {
            bool Filter = (bool)CheckFilter.IsChecked;
            bool Manual = (bool)CheckManual.IsChecked;

            #region Get all movies that can potentially be used

            List <TiltSeries> ValidSeries = Series.Where(v =>
            {
                if (!Filter && v.UnselectFilter && v.UnselectManual == null)
                {
                    return(false);
                }
                if (!Manual && v.UnselectManual != null && (bool)v.UnselectManual)
                {
                    return(false);
                }
                if (v.OptionsCTF == null)
                {
                    return(false);
                }
                return(true);
            }).ToList();

            if (ValidSeries.Count == 0)
            {
                Close?.Invoke();
                return;
            }

            #endregion

            #region Set up progress displays

            NParallel    = Math.Min(ValidSeries.Count, GPU.GetDeviceCount());
            GridSizes    = Helper.ArrayOfConstant(new int3(1), NParallel);
            GridProgress = new int[NParallel];
            GridNames    = new string[NParallel];

            GridControls = Helper.ArrayOfFunction(i => new ReconstructionMiniature {
                Width = 256
            }, NParallel);
            GridLabels = Helper.ArrayOfFunction(i => new TextBlock {
                FontSize = 18, Margin = new Thickness(0, 15, 0, 0), HorizontalAlignment = HorizontalAlignment.Center
            }, NParallel);

            for (int n = 0; n < NParallel; n++)
            {
                StackPanel SP = new StackPanel {
                    Orientation = Orientation.Vertical, Margin = new Thickness(15, 0, 15, 0)
                };
                SP.Children.Add(GridControls[n]);
                SP.Children.Add(GridLabels[n]);

                PanelGrids.Children.Add(SP);
            }

            #endregion

            PanelConfiguration.Visibility = Visibility.Collapsed;
            PanelProgress.Visibility      = Visibility.Visible;

            int Completed = 0;
            ProgressOverall.Maximum = ValidSeries.Count;

            await Task.Run(() =>
            {
                #region Load template and make copies for all devices

                Image[] Template = new Image[NParallel];
                {
                    Template[0] = Image.FromFile(PathTemplate);

                    if (Options.Tasks.TomoMatchWhitenSpectrum)
                    {
                        Image Whitened = Template[0].AsSpectrumFlattened(true, 0.99f);
                        Template[0].Dispose();
                        Template[0] = Whitened;
                    }

                    Template[0].FreeDevice();

                    Template[0].PixelSize = (float)Options.Tasks.TomoMatchTemplatePixel;
                    for (int i = 0; i < Template.Length; i++)
                    {
                        Template[i] = Template[0].GetCopy();
                    }
                }

                #endregion

                Helper.ForEachGPU(ValidSeries, (item, gpuID) =>
                {
                    if (IsCanceled)
                    {
                        return(true);    // This cancels the iterator
                    }
                    ProcessingOptionsTomoFullMatch SeriesOptions = Options.GetProcessingTomoFullMatch();
                    SeriesOptions.TemplateName = Helper.PathToName(PathTemplate);

                    item.MatchFull(SeriesOptions, Template[gpuID], (size, value, name) =>
                    {
                        Dispatcher.Invoke(() =>
                        {
                            SetGridSize(gpuID, size);
                            SetGridProgress(gpuID, value);
                            SetGridName(gpuID, name);
                        });

                        return(IsCanceled);
                    });

                    Dispatcher.Invoke(() => ProgressOverall.Value = ++Completed);

                    return(false);   // No need to cancel GPU ForEach iterator
                }, 1, Helper.ArrayOfSequence(0, NParallel, 1).ToList());
            });

            Close?.Invoke();
        }
Example #48
0
 public override void OnApplyTemplate()
 {
     base.OnApplyTemplate();
     buttonsPanel = GetTemplateChild("buttonsPanel") as StackPanel;
 }
        public StackPanel PreencherLinhaUsuario(string IdPar, string NomePar, string KdaPar, string AdrPar, string MatouPar, string MorreuPar, string KastPar, string MkPar, string FkPar, string ClutchPar, string HsPar, string PrecisaoPar, string BombaPlanPar, string BombaDefPar)
        {
            //Tentar!!
            //Se ja existe o registro em vez de criar um novo stackpanel, editar o atual?
            //Ou...Editar o csv...

            if (!CsvUserExec.Lista.Exists(xy => xy.Id == IdPar))
            {
            }

            StackPanel stackPanel = new StackPanel {
                Orientation = Orientation.Horizontal, Name = "Amigo" + IdPar.ToString()
            };

            Label Nome = new Label {
                Content = NomePar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label Kda = new Label {
                Content = KdaPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label Adr = new Label {
                Content = AdrPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label Matou = new Label {
                Content = MatouPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label Morreu = new Label {
                Content = MorreuPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label Kast = new Label {
                Content = KastPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label MultiKills = new Label {
                Content = MkPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label FirstKills = new Label {
                Content = FkPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label Clutches = new Label {
                Content = ClutchPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label Hs = new Label {
                Content = HsPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label Precisao = new Label {
                Content = PrecisaoPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label BombasPlan = new Label {
                Content = BombaPlanPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };
            Label BombasDef = new Label {
                Content = BombaDefPar, Width = 80, HorizontalContentAlignment = HorizontalAlignment.Center
            };

            stackPanel.Children.Add(Nome);
            stackPanel.Children.Add(Kda);
            stackPanel.Children.Add(Adr);
            stackPanel.Children.Add(Matou);
            stackPanel.Children.Add(Morreu);
            stackPanel.Children.Add(Kast);
            stackPanel.Children.Add(MultiKills);
            stackPanel.Children.Add(FirstKills);
            stackPanel.Children.Add(Clutches);
            stackPanel.Children.Add(Hs);
            stackPanel.Children.Add(Precisao);
            stackPanel.Children.Add(BombasPlan);
            stackPanel.Children.Add(BombasDef);

            return(stackPanel);
        }
Example #50
0
        public AggravationMainView(IEventAggregator aggregator,
                                   TestOptions test,
                                   AggravationVMData model,
                                   AggravationGameContainer gameContainer,
                                   GameBoardGraphicsCP graphicsCP,
                                   IGamePackageRegister register
                                   )
        {
            _aggregator    = aggregator;
            _model         = model;
            _gameContainer = gameContainer;
            _aggregator.Subscribe(this);
            register.RegisterControl(_board.ThisElement, "");
            graphicsCP.LinkBoard();
            _ourPiece        = new MarblePiecesWPF <EnumColorChoice>();
            _ourPiece.Width  = 80;
            _ourPiece.Height = 80;
            _ourPiece.Init(); //i think.
            StackPanel mainStack             = new StackPanel();
            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer()
                {
                    Name = nameof(AggravationMainViewModel.RestoreScreen)
                };
            }
            Grid tempGrid = new Grid();

            mainStack.Children.Add(tempGrid);
            var        thisRoll   = GetGamingButton("Roll Dice", nameof(AggravationMainViewModel.RollDiceAsync));
            StackPanel otherStack = new StackPanel();

            otherStack.Orientation = Orientation.Horizontal;
            _diceControl           = new DiceListControlWPF <SimpleDice>();


            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Turn", nameof(AggravationMainViewModel.NormalTurn));
            firstInfo.AddRow("Instructions", nameof(AggravationMainViewModel.Instructions));
            firstInfo.AddRow("Status", nameof(AggravationMainViewModel.Status));
            //if we need to put to main, just change to main (?)

            StackPanel firstStack = new StackPanel();

            firstStack.Margin = new Thickness(3, 3, 3, 3);
            firstStack.Children.Add(firstInfo.GetContent);
            firstStack.Children.Add(_ourPiece);
            otherStack.Children.Add(thisRoll);
            otherStack.Children.Add(_diceControl);
            firstStack.Children.Add(otherStack);
            tempGrid.Children.Add(firstStack);
            tempGrid.Children.Add(_board);

            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
        /// <summary>
        /// 更新原文
        /// 注意执行过程中调用了StackPanel等UI组件,必须交回主线程才能执行。
        /// </summary>
        /// <param name="repairedText">原文</param>
        private void UpdateSource(string repairedText)
        {
            if (_isShowSource)
            {
                // 使用BeginInvoke,在更新原文时可以去获取翻译
                Application.Current.Dispatcher.BeginInvoke((Action)(() =>
                {
                    //3.分词
                    var mwi = _mecabHelper.SentenceHandle(repairedText);
                    //分词后结果显示
                    for (int i = 0; i < mwi.Count; i++)
                    {
                        StackPanel stackPanel = new StackPanel();
                        stackPanel.Orientation = Orientation.Vertical;
                        stackPanel.Margin = new Thickness(10, 0, 0, 10);

                        TextBlock textBlock = new TextBlock();
                        if (!string.IsNullOrEmpty(SourceTextFont))
                        {
                            FontFamily fontFamily = new FontFamily(SourceTextFont);
                            textBlock.FontFamily = fontFamily;
                        }
                        textBlock.Text = mwi[i].Word;
                        textBlock.Tag = mwi[i].Kana;
                        textBlock.Margin = new Thickness(0, 0, 0, 0);
                        textBlock.FontSize = SourceTextFontSize;
                        textBlock.Background = Brushes.Transparent;
                        textBlock.MouseLeftButtonDown += DictArea_MouseLeftButtonDown;
                        //根据不同词性跟字体上色
                        switch (mwi[i].PartOfSpeech)
                        {
                        case "名詞":
                            textBlock.Foreground = Brushes.AliceBlue;
                            break;

                        case "助詞":
                            textBlock.Foreground = Brushes.LightGreen;
                            break;

                        case "動詞":
                            textBlock.Foreground = Brushes.Red;
                            break;

                        case "連体詞":
                            textBlock.Foreground = Brushes.Orange;
                            break;

                        default:
                            textBlock.Foreground = Brushes.White;
                            break;
                        }


                        TextBlock superScript = new TextBlock();//假名或注释等的上标标签
                        if (!string.IsNullOrEmpty(SourceTextFont))
                        {
                            FontFamily fontFamily = new FontFamily(SourceTextFont);
                            superScript.FontFamily = fontFamily;
                        }
                        superScript.Text = mwi[i].Kana;
                        superScript.Margin = new Thickness(0, 0, 0, 2);
                        superScript.HorizontalAlignment = HorizontalAlignment.Center;
                        if ((double)SourceTextFontSize - 6.5 > 0)
                        {
                            superScript.FontSize = (double)SourceTextFontSize - 6.5;
                        }
                        else
                        {
                            superScript.FontSize = 1;
                        }
                        superScript.Background = Brushes.Transparent;
                        superScript.Foreground = Brushes.White;
                        stackPanel.Children.Add(superScript);


                        //是否打开假名标注
                        if (Common.appSettings.TF_isKanaShow)
                        {
                            stackPanel.Children.Add(textBlock);
                            SourceTextPanel.Children.Add(stackPanel);
                        }
                        else
                        {
                            textBlock.Margin = new Thickness(10, 0, 0, 10);
                            SourceTextPanel.Children.Add(textBlock);
                        }
                    }
                }));
            }
        }
        void IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                ((FrameworkElement)target).Loaded += new RoutedEventHandler(this.MainWindow_Loaded);
                break;

            case 2:
                this.mTitleIcon = (CustomPictureBox)target;
                break;

            case 3:
                this.mTitle            = (TextBlock)target;
                this.mTitle.MouseDown += new MouseButtonEventHandler(this.TitleBar_MouseDown);
                break;

            case 4:
                this.mMinimizeButton = (CustomPictureBox)target;
                this.mMinimizeButton.PreviewMouseLeftButtonUp += new MouseButtonEventHandler(this.MinimizeButton_MouseLeftButtonUp);
                break;

            case 5:
                this.mCrossButton = (CustomPictureBox)target;
                this.mCrossButton.MouseLeftButtonUp += new MouseButtonEventHandler(this.CloseButton_MouseLeftButtonUp);
                break;

            case 6:
                this.mBodyPanel = (StackPanel)target;
                break;

            case 7:
                this.mBodyText = (TextBlock)target;
                break;

            case 8:
                this.mProgressGrid = (Grid)target;
                break;

            case 9:
                this.mProgressStatus = (TextBlock)target;
                break;

            case 10:
                this.mProgressPercent = (TextBlock)target;
                break;

            case 11:
                this.mProgressBar = (BlueProgressBar)target;
                break;

            case 12:
                this.mButtonGrid = (Grid)target;
                break;

            case 13:
                this.mCancelBtn        = (CustomButton)target;
                this.mCancelBtn.Click += new RoutedEventHandler(this.Btn_Click);
                break;

            case 14:
                this.mBtn        = (CustomButton)target;
                this.mBtn.Click += new RoutedEventHandler(this.Launch_Click);
                break;

            default:
                this._contentLoaded = true;
                break;
            }
        }
Example #53
0
        private UIElement Element(int id)
        {
            dynamic element = null;

            switch (id)
            {
            case 0:
                element = new Label()
                {
                    Style   = Resources["ParamLabel"] as Style,
                    Content = Encryption.currentAlg == 3 ? "128" : "64"
                };
                break;

            case 1:
                if (Encryption.currentAlg == 1)
                {
                    element = new Label()
                    {
                        Style   = Resources["ParamLabel"] as Style,
                        Content = "64"
                    }
                }
                ;
                else if (Encryption.currentAlg == 4)
                {
                    element = new WrapPanel();
                    element.Children.Add(new TextBox()
                    {
                        Style = Resources["MainTextBox"] as Style,
                        Width = 50,
                        Text  = Encryption.algParams[1].ToString()
                    });
                    element.Children[0].AddHandler(TextBox.TextChangedEvent, new RoutedEventHandler(BlockSize));
                    var buttons = new StackPanel();
                    buttons.Children.Add(new Button()
                    {
                        Style   = Resources["AddButton"] as Style,
                        Content = '+'
                    });
                    buttons.Children[0].AddHandler(Button.ClickEvent, new RoutedEventHandler(PlusButton));
                    buttons.Children.Add(new Button()
                    {
                        Style   = Resources["AddButton"] as Style,
                        Content = '-'
                    });
                    buttons.Children[1].AddHandler(Button.ClickEvent, new RoutedEventHandler(MinusButton));
                    element.Children.Add(buttons);
                }
                else
                {
                    var items = Encryption.currentAlg == 2 ? new List <string>()
                    {
                        "128", "192"
                    }
                                            : new List <string>()
                    {
                        "128", "192", "256"
                    };
                    element = new ComboBox()
                    {
                        Width         = 100,
                        Margin        = new Thickness(5, 0, 0, 0),
                        ItemsSource   = items,
                        SelectedIndex = items.IndexOf(Encryption.algParams[1].ToString())
                    };
                    element.AddHandler(ComboBox.SelectionChangedEvent, new RoutedEventHandler(BlockSize));
                }
                break;

            case 2:
                element = new Label()
                {
                    Style   = Resources["ParamLabel"] as Style,
                    Content = Encryption.currentAlg == 1 ? "16"
                                : Encryption.currentAlg == 2 ? "16 * 3"
                                : Encryption.currentAlg == 3 ? "10, 12, 14"
                                : Encryption.currentAlg == 4 ? "15 + 3"
                                : null
                };
                break;
            }
            return(element);
        }
Example #54
0
        private (Button, Button, TextBox, TextBox, TextBox, PilotDTO) RenderDetail(ItemClickEventArgs e)
        {
            var pilot = (PilotDTO)e.ClickedItem;

            SingleItem.Children.Clear();

            var id = new TextBlock();

            id.Text       = "Pilot id:" + pilot.Id;
            id.FontWeight = Windows.UI.Text.FontWeights.Bold;
            id.Margin     = new Thickness(0, 100, 10, 10);
            id.Width      = 200;

            var firstname = new TextBox
            {
                Header = "FirstName",
                Text   = pilot.FirstName,
                Width  = 200,
                HorizontalAlignment = HorizontalAlignment.Center
            };


            var lastname = new TextBox
            {
                Header = "Lastname",
                Text   = pilot.LastName,
                Width  = 200,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            var experience = new TextBox
            {
                Header = "Experience",
                Text   = pilot.Experience.ToString(),
                Width  = 200,
                HorizontalAlignment = HorizontalAlignment.Center
            };

            experience.KeyDown += (object obj, KeyRoutedEventArgs evArgs) =>
            {
                if (evArgs.Key.ToString().Equals("Back"))
                {
                    evArgs.Handled = false;
                    return;
                }
                for (int i = 0; i < 10; i++)
                {
                    if (evArgs.Key.ToString() == string.Format("Number{0}", i))
                    {
                        evArgs.Handled = false;
                        return;
                    }
                }
                evArgs.Handled = true;
            };


            var btnUpdate = new Button
            {
                Content = "Update",
                Width   = 100
            };
            var btnDelete = new Button
            {
                Content = "Delete",
                Width   = 100
            };

            var buttonsStack = new StackPanel
            {
                Orientation         = Orientation.Horizontal,
                HorizontalAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(0, 20, 0, 0)
            };

            SingleItem.Children.Add(id);
            SingleItem.Children.Add(firstname);
            SingleItem.Children.Add(lastname);
            SingleItem.Children.Add(experience);
            buttonsStack.Children.Add(btnUpdate);
            buttonsStack.Children.Add(btnDelete);
            SingleItem.Children.Add(buttonsStack);

            return(btnUpdate, btnDelete, firstname, lastname, experience, pilot);
        }
Example #55
0
        private void MakeButtons()
        {
            for (int r = 1; r < 9; r++)
            {
                for (int c = 0; c < 8; c++)
                {
                    StackPanel stackPanel = (StackPanel)GetGridElement(CheckersGrid, r, c);
                    Button     button     = new Button();
                    button.Click += new RoutedEventHandler(button_Click);
                    button.Height = 60;
                    button.Width  = 60;
                    button.HorizontalAlignment = HorizontalAlignment.Center;
                    button.VerticalAlignment   = VerticalAlignment.Center;
                    var redBrush = new ImageBrush();
                    redBrush.ImageSource = new BitmapImage(new Uri("Resources/red60p.png", UriKind.Relative));
                    var blackBrush = new ImageBrush();
                    blackBrush.ImageSource = new BitmapImage(new Uri("Resources/black60p.png", UriKind.Relative));
                    switch (r)
                    {
                    case 1:
                        if (c % 2 == 1)
                        {
                            button.Background = redBrush;
                            button.Name       = "buttonRed" + r + c;
                            stackPanel.Children.Add(button);
                        }
                        break;

                    case 2:
                        if (c % 2 == 0)
                        {
                            button.Background = redBrush;
                            button.Name       = "buttonRed" + r + c;
                            stackPanel.Children.Add(button);
                        }
                        break;

                    case 3:
                        if (c % 2 == 1)
                        {
                            button.Background = redBrush;
                            button.Name       = "buttonRed" + r + c;
                            stackPanel.Children.Add(button);
                        }
                        break;

                    case 4:
                        if (c % 2 == 0)
                        {
                            button.Background = Brushes.Black;
                            button.Name       = "button" + r + c;
                            stackPanel.Children.Add(button);
                        }
                        break;

                    case 5:
                        if (c % 2 == 1)
                        {
                            button.Background = Brushes.Black;
                            button.Name       = "button" + r + c;
                            stackPanel.Children.Add(button);
                        }
                        break;

                    case 6:
                        if (c % 2 == 0)
                        {
                            button.Background = blackBrush;
                            button.Name       = "buttonBlack" + r + c;
                            stackPanel.Children.Add(button);
                        }
                        break;

                    case 7:
                        if (c % 2 == 1)
                        {
                            button.Background = blackBrush;
                            button.Name       = "buttonBlack" + r + c;
                            stackPanel.Children.Add(button);
                        }
                        break;

                    case 8:
                        if (c % 2 == 0)
                        {
                            button.Background = blackBrush;
                            button.Name       = "buttonBlack" + r + c;
                            stackPanel.Children.Add(button);
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
        }
Example #56
0
 /// <summary>
 /// 通过下标移除堆栈面板的元素
 /// </summary>
 /// <param name="stackPanel">需要进行移除的堆栈面板</param>
 /// <param name="index">指定下标</param>
 public static void RemoveChildrenAt(StackPanel stackPanel, int index)
 {
     stackPanel.Children.RemoveAt(index);
 }
        /// <summary>
        /// Adds the DataFields to the TestPanel in a StackPanel and waits for it to load.
        /// </summary>
        private void AddToPanelInStackPanelAndWaitForLoad()
        {
            this.EnqueueCallback(() =>
            {
                StackPanel stackPanel = new StackPanel();

                stackPanel.DataContext =
                    new DataClassWithValidation()
                    {
                        BoolProperty = true,
                        IntProperty = 1,
                        StringProperty = "test string"
                    };

                DataField.SetIsFieldGroup(stackPanel, true);
                stackPanel.Children.Add(this._dataField);
                stackPanel.Children.Add(this._dataField2);

                this._dataFieldLoaded = false;
                this._dataField.Loaded += new RoutedEventHandler(this.OnDataFieldLoaded);
                this.TestPanel.Children.Add(stackPanel);
            });

            this.EnqueueConditional(() => this._dataFieldLoaded);
        }
        public MainWindow()
        {
            InitializeComponent();
            StackPanel stackPanel = new StackPanel();

            this.Content = stackPanel;
            var data = new ProgramData();

            // Create the Button

            TestUI(stackPanel);

            var bluetoothStatus = CheckIfDeviceHasSupportedBluetooth();

            var UI_BluetoothStatus = new TextBox()
            {
                Text = bluetoothStatus.description,
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment   = VerticalAlignment.Top,
                Margin     = new Thickness(10),
                FontSize   = 16,
                FontFamily = new FontFamily("Segoe"),
                FontWeight = FontWeights.Medium,
            };

            if (bluetoothStatus.supported == false)
            {
                UI_BluetoothStatus.Background = Brushes.Tomato;
            }

            stackPanel.Children.Add(UI_BluetoothStatus);

            if (bluetoothStatus.supported)
            {
                UI_BluetoothStatus.Background = Brushes.LightGreen;

                var BTCLI = new BluetoothClient();

                Button UI_But_Scan = new Button();

                UI_But_Scan.Click += (sender, e) => UI_bluetoothDevicesListBox.ItemsSource = BTCLI.DiscoverDevicesInRange();

                UI_But_Scan.Content             = "ScanDevices";
                UI_But_Scan.HorizontalAlignment = HorizontalAlignment.Left;
                UI_But_Scan.Margin            = new Thickness(150);
                UI_But_Scan.VerticalAlignment = VerticalAlignment.Top;
                UI_But_Scan.Width             = 75;

                stackPanel.Children.Add(UI_But_Scan);
                stackPanel.Children.Add(UI_bluetoothDevicesListBox);

                var UI_ConnectToDevice = new Button()
                {
                    Content             = "Connect To Device",
                    HorizontalAlignment = HorizontalAlignment.Center,
                    Margin            = new Thickness(30),
                    VerticalAlignment = VerticalAlignment.Bottom,
                    Width             = 75,
                };
                UI_ConnectToDevice.Click += (sender, e) =>
                {
                    ConnectToBluetoothDevice(UI_bluetoothDevicesListBox.SelectedItem as BluetoothDeviceInfo, BTCLI);
                };
            }
        }
        public virtual void ShouldAllowTemplateWithUIElements()
        {
            // this tests adds back the coverage lost by the exclusion of
            // test: Content*DataTemplateWithUIElementsFails (see GetDPTests())
            AccordionItem instance = new AccordionItem();
            instance.Width = 300;
            instance.Height = 300;

            TestAsync(
                    instance,
                    () =>
                        {
                            StackPanel element = new StackPanel();
                            element.SetValue(FrameworkElement.NameProperty, "UIElementContent");
                            element.Children.Add(new Ellipse
                                                     {
                                                             Fill = new SolidColorBrush(Colors.Red),
                                                             Width = 20,
                                                             Height = 20
                                                     });
                            element.Children.Add(new TextBlock
                                                     {
                                                             Text = "UIElement Content"
                                                     });
                            element.Children.Add(new Ellipse
                                                     {
                                                             Fill = new SolidColorBrush(Colors.Blue),
                                                             Width = 20,
                                                             Height = 20
                                                     });
                            instance.SetValue(ContentControl.ContentProperty, element);
                        },
                    () => instance.IsSelected = true,
                () =>
                {
                    // Create the DataTemplate
                    XamlBuilder<DataTemplate> xamlTemplate = new XamlBuilder<DataTemplate>
                    {
                        Name = "template",
                        Children = new List<XamlBuilder>
                        {
                            new XamlBuilder<StackPanel>
                            {
                                Children = new List<XamlBuilder>
                                {
                                    new XamlBuilder<StackPanel>
                                    {
                                        AttributeProperties = new Dictionary<string, string> { { "Orientation", "Horizontal" } },
                                        Children = new List<XamlBuilder>
                                        {
                                            new XamlBuilder<TextBlock>
                                            {
                                                AttributeProperties = new Dictionary<string, string> { { "Text", "{}{Binding Name}:  " } }
                                            },
                                            new XamlBuilder<TextBlock>
                                            {
                                                Name = "nameBinding",
                                                AttributeProperties = new Dictionary<string, string> { { "Text", "{Binding Name}" } }
                                            }
                                        }
                                    },
                                    new XamlBuilder<StackPanel>
                                    {
                                        AttributeProperties = new Dictionary<string, string> { { "Orientation", "Horizontal" } },
                                        Children = new List<XamlBuilder>
                                        {
                                            new XamlBuilder<TextBlock>
                                            {
                                                AttributeProperties = new Dictionary<string, string> { { "Text", "{}{Binding}:  " } }
                                            },
                                            new XamlBuilder<ContentControl>
                                            {
                                                Name = "contentBinding",
                                                AttributeProperties = new Dictionary<string, string> { { "Content", "{Binding}" } }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    };

                    // Generate the DataTemplate and set it
                    instance.SetValue(ContentControl.ContentTemplateProperty, xamlTemplate.Load());
                },
                () =>
                {
                    // Verify the bindings didn't work
                    TextBlock text = instance.GetVisualChild("nameBinding") as TextBlock;
                    Assert.IsNotNull(text, "Failed to find nameBinding TextBlock!");
                    TestExtensions.AssertIsNullOrEmpty(text.Text);

                    ContentControl content = instance.GetVisualChild("contentBinding") as ContentControl;
                    Assert.IsNotNull(content, "Failed to find contentBinding ContentControl!");
                    Assert.IsNull(content.Content, "The bound Content should be null!");
                });
        }
Example #60
0
        public static void CreateContextMenu(int i, Neuron n, ContextMenu cm)
        {
            cm.SetValue(NeuronIDProperty, n.Id);
            cm.Closed  += Cm_Closed;
            cmCancelled = false;
            StackPanel sp = new StackPanel {
                Orientation = Orientation.Horizontal, Margin = new Thickness(0, 3, 3, 3)
            };

            sp.Children.Add(new Label {
                Content = "Charge: ", Padding = new Thickness(0)
            });
            if (n.Model != Neuron.modelType.FloatValue)
            {
                sp.Children.Add(new TextBox {
                    Text = n.LastCharge.ToString("f2"), Width = 60, Name = "CurrentCharge", VerticalAlignment = VerticalAlignment.Center
                });
            }
            else
            {
                sp.Children.Add(new TextBox {
                    Text = n.CurrentCharge.ToString("f2"), Width = 60, Name = "CurrentCharge", VerticalAlignment = VerticalAlignment.Center
                });
            }
            cm.Items.Add(sp);
            if (n.Model == Neuron.modelType.LIF)
            {
                sp = new StackPanel {
                    Orientation = Orientation.Horizontal, Margin = new Thickness(0, 3, 3, 3)
                };
                sp.Children.Add(new Label {
                    Content = "Leak Rate: ", Padding = new Thickness(0)
                });
                sp.Children.Add(new TextBox {
                    Text = n.LeakRate.ToString("f4"), Width = 60, Name = "LeakRate", VerticalAlignment = VerticalAlignment.Center
                });
                cm.Items.Add(sp);
            }

            MenuItem mi = new MenuItem();

            mi.Header = "Neuron ID: " + n.Id;
            cm.Items.Add(mi);
            cm.Items.Add(new Separator());
            mi        = new MenuItem();
            mi.Header = "Always Fire";
            mi.Click += Mi_Click;
            cm.Items.Add(mi);
            mi        = new MenuItem();
            mi.Header = "Paste Here";
            mi.Click += Mi_Click;
            cm.Items.Add(mi);
            mi        = new MenuItem();
            mi.Header = "Clipboard";
            mi.Click += Mi_Click;
            mi.Items.Add(new MenuItem()
            {
                Header = "Paste Here"
            });
            ((MenuItem)mi.Items[mi.Items.Count - 1]).Click += Mi_Click;
            mi.Items.Add(new MenuItem()
            {
                Header = "Move Here"
            });
            ((MenuItem)mi.Items[mi.Items.Count - 1]).Click += Mi_Click;
            mi.Items.Add(new MenuItem()
            {
                Header = "Connect to Here"
            });
            ((MenuItem)mi.Items[mi.Items.Count - 1]).Click += Mi_Click;
            mi.Items.Add(new MenuItem()
            {
                Header = "Connect from Here"
            });
            ((MenuItem)mi.Items[mi.Items.Count - 1]).Click += Mi_Click;
            mi.Items.Add(new MenuItem()
            {
                Header = "Select as Target"
            });
            ((MenuItem)mi.Items[mi.Items.Count - 1]).Click += Mi_Click;
            cm.Items.Add(mi);
            sp = new StackPanel {
                Orientation = Orientation.Horizontal, Margin = new Thickness(0, 3, 3, 3)
            };
            sp.Children.Add(new Label {
                Content = "Label: ", Padding = new Thickness(0)
            });
            sp.Children.Add(new TextBox {
                Text = n.Label, Width = 150, Name = "Label", VerticalAlignment = VerticalAlignment.Center
            });
            cm.Items.Add(sp);

            sp = new StackPanel {
                Orientation = Orientation.Horizontal, Margin = new Thickness(0, 3, 3, 3)
            };
            sp.Children.Add(new Label {
                Content = "Model: ", Padding = new Thickness(0)
            });
            ComboBox cb = new ComboBox()
            {
                Width = 100
            };

            for (int index = 0; index < Enum.GetValues(typeof(Neuron.modelType)).Length; index++)
            {
                Neuron.modelType model = (Neuron.modelType)index;
                cb.Items.Add(new ListBoxItem()
                {
                    Content = model.ToString(),
                    ToolTip = Neuron.modelToolTip[index],
                    Width   = 100,
                });
            }
            cb.SelectedIndex     = (int)n.Model;
            cb.SelectionChanged += Cb_SelectionChanged;
            sp.Children.Add(cb);
            cm.Items.Add(sp);
            CheckBox cbHistory = new CheckBox
            {
                IsChecked = n.KeepHistory,
                Content   = "Record Firing History",
                Name      = "History",
            };

            cbHistory.Checked   += CbHistory_Checked;
            cbHistory.Unchecked += CbHistory_Checked;
            cm.Items.Add(cbHistory);

            mi        = new MenuItem();
            mi.Header = "Synapses";
            mi.Click += Mi_Click;
            if (n.synapses == null)
            {
                n.synapses = new List <Synapse>();
            }
            foreach (Synapse s in n.synapses)
            {
                mi.Items.Add(new MenuItem()
                {
                    Header = s.targetNeuron + " " + s.Weight
                });
            }

            cm.Items.Add(mi);

            mi        = new MenuItem();
            mi.Header = "Synapses In";
            mi.Click += Mi_Click;
            if (n.synapsesFrom == null)
            {
                n.synapsesFrom = new List <Synapse>();
            }
            foreach (Synapse s in n.synapsesFrom)
            {
                mi.Items.Add(new MenuItem()
                {
                    Header = s.targetNeuron + " " + s.Weight
                });
            }
            cm.Items.Add(mi);
        }