Exemplo n.º 1
0
        public FrameworkElement GetControl(WorkFlowViewElement viewElement, Context context)
        {
            var button = new System.Windows.Controls.Button()
            {
                Content  = viewElement.Properties["Caption"].ToString(context),
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
            };

            viewElement.SetSize(button, context);

            button.Click += (sender, args) =>
            {
                WorkflowManager.ExecuteAsync(viewElement.GetEventCommands("Click"), WorkflowManager.Instance.Context);
            };
            if (viewElement.Properties["Style"].Value == "Rounded")
            {
                button.Style = Application.Current.Resources["MaterialDesignFloatingActionButton"] as Style;
            }

            if (!string.IsNullOrWhiteSpace(viewElement.Properties["Enabled"].Value))
            {
                button.DataContext = viewElement.Parent.Parent.Variables[viewElement.Properties["Enabled"].Value];
                button.SetBinding(UIElement.IsEnabledProperty, "Value");
            }

            PackIconKind kind;

            if (Enum.TryParse(viewElement.Properties["Icon"].Value, out kind))
            {
                button.Content = new PackIcon()
                {
                    Kind = kind, Width = button.Width / 2, Height = button.Height / 2
                }
            }
            ;

            if (viewElement.Properties["BackgroundColor"].ToString(context) != "Transparent" && viewElement.Properties["BackgroundColor"].ToString(context) != "#00FFFFFF")
            {
                button.Background =
                    new SolidColorBrush(
                        (Color)ColorConverter.ConvertFromString(viewElement.Properties["BackgroundColor"].ToString(context)));
            }
            if (viewElement.Properties["ForegroundColor"].ToString(context) != "Transparent" && viewElement.Properties["ForegroundColor"].ToString(context) != "#00FFFFFF")
            {
                button.Foreground =
                    new SolidColorBrush(
                        (Color)ColorConverter.ConvertFromString(viewElement.Properties["ForegroundColor"].ToString(context)));
            }

            return(button);
        }
    }
Exemplo n.º 2
0
        public FrameworkElement GetControl(WorkFlowViewElement viewElement)
        {
            var button = new System.Windows.Controls.Button()
            {
                Width    = viewElement.Properties["Width"].ToInt(),
                Height   = viewElement.Properties["Height"].ToInt(),
                Content  = viewElement.Properties["Caption"].Value,
                Margin   = new Thickness(viewElement.Properties["Margins"].ToInt()),
                FontSize = viewElement.Properties["FontSize"].ToInt(),
            };

            button.Click += (sender, args) =>
            {
                WorkflowManager.Execute(viewElement.GetEventCommands("Click"));
            };
            if (viewElement.Properties["Style"].Value == "Rounded")
            {
                button.Style = Application.Current.Resources["MaterialDesignFloatingActionButton"] as Style;
            }

            PackIconKind kind;

            if (Enum.TryParse(viewElement.Properties["Icon"].Value, out kind))
            {
                button.Content = new PackIcon()
                {
                    Kind = kind, Width = button.Width / 2, Height = button.Height / 2
                }
            }
            ;

            if (viewElement.Properties["BackgroundColor"].Value != "Transparent" && viewElement.Properties["BackgroundColor"].Value != "#00FFFFFF")
            {
                button.Background =
                    new SolidColorBrush(
                        (Color)ColorConverter.ConvertFromString(viewElement.Properties["BackgroundColor"].Value));
            }
            if (viewElement.Properties["ForegroundColor"].Value != "Transparent" && viewElement.Properties["ForegroundColor"].Value != "#00FFFFFF")
            {
                button.Foreground =
                    new SolidColorBrush(
                        (Color)ColorConverter.ConvertFromString(viewElement.Properties["ForegroundColor"].Value));
            }

            return(button);
        }
    }