using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using ActiproSoftware.Windows.Controls.Docking;
using ActiproSoftware.Windows.Controls.Ribbon;
using ActiproSoftware.Windows.Controls.Ribbon.Input;
using ActiproSoftware.Windows.Controls.Ribbon.Controls;
using agree;
namespace agree.Wpf
{
class MyApplicationMenu : ApplicationMenu
{
public MyApplicationMenu()
{
SplitButton sb;
Button b;
sb = new SplitButton(ApplicationCommands.New);
sb.Label = "New";
sb.KeyTipAccessText = "N";
sb.ImageSourceLarge = new BitmapImage(new Uri("/Images/New32.png", UriKind.Relative));
this.Items.Add(sb);
b = new Button(ApplicationCommands.Open);
b.Label = "Open";
b.KeyTipAccessText = "O";
b.ImageSourceLarge = new BitmapImage(new Uri("/Images/Open32.png", UriKind.Relative));
this.Items.Add(b);
b = new Button(ApplicationCommands.Save);
b.Label = "Save";
b.KeyTipAccessText = "S";
b.ImageSourceLarge = new BitmapImage(new Uri("/Images/Save32.png", UriKind.Relative));
this.Items.Add(b);
sb = new SplitButton(ApplicationCommands.New);
sb.Label = "Save As";
sb.KeyTipAccessText = "A";
sb.ImageSourceLarge = new BitmapImage(new Uri("/Images/SaveAs32.png", UriKind.Relative));
this.Items.Add(sb);
b = new Button(ApplicationCommands.Print);
b.Label = "Print";
b.KeyTipAccessText = "P";
b.ImageSourceLarge = new BitmapImage(new Uri("/Images/Print32.png", UriKind.Relative));
this.Items.Add(b);
}
};
class MyRibbon : Ribbon
{
public MyRibbon()
{
RibbonCommandUIManager.Register(MainWindow.optionSetting3d,
new RibbonCommandUIProvider("3D", "/Resources/Images/Cube.png", "/Resources/Images/Bold16.png", "Do something in 3-D."));
this.SetValue(System.Windows.Controls.DockPanel.DockProperty, System.Windows.Controls.Dock.Top);
this.ApplicationMenu = new MyApplicationMenu();
this.Tabs.Add(new HomeTab());
this.Tabs.Add(new ViewTab());
this.Tabs.Add(new ParseTab());
this.Tabs.Add(new TestTab());
}
};
class BaseTab : Tab
{
public BaseTab(String label, String key)
{
this.Label = label;
this.KeyTipAccessText = key;
}
}
class HomeTab : BaseTab
{
public HomeTab()
: base("Home", "H")
{
this.Items.Add(ClipboardGroup());
this.Items.Add(FontGroup());
this.Items.Add(ViewGroup());
}
Group ClipboardGroup()
{
Button b;
Group grp = new Group();
grp.Label = "Clipboard";
b = new Button(ApplicationCommands.Paste);
b.Label = "Paste";
b.KeyTipAccessText = "P";
b.ImageSourceLarge = new BitmapImage(new Uri("/Images/Paste32.png", UriKind.Relative));
grp.Items.Add(b);
//StackPanel sp = new StackPanel();
b = new Button(ApplicationCommands.Cut);
b.KeyTipAccessText = "X";
b.Label = "Cut";
//sp.Children.Add(b);
b.ImageSourceLarge = new BitmapImage(new Uri("/Images/Cut32.png", UriKind.Relative));
grp.Items.Add(b);
b = new Button(ApplicationCommands.Copy);
b.KeyTipAccessText = "C";
b.Label = "Copy";
//sp.Children.Add(b);
b.ImageSourceLarge = new BitmapImage(new Uri("/Images/Copy32.png", UriKind.Relative));
grp.Items.Add(b);
//grp.Items.Add(sp);
return grp;
}
Group FontGroup()
{
Group grp = new Group();
grp.Label = "Font";
return grp;
}
Group ViewGroup()
{
Button b;
Group grp = new Group();
grp.Label = "View";
b = new Button();
b.Command = MainWindow.optionSetting3d;
b.CommandTarget = MainWindow.w;
b.CommandBindings.Add(MainWindow.optionSetting3d.CommandBinding);
b.Label = "3-D";
//b.Click += (e, x) => MainWindow.optionSetting3d.Execute(null, MainWindow.w);
b.ImageSourceLarge = new BitmapImage(new Uri("/Images/Cube.png", UriKind.Relative));
grp.Items.Add(b);
return grp;
}
};
class ViewTab : BaseTab
{
public ViewTab()
: base("View", "V")
{
}
}
class ParseTab : BaseTab
{
public ParseTab()
: base("Parse", "P")
{
}
}
class TestTab : BaseTab
{
public TestTab()
: base("Test", "T")
{
}
}
public class OptionSetting3d : CommandBase
{
static bool toggle_3d = false;
public OptionSetting3d(MainWindow w)
: base(w, "Toggle3d", "Toggle3d", typeof(OptionSetting3d))
{
}
public bool Value { get { return toggle_3d; } }
protected override void OnExecute(object target, ExecutedRoutedEventArgs args)
{
toggle_3d = !toggle_3d;
#if false
ICheckableCommandParameter icp = args.Parameter as ICheckableCommandParameter;
if (icp != null)
{
//icp.IsChecked = toggle_3d;
}
//(args.Source as Button).IsChecked = toggle_3d;
#endif
//Debug.WriteLine("ex {0} {1} {2}", args.Source, args.OriginalSource, toggle_3d);
args.Handled = true;
//CommandManager.InvalidateRequerySuggested();
}
protected override void OnCanExecute(object target, CanExecuteRoutedEventArgs args)
{
ICheckableCommandParameter icp = args.Parameter as ICheckableCommandParameter;
if (icp != null)
{
icp.Handled = true;
icp.IsChecked = toggle_3d;
//Debug.WriteLine("canex {0} {1} {2}", args.Source, args.OriginalSource, toggle_3d);
}
args.Handled = true;
args.CanExecute = true;
}
};
}