public async Task SetUpPageProperties(string aMessage = null, bool?isMessageGood = null, int anOperationId = 0)
        {
            if (aMessage != null)
            {
                Message = new PopUpMessageModel()
                {
                    Text          = aMessage,
                    IsMessageGood = isMessageGood
                };
            }


            var theAllOperationsTemp = await OperationDataAccess.GetAllOperations();

            AllOperations = theAllOperationsTemp.OrderBy(i => i.Name).ToList();

            var theAllOperationGroupsTemp = await OperationDataAccess.GetAllOperationGroups();

            AllOperationGroups = theAllOperationGroupsTemp.OrderBy(i => i.Name).ToList();

            //Writing all the values for the current operation to the bound properties.
            if (anOperationId != 0)
            {
                var theCurrentOperation = AllOperations.FirstOrDefault(i => i.Id == anOperationId);
                CurrentOperationId             = theCurrentOperation.Id;
                CurrentOperationName           = theCurrentOperation.Name;
                CurrentOperationCode           = theCurrentOperation.OperShortName;
                CurrentOperationDefaultDueDays = theCurrentOperation.DefaultDueDays;
                CurrentOperationThicknessReq   = theCurrentOperation.ThicknessIsRequired;
                CurrentOperationGroupId        = theCurrentOperation.Group.Id;
            }
        }
        public void AssertConfigurationIsValid()
        {
            var sb          = new StringBuilder();
            var identifiers = AllOperations.GroupBy(s => s.OperationIdentifier);
            var duplicated  = identifiers.Where(s => s.Count() > 1).ToList();

            if (!duplicated.Any())
            {
                // no duplicity - OK
                return;
            }

            var errors = new List <Exception>();

            foreach (var duplicityGroup in duplicated)
            {
                sb.Clear();
                sb.AppendLine(
                    $"Operation identifier {duplicityGroup.First().OperationIdentifier} is duplicated in types: ");
                foreach (var s1 in duplicityGroup.Select(s => s.GetType().FullName))
                {
                    sb.AppendLine(s1);
                }
                errors.Add(new OperationsResolverException(sb.ToString()));
            }
        }
示例#3
0
 private void buttonDot_Click(object sender, EventArgs e)
 {
     string[] lexems = expression.Text.Split(AllOperations.ToCharArray());
     if (!lexems.Last().Contains("."))
     {
         expression.Text += ".";
     }
 }
        private static TestOperation[] TestOperations()
        {
            var fixture    = new Fixture();
            var context    = new SpecimenContext(fixture);
            var allOpTypes = AllOperations.GetAllTypes();

            return(allOpTypes.Select(type => (TestOperation)context.Resolve(type)).ToArray());
        }
示例#5
0
        private void buttonProcent_Click(object sender, EventArgs e)
        {
            Evalueted = true;

            string[] lexems = expression.Text.Split(AllOperations.ToCharArray());
            double   input;

            input           = Convert.ToDouble((string.IsNullOrEmpty(lexems.Last()) ? lexems[lexems.Length - 2] : lexems.Last()).Replace('.', ','));
            expression.Text = ApplyOne(expression.Text, lexems.Last(), new operation(Procent), input);
        }
示例#6
0
        private void buttonInvert_Click(object sender, EventArgs e)
        {
            Evalueted = true;

            string[] lexems = expression.Text.Split(AllOperations.ToCharArray());
            if (!string.IsNullOrEmpty(lexems.Last()))
            {
                double input = Convert.ToDouble(lexems.Last().Replace('.', ','));
                expression.Text = ApplyOne(expression.Text, lexems.Last(), new operation(Inverse), input);
            }
        }
示例#7
0
 private void buttonMod_Click(object sender, EventArgs e)
 {
     Evalueted = false;
     if (AllOperations.Contains(expression.Text.Last()))
     {
         expression.Text = $"{expression.Text.Remove(expression.Text.Length - 1, 1)}%";
     }
     else
     {
         expression.Text += "%";
     }
 }
示例#8
0
        public static GetViewsAllowedOperation[] Disallow(this GetViewsAllowedOperation[] existingOperations,
                                                          params ViewAllowedOperations[] operations)
        {
            List <ViewAllowedOperations> disallowedOperations = new List <ViewAllowedOperations>(operations ?? new ViewAllowedOperations[0]);
            List <ViewAllowedOperations> existingPermissions  = (from operation in existingOperations where operation.Allowed select operation.Operation).ToList();

            return(AllOperations.Select(operation => new GetViewsAllowedOperation
            {
                Operation = operation,
                Allowed = existingPermissions.Contains(operation) && !disallowedOperations.Contains(operation)
            }).ToArray());
        }
示例#9
0
 private void ButtonRightBranch_Click(object sender, EventArgs e)
 {
     if ((expression.Text == "0" || Evalueted) && expression.Text.IndexOfAny(AllOperations.ToCharArray()) == -1)
     {
         expression.Text = ")";
         Evalueted       = false;
         CountBranches   = -1;
     }
     else
     {
         expression.Text += ")";
         CountBranches--;
     }
 }
示例#10
0
        private void buttonPI_Click(object sender, EventArgs e)
        {
            string[] lexems = expression.Text.Split(SplitersOperation);

            if (expression.Text == "0" || lexems.Last().Contains(".") || !AllOperations.Contains(expression.Text.Last()))
            {
                expression.Text = Math.Round(Math.PI, 10).ToString().Replace(",", ".");
                Evalueted       = false;
            }
            else
            {
                expression.Text += Math.PI.ToString().Replace(",", ".");
            }
        }
