public static Button CreateButton(String text, int height, int width, String horizAlign, String vertAlign)
 {
     Button basicButton = new Button();
     basicButton.Height = height;
     basicButton.Width = width;
     basicButton.Content = text;
     basicButton.SetBinding(Button.HorizontalAlignmentProperty, horizAlign);
     basicButton.SetBinding(Button.VerticalAlignmentProperty, vertAlign);
     return basicButton;
 }
        public GlobalDaysOfWeek()
        {
            _currentDateFormat = DateTimeTools.GetCurrentDateFormat();
            _dayOfWeekSelections = new List<DayOfWeekSelection>();

            var shortestDayNamesInOrder = _currentDateFormat.ShortestDayNamesInOrder();
            int i = 0;
            foreach (var shortestDayName in shortestDayNamesInOrder)
            {
                var selection = new DayOfWeekSelection(_currentDateFormat.DayOfWeek(i++), shortestDayName)
                                                   {
                                                       IsSelected = false
                                                   };
                _dayOfWeekSelections.Add(selection);
            }

            InitializeComponent();

            foreach (var dayOfWeekSelection in _dayOfWeekSelections)
            {
                var dayOfWeekButton = new Button() { DataContext = dayOfWeekSelection, FontSize = 14};
                dayOfWeekButton.SetBinding(ContentControl.ContentProperty, new Binding("ShortestDayName"));
                dayOfWeekButton.SetBinding(Control.ForegroundProperty,
                                           new Binding("IsSelected")
                                               {
                                                   Converter = new SelectedStatusColorConverter(),
                                                   ConverterParameter = Foreground
                                               });
               
                dayOfWeekButton.Click += ((s, e) =>
                                              {
                                                  var dows = (DayOfWeekSelection) ((Button) s).DataContext;
                                                  if (AllowEdit)
                                                  {
                                                      dows.IsSelected = !dows.IsSelected;

                                                      var selectedDaysOfWeekList = SelectedDaysOfWeek.ToList();

                                                      if (dows.IsSelected)
                                                          selectedDaysOfWeekList.Add(dows.DayOfWeek);
                                                      else
                                                          selectedDaysOfWeekList.Remove(dows.DayOfWeek);

                                                      SelectedDaysOfWeek = selectedDaysOfWeekList.ToArray();

                                                      //Update binding
                                                      BindingExpression be =
                                                          this.GetBindingExpression(SelectedDaysOfWeekProperty);
                                                      be.UpdateSource();
                                                  }
                                              });

                this.GlobalDaysOfWeekLayoutRoot.Children.Add(dayOfWeekButton);
            }
        }
Beispiel #3
0
        public SetPage()
        {
            InitializeComponent();

              this.DataContext = m_setGame;

              m_setBoardElement.ProvideGame(m_setGame);

              this.Unloaded += delegate(object sender, RoutedEventArgs e) {
            m_setBoardElement.Dispose();
              };

            #if DEBUG

              Button testButton = new Button();
              testButton.Content = "_Test";
              testButton.Click += test_click;
              testButton.SetBinding(Button.IsEnabledProperty, "CanPlay");

              testButton.Padding = new Thickness(5);
              testButton.Margin = new Thickness(10, 0, 0, 0);

              m_stackPanel.Children.Add(testButton);

            #endif
        }
Beispiel #4
0
        public GameDialog() {
            DataContext = new ViewModel();
            InitializeComponent();

            ProgressRing.Style = FindResource(ProgressStyles.Next) as Style;

            _cancellationSource = new CancellationTokenSource();
            CancellationToken = _cancellationSource.Token;

            var rhmSettingsButton = new Button {
                Content = "RHM Settings",
                Command = RhmService.Instance.ShowSettingsCommand,
                MinHeight = 21,
                MinWidth = 65,
                Margin = new Thickness(4, 0, 0, 0)
            };

            rhmSettingsButton.SetBinding(VisibilityProperty, new Binding {
                Source = RhmService.Instance,
                Path = new PropertyPath(nameof(RhmService.Active)),
                Converter = new FirstFloor.ModernUI.Windows.Converters.BooleanToVisibilityConverter()
            });

            Buttons = new[] { rhmSettingsButton, CancelButton };
        }
Beispiel #5
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 #6
0
        /// <summary>
        /// Creates the element for a label.
        /// </summary>
        /// <param name="text">The text that is set as content.</param>
        /// <param name="timespan">The TimeSpan that is represented by the Button.</param>
        /// <returns>A Button representing the label.</returns>
        private Button CreateLabelElement(string text, TimeSpan timespan)
        {
            Button c = new Button();

            c.SetBinding(
                StyleProperty,
                new Binding()
            {
                Path   = new PropertyPath("TimeButtonStyle"),
                Source = this
            });
            c.VerticalAlignment = VerticalAlignment.Top;
            // the easiest way to pass a value. Since we manage this element
            // there is no interference possible.
            c.Tag     = timespan;
            c.Content = text;
            c.Click  += OnLabelClicked;
            return(c);
        }
Beispiel #7
0
        public ComboBox( )
        {
            this.Background = Brushes.Red;

            this.Padding = new Thickness();
            this.Margin  = new Thickness();

            window  = new Window(this);
            cmdItem = new Button();
            lbItems = new ListBox();

            var itemsBinding = new Binding();

            itemsBinding.Mode   = BindingMode.OneWay;
            itemsBinding.Source = this;
            itemsBinding.Path   = new PropertyPath("Items");

            lbItems.Margin             = new Thickness(2);
            lbItems.BorderThickness    = new Thickness(0);
            lbItems.ItemContainerStyle = (Style)this.FindResource("ComboBoxItemStyle");
            lbItems.SetBinding(ListBox.ItemsProperty, itemsBinding);
            lbItems.SelectionChanged += (s, e) => {
                window.DialogResult = this.SelectedItem != null;
                window.Close();
                this.IsDropDownOpen = false;
            };

            window.Content = lbItems;

            var selectedItemBinding = new Binding("SelectedItem");

            selectedItemBinding.Mode   = BindingMode.TwoWay;
            selectedItemBinding.Source = lbItems;

            cmdItem.SetBinding(
                Button.ContentProperty,
                selectedItemBinding);

            this.SetBinding(
                ListBox.SelectedItemProperty,
                selectedItemBinding);
        }
