private void buttonMoveDown_Click(object sender, RoutedEventArgs e)
        {
            int index = listBoxGradientStopCollection.SelectedIndex;

            if (index > listBoxGradientStopCollection.Items.Count - 2)
            {
                return;
            }
            FormattedListBoxItem selectedItem =
                listBoxGradientStopCollection.Items[index] as FormattedListBoxItem;
            FormattedListBoxItem oneDownItem =
                listBoxGradientStopCollection.Items[index + 1] as FormattedListBoxItem;

            // Update GradientStops
            GradientStop gs1 = selectedItem.GradientStop;
            GradientStop gs2 = oneDownItem.GradientStop;

            selectedItem.SetGradientStop(new GradientStop(gs2.Color, gs1.Offset));
            oneDownItem.SetGradientStop(new GradientStop(gs1.Color, gs2.Offset));
            gradientStopCollection[index]     = selectedItem.GradientStop;
            gradientStopCollection[index + 1] = oneDownItem.GradientStop;

            // Update UI
            listBoxGradientStopCollection.SelectedItem =
                listBoxGradientStopCollection.Items[listBoxGradientStopCollection.SelectedIndex + 1];
            SetEnabledButtons();
            SetPreviewSwatch();
            buttonSave.IsEnabled = true;
        }
 protected static void ForegroundValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (d is FormattedListBoxItem)
     {
         FormattedListBoxItem obj = (d as FormattedListBoxItem);
         //obj.textBoxItem.Foreground = ConfigurationManagerForegroundBrush;
         return;
     }
 }
Beispiel #3
0
        private void listBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((e.AddedItems == null) || (e.AddedItems.Count == 0))
            {
                return;
            }
            FormattedListBoxItem listItem = e.AddedItems[0] as FormattedListBoxItem;

            borderControl.ContextMenu.IsOpen = false;
            SelectedIndex = listItem.Id;
        }
        protected static object IsSelectedCoerceValue(DependencyObject depObject, object value)
        {
            FormattedListBoxItem myClass = (FormattedListBoxItem)depObject;
            bool newValue = (bool)value;

            if (newValue && !myClass.IsSelectable)
            {
                return(false);
            }
            return(value);
        }
        private void SetEnabledButtons()
        {
            FormattedListBoxItem selectedItem =
                listBoxGradientStopCollection.SelectedItem as FormattedListBoxItem;

            buttonEdit.IsEnabled       =
                buttonRemove.IsEnabled =
                    (selectedItem != null);
            buttonMoveUp.IsEnabled =
                ((selectedItem != null) && (listBoxGradientStopCollection.SelectedIndex > 0));
            buttonMoveDown.IsEnabled =
                ((selectedItem != null) && (listBoxGradientStopCollection.SelectedIndex <=
                                            listBoxGradientStopCollection.Items.Count - 2));
        }
        protected static void IsSelectedValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            FormattedListBoxItem myClass = (FormattedListBoxItem)d;
            bool newValue = (bool)e.NewValue;
            bool oldValue = (bool)e.OldValue;

            // A tag value of null is the same as IsSelected == true
            if (newValue)
            {
                myClass.Tag = null;
            }
            else
            {
                myClass.Tag = true;
            }
        }
Beispiel #7
0
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.ThisControl = ((PosControls.FormattedListBoxItem)(target));
                return;

            case 2:
                this.mainPane = ((System.Windows.Controls.DockPanel)(target));
                return;

            case 3:
                this.Configuration = ((PosControls.ConfigurationManager)(target));
                return;

            case 4:
                this.gridControl = ((System.Windows.Controls.Grid)(target));
                return;

            case 5:
                this.textBoxItem = ((System.Windows.Controls.TextBlock)(target));

            #line 16 "..\..\FormattedListBoxItem.xaml"
                this.textBoxItem.IsEnabledChanged += new System.Windows.DependencyPropertyChangedEventHandler(this.textBoxItem_IsEnabledChanged);

            #line default
            #line hidden
                return;

            case 6:
                this.gridControlGradientStops = ((System.Windows.Controls.Grid)(target));
                return;

            case 7:
                this.borderSwatch = ((System.Windows.Controls.Border)(target));
                return;

            case 8:
                this.labelOffsetValue = ((System.Windows.Controls.Label)(target));
                return;
            }
            this._contentLoaded = true;
        }
        private void buttonRemove_Click(object sender, RoutedEventArgs e)
        {
            FormattedListBoxItem selectedItem =
                listBoxGradientStopCollection.SelectedItem as FormattedListBoxItem;

            if (selectedItem == null)
            {
                return;
            }
            int index = listBoxGradientStopCollection.SelectedIndex;

            // Remove GradientStop
            listBoxGradientStopCollection.Items.Remove(selectedItem);
            listBoxGradientStopCollection.SelectedItem = null;
            gradientStopCollection.RemoveAt(index);

            // Update UI
            SetPreviewSwatch();
            SetEnabledButtons();
            buttonSave.IsEnabled = true;
        }
Beispiel #9
0
 private void AddFormattedListBoxItems(DragScrollListBox listBox)
 {
     listItemCollection.Clear();
     listBox.Items.Clear();
     for (int i = 0; i < Items.Count; i++)
     {
         FormattedListBoxItem listBoxItem =
             new FormattedListBoxItem(i, Items[i], true);
         listBoxItem.IsSelected = (i == selectedIndex);
         if (listBoxItem.IsSelected)
         {
             selectedListBoxItem = listBoxItem;
         }
         listBoxItem.AllHeights = 45;
         listItemCollection.Add(listBoxItem);
         listBox.Items.Add(listBoxItem);
     }
     if ((selectedListBoxItem != null) && (currentListBox != null))
     {
         currentListBox.ScrollIntoView(selectedListBoxItem);
     }
 }
        private void buttonEdit_Click(object sender, RoutedEventArgs e)
        {
            if (listBoxGradientStopCollection.SelectedItem == null)
            {
                return;
            }
            FormattedListBoxItem selectedItem =
                listBoxGradientStopCollection.SelectedItem as FormattedListBoxItem;
            GradientStop gradientStop         = selectedItem.GradientStop;
            GradientStopEditorControl control = new GradientStopEditorControl();
            PosDialogWindow           window  = new PosDialogWindow(control, "Gradient Stop Editor", 450, 500);

            control.GradientStop = gradientStop;
            if (PosDialogWindow.ShowPosDialogWindow(this, window) != null)
            {
                selectedItem.SetGradientStop(control.GradientStop);
                gradientStopCollection[listBoxGradientStopCollection.SelectedIndex] =
                    control.GradientStop;

                // Update UI
                SetPreviewSwatch();
                buttonSave.IsEnabled = true;
            }
        }