示例#11
0
        private void buttonCot_Click(object sender, EventArgs e)
        {
            Evalueted = true;

            string[] lexems = expression.Text.Split(AllOperations.ToCharArray());
            string   input  = lexems.Length == 2
                                ? lexems[lexems.Length - 1].Replace('.', ',')
                                : (string.IsNullOrEmpty(lexems.Last()) ? lexems[lexems.Length - 2] : lexems.Last()).Replace('.', ',');

            expression.Text = ApplyTrig(expression.Text,
                                        lexems.Last(),
                                        isInverse.Checked ? new ifoperation(Cot) : new ifoperation(Acot),
                                        input,
                                        isRad.Checked);
        }
示例#12
0
        private void Memory_MouseDown(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
            case MouseButtons.Left:
                Memory.Text = "0";
                break;

            case MouseButtons.Middle:
                Clipboard.SetText(Memory.Text);
                break;

            case MouseButtons.Right:
                expression.Text = !AllOperations.Contains(expression.Text.Last())
                                                                                ? Memory.Text
                                                                                : (expression.Text + Memory.Text);
                break;
            }
        }
示例#13
0
        private void buttonCube_Click(object sender, EventArgs e)
        {
            Evalueted = true;

            string[] lexems = expression.Text.Split(AllOperations.ToCharArray());
            double   input;

            switch (lexems.Length)
            {
            case 2 when expression.Text[0] == '-':
                input           = Convert.ToDouble(lexems.Last().Replace('.', ','));
                expression.Text = ConvertToString(Cube(input)).Replace(',', '.');
                break;

            default:
                input           = Convert.ToDouble((string.IsNullOrEmpty(lexems.Last()) ? lexems[lexems.Length - 2] : lexems.Last()).Replace('.', ','));
                expression.Text = ApplyOne(expression.Text, lexems.Last(), new operation(Cube), input);
                break;
            }
        }
示例#14
0
        private void buttonNegative_Click(object sender, EventArgs e)
        {
            string[] lexems = expression.Text.Split(AllOperations.ToCharArray());
            if (lexems.Length != 1 || lexems[lexems.Length - 1] != "0")
            {
                int nearestOperationIndex = expression.Text.LastIndexOf("+") > expression.Text.LastIndexOf("-") ? expression.Text.LastIndexOf("+") : expression.Text.LastIndexOf("-");

                if (nearestOperationIndex != -1)
                {
                    expression.Text = $"{expression.Text.Substring(0, nearestOperationIndex)}{expression.Text.Substring(nearestOperationIndex).Remove(0, 1).Insert(0, expression.Text[nearestOperationIndex] == '+' ? "-" : "+")}";
                }
                else if (expression.Text.Contains("%"))
                {
                    expression.Text = expression.Text.Insert(expression.Text.LastIndexOf("%") + 1, "-");
                }
                else if (!(expression.Text.EndsWith("+") || expression.Text.EndsWith("-")))
                {
                    expression.Text = expression.Text.Insert(0, "-");
                }
            }
        }
示例#15
0
        private void buttonLog10_Click(object sender, EventArgs e)
        {
            Evalueted = true;

            string[] lexems = expression.Text.Split(AllOperations.ToCharArray());
            switch (lexems.Length)
            {
            case 2 when expression.Text[0] == '-':
                expression.Font = new Font(expression.Font.FontFamily, 16.25f);
                expression.Text = "Неверный формат";
                DisableButtons();
                ErrorState = true;
                break;

            default: {
                double input = Convert.ToDouble((string.IsNullOrEmpty(lexems.Last()) ? lexems[lexems.Length - 2] : lexems.Last()).Replace('.', ','));
                expression.Text = ApplyOne(expression.Text, lexems.Last(), new operation(Math.Log10), input);
                break;
            }
            }
        }
示例#16
0
        private void buttonCubeRoot_Click(object sender, EventArgs e)
        {
            Evalueted = true;

            string[] lexems = expression.Text.Split(AllOperations.ToCharArray());
            double   input;

            switch (lexems.Length)
            {
            case 2 when expression.Text[0] == '-': {
                input           = Convert.ToDouble(lexems.Last());
                expression.Text = $"-{ConvertToString(Math.Pow(input, 1d / 3d)).Replace(',', '.')}";
                break;
            }

            default: {
                input           = Convert.ToDouble((string.IsNullOrEmpty(lexems.Last()) ? lexems[lexems.Length - 2] : lexems.Last()).Replace('.', ','));
                expression.Text = ApplyTwo(expression.Text, lexems.Last(), new twooperation(Math.Pow), input, 1d / 3d);
                break;
            }
            }
        }
示例#17
0
        private void buttonFactorial_Click(object sender, EventArgs e)
        {
            Evalueted = true;

            string[] lexems = expression.Text.Split(AllOperations.ToCharArray());
            switch (lexems.Length)
            {
            case 2 when expression.Text[0] == '-':
                expression.Font = new Font(expression.Font.FontFamily, 16.25f);
                expression.Text = "Неверный формат";
                DisableButtons();
                ErrorState = true;
                break;

            default: {
                using (Chart a = new Chart()) {
                    double input = Convert.ToDouble((string.IsNullOrEmpty(lexems.Last()) ? lexems[lexems.Length - 2] : lexems.Last()).Replace('.', ','));
                    expression.Text = ApplyOne(expression.Text, lexems.Last(), new operation(a.DataManipulator.Statistics.GammaFunction), input + 1);
                }

                break;
            }
            }
        }
 private void WriteRegisteredOperations()
 {
     logger.LogDebug("Registered operations: \r\n" + string.Join("\r\n", AllOperations.Select(s => s.OperationIdentifier.ToString()).ToArray()));
 }