public FrameworkElement GetControl(WorkFlowViewElement viewElement, Context context)
        {
            var checkbox = new System.Windows.Controls.CheckBox()
            {
                Content  = viewElement.Properties["Caption"].ToString(context),
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
            };

            viewElement.SetSize(checkbox, context);

            checkbox.DataContext = viewElement.Parent.Parent.Variables[viewElement.Properties["Variable"].ToString(context)];
            checkbox.SetBinding(ToggleButton.IsCheckedProperty, "Value");

            //if (viewElement.Properties["Style"].Value == "Rounded")
            //{
            //    checkbox.Style = Application.Current.Resources["MaterialDesignFloatingActionButton"] as Style;
            //}


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

            return(checkbox);
        }
        public FrameworkElement GetControl(WorkFlowViewElement viewElement, Context context)
        {
            var separator = new System.Windows.Controls.Separator();

            {
            };
            viewElement.SetSize(separator, context);
            //separator. = viewElement.Properties["Orientation"].ToString(context) == "Horizontal" ? Orientation.Horizontal : Orientation.Vertical;
            return(separator);
        }
Beispiel #3
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);
        }
    }
Beispiel #4
0
        public FrameworkElement GetControl(WorkFlowViewElement viewElement, Context context)
        {
            var image = new System.Windows.Controls.Image();

            viewElement.SetSize(image, context);

            try
            {
                image.Source = Utils.LoadImage(
                    viewElement.Parent.Parent.GetFileStream(viewElement.Properties["ImageFile"].ToString(context)), 0, 0);
                image.Stretch = Stretch.Fill;
            }
            catch (Exception e)
            {
                Log.Debug("Unable to load image ", e);
            }
            return(image);
        }
        public FrameworkElement GetControl(WorkFlowViewElement viewElement, Context context)
        {
            var slider = new Slider()
            {
                Orientation = Orientation.Horizontal,
                VerticalContentAlignment   = VerticalAlignment.Center,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                VerticalAlignment          = VerticalAlignment.Center,
                HorizontalAlignment        = HorizontalAlignment.Center
            };

            viewElement.SetSize(slider, context);

            slider.DataContext = viewElement.Parent.Parent.Variables[viewElement.Properties["Variable"].ToString(context)];
            slider.SetBinding(RangeBase.ValueProperty, "Value");

            slider.Minimum = viewElement.Properties["Minimum"].ToInt(context);
            slider.Maximum = viewElement.Properties["Maximum"].ToInt(context);

            var label = new System.Windows.Controls.Label()
            {
                Height   = viewElement.Properties["Height"].ToInt(context),
                Content  = viewElement.Properties["Caption"].ToString(context),
                Margin   = new Thickness(viewElement.Properties["Margins"].ToInt(context)),
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
                VerticalContentAlignment = VerticalAlignment.Center,
                VerticalAlignment        = VerticalAlignment.Center
            };

            if (viewElement.Properties["LabelWidth"].ToInt(context) > 0)
            {
                label.Width = viewElement.Properties["LabelWidth"].ToInt(context);
            }


            var stackpanel = new StackPanel();

            stackpanel.Children.Add(label);
            stackpanel.Children.Add(slider);
            stackpanel.Orientation = viewElement.Properties["Orientation"].ToString(context) == "Horizontal" ? Orientation.Horizontal : Orientation.Vertical;
            return(stackpanel);
        }