Beispiel #8
0
        // Constructor
        public MainPage()
        {
            this.DataContext = this._viewModel;

            InitializeComponent();

            for (int i = 0; i < 7; i++)
            {
                ContentGameGrid.RowDefinitions.Add(new RowDefinition());
                ContentGameGrid.ColumnDefinitions.Add(new ColumnDefinition());
            }

            for (int i = 0; i < 7; i++)
            {
                for (int j = 0; j < 7; j++)
                {

                    var button = new Button();
                    button.Style = (Style)Resources["TextButton"];
                    button.Name = i.ToString() + j.ToString();
                    button.SetBinding(Button.ContentProperty, new Binding("Content") { Source = _viewModel.Items[i, j] });
                    button.DataContext = _viewModel.Items[i, j];

                    ContentGameGrid.Children.Add(button);
                    button.Height = 80;
                    int x = i;
                    int y = j;
                    _viewModel.Items[x, y].PropertyChanged += (sender, e) =>
                    {
                        if (_viewModel.Items[x, y].State == inline.Model.State.Empty && mState == GameState.AboutToMoveTheItem)
                            VisualStateManager.GoToState(button, "ValidDestinationForSelected", true);
                        else
                            VisualStateManager.GoToState(button, _viewModel.Items[x, y].State.ToString(), true);
                    };
                    button.Click += new RoutedEventHandler(button_Click);
                    Grid.SetRow(button, i);
                    Grid.SetColumn(button, j);

                }
            }
            this.Loaded += new RoutedEventHandler(MainPage_Loaded);
        }
Beispiel #9
0
        private void AddButtonControls(ToolbarInfo info)
        {
            var image = new Image
            {
                Source = new BitmapImage(new Uri(info.Image, UriKind.Relative))
            };

            var button = new Button
            {
                Content = image,
                ToolTip = IoC.Kernel.Get<IResourceHelper>().ReadResource(info.Text)
            };

            var binding = new Binding("DataContext." + info.Command)
            {
                RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(BaseWindow), 1),
                UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
            };
            button.SetBinding(Button.CommandProperty, binding);
            Items.Add(button);
        }
        public UIWithHierarchicalPath()
        {
            var grid = new Grid();
            Content = grid;

            var label = new Label();
            label.SetBinding(Label.ContentProperty, new Binding("Items/Description"));
            grid.Children.Add(label);

            var stack = new StackPanel();
            stack.SetBinding(StackPanel.DataContextProperty, new Binding("Items"));
            grid.Children.Add(stack);

            label = new Label();
            label.SetBinding(Label.ContentProperty, new Binding("/Description"));
            stack.Children.Add(label);

            var button = new Button();
            button.SetBinding(Button.ContentProperty, new Binding("/"));
            button.Template = CreateTemplate();
            stack.Children.Add(button);
        }
Beispiel #11
0
        public ComboBox ( ) {
			this.Background = Brushes.Red;

			this.Padding = new Thickness ();
			this.Margin = new Thickness ();

			window = new Window(this);
			cmdItem = new Button ();
			lbItems = new ListBox ();

			var itemsBinding = new Binding ();
			itemsBinding.Mode = BindingMode.OneWay;
			itemsBinding.Source = this;
			itemsBinding.Path = new PropertyPath ("Items");

			lbItems.Margin = new Thickness (2);
			lbItems.BorderThickness = new Thickness (0);
			lbItems.ItemContainerStyle = (Style)this.FindResource ("ComboBoxItemStyle");
			lbItems.SetBinding (ListBox.ItemsProperty, itemsBinding);
			lbItems.SelectionChanged += (s,e) => {
				window.DialogResult = this.SelectedItem != null;
				window.Close ();
				this.IsDropDownOpen = false;
			};
				
			window.Content = lbItems;

			var selectedItemBinding = new Binding ("SelectedItem");
			selectedItemBinding.Mode = BindingMode.TwoWay;
			selectedItemBinding.Source = lbItems;

			cmdItem.SetBinding (
				Button.ContentProperty, 
				selectedItemBinding);

			this.SetBinding (
				ListBox.SelectedItemProperty, 
				selectedItemBinding);
        }
