1. 26.
    0
    using System. Windows.Interop;

    namespace BarsDemo {
    public enum ImageBorderShapeType { None, Rectangle, Circle, Triangle, Star, LeftArrow, RightArrow, UpArrow, DownArrow }
    public partial class RibbonSimplePad : BarsDemoModule {


    public RibbonSimplePad() {
    InitializeComponent();
    ViewModel = new SimplePadViewModel(richControl, RibbonControl, barManager);
    DataContext = this;

    }
    public SimplePadViewModel ViewModel { get; set; }
    protected override void OnLoaded(object sender, RoutedEventArgs e) {
    richControl. AcceptsTab = true;
    richControl. Focus();
    }
    protected override bool CanLeave() {
    RibbonControl. CloseApplicationMenu();
    return base. CanLeave();
    }

    protected override void OnUnloaded(object sender, RoutedEventArgs e) {
    if(!BrowserInteropHelper. IsBrowserHosted) {
    gTheme. Gallery.Groups. Clear();
    }
    }

    protected virtual void OnMarkerTypeOpened(object sender, EventArgs e) {
    }
    protected virtual void OnShapesDropDownGalleryInit(object sender, DropDownGalleryEventArgs e) {
    e.DropDownGallery. Gallery.IsGroupCaptionVisible = DefaultBoolean. False;
    e.DropDownGallery. Gallery.AllowFilter = false;
    e.DropDownGallery. InitialVisibleColCount = 3;
    e.DropDownGallery. Gallery.IsItemDescriptionVisible = true;
    e.DropDownGallery. Gallery.ItemDescriptionHorizontalAlignment = HorizontalAlignment. Center;
    e.DropDownGallery. Gallery.ItemCaptionHorizontalAlignment = HorizontalAlignment. Center;
    }
    protected virtual void OnShapesItemClick(object sender, GalleryItemEventArgs e) {
    if(ViewModel. SelectedImage != null) {
    ViewModel. SelectedImage.ShapeType = ((ImageInfo)e.Item. Caption).ShapeType;
    }
    }

    protected virtual void OnFontItemClick(object sender, ItemClickEventArgs e) {
    }

    protected virtual void OnThemeDropDownGalleryInit(object sender, DropDownGalleryEventArgs e) {
    Gallery gallery = e.DropDownGallery. Gallery;
    gallery. AllowHoverImages = false;
    gallery. IsItemCaptionVisible = true;
    gallery. ItemGlyphLocation = Dock.Top;
    gallery. IsGroupCaptionVisible = DefaultBoolean. True;
    }
    protected virtual void OnThemeItemClick(object sender, GalleryItemEventArgs e) {
    string themeName = (string)e.Item. Caption;
    themeName = themeName. Replace(" ", string. Empty);
    SelectTheme(Theme. FindTheme(themeName));
    }
    protected virtual void OnClipartDropDownGalleryInit(object sender, DropDownGalleryEventArgs e) {
    e.DropDownGallery. Gallery.IsItemCaptionVisible = false;
    e.DropDownGallery. Gallery.IsItemDescriptionVisible = false;
    e.DropDownGallery. Gallery.IsGroupCaptionVisible = DefaultBoolean. False;
    e.DropDownGallery. Gallery.ColCount = 0;
    e.DropDownGallery. Gallery.ItemGlyphStretch = Stretch. Fill;
    e.DropDownGallery. Gallery.ItemGlyphHorizontalAlignment = HorizontalAlignment. Center;
    e.DropDownGallery. Gallery.ItemGlyphVerticalAlignment = VerticalAlignment. Center;
    e.DropDownGallery. Gallery.MinColCount = 4;
    e.DropDownGallery. InitialVisibleColCount = 3;
    }
    protected virtual void OnClipartItemClick(object sender, GalleryItemEventArgs e) {
    InsertImage(e.Item. Glyph);
    }

    void CheckMarkerTypeInGallery(string markerStyle) {
    foreach(GalleryItem item in gMarkerType. Groups[0].Items) {
    if(item. Caption.ToString() != markerStyle)
    continue;
    item. IsChecked = true;
    return;
    }
    }

    void InsertImage(ImageSource glyph) {
    if(richControl == null)
    return;
    ImageBorder imgBorder = new ImageBorder() { BorderBrush = new SolidColorBrush(Colors. Black), BorderThickness = new Thickness(1), Content = glyph };
    InlineUIContainer c = new InlineUIContainer();
    c.Child = imgBorder;
    richControl. Selection.Text = "";
    if(richControl. Selection.End. Paragraph == null) {
    richControl. Selection.End. InsertTextInRun("");
    }
    if(richControl. Selection.End. Paragraph != null) {
    richControl. Selection.End. Paragraph.Inlines.Add(c);
    richControl. CaretPosition = richControl. Selection.End. Paragraph.Inlines. LastInline.ElementEnd;
    }
    }
    void RecentItemsListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) {
    ((ApplicationMenuInfo)RibbonControl. ApplicationMenu).ClosePopup();
    }

    private void RibbonControl_BackstageOpened(object sender, EventArgs e) {
    ViewModel. InitializeOptions();
    }

    private void gMarkerType_ItemClick(object sender, GalleryItemEventArgs e) {
    ViewModel. ListMarkerStyle = (TextMarkerStyle)Enum. Parse(typeof(TextMarkerStyle), e.Item. Caption.ToString());
    }
    }
    public class RecentItem {
    public int Number { get; set; }
    public string FileName { get; set; }
    }
    public class BackstageLabel {
    public string Caption { get; set; }
    public string Description { get; set; }
    public string Glyph { get; set; }
    }
    public class ButtonWithImageContent {
    public string ImageSource { get; set; }
    Tümünü Göster
    ···
   tümünü göster