Beispiel #6
0
        public FrameworkElement GetControl(WorkFlowViewElement viewElement, Context context)
        {
            var label = new System.Windows.Controls.Label()
            {
                Content  = viewElement.Properties["Text"].ToString(context),
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
            };

            viewElement.SetSize(label, context);

            if (viewElement.Properties["BackgroundColor"].ToString(context) != "Transparent" && viewElement.Properties["BackgroundColor"].ToString(context) != "#00FFFFFF")
            {
                label.Background =
                    new SolidColorBrush(
                        (Color)ColorConverter.ConvertFromString(viewElement.Properties["BackgroundColor"].ToString(context)));
            }
            if (viewElement.Properties["ForegroundColor"].ToString(context) != "Transparent" && viewElement.Properties["ForegroundColor"].ToString(context) != "#00FFFFFF")
            {
                label.Foreground =
                    new SolidColorBrush(
                        (Color)ColorConverter.ConvertFromString(viewElement.Properties["ForegroundColor"].ToString(context)));
            }
            return(label);
        }
        public FrameworkElement GetControl(WorkFlowViewElement viewElement, Context context)
        {
            ComboBox comboBox = new ComboBox()
            {
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
                VerticalContentAlignment   = VerticalAlignment.Center,
                HorizontalContentAlignment = HorizontalAlignment.Center
            };

            viewElement.SetSize(comboBox, context);
            var variable = viewElement.Properties["Variable"].ToString(context);

            comboBox.DataContext = viewElement.Parent.Parent;
            if (string.IsNullOrEmpty(viewElement.Properties["ValueListVariable"].ToString(context)))
            {
                comboBox.ItemsSource = viewElement.Properties["ValueList"].ToString(context).Split('|');
            }
            else
            {
                comboBox.SetBinding(ComboBox.ItemsSourceProperty, "Variables[" + viewElement.Properties["ValueListVariable"].ToString(context) + "].ValueList");
            }

            comboBox.SetBinding(ComboBox.TextProperty, "Variables[" + variable + "].Value");
            comboBox.IsEditable = viewElement.Properties["Editable"].ToBool(context);


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

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

            var label = new TextBlock()
            {
                Text              = viewElement.Properties["Caption"].ToString(context),
                FontSize          = viewElement.Properties["FontSize"].ToInt(context),
                VerticalAlignment = VerticalAlignment.Center,
            };

            if (viewElement.Properties["Orientation"].ToString(context) == "Vertical")
            {
                label.TextAlignment = TextAlignment.Center;
            }


            if (viewElement.Properties["LabelWidth"].ToInt(context) > 0)
            {
                label.Width = viewElement.Properties["LabelWidth"].ToInt(context);
            }

            if (viewElement.Properties["Height"].ToInt(context) > 0)
            {
                label.Height = viewElement.Properties["Height"].ToInt(context);
            }

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

            var stackpanel = new StackPanel()
            {
                Margin      = new Thickness(viewElement.Properties["Margins"].ToInt(context)),
                Orientation = viewElement.Properties["Orientation"].ToString(context) == "Horizontal"
                    ? Orientation.Horizontal
                    : Orientation.Vertical
            };

            stackpanel.Children.Add(label);
            stackpanel.Children.Add(comboBox);

            return(stackpanel);
        }
        public FrameworkElement GetControl(WorkFlowViewElement viewElement, Context context)
        {
            var textBox = new TextBox()
            {
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
                VerticalContentAlignment   = VerticalAlignment.Center,
                HorizontalContentAlignment = HorizontalAlignment.Center
            };

            viewElement.SetSize(textBox, context);

            textBox.DataContext = viewElement.Parent.Parent.Variables[viewElement.Properties["Variable"].Value];
            textBox.SetBinding(TextBox.TextProperty, "Value");

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

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

            var label = new System.Windows.Controls.Label()
            {
                Height   = viewElement.Properties["Height"].ToInt(context),
                Content  = viewElement.Properties["Caption"].Value,
                Margin   = new Thickness(viewElement.Properties["Margins"].ToInt(context)),
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
                VerticalContentAlignment = VerticalAlignment.Center,
            };

            if (viewElement.Properties["Orientation"].ToString(context) == "Vertical")
            {
                label.HorizontalContentAlignment = HorizontalAlignment.Center;
            }

            if (viewElement.Properties["LabelWidth"].ToInt(context) > 0)
            {
                label.Width = viewElement.Properties["LabelWidth"].ToInt(context);
            }


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

            var button = new System.Windows.Controls.Button()
            {
                Height   = viewElement.Properties["Height"].ToInt(context),
                Content  = viewElement.Properties["ButtonText"].Value,
                Margin   = new Thickness(viewElement.Properties["Margins"].ToInt(context)),
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
                VerticalContentAlignment = VerticalAlignment.Center,
                HorizontalAlignment      = HorizontalAlignment.Right
            };

            if (viewElement.Properties["Orientation"].Value == "Vertical")
            {
                button.HorizontalAlignment = HorizontalAlignment.Stretch;
            }

            button.Click += (sender, e) =>
            {
                try
                {
                    FolderBrowserDialog browserDialog = new FolderBrowserDialog();
                    if (viewElement.Parent.Parent.Variables[viewElement.Properties["Variable"].Value].Value != null)
                    {
                        browserDialog.SelectedPath =
                            viewElement.Parent.Parent.Variables[viewElement.Properties["Variable"].Value].Value;
                    }
                    if (browserDialog.ShowDialog() == DialogResult.OK)
                    {
                        viewElement.Parent.Parent.Variables[viewElement.Properties["Variable"].Value].Value =
                            browserDialog.SelectedPath;
                    }
                }
                catch (Exception ex)
                {
                    Log.Error("Unable to browse folder", ex);
                }
            };
            var stackpanel = new StackPanel();

            stackpanel.Children.Add(label);
            stackpanel.Children.Add(textBox);
            stackpanel.Children.Add(button);
            stackpanel.Orientation = viewElement.Properties["Orientation"].Value == "Horizontal" ? Orientation.Horizontal : Orientation.Vertical;
            return(stackpanel);
        }