Beispiel #12
0
        public override void SetupCustomUIElements(object ui)
        {
            var nodeUI = ui as dynNodeView;

            //add a button to the inputGrid on the dynElement
            _selectButton = new dynNodeButton
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Center
            };
            _selectButton.Click += selectButton_Click;

            _tb = new TextBlock
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Center,
                Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0)),
                TextWrapping = TextWrapping.Wrap,
                TextTrimming = TextTrimming.WordEllipsis,
                MaxWidth = 200,
                MaxHeight = 100
            };

            if (SelectedElements == null || !SelectedElements.Any() || !SelectionText.Any() || !SelectButtonContent.Any())
            {
                SelectionText = "Nothing Selected";
                SelectButtonContent = "Select Instances";
            }

            nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());
            nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());

            nodeUI.inputGrid.Children.Add(_tb);
            nodeUI.inputGrid.Children.Add(_selectButton);

            System.Windows.Controls.Grid.SetRow(_selectButton, 0);
            System.Windows.Controls.Grid.SetRow(_tb, 1);

            _tb.DataContext = this;
            _selectButton.DataContext = this;

            var selectTextBinding = new System.Windows.Data.Binding("SelectionText")
            {
                Mode = BindingMode.TwoWay,
            };
            _tb.SetBinding(TextBlock.TextProperty, selectTextBinding);

            var buttonTextBinding = new System.Windows.Data.Binding("SelectButtonContent")
            {
                Mode = BindingMode.TwoWay,
            };
            _selectButton.SetBinding(ContentControl.ContentProperty, buttonTextBinding);

            var buttonEnabledBinding = new System.Windows.Data.Binding("CanSelect")
            {
                Mode = BindingMode.TwoWay,
            };
            _selectButton.SetBinding(Button.IsEnabledProperty, buttonEnabledBinding);
        }
        private void CreateOnOffStopOperationInfo(Grid grid, FALibrary.Part.FAPart part, string name, Action<object> OnAction, Action<object> OffAction, Action<object> StopAction, Func<bool> IsOn, Func<bool> IsOff, string onName, string offName)
        {
            GeneralOperationInfo obj = new GeneralOperationInfo();
            RowDefinition rd = new RowDefinition();
            rd.Height = new GridLength(150, GridUnitType.Auto);
            rd.MinHeight = 100;
            grid.RowDefinitions.Add(rd);
            SetOperationGridColor(grid, grid.RowDefinitions.Count - 1);

            obj.Name = name;
            obj.On = OnAction;
            obj.Off = OffAction;
            obj.StatusOnName = onName;
            obj.StatusOffName = offName;
            obj.IsOn = IsOn;
            obj.IsOff = IsOff;

            Label labelName = new Label();
            labelName.Height = Double.NaN;
            labelName.Width = Double.NaN;
            labelName.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            labelName.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            labelName.Margin = new Thickness(2);
            Binding bd = new Binding("Name");
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            TextBlock textBlockName = new TextBlock();
            textBlockName.TextWrapping = TextWrapping.Wrap;
            textBlockName.TextAlignment = TextAlignment.Center;
            textBlockName.SetBinding(TextBlock.TextProperty, bd);
            labelName.Content = textBlockName;

            Label labelStatus = new Label();
            labelStatus.Height = Double.NaN;
            labelStatus.Width = Double.NaN;
            labelStatus.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            labelStatus.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            labelStatus.Margin = new Thickness(2);
            bd = new Binding("Status");
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            TextBlock textBlockStatus = new TextBlock();
            textBlockStatus.TextWrapping = TextWrapping.Wrap;
            textBlockStatus.TextAlignment = TextAlignment.Center;
            textBlockStatus.SetBinding(TextBlock.TextProperty, bd);
            labelStatus.Content = textBlockStatus;

            Grid gridInputIOList = CreatePartInputIOList(part);
            Grid gridOutputIOList = CreatePartOutputIOList(part);

            Button buttonOnOff = new Button();
            buttonOnOff.Height = Double.NaN;
            buttonOnOff.Width = Double.NaN;
            buttonOnOff.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            buttonOnOff.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            buttonOnOff.Margin = new Thickness(2);
            bd = new Binding("ButtonCaption");
            bd.Source = obj;
            bd.Mode = BindingMode.OneWay;
            buttonOnOff.SetBinding(Button.ContentProperty, bd);
            buttonOnOff.Click +=
                delegate(object sender, RoutedEventArgs e)
                {
                    if (obj.IsOn())
                        OffAction(sender);
                    else
                    {
                        if (obj.IsOff())
                            OnAction(sender);
                        else if (StopAction != null)
                        {
                            StopAction(sender);
                        }
                        else
                            OnAction(sender);
                    }
                };

            TextBox textBoxRepeat = new TextBox();
            textBoxRepeat.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
            textBoxRepeat.VerticalContentAlignment = System.Windows.VerticalAlignment.Center;
            textBoxRepeat.Height = Double.NaN;
            textBoxRepeat.Width = Double.NaN;
            textBoxRepeat.Margin = new Thickness(2);
            bd = new Binding("RepeatTime");
            bd.Source = obj;
            bd.Mode = BindingMode.TwoWay;
            FAFramework.Utility.BindingUtility.SetBindingObject(textBoxRepeat, BindingMode.TwoWay, obj, TextBox.TextProperty, "RepeatTime");

            CheckBox checkBoxRepeatUse = new CheckBox();
            checkBoxRepeatUse.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            checkBoxRepeatUse.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            checkBoxRepeatUse.LayoutTransform = new ScaleTransform(CHECKBOX_SIZE, CHECKBOX_SIZE);
            bd = new Binding("RepeatUse");
            bd.Source = obj;
            bd.Mode = BindingMode.TwoWay;
            checkBoxRepeatUse.SetBinding(CheckBox.IsCheckedProperty, bd);

            int rowCount = grid.RowDefinitions.Count - 1;
            grid.Children.Add(labelName);
            Grid.SetColumn(labelName, 0);
            Grid.SetRow(labelName, rowCount);

            grid.Children.Add(labelStatus);
            Grid.SetColumn(labelStatus, 1);
            Grid.SetRow(labelStatus, rowCount);

            grid.Children.Add(gridInputIOList);
            Grid.SetColumn(gridInputIOList, 2);
            Grid.SetRow(gridInputIOList, rowCount);

            grid.Children.Add(gridOutputIOList);
            Grid.SetColumn(gridOutputIOList, 3);
            Grid.SetRow(gridOutputIOList, rowCount);

            grid.Children.Add(buttonOnOff);
            Grid.SetColumn(buttonOnOff, 4);
            Grid.SetRow(buttonOnOff, rowCount);

            grid.Children.Add(textBoxRepeat);
            Grid.SetColumn(textBoxRepeat, 5);
            Grid.SetRow(textBoxRepeat, rowCount);

            grid.Children.Add(checkBoxRepeatUse);
            Grid.SetColumn(checkBoxRepeatUse, 6);
            Grid.SetRow(checkBoxRepeatUse, rowCount);

            _ioOperationList.Add(obj);

            bd = new Binding("IsEnabledOutputIODirectControl");
            bd.Source = this;
            bd.Mode = BindingMode.OneWay;
            gridOutputIOList.SetBinding(ListView.IsEnabledProperty, bd);
        }
