public Calculator2() { InitializeComponent(); col0 = InputGrid.ColumnDefinitions[0].Width.Value; col1 = InputGrid.ColumnDefinitions[1].Width.Value; col2 = InputGrid.ColumnDefinitions[2].Width.Value; _core = new PythonCore(this.Output); vars = new Dictionary <string, string>(); Calc.Core = _core; _buffer = new StringBuilder(); _calc = new Thread(TFunc); _help = new HelpGenerator(); _history = new ObservableCollection <HistoryItem>(); LbHistory.ItemsSource = _history; _canrun = true; _core.AttachTypeToRuntime(typeof(Calc)); _core.AttachTypeToRuntime(typeof(Maths.Fraction)); _core.AttachTypeToRuntime(typeof(UserInterface.InputForm)); CreateButtons(typeof(Maths.Functions), Functions); CreateButtons(typeof(Maths.Trigonometry), Trig); CreateButtons(typeof(Maths.Rnd), Rand); CreateButtons(typeof(Maths.Binary), Bin); CreateButtons(typeof(Maths.Complex), Cplx); CreateButtons(typeof(Maths.Sets), SetStat); CreateButtons(typeof(Maths.Stat), SetStat); CreateButtons(typeof(Maths.Matrices), Matrix); CreateButtons(typeof(Maths.Specials), Specials); CreateButtons(typeof(Maths.NumberInfo), Specials); CreateButtons(typeof(Maths.Const), ConstantsPanel); CreateButtons(typeof(UserInterface.UserInterface), Dialogs); _defaultvars = _core.VariablesNames; SynBox.SyntaxLexer = _core.SyntaxProvider; Output.WriteImage(new Uri("pack://application:,,,/MCalculator.Tool;component/icon/calcintro.png", UriKind.Absolute)); }
private void CreateButtons(Type Class, WrapPanel target) { _core.AttachTypeToRuntime(Class); var items = PythonCore.GetClassMembers(Class); CompleteButton cb; foreach (var item in items) { cb = new CompleteButton(); cb.Content = item.Key; cb.CompleteText = item.Value; cb.Click += InstertButton_Click; cb.Margin = new Thickness(2); cb.ToolTip += _help.LookupDescription(item.Value); cb.Height = 54; cb.Width = 100; target.Children.Add(cb); } }