Beispiel #9
0
        public FrameworkElement GetControl(WorkFlowViewElement viewElement, Context context)
        {
            var textBox = new TextBox()
            {
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
                VerticalContentAlignment   = VerticalAlignment.Center,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                IsReadOnly = viewElement.Properties["IsReadOnly"].ToBool(context),
            };

            viewElement.SetSize(textBox, context);

            textBox.DataContext = viewElement.Parent.Parent.Variables[viewElement.Properties["Variable"].ToString(context)];
            textBox.SetBinding(TextBox.TextProperty, "Value");

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

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

            var label = new System.Windows.Controls.Label()
            {
                Height   = viewElement.Properties["Height"].ToInt(context),
                Content  = viewElement.Properties["Caption"].ToString(context),
                Margin   = new Thickness(viewElement.Properties["Margins"].ToInt(context)),
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
                VerticalContentAlignment = VerticalAlignment.Center,
            };

            if (viewElement.Properties["LabelWidth"].ToInt(context) > 0)
            {
                label.Width = viewElement.Properties["LabelWidth"].ToInt(context);
            }

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

            var stackpanel = new StackPanel();

            stackpanel.Children.Add(label);
            stackpanel.Children.Add(textBox);
            stackpanel.Orientation = viewElement.Properties["Orientation"].ToString(context) == "Horizontal" ? Orientation.Horizontal : Orientation.Vertical;
            return(stackpanel);
        }
        public FrameworkElement GetControl(WorkFlowViewElement viewElement, Context context)
        {
            //< StackPanel Margin = "2,0" >

            //    < Label Content = "{T:TranslateExtension Iso}" Target = "{Binding ElementName=cmb_iso}" Padding = "0" />

            //    < Border BorderThickness = "1" BorderBrush = "{Binding Path=IsoNumber.ErrorColor}" >

            //    < ComboBox Name = "cmb_iso" IsEnabled = "{Binding Path=IsoNumber.IsEnabled}" ItemsSource = "{Binding Path=IsoNumber.Values}" SelectedValue = "{Binding Path=IsoNumber.Value}" />

            //    </ Border >

            //    </ StackPanel >

            var property = GetProperty(viewElement.Properties["Property"].Value,
                                       ServiceProvider.Instance.DeviceManager.SelectedCameraDevice);
            ComboBox comboBox = new ComboBox()
            {
                FontSize = viewElement.Properties["FontSize"].ToInt(context),
                VerticalContentAlignment   = VerticalAlignment.Center,
                HorizontalContentAlignment = HorizontalAlignment.Center
            };

            viewElement.SetSize(comboBox, context);

            comboBox.DataContext = property;
            comboBox.SetBinding(ComboBox.IsEnabledProperty, "IsEnabled");
            comboBox.SetBinding(ComboBox.ItemsSourceProperty, "Values");
            comboBox.SetBinding(ComboBox.SelectedValueProperty, "Value");

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

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

            var label = new TextBlock()
            {
                Text              = viewElement.Properties["Caption"].ToString(context),
                FontSize          = viewElement.Properties["FontSize"].ToInt(context),
                VerticalAlignment = VerticalAlignment.Center,
            };

            if (viewElement.Properties["LabelWidth"].ToInt(context) > 0)
            {
                label.Width = viewElement.Properties["LabelWidth"].ToInt(context);
            }

            if (viewElement.Properties["Height"].ToInt(context) > 0)
            {
                label.Height = viewElement.Properties["Height"].ToInt(context);
            }

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

            var stackpanel = new StackPanel()
            {
                Margin      = new Thickness(viewElement.Properties["Margins"].ToInt(context)),
                Orientation = viewElement.Properties["Orientation"].ToString(context) == "Horizontal"
                    ? Orientation.Horizontal
                    : Orientation.Vertical
            };

            stackpanel.Children.Add(label);
            stackpanel.Children.Add(comboBox);

            return(stackpanel);
        }