コード例 #1
0
ファイル: Calculator.cs プロジェクト: soziele/Kalkulator-POiG
        public void undo()
        {
            if (OperationDisplay != "")
            {
                OperationDisplay = OperationDisplay.Remove(OperationDisplay.Length - 1);
            }

            int openingBrackets = 0;
            int closingBrackets = 0;

            for (int i = 0; i < OperationDisplay.Length; i++)
            {
                if (OperationDisplay[i] == '(')
                {
                    openingBrackets++;
                }
                if (OperationDisplay[i] == ')')
                {
                    closingBrackets++;
                }
            }

            if (openingBrackets > closingBrackets)
            {
                string x = OperationDisplay.Substring(OperationDisplay.LastIndexOf('('));
                x = x.Trim('(');
                x = x.Trim('-');
                OperationDisplay  = OperationDisplay.Remove(OperationDisplay.LastIndexOf('('));
                OperationDisplay += x;
            }
        }
コード例 #2
0
 internal Operation(string name, OperationDisplay display, string origin, OperationPropertiesFormatServiceSpecification serviceSpecification)
 {
     Name    = name;
     Display = display;
     Origin  = origin;
     ServiceSpecification = serviceSpecification;
 }
コード例 #3
0
 internal Operation(string name, OperationDisplay display, string origin, OperationProperties properties)
 {
     Name       = name;
     Display    = display;
     Origin     = origin;
     Properties = properties;
 }
コード例 #4
0
ファイル: Calculator.cs プロジェクト: soziele/Kalkulator-POiG
        public void signChange()
        {
            bool   anyOperators = false;
            bool   positiveSign = true;
            int    index        = 0;
            string x            = "";


            if (OperationDisplay.Length != 0 && !(OperationDisplay.LastIndexOfAny(operators.ToArray()) == OperationDisplay.Length - 1))
            {
                for (int i = 0; i < 4; i++)
                {
                    if (OperationDisplay.Contains(operators[i]))
                    {
                        anyOperators = true;
                    }
                }

                if (anyOperators)
                {
                    index = OperationDisplay.LastIndexOfAny(operators.ToArray());
                }

                if (anyOperators && OperationDisplay.Substring(index - 1).Contains('('))
                {
                    positiveSign = false;
                }

                if (positiveSign)
                {
                    if (index != 0)
                    {
                        x = OperationDisplay.Substring(index + 1);
                    }
                    else
                    {
                        x = OperationDisplay;
                    }
                    x = "(-" + x + ')';
                    if (index != 0)
                    {
                        OperationDisplay  = OperationDisplay.Remove(index + 1);
                        OperationDisplay += x;
                    }
                    else
                    {
                        OperationDisplay = x;
                    }
                }
                else
                {
                    x = OperationDisplay.Substring(index - 1);
                    x = x.Trim('(', ')');
                    x = x.Trim('-');
                    OperationDisplay  = OperationDisplay.Remove(index - 1);
                    OperationDisplay += x;
                }
            }
        }
コード例 #5
0
 internal Operation(string name, bool?isDataAction, OperationDisplay display, Origin?origin, ActionType?actionType)
 {
     Name         = name;
     IsDataAction = isDataAction;
     Display      = display;
     Origin       = origin;
     ActionType   = actionType;
 }
コード例 #6
0
ファイル: Calculator.cs プロジェクト: soziele/Kalkulator-POiG
        public bool isNegative()
        {
            int index_oprtr   = OperationDisplay.LastIndexOfAny(operators.ToArray());
            int index_bracket = OperationDisplay.LastIndexOf('(');

            if (index_oprtr == index_bracket + 1)
            {
                return(true);
            }
            return(false);
        }
コード例 #7
0
ファイル: Calculator.cs プロジェクト: soziele/Kalkulator-POiG
        public bool operatorAtEnd()
        {
            bool oAE = false;

            for (int i = 0; i < 4; i++)
            {
                if (OperationDisplay.EndsWith(operators[i].ToString()))
                {
                    oAE = true;
                }
            }
            return(oAE);
        }
コード例 #8
0
ファイル: Calculator.cs プロジェクト: soziele/Kalkulator-POiG
 public void noWrongDots()
 {
     if (((OperationDisplay.LastIndexOf('.') < OperationDisplay.LastIndexOfAny(operators.ToArray())) || (!OperationDisplay.Contains('.'))) && OperationDisplay != "")
     {
         if (OperationDisplay.LastIndexOf(')') == OperationDisplay.Length - 1)
         {
             OperationDisplay = OperationDisplay.Insert(OperationDisplay.Length - 1, ".");
         }
         else if (OperationDisplay.LastIndexOfAny(operators.ToArray()) != OperationDisplay.Length - 1)
         {
             OperationDisplay += '.';
         }
     }
 }
コード例 #9
0
ファイル: Calculator.cs プロジェクト: soziele/Kalkulator-POiG
        public bool noDoubleOperators()
        {
            if (OperationDisplay.LastIndexOfAny(operators.ToArray()) == OperationDisplay.Length - 1)
            {
                OperationDisplay = OperationDisplay.Trim(operators.ToArray());
            }

            bool anyPreviousOperations = false;

            for (int i = 0; i < 4; i++)
            {
                if (OperationDisplay.Contains(operators[i]))
                {
                    anyPreviousOperations = true;
                }
            }
            return(anyPreviousOperations);
        }
コード例 #10
0
 internal Operation(string name, OperationDisplay display)
 {
     Name    = name;
     Display = display;
 }
コード例 #11
0
 public PSOperationDisplayAttributes(OperationDisplay operationDisplay)
 {
     Provider  = operationDisplay.Provider;
     Resource  = operationDisplay.Resource;
     Operation = operationDisplay.Operation;
 }
コード例 #12
0
 internal OperationResult(string name, OperationDisplay display, bool?isDataAction)
 {
     Name         = name;
     Display      = display;
     IsDataAction = isDataAction;
 }