Mini Kabibi Habibi
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using DevExpress.Xpf.Bars;
using DevExpress.Xpf.Core;
using DevExpress.Xpf.Utils;
namespace BarsDemo {
public class DockEnumProvider {
public IEnumerable DockItemsSource {
get {
List<Dock> dockItems = new List<Dock>();
dockItems.Add(Dock.Left);
dockItems.Add(Dock.Top);
dockItems.Add(Dock.Right);
dockItems.Add(Dock.Bottom);
return dockItems;
}
}
public IEnumerable DockRightBottomItemsSource {
get {
List<Dock> dockItems = new List<Dock>();
dockItems.Add(Dock.Right);
dockItems.Add(Dock.Bottom);
return dockItems;
}
}
}
public partial class ItemProperties : BarsDemoModule {
public static readonly DependencyProperty SelectedItemProperty =
DependencyPropertyManager.Register("SelectedItem", typeof(BarItemLink), typeof(ItemProperties), new FrameworkPropertyMetadata());
public static readonly DependencyProperty ButtonItemProperty =
DependencyPropertyManager.Register("ButtonItem", typeof(BarButtonItemLink), typeof(ItemProperties), new FrameworkPropertyMetadata());
public static readonly DependencyProperty CheckItemProperty =
DependencyPropertyManager.Register("CheckItem", typeof(BarCheckItemLink), typeof(ItemProperties), new FrameworkPropertyMetadata());
public static readonly DependencyProperty StaticItemProperty =
DependencyPropertyManager.Register("StaticItem", typeof(BarStaticItemLink), typeof(ItemProperties), new FrameworkPropertyMetadata());
public static readonly DependencyProperty SplitButtonItemProperty =
DependencyPropertyManager.Register("SplitButtonItem", typeof(BarSplitButtonItemLink), typeof(ItemProperties), new FrameworkPropertyMetadata());
public static readonly DependencyProperty SubItemProperty =
DependencyPropertyManager.Register("SubItem", typeof(BarSubItemLink), typeof(ItemProperties), new FrameworkPropertyMetadata());
public BarItemLink SelectedItem {
get { return (BarItemLink)GetValue(SelectedItemProperty); }
set { SetValue(SelectedItemProperty, value); }
}
public BarButtonItemLink ButtonItem {
get { return (BarButtonItemLink)GetValue(ButtonItemProperty); }
set { SetValue(ButtonItemProperty, value); }
}
public BarCheckItemLink CheckItem {
get { return (BarCheckItemLink)GetValue(CheckItemProperty); }
set { SetValue(CheckItemProperty, value); }
}
public BarStaticItemLink StaticItem {
get { return (BarStaticItemLink)GetValue(StaticItemProperty); }
set { SetValue(StaticItemProperty, value); }
}
public BarSplitButtonItemLink SplitButtonItem {
get { return (BarSplitButtonItemLink)GetValue(SplitButtonItemProperty); }
set { SetValue(SplitButtonItemProperty, value); }
}
public BarSubItemLink SubItem {
get { return (BarSubItemLink)GetValue(SubItemProperty); }
set { SetValue(SubItemProperty, value); }
}
public ItemProperties() {
InitializeComponent();
ButtonItem = (BarButtonItemLink)this.barManager.Bars[0].ItemLinks[0];
CheckItem = (BarCheckItemLink)this.barManager.Bars[0].ItemLinks[1];
StaticItem = (BarStaticItemLink)this.barManager.Bars[1].ItemLinks[0];
SplitButtonItem = (BarSplitButtonItemLink)this.barManager.Bars[0].ItemLinks[2];
SubItem = (BarSubItemLink)this.barManager.Bars[0].ItemLinks[3];
SelectedItem = ButtonItem;
OnRadioButtonClick(newRadioButton, null);
}
protected virtual void SelectItem(object radioButton) {
if(radioButton == this.newRadioButton) SelectedItem = ButtonItem;
else if(radioButton == this.bulletsRadioButton) SelectedItem = CheckItem;
else if(radioButton == this.saveMenuRadioButton) SelectedItem = SubItem;
else if(radioButton == this.fontColorRadioButton) SelectedItem = SplitButtonItem;
else SelectedItem = StaticItem;
}
protected virtual void UpdateSettingsVisibility() {
this.subProps.Visibility = (SelectedItem == SubItem) ? Visibility.Visible : Visibility.Collapsed;
this.staticProperties.Visibility = (SelectedItem == StaticItem) ? Visibility.Visible : Visibility.Collapsed;
this.splitProps.Visibility = (SelectedItem == SplitButtonItem) ? Visibility.Visible : Visibility.Collapsed;
}
protected virtual void UpdateSettingsValues() {
this.displayMode.SelectedIndex = (int)SelectedItem.BarItemDisplayMode;
if(SelectedItem.UserGlyphAlignment == null)
this.captionGlyphAlignment.SelectedIndex = 0;
else this.captionGlyphAlignment.SelectedIndex = (int)SelectedItem.UserGlyphAlignment;
this.glyphSize.SelectedIndex = (int)SelectedItem.UserGlyphSize;
}
protected virtual void OnRadioButtonClick(object sender, RoutedEventArgs e) {
SelectItem(sender);
UpdateSettingsVisibility();
UpdateSettingsValues();
}
protected virtual void displayMode_SelectedIndexChanged(object sender, RoutedEventArgs e) {
if(this.displayMode.SelectedItem == null)
return;
BarItemDisplayMode itemDisplayMode = (BarItemDisplayMode)this.displayMode.SelectedItem;
this.captionGlyphAlignment.IsEnabled = itemDisplayMode.Equals(BarItemDisplayMode.ContentAndGlyph);
}
protected virtual void captionGlyphAlignment_SelectedIndexChanged(object sender, RoutedEventArgs e) {
if(this.displayMode.SelectedItem == null)
return;
BarItemDisplayMode itemDisplayMode = (BarItemDisplayMode)this.displayMode.SelectedItem;
this.glyphSize.IsEnabled = itemDisplayMode.Equals(BarItemDisplayMode.ContentAndGlyph) || itemDisplayMode.Equals(BarItemDisplayMode.Default);
}
protected virtual void autoSizeMode_SelectedIndexChanged(object sender, RoutedEventArgs e) {
if(this.autoSizeMode.SelectedItem == null)
return;
BarItemAutoSizeMode itemAutoSizeMode = (BarItemAutoSizeMode)this.autoSizeMode.SelectedItem;
this.widthTrackBar.IsEnabled = itemAutoSizeMode.Equals(BarItemAutoSizeMode.None);
}
protected virtual void actAsDropDownCheck_EditValueChanged(object sender, DevExpress.Xpf.Editors.EditValueChangedEventArgs e) {
this.arrowAlignment.IsEnabled = !this.actAsDropDownCheck.IsChecked.Value;
}
}
public class BarItemInfoControl : ContentControl {
public static readonly DependencyProperty LinkProperty =
DependencyPropertyManager.Register("Link", typeof(BarItemLink), typeof(BarItemInfoControl), new FrameworkPropertyMetadata());
public static readonly DependencyProperty DescriptionProperty =
DependencyPropertyManager.Register("Description", typeof(string), typeof(BarItemInfoControl), new FrameworkPropertyMetadata(string.Empty));
public BarItemLink Link {
get { return (BarItemLink)GetValue(LinkProperty); }
set { SetValue(LinkProperty, value); }
}
public string Description {
get { return (string)GetValue(DescriptionProperty); }
set { SetValue(DescriptionProperty, value); }
}
public BarItemInfoControl() {
DefaultStyleKey = typeof(BarItemInfoControl);
Focusable = false;
}
}
}