Example #1
0
        public MainWindow()
        {
            InitializeComponent();

            _isBig        = true;
            _end          = true;
            _selectedFunc = -1;
            _numbers      = new object[4];

            CalculatorWindow.Width = (_isBig = !_isBig) ? 400 : 300;
            BaseGrid.Margin        = new Thickness(10, 61, _isBig ? 110 : 10, 9.8);
            ExtraGrid.Visibility   = _isBig ? Visibility.Visible : Visibility.Hidden;

            try
            {
                var ef = new ExtraFunctions();

                var temp = new[] { M0, M1, M2, M3 };

                foreach (var button in temp.Skip(ef.ExtraFuncCount))
                {
                    button.Visibility = Visibility.Hidden;
                }

                for (int i = 0; i < ef.ExtraFuncCount; i++)
                {
                    temp[i].Content = ef.GetFuncName(i);
                }
            }
            catch
            {
                C3.Visibility = Visibility.Hidden;
            }
        }
Example #2
0
        public ExtraFunctions()
        {
            var dll       = Assembly.LoadFile($"{Directory.GetCurrentDirectory()}/Extra.dll");
            var funcsType = dll.GetType("Extra.Functions");

            _methods = funcsType.GetMethods()
                       .Where(x =>
                              x.IsStatic &&
                              !x.IsAbstract &&
                              !x.IsConstructor &&
                              x.IsPublic &&
                              x.ReturnType == typeof(double) &&
                              x.GetParameters().Length == 1 &&
                              x.GetParameters()[0].ParameterType == typeof(double))
                       .Take(4)
                       .ToArray();

            Instance = this;
        }