Beispiel #14
0
        internal static void DisplayXML(ListBox ListBox1, ObjectXML table)
        {
            ListBox1.Items.Clear();

            StackPanel panel1 = new StackPanel();
            panel1.Orientation = Orientation.Horizontal;
            ListBox1.VerticalAlignment = VerticalAlignment.Center;
            ListBox1.HorizontalAlignment = HorizontalAlignment.Center;

            for (int col = 0; col < table.colNum; col++)
            {
                Button button = new Button();
                Coords coords = new Coords(0, col);

                button.Name = "field" + '_' + (col + 1).ToString() + '_' + 0.ToString();
                button.DataContext = MainWindow.objectXML.header[coords.GetHashCode()];
                button.SetBinding(Button.ContentProperty, new Binding("headerCellHeader"));
                button.SetBinding(Button.HeightProperty, new Binding("headerCellHeight"));
                button.SetBinding(Button.WidthProperty, new Binding("headerCellWidth"));
                button.SetBinding(Button.FontSizeProperty, new Binding("headerCellFontSize"));

                button.Click += EditHeaderClick;
                button.Foreground = Brushes.Black;

                AlignChange(ref button, coords);
                getRes(button);

                button.Padding = new Thickness(5, 0, 5, 0);
                button.Background = Brushes.LightGray;
                button.BorderBrush = Brushes.Black;

                if (coords.Equals(MainWindow.LastActiveCoords)) button.Background = Brushes.LightSkyBlue;

                panel1.Children.Add(button);
            }

            ListBox1.Items.Add(panel1);

            for (int row = 1; row < table.rowNum; row++)
            {

                StackPanel panel = new StackPanel();
                panel.Orientation = Orientation.Horizontal;
                for (int col = 0; col < table.colNum; col++)
                {
                    Button button = new Button();
                    Coords coords = new Coords(row, col);
                    Binding bindParam = new Binding();
                    bindParam.Source = MainWindow.objectXML.cells[coords.GetHashCode()];
                    bindParam.Path = new PropertyPath("tabCellParametr");
                    button.Name = "field" + '_' + (col + 1).ToString() + '_' + row.ToString();
                    button.SetBinding(Button.ContentProperty,bindParam);
                    button.DataContext = MainWindow.objectXML.header[new Coords(0, col).GetHashCode()];
                    button.SetBinding(Button.HeightProperty, new Binding("headerCellHeight"));
                    button.SetBinding(Button.WidthProperty, new Binding("headerCellWidth"));
                    button.SetBinding(Button.FontSizeProperty, new Binding("headerCellFontSize"));
                    button.Foreground = Brushes.Black;
                    button.Padding = new Thickness(5, 0, 5, 0);
                    button.Click += EditCellClick;
                    getRes(button);
                    AlignChange(ref button, coords);

                    button.Background = Brushes.LightGray;
                    button.BorderBrush = Brushes.Black;

                    if (coords.Equals(MainWindow.LastActiveCoords)) button.Background = Brushes.LightSkyBlue;

                    panel.Children.Add(button);
                }

                ListBox1.Items.Add(panel);
            }
        }
Beispiel #15
0
        public override void SetupCustomUIElements(Controls.dynNodeView nodeUI)
        {
            //add a button to the inputGrid on the dynElement
            _selectButton = new dynNodeButton
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Center
            };
            _selectButton.Click += selectButton_Click;

            _tb = new TextBox
            {
                HorizontalAlignment = HorizontalAlignment.Stretch,
                VerticalAlignment = VerticalAlignment.Center,
                Background = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0)),
                BorderThickness = new Thickness(0),
                IsReadOnly = true,
                IsReadOnlyCaretVisible = false
            };

            //tb.Text = "Nothing Selected";
            if (SelectedElement == null || !SelectionText.Any() || !SelectButtonContent.Any())
            {
                SelectionText = "Nothing Selected";
                SelectButtonContent = "Select Instance";
            }

            //NodeUI.SetRowAmount(2);
            nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());
            nodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());

            nodeUI.inputGrid.Children.Add(_tb);
            nodeUI.inputGrid.Children.Add(_selectButton);

            System.Windows.Controls.Grid.SetRow(_selectButton, 0);
            System.Windows.Controls.Grid.SetRow(_tb, 1);

            _tb.DataContext = this;
            _selectButton.DataContext = this;

            var selectTextBinding = new System.Windows.Data.Binding("SelectionText")
            {
                Mode = BindingMode.TwoWay,
            };
            _tb.SetBinding(TextBox.TextProperty, selectTextBinding);

            var buttonTextBinding = new System.Windows.Data.Binding("SelectButtonContent")
            {
                Mode = BindingMode.TwoWay,
            };
            _selectButton.SetBinding(ContentControl.ContentProperty, buttonTextBinding);
        }
        private void LoadTiles()
        {
            // TODO: This method could probably be be optimized! We can probably get away without reloading everything every time.

            lock (this)
            {
                foreach (var child in Children)
                {
                    var childButton = child as Button;
                    if (childButton != null)
                    {
                        childButton.Content = null;
                        childButton.DataContext = null;
                    }
                }
                Children.Clear();

                var actionsHost = DataContext as IHaveActions;
                if (actionsHost != null)
                {
                    List<IViewAction> currentActions;
                    lock (actionsHost.Actions) // Trying to do this as quickly as possible to avoid threading problems
                        currentActions = actionsHost.Actions.OrderBy(a => a.CategoryOrder).ToList();

                    RemoveAllMenuKeyBindings();

                    foreach (var action in currentActions)
                    {
                        var button = new Button();
                        button.SetResourceReference(StyleProperty, "Metro-Control-TileButton");
                        button.Command = action;

                        var visibilityBinding = new Binding("Availability") {Source = action, Converter = new AvailabilityToVisibilityConverter()};
                        button.SetBinding(VisibilityProperty, visibilityBinding);

                        if (action.ActionView == null)
                        {
                            var realAction = action as ViewAction;
                            if (realAction != null && !realAction.HasBrush && !realAction.HasExecuteDelegate && string.IsNullOrEmpty(action.Caption))
                                continue; // Not adding this since is has no brush and no execute and no caption

                            switch (action.Significance)
                            {
                                case ViewActionSignificance.Highest:
                                    var view = Controller.LoadView("CODEFrameworkStandardViewTileWideSquare");
                                    button.Content = view;
                                    view.DataContext = action.ActionViewModel ?? action;
                                    //action.ActionView = view; // No need to re-load this later...
                                    SetTileWidthMode(button, TileWidthModes.DoubleSquare);
                                    break;
                                case ViewActionSignificance.AboveNormal:
                                    var view2 = Controller.LoadView("CODEFrameworkStandardViewTileWide");
                                    button.Content = view2;
                                    view2.DataContext = action.ActionViewModel ?? action;
                                    //action.ActionView = view2; // No need to re-load this later...
                                    SetTileWidthMode(button, TileWidthModes.Double);
                                    break;
                                case ViewActionSignificance.Normal:
                                case ViewActionSignificance.BelowNormal:
                                    var view3 = Controller.LoadView("CODEFrameworkStandardViewTileNarrow");
                                    button.Content = view3;
                                    view3.DataContext = action.ActionViewModel ?? action;
                                    //action.ActionView = view3; // No need to re-load this later...
                                    SetTileWidthMode(button, TileWidthModes.Normal);
                                    break;
                                case ViewActionSignificance.Lowest:
                                    var view4 = Controller.LoadView("CODEFrameworkStandardViewTileTiny");
                                    button.Content = view4;
                                    view4.DataContext = action.ActionViewModel ?? action;
                                    //action.ActionView = view4; // No need to re-load this later...
                                    SetTileWidthMode(button, TileWidthModes.Tiny);
                                    break;
                            }
                        }
                        else
                        {
                            button.Content = action.ActionView;
                            if (action.ActionView.DataContext == null) action.ActionView.DataContext = action.ActionViewModel ?? action;
                            switch (action.Significance)
                            {
                                case ViewActionSignificance.Highest:
                                    SetTileWidthMode(button, TileWidthModes.DoubleSquare);
                                    break;
                                case ViewActionSignificance.AboveNormal:
                                    SetTileWidthMode(button, TileWidthModes.Double);
                                    break;
                                case ViewActionSignificance.Normal:
                                case ViewActionSignificance.BelowNormal:
                                    SetTileWidthMode(button, TileWidthModes.Normal);
                                    break;
                                case ViewActionSignificance.Lowest:
                                    SetTileWidthMode(button, TileWidthModes.Tiny);
                                    break;
                            }
                        }

                        if (action.Categories.Count > 0)
                        {
                            SetGroupName(button, action.Categories[0].Id);
                            SetGroupTitle(button, action.Categories[0].Caption);
                        }
                        else
                        {
                            SetGroupName(button, string.Empty);
                            SetGroupTitle(button, string.Empty);
                        }

                        Children.Add(button);

                        if (action.AccessKey != ' ')
                            _menuKeyBindings.Add(new ViewActionMenuKeyBinding(action) {Key = action.ShortcutKey, Modifiers = action.ShortcutModifiers});
                    }

                    CreateAllMenuKeyBindings();
                }
            }
        }
Beispiel #17
0
        public override void SetupCustomUIElements(Controls.dynNodeView NodeUI)
        {
            //add a button to the inputGrid on the dynElement
            selectButton = new System.Windows.Controls.Button();
            selectButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            selectButton.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            selectButton.Click += new System.Windows.RoutedEventHandler(selectButton_Click);
            //selectButton.Content = "Select Instances";
            selectButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            selectButton.VerticalAlignment = System.Windows.VerticalAlignment.Center;

            tb = new TextBox();
            //tb.Text = "Nothing Selected";
            SelectionText = "Nothing Selected";
            SelectButtonContent = "Select Instances";

            tb.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
            tb.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            SolidColorBrush backgroundBrush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(0, 0, 0, 0));
            tb.Background = backgroundBrush;
            tb.BorderThickness = new Thickness(0);
            tb.IsReadOnly = true;
            tb.IsReadOnlyCaretVisible = false;

            NodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());
            NodeUI.inputGrid.RowDefinitions.Add(new RowDefinition());

            NodeUI.inputGrid.Children.Add(tb);
            NodeUI.inputGrid.Children.Add(selectButton);

            System.Windows.Controls.Grid.SetRow(selectButton, 0);
            System.Windows.Controls.Grid.SetRow(tb, 1);

            tb.DataContext = this;
            selectButton.DataContext = this;

            var selectTextBinding = new System.Windows.Data.Binding("SelectionText")
            {
                Mode = BindingMode.TwoWay,
            };
            tb.SetBinding(TextBox.TextProperty, selectTextBinding);

            var buttonTextBinding = new System.Windows.Data.Binding("SelectButtonContent")
            {
                Mode = BindingMode.TwoWay,
            };
            selectButton.SetBinding(Button.ContentProperty, buttonTextBinding);
        }
 /// <summary>
 /// Creates the element for a label.
 /// </summary>
 /// <param name="text">The text that is set as content.</param>
 /// <param name="timespan">The TimeSpan that is represented by the Button.</param>
 /// <returns>A Button representing the label.</returns>
 private Button CreateLabelElement(string text, TimeSpan timespan)
 {
     Button c = new Button();
     c.SetBinding(
         StyleProperty, 
         new Binding()
                                     {
                                             Path = new PropertyPath("TimeButtonStyle"),
                                             Source = this
                                     });
     c.VerticalAlignment = VerticalAlignment.Top;
     // the easiest way to pass a value. Since we manage this element
     // there is no interference possible.
     c.Tag = timespan;
     c.Content = text;
     c.Click += OnLabelClicked;
     return c;
 }
Beispiel #19
0
        private void Init()
        {
            scaleConv = new ScaleConverter();

            coins = new Dictionary<FHVGame.Shared.Models.Game.Point, Ellipse>();
            lines = new List<Line>();

            // Remove all elements
            rootCanvas.Children.RemoveRange(0, rootCanvas.Children.Count);

            Level = DataClient.Get();
            DrawWalls(Level.Lvl.Walls);
            DrawCoins(Level);

            if (IsDebug)
            {
                DrawAchsis();

                Binding bCommand = new Binding("CmdSave");
                Button save = new Button();
                save.Content = "Save";
                save.SetValue(Grid.RowProperty, 1);
                save.SetBinding(Button.CommandProperty, bCommand);
                save.SetValue(Grid.ColumnProperty, 1);
                InfoGrid.Children.Add(save);
            }
        }
Beispiel #20
0
        /// <summary>
        /// Called when [apply template].
        /// </summary>
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate ();
            _btnSave = GetTemplateChild ( "Part_SaveButton" ) as Button;
            _btnNext = GetTemplateChild ( "Part_NextButton" ) as Button;
            _btnCancel = GetTemplateChild ( "Part_CancelButton" ) as Button;
            _focusElement = GetTemplateChild ( "Part_Focus" ) as Grid;
            _contentPresenter = GetTemplateChild ( "PART_ContentPresenter" ) as ContentPresenter;
            _maximizeGrid = GetTemplateChild ( "PART_MaximizeGrid" ) as Grid;
            _rootGrid = GetTemplateChild ( "PART_RootGrid" ) as Grid;

            _saveCompositeCommand = new CompositeCommand ();
            _saveCompositeCommand.RegisterCommand ( new DelegateCommand ( ExecuteSaveCommand ) );
            if ( SaveCommand != null )
            {
                _saveCompositeCommand.RegisterCommand ( SaveCommand );
                if ( !_afterSaveCommandIntialized )
                {
                    _afterSaveCommandIntialized = true;
                    _saveCompositeCommand.RegisterCommand ( new DelegateCommand ( AfterSaveCommandExecute ) );
                }
            }
            _btnSave.Command = _saveCompositeCommand;
            var contentBinding = new Binding ();
            contentBinding.Source = this;
            contentBinding.Path = new PropertyPath ( PropertyUtil.ExtractPropertyName ( () => Content ) );
            _btnSave.SetBinding ( ButtonBase.CommandParameterProperty, contentBinding );
            _btnNext.Click += NextClicked;
            _btnCancel.Click += CancelClick;
            LostFocus += Content_LostFocus;
            _focusElement.MouseLeftButtonDown += Content_MouseLeftButtonDown;
            AddHandler ( MouseLeftButtonDownEvent, new MouseButtonEventHandler ( EditableExpander_MouseLeftButtonDown ), true );
            MouseLeftButtonDown += EditableExpander_MouseLeftButtonDown;

            if ( IsExpanded )
            {
                VisualStateManager.GoToState ( this, "RevealState", true );
            }

            if ( UsingEditableContentTemplate () )
            {
                ContentTemplate = EditableContentTemplate;
            }

            _templateApplied = true;

            UpdateContentPresenter();

            if ( IsEditing )
            {
                TurnOnEditing ();
            }
            else
            {
                TurnOffEditing ();
            }
        }
        private void addButton(
            string buttonText,
            Action callback,
            bool isDefault,
            bool isCancel,
            string bindingPath)
        {
            var btn = new Button
            {
                Content = buttonText,
                IsDefault = isDefault,
                IsCancel = isCancel,
                Margin = new Thickness(5),
                FontFamily = new FontFamily("Tahoma"),
                Width = 30,
                Height = 30
            };

            var enabledBinding = new Binding(bindingPath) { Source = _dialog };
            btn.SetBinding(IsEnabledProperty, enabledBinding);

            btn.Click += (s, e) => callback();

            ButtonsGrid.Columns++;
            ButtonsGrid.Children.Add(btn);
        }
        private void PopulatePropertyValues(ControlSystemComponent controlSystemComponent)
        {
            int rowCount = 1;
            const int rowHeight = 25;

            //var controlSystemComponentProperies = controlSystemComponent.ControlSystemComponentType.ControlSystemComponentTypeProperties.OrderBy(x => x.Ordinal).ToList();
            var controlSystemComponentTypeTuningProperties =
                controlSystemComponent.ControlSystemComponentType.ControlSystemComponentTypeTuningProperties.OrderBy(x => x.Ordinal).ToList();

            CmsWebServiceClient cmsWebServiceClient = new CmsWebServiceClient(Utils.WcfBinding, Utils.WcfEndPoint);
            cmsWebServiceClient.GetAllPropertyListsCompleted += (s, e) =>
            {
                List<ComponentTypeGroup> addedGroups = new List<ComponentTypeGroup>();
                //controlSystemComponentProperies.Where(x => x.ComponentTypeGroupId.HasValue).ToList().ForEach(x => x.Ordinal = x.ComponentTypeGroup.Ordinal);
                controlSystemComponentTypeTuningProperties = controlSystemComponentTypeTuningProperties.
                    OrderBy(x => x.Ordinal).ThenBy(x => x.GroupOrdinal).ToList();

                foreach (var controlSystemComponentTypeTuningProperty in controlSystemComponentTypeTuningProperties.Where(x => x.ControlSystemTuningProperty.IsVisible))
                {
                    if (controlSystemComponentTypeTuningProperty.ComponentTypeGroupId.HasValue && !addedGroups.Contains(controlSystemComponentTypeTuningProperty.ComponentTypeGroup))
                    {
                        Label groupLabel = new Label
                        {
                            Content = controlSystemComponentTypeTuningProperty.ComponentTypeGroup.Name,
                            VerticalAlignment = VerticalAlignment.Center,
                            Margin = new Thickness(1),
                            FontWeight = FontWeights.Bold
                        };

                        PropertiesGrid.Children.Add(groupLabel);
                        Grid.SetRow(groupLabel, rowCount);
                        Grid.SetColumn(groupLabel, 0);
                        PropertiesGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(26) });
                        rowCount++;
                        addedGroups.Add(controlSystemComponentTypeTuningProperty.ComponentTypeGroup);
                    }

                    //Property Label
                    Label label = new Label();

                    Binding labelBinding = new Binding("Name")
                    {
                        Mode = BindingMode.OneTime,
                        Source = controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty
                    };

                    label.SetBinding(ContentControl.ContentProperty, labelBinding);
                    label.VerticalAlignment = VerticalAlignment.Center;
                    label.Margin = new Thickness(1);

                    Silverlight.Controls.ToolTips.ToolTip nameTip = new Silverlight.Controls.ToolTips.ToolTip
                    {
                        Content = controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty.Description
                    };
                    ToolTipService.SetToolTip(label, nameTip);

                    PropertiesGrid.Children.Add(label);
                    Grid.SetRow(label, rowCount);
                    Grid.SetColumn(label, 0);

                    var propertyValue = GetPropertyValue(controlSystemComponent, controlSystemComponentTypeTuningProperty);

                    var tuningPropertyWrapViewModel = new TuningPropertyWrapViewModel(controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty, propertyValue);
                    TuningPropertyWrapViewModels.Add(tuningPropertyWrapViewModel);

                    //Property VALUE
                    var element = BindElementValue(tuningPropertyWrapViewModel, e.Result);
                    PropertiesGrid.Children.Add(element);
                    Grid.SetRow((FrameworkElement) element, rowCount);
                    Grid.SetColumn((FrameworkElement) element, 1);

                    //PCS Value
                    var pcsValueElement = BindElementPcsvalue(tuningPropertyWrapViewModel, "PcsValue");
                    pcsValueElement.IsHitTestVisible = false;
                    //((CmsTextBox)pcsValueElement).Background = new SolidColorBrush(Color.FromArgb(255, 239, 239, 239));

                    PropertiesGrid.Children.Add(pcsValueElement);
                    Grid.SetRow((FrameworkElement) pcsValueElement, rowCount);
                    Grid.SetColumn((FrameworkElement) pcsValueElement, 2);

                    //Trended
                    var trendedElement = BindCheckBoxElement(tuningPropertyWrapViewModel, "Trended");
                    ((FrameworkElement) trendedElement).HorizontalAlignment = HorizontalAlignment.Center;

                    PropertiesGrid.Children.Add(trendedElement);
                    Grid.SetRow((FrameworkElement) trendedElement, rowCount);
                    Grid.SetColumn((FrameworkElement) trendedElement, 3);

                    //Notes
                    var notesElement = BindElementTextBox(tuningPropertyWrapViewModel, "Notes");

                    PropertiesGrid.Children.Add(notesElement);
                    Grid.SetRow((FrameworkElement) notesElement, rowCount);
                    Grid.SetColumn((FrameworkElement) notesElement, 4);

                    //Accept
                    Button acceptButton = new Button {Content = "Accept"};
                    acceptButton.Height = 23;
                    acceptButton.DataContext = tuningPropertyWrapViewModel;
                    acceptButton.Command = tuningPropertyWrapViewModel.AcceptCommand;
                    acceptButton.IsEnabled = controlSystemComponentTypeTuningProperty.ControlSystemTuningProperty.IsEditable;

                    Binding visibilityBinding = new Binding("AcceptButtonVisibility")
                    {
                        Mode = BindingMode.OneWay,
                        Source = tuningPropertyWrapViewModel
                    };
                    acceptButton.SetBinding(VisibilityProperty, visibilityBinding);

                    acceptButton.Width = 60;
                    PropertiesGrid.Children.Add(acceptButton);
                    Grid.SetRow((FrameworkElement) acceptButton, rowCount);
                    Grid.SetColumn((FrameworkElement) acceptButton, 5);

                    //ModfiedUserDate
                    var modfiedUserDate = BindElementLabel(tuningPropertyWrapViewModel, "ModfiedUserDate");
                    PropertiesGrid.Children.Add(modfiedUserDate);
                    Grid.SetRow((FrameworkElement) modfiedUserDate, rowCount);
                    Grid.SetColumn((FrameworkElement) modfiedUserDate, 6);

                    PropertiesGrid.RowDefinitions.Add(new RowDefinition {Height = new GridLength(rowHeight)});

                    rowCount++;
                }
            };
            cmsWebServiceClient.GetAllPropertyListsAsync();
        }
Beispiel #23
0
        // 创建一个动态属性编辑项
        private Grid createPropEntryGrid(PropertyInfo propInfo)
        {
            Grid grid = new Grid();

            Label lbSCParamName = new Label();
            lbSCParamName.Content = propInfo.Name;
            grid.Children.Add(lbSCParamName);

            ELogicType logicType = AssemblyUtil.GetPropertyLogicType(propInfo);

            if (logicType == ELogicType.Int || logicType == ELogicType.Percent)
            {
                TextBox tbSCParamValue = new TextBox();
                Binding tbBinding = new Binding(propInfo.Name);
                tbBinding.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                tbSCParamValue.SetBinding(TextBox.TextProperty, tbBinding);
                tbSCParamValue.Margin = new Thickness(80, 4, 0, 4);
                grid.Children.Add(tbSCParamValue);
            }
            else if (logicType == ELogicType.String)
            {
                LogManager.Instance.Error("此版本不支持String类型的动态类属性: " + propInfo.Name);
            }
            else if (logicType == ELogicType.BuffType)
            {
                Button btnBuff = new Button();
                Binding txtBinding = new Binding(propInfo.Name);
                txtBinding.Converter = (IValueConverter)Application.Current.TryFindResource("ID2BuffNameConverter");
                btnBuff.SetBinding(Button.ContentProperty, txtBinding);
                btnBuff.Margin = new Thickness(80, 4, 0, 4);
                grid.Children.Add(btnBuff);

                btnBuff.Click += (o, re) =>
                {
                    BuffPickWindow buffPickWindow = new BuffPickWindow();
                    if (buffPickWindow.ShowDialog() == true)
                    {
                        propInfo.SetValue(btnBuff.DataContext, buffPickWindow.PickedBuffType);
                    }
                };
            }
            else if (logicType == ELogicType.Element)
            {
                ComboBox cb = new ComboBox();
                cb.ItemsSource = Enum.GetNames(typeof(EElement));

                Binding binding = new Binding(propInfo.Name);
                binding.Converter = (IValueConverter)Application.Current.TryFindResource("Enum2StrConverter");
                binding.ConverterParameter = typeof(EElement);
                cb.SetBinding(ComboBox.TextProperty, binding);
                cb.Margin = new Thickness(80, 4, 0, 4);
                grid.Children.Add(cb);
            }
            else
            {
                LogManager.Instance.Error("配置了不支持的参数类型: " + propInfo.Name + " - " + logicType);
            }

            return grid;
        }
		public GroupBox CreateViewLayout (TemplateElementManagement.UpdateStatus UStatus)
			{
			GroupBoxForOneInfoAddOn = new GroupBox ();
			GroupBoxForOneInfoAddOn.HorizontalContentAlignment = HorizontalAlignment.Stretch;
			if ((String.Compare (WMB.Basics.GetComputerName (), "Heinz64", true) == 0)
				&& (WMB.WPMediaApplicationState.Instance.Properties.Keys.Contains ("TestOptionForDebugging")))
				{
				GroupBoxForOneInfoAddOn.Header = ActuallBezeichner + " (IAddOn= "
												+ this.InfoAddOn.ID.ToString() + ", "
												+ "Desc= " + this.DataTemplatesDescriptionEntry.ID.ToString()
												+ ", Elem= " + DataTemplatesDescriptionEntry.DataElementTemplateID.ToString() + ", "
												+ TemplateHandling.TemplateManagement.AllDataTemplates
													[(System.Guid)DataTemplatesDescriptionEntry.RootDataTemplatesID].NameID + ", "
												+ TemplateHandling.TemplateManagement.AllDataElement
													[(System.Guid)DataTemplatesDescriptionEntry.PhysicalDataElementID].Bezeichner + ", "
												+ DataTemplatesDescriptionEntry.Visibility + ")";
				}
			else
				GroupBoxForOneInfoAddOn.Header = ActuallBezeichner;

			GroupBoxForOneInfoAddOn.Tag = this;
			Grid LineGrid = new Grid ();
			GroupBoxForOneInfoAddOn.Content = LineGrid;
			LineGrid.ColumnDefinitions.Add (new ColumnDefinition ());
			LineGrid.ColumnDefinitions.Add (new ColumnDefinition ());
			LineGrid.ColumnDefinitions.Add (new ColumnDefinition ());
			LineGrid.ColumnDefinitions [0].Width = (GridLength) GLConverter.ConvertFromString ("20");
			if (UpdateMode == true)
				{
				LineGrid.ColumnDefinitions [1].Width = (GridLength) GLConverter.ConvertFromString ("*");
				LineGrid.ColumnDefinitions [2].Width = (GridLength) GLConverter.ConvertFromString ("80");
				}
			else
				{
				LineGrid.ColumnDefinitions [1].Width = (GridLength) GLConverter.ConvertFromString ("*");
				LineGrid.ColumnDefinitions [2].Width = (GridLength) GLConverter.ConvertFromString ("0");

				}
			TextBlock FreitextBlock = new TextBlock ();
			FreitextBlock.TextWrapping = TextWrapping.Wrap;
			FreitextBlock.FontWeight = FontWeights.Bold;
			LineGrid.Children.Add (FreitextBlock);
			Grid.SetColumn (FreitextBlock, 1);
			if (InfoAddOn != null)
				{
				FreitextBlock.Text = InfoAddOn.FreiText;
				}
			if (UpdateMode)
				{
				ButtonStackPanel = new StackPanel ();
				LineGrid.Children.Add (ButtonStackPanel);
				Grid.SetColumn (ButtonStackPanel, 2);
				Grid.SetRow (ButtonStackPanel, 0);
				Button InsertOrUpdateItem = new Button ();
				ButtonStackPanel.Children.Add (InsertOrUpdateItem);
				InsertOrUpdateItem.Tag = GroupBoxForOneInfoAddOn;
				InsertOrUpdateItem.Click += new RoutedEventHandler (InsertOrUpdateButton_Click);
				if (String.IsNullOrEmpty(FreitextBlock.Text))
					{
					InsertOrUpdateItem.Content = "Eintragen";
					Binding RootEntryCompletedBinding = new Binding("RootEntryCompleted");
					RootEntryCompletedBinding.Source = ParentTemplateRuntime;
					InsertOrUpdateItem.SetBinding(Button.IsEnabledProperty, RootEntryCompletedBinding);
					}
				else
					{
					InsertOrUpdateItem.Content = "Ändern";
					CheckForInsertDragDrop (this, InsertOrUpdateItem, FreitextBlock);
					
					}
				}
			return GroupBoxForOneInfoAddOn;
			}
		private void AddButton(
			string buttonText,
			Action callback,
			bool isDefault,
			bool isCancel,
			string bindingPath)
		{
			var btn = new Button
			{
				Content = buttonText,
				MinWidth = 80,
				MaxWidth = 150,
				IsDefault = isDefault,
				IsCancel = isCancel,
				Margin = new Thickness(5)
			};

			var enabledBinding = new Binding(bindingPath) { Source = _dialog };
			btn.SetBinding(IsEnabledProperty, enabledBinding);

			btn.Click += (s, e) => callback();

			ButtonsGrid.Columns++;
			ButtonsGrid.Children.Add(btn);
		}
        /// <summary>
        /// Builds the visual tree for the <see cref="T:Kavand.Windows.Controls.Calendar"/> control when a new template is applied.
        /// </summary>
        public override void OnApplyTemplate() {
            if (_viewPresenter != null)
                _viewPresenter.Owner = null;
            base.OnApplyTemplate();

            // _viewPresenter
            _viewPresenter = GetTemplateChild(PartViewPresenterName) as CalendarViewPresenter;
            if (_viewPresenter != null)
                _viewPresenter.Owner = this;

            // 
            if (_previousButton != null)
                _previousButton.Click -= PreviousButton_Click;
            _previousButton = GetTemplateChild(PartPreviousButtonName) as Button;
            if (_previousButton != null) {
                _previousButton.SetBinding(StyleProperty, GetSelfBinding(PreviousButtonStyleProperty));
                _previousButton.SetBinding(ContentControl.ContentProperty, GetSelfBinding(PreviousButtonContentProperty));
                _previousButton.Click += PreviousButton_Click;
            }

            if (_nextButton != null)
                _nextButton.Click -= NextButton_Click;
            _nextButton = GetTemplateChild(PartNextButtonName) as Button;
            if (_nextButton != null) {
                _nextButton.SetBinding(StyleProperty, GetSelfBinding(NextButtonStyleProperty));
                _nextButton.SetBinding(ContentControl.ContentProperty, GetSelfBinding(NextButtonContentProperty));
                _nextButton.Click += NextButton_Click;
            }

            if (_headerButton != null)
                _headerButton.Click -= HeaderButton_Click;
            _headerButton = GetTemplateChild(PartHeaderButtonName) as Button;
            if (_headerButton != null) {
                _headerButton.SetBinding(StyleProperty, GetSelfBinding(HeaderButtonStyleProperty));
                _headerButton.Click += HeaderButton_Click;
            }

            CurrentDate = DisplayDate;
            UpdatePresenter();
        }
        private int AddDateCellToLedgerEntryLine(Grid grid, int gridRow, ref int gridColumn, LedgerEntryLine line)
        {
            Border dateBorder = AddBorderToGridCell(grid, false, true, gridRow, gridColumn);
            AddContentToGrid(dateBorder, line.Date.ToString(DateFormat, CultureInfo.CurrentCulture), ref gridRow, gridColumn, DateColumnStyle);
            gridRow--; // Not finished adding content to this cell yet.
            var button = new Button
            {
                Style = Application.Current.Resources["Button.Round.SmallCross"] as Style,
                HorizontalAlignment = HorizontalAlignment.Right,
                Command = this.removeLedgerEntryLineCommand,
                CommandParameter = line,
            };
            var visibilityBinding = new Binding("IsEnabled")
            {
                Converter = (IValueConverter)Application.Current.Resources["Converter.BoolToVis"],
                RelativeSource = new RelativeSource(RelativeSourceMode.Self),
            };
            button.SetBinding(UIElement.VisibilityProperty, visibilityBinding);

            grid.Children.Add(button);
            Grid.SetColumn(button, gridColumn);
            Grid.SetRow(button, gridRow++);

            return gridRow;
        }