Example #1
0
        public static ExcelErrorValue Create(eErrorType errorType)
        {
            switch (errorType)
            {
            case eErrorType.Div0:
                return(Div0);

            case eErrorType.NA:
                return(NA);

            case eErrorType.Name:
                return(Name);

            case eErrorType.Null:
                return(Null);

            case eErrorType.Num:
                return(Num);

            case eErrorType.Ref:
                return(Ref);

            case eErrorType.Value:
                return(Value);

            case eErrorType.GettingData:
                return(GettingData);
            }
            return(new ExcelErrorValue(errorType));
        }
        private eErrorType isFormValid()
        {
            eErrorType result = eErrorType.OK;

            if (string.IsNullOrEmpty(locationTextBox.Text))
            {
                result = eErrorType.emptyLocation;
            }

            if (string.IsNullOrEmpty(descriptionTextBox.Text))
            {
                result = eErrorType.emptyDescription;
            }

            if (string.IsNullOrEmpty(nameTextBox.Text))
            {
                result = eErrorType.emptyName;
            }

            if (endMonthCalender.SelectionStart < startMonthCalendar.SelectionStart)
            {
                result = eErrorType.endSmallerThanStart;
            }

            return(result);
        }
        private void OkBtn_Click(object sender, EventArgs e)
        {
            eErrorType result = isFormValid();

            switch (result)
            {
            case eErrorType.OK:
                m_eventToEdit.Name        = nameTextBox.Text;
                m_eventToEdit.Location    = locationTextBox.Text;
                m_eventToEdit.Description = descriptionTextBox.Text;
                m_eventToEdit.StartTime   = startMonthCalendar.SelectionStart;
                m_eventToEdit.EndTime     = endMonthCalender.SelectionStart;

                this.Close();
                break;

            case eErrorType.endSmallerThanStart:
                MessageBox.Show("End date has to be after start date");
                break;

            case eErrorType.emptyName:
                MessageBox.Show("Name field is empty");
                break;

            case eErrorType.emptyLocation:
                MessageBox.Show("Location field is empty");
                break;

            case eErrorType.emptyDescription:
                MessageBox.Show("Description field is empty");
                break;
            }
        }
Example #4
0
 /// <summary>
 /// This functions validates that the supplied <paramref name="arguments"/> contains at least
 /// (the value of) <paramref name="minLength"/> elements. If one of the arguments is an
 /// <see cref="ExcelDataProvider.IRangeInfo">Excel range</see> the number of cells in
 /// that range will be counted as well.
 /// </summary>
 /// <param name="arguments"></param>
 /// <param name="minLength"></param>
 /// <param name="errorTypeToThrow">The <see cref="eErrorType"/> of the <see cref="ExcelErrorValueException"/> that will be thrown if <paramref name="minLength"/> is not met.</param>
 protected void ValidateArguments(IEnumerable <FunctionArgument> arguments, int minLength,
                                  eErrorType errorTypeToThrow)
 {
     Require.That(arguments).Named("arguments").IsNotNull();
     ThrowExcelErrorValueExceptionIf(() =>
     {
         var nArgs = 0;
         if (arguments.Any())
         {
             foreach (var arg in arguments)
             {
                 nArgs++;
                 if (nArgs >= minLength)
                 {
                     return(false);
                 }
                 if (arg.IsExcelRange)
                 {
                     nArgs += arg.ValueAsRangeInfo.GetNCells();
                     if (nArgs >= minLength)
                     {
                         return(false);
                     }
                 }
             }
         }
         return(true);
     }, errorTypeToThrow);
 }
Example #5
0
 /// <summary>
 /// Throws an <see cref="ArgumentException"/> if <paramref name="condition"/> evaluates to true.
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="errorType"></param>
 /// <exception cref="ExcelErrorValueException"></exception>
 protected void ThrowExcelErrorValueExceptionIf(Func <bool> condition, eErrorType errorType)
 {
     if (condition())
     {
         throw new ExcelErrorValueException("An excel function error occurred", ExcelErrorValue.Create(errorType));
     }
 }
Example #6
0
 private ExcelErrorValue(eErrorType type)
 {
     if (type == default(eErrorType))
     {
         throw new ArgumentException($"{nameof(type)} must be a valid error type.");
     }
     this.Type = type;
 }
Example #7
0
 /// <summary>
 /// Tries to convert a string to an <see cref="eErrorType"/>.
 /// </summary>
 /// <param name="candidate">The string to convert to an error value.</param>
 /// <param name="eErrorType">The converted <see cref="eErrorType"/>.</param>
 /// <returns>True if succesfully converted, otherwise false.</returns>
 public static bool TryGetErrorType(string candidate, out eErrorType eErrorType)
 {
     eErrorType = eErrorType.Value;
     if (candidate == null)
     {
         return(false);
     }
     return(_values.TryGetValue(candidate, out eErrorType));
 }
Example #8
0
        static public eErrorType sendFile(XboxConsole console, string localName, string remoteName, bool createDir, bool onlyIfNewer)
        {
            if (console == null)
            {
                return(eErrorType.cNotConnected);
            }

            eErrorType res = eErrorType.c*K;

            try
            {
                if (createDir)
                {
                    string path = remoteName;
                    int    i    = path.LastIndexOf('\\');
                    if (i >= 0)
                    {
                        path = path.Substring(0, i);
                    }
                    createDirectory(console, path);
                }

                bool     gotLocalDateTime = false;
                DateTime localDateTime    = DateTime.Now;
                try
                {
                    localDateTime    = File.GetLastWriteTime(localName);
                    gotLocalDateTime = true;
                }
                catch { }

                if (onlyIfNewer && gotLocalDateTime)
                {
                    IXboxFile fileObject = null;
                    try
                    {
                        fileObject = console.GetFileObject(remoteName);
                    }
                    catch { }
                    if (fileObject != null)
                    {
                        DateTime remoteDateTime = (DateTime)fileObject.ChangeTime;
                        if (localDateTime <= remoteDateTime)
                        {
                            return(res);
                        }
                    }
                }

                console.SendFile(localName, remoteName);
            }
            catch (Exception e)
            {
                res = errorCatch(e);
            }
            return(res);
        }
    static public void ResponseError(eErrorType type)
    {
        string message = null;

        switch (type)
        {
        case eErrorType.None:
            message = "Error";
            break;

        case eErrorType.Login:
            message = "Error";
            break;

        case eErrorType.Null:
            message = "Error";
            break;

        case eErrorType.getAllStages:
            message = "Error";
            break;

        case eErrorType.doSaveStage:
            message = "Error";
            break;

        case eErrorType.doPlay:
            message = "Error";
            break;

        case eErrorType.getRank:
            message = "Error";
            break;

        case eErrorType.doFavoriteStage:
            message = "Error";
            break;

        case eErrorType.clearStage:
            message = "Error";
            break;

        case eErrorType.failedStage:
            message = "Error";
            break;

        default:
            message = "Error";
            break;
        }

        if (App.Instance != null)
        {
            App.Instance.ShowMessage(message);
        }
    }
Example #10
0
        /// <summary>
        /// Checks for a #Num Excel error.
        /// </summary>
        /// <param name="obj">The excel object to check for a num error.</param>
        /// <param name="error">Sends out the eErrorType type.</param>
        /// <returns>Returns false if the value of obj is either Nan or Infinity. Otherwise It returns true and the program continues like normal.</returns>
        public override bool TryValidateObjValueIsNotNaNOrinfinity(object obj, out eErrorType error)
        {
            var num = ConvertUtil.GetValueDouble(obj);

            if (double.IsNaN(num) || double.IsInfinity(num))
            {
                error = eErrorType.Num;
                return(false);
            }
            //If this returns true ignore the out eError
            error = eErrorType.Null;
            return(true);
        }
Example #11
0
 public static void mngError(Exception ex,
                      string function,
                      string module,
                      string infoAdd,
                      string title,
                      eErrorLevel level,
                      eErrorType varType,
                      object connection)
 {
     // TODO: implement function
     fErrors f = new fErrors();
     f.setErrorIcon();
     f.setDetails(ex.Message);
     f.ShowDialog();
 }
Example #12
0
        /// <summary>
        /// This functions validates that the supplied <paramref name="arguments"/> contains at least
        /// (the value of) <paramref name="minLength"/> elements. If one of the arguments is an
        /// <see cref="ExcelDataProvider.IRangeInfo">Excel range</see> the number of cells in
        /// that range will be counted as well. Additionally, if any of the given arguments are an
        /// <see cref="ExcelErrorValue"/>, that error value will be passed back in <paramref name="errorValue"/>.
        /// </summary>
        /// <param name="arguments">The arguments to validate.</param>
        /// <param name="minLength">The expected minimum number of elements in <paramref name="arguments"/>.</param>
        /// <param name="errorValue">The <see cref="eErrorType"/> contained in the first <see cref="ExcelErrorValue"/> encountered
        ///								if this method returns false. The default value is the value given for <paramref name="errorOnInvalidCount"/>.</param>
        /// <param name="errorOnInvalidCount">The desired <see cref="eErrorType"/> to receive if this method returns false.</param>
        /// <returns>Returns true if there are at least the <paramref name="minLength"/> number of arguments present
        ///			 and none of the arguments contain an <see cref="ExcelErrorValue"/>, and returns false if otherwise.</returns>
        protected bool ArgumentsAreValid(IEnumerable <FunctionArgument> arguments, int minLength, out eErrorType errorValue, eErrorType errorOnInvalidCount = eErrorType.Value)
        {
            errorValue = errorOnInvalidCount;
            if (!this.ArgumentCountIsValid(arguments, minLength))
            {
                return(false);
            }
            var argumentContainingError = arguments.FirstOrDefault(arg => arg.ValueIsExcelError);

            if (argumentContainingError != null)
            {
                errorValue = argumentContainingError.ValueAsExcelErrorValue.Type;
                return(false);
            }
            return(true);
        }
Example #13
0
        public static void mngError(Exception ex,
                                    string function,
                                    string module,
                                    string infoAdd,
                                    string title,
                                    eErrorLevel level,
                                    eErrorType varType,
                                    object connection)
        {
            // TODO: implement function
            fErrors f = new fErrors();

            f.setErrorIcon();
            f.setDetails(ex.Message);
            f.ShowDialog();
        }
Example #14
0
        public void AverageShouldThrowDivByZeroExcelErrorValueIfEmptyArgs()
        {
            eErrorType errorType = eErrorType.Value;

            var func = new Average();
            var args = new FunctionArgument[0];

            try
            {
                func.Execute(args, _parsingContext);
            }
            catch (ExcelErrorValueException e)
            {
                errorType = e.ErrorValue.Type;
            }
            Assert.AreEqual(eErrorType.Div0, errorType);
        }
Example #15
0
        static public void sendCommand(string cmd, out string resp)
        {
            resp = "";
            eErrorType res = eErrorType.cConnectionLost;

            try
            {
                closeConnection();
                openConnection();

                mDefaultConsole.SendTextCommand(mCommandConnectionID, mCommandStringHandle + "!" + cmd, out resp);
                res = eErrorType.c*K;
            }
            catch (Exception e)
            {
                res = errorCatch(e);
            }
        }
Example #16
0
 public override bool TryValidateObjValueIsNotNaNOrinfinity(object obj, out eErrorType error)
 {
     error = eErrorType.Null;
     return(true);
 }
Example #17
0
 private ExcelErrorValue(eErrorType type)
 {
     Type = type;
 }
Example #18
0
 internal static ExcelErrorValue Create(eErrorType errorType)
 {
     return(new ExcelErrorValue(errorType));
 }
Example #19
0
 /// <summary>
 /// Throws an <see cref="ExcelErrorValueException"/> with the given <paramref name="errorType"/> set.
 /// </summary>
 /// <param name="errorType"></param>
 protected void ThrowExcelErrorValueException(eErrorType errorType)
 {
     throw new ExcelErrorValueException("An excel function error occurred", ExcelErrorValue.Create(errorType));
 }
Example #20
0
 /// <summary>
 /// This functions validates that the supplied <paramref name="arguments"/> contains at least
 /// (the value of) <paramref name="minLength"/> elements. If one of the arguments is an
 /// <see cref="ExcelDataProvider.IRangeInfo">Excel range</see> the number of cells in
 /// that range will be counted as well.
 /// </summary>
 /// <param name="arguments"></param>
 /// <param name="minLength"></param>
 /// <param name="errorTypeToThrow">The <see cref="eErrorType"/> of the <see cref="ExcelErrorValueException"/> that will be thrown if <paramref name="minLength"/> is not met.</param>
 protected void ValidateArguments(IEnumerable<FunctionArgument> arguments, int minLength,
                                  eErrorType errorTypeToThrow)
 {
     Require.That(arguments).Named("arguments").IsNotNull();
     ThrowExcelErrorValueExceptionIf(() =>
         {
             var nArgs = 0;
             if (arguments.Any())
             {
                 foreach (var arg in arguments)
                 {
                     nArgs++;
                     if (nArgs >= minLength) return false;
                     if (arg.IsExcelRange)
                     {
                         nArgs += arg.ValueAsRangeInfo.GetNCells();
                         if (nArgs >= minLength) return false;
                     }
                 }
             }
             return true;
         }, errorTypeToThrow);
 }
Example #21
0
 public override void Read(ByteArray by)
 {
     base.Read(by);
     type   = (eErrorType)by.ReadUShort();
     action = (eErrorAction)by.ReadUShort();
 }
Example #22
0
 internal static ExcelErrorValue Create(eErrorType errorType)
 {
     return new ExcelErrorValue(errorType);
 }
Example #23
0
        public override void DrawWindow()
        {
            base.DrawWindow();
            Dialog DInstance = DialogEditor.Instance.currentDialog;

            hasBeenClicked = false;

            newName = EditorGUILayout.TextField(newName);
            if (showError)
            {
                EditorGUILayout.HelpBox(error[(int)errorType], MessageType.Error);
                if (windowRect.height < 105)
                {
                    windowRect.height = 105;
                }
            }

            /*else
             * {
             *  EditorGUILayout.LabelField("");
             * }*/

            //follow target node
            Vector2 topRPos = targetNode.GetTopRightCornerPos();

            windowRect.x = topRPos.x;
            windowRect.y = topRPos.y;


            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Apply"))
            {
                hasBeenClicked = true;
                bool isAcceptable = true;

                if (newName != "")
                {
                    foreach (BaseNode node in DInstance.NodeList)
                    {
                        if (node.windowTitle == newName)
                        {
                            isAcceptable = false;
                            errorType    = eErrorType.Used;
                            break;
                        }
                    }
                }
                else
                {
                    isAcceptable = false;
                    errorType    = eErrorType.NoName;
                }
                if (isAcceptable)
                {
                    foreach (BaseNode node in DInstance.ActionNodeList)
                    {
                        //rename dialogText attached
                        if (node is DialogText)
                        {
                            if ((node as DialogText).targetNode == targetNode)
                            {
                                (node as DialogText).windowTitle = "Text from:" + newName;
                            }
                        }
                        //rename AnswerText attached
                        else if (node is AnswerText)
                        {
                            if ((node as AnswerText).targetNode == targetNode)
                            {
                                string prevTitle = (node as AnswerText).windowTitle;
                                int    posString = prevTitle.IndexOf(":") + 1;
                                prevTitle = prevTitle.Substring(0, posString);

                                (node as AnswerText).windowTitle = prevTitle + newName;
                            }
                        }
                    }

                    DInstance.DECtrlZInstance.Add(new CtrlZNodeRenamed(targetNode, DInstance, targetNode.windowTitle, newName));
                    targetNode.windowTitle = newName;
                    DInstance.RemoveRenameNode(targetNode);
                }
                else
                {
                    showError = true;
                }
            }
            if (GUILayout.Button("Cancel"))
            {
                hasBeenClicked = true;
                DInstance.RemoveRenameNode(this);
            }
            GUILayout.EndHorizontal();

            if (hasBeenClicked)
            {
                DInstance.SetNodeToFront(this);
            }
            DInstance.SetLastDrawnWindow(this);
        }
 public ExcelErrorValueException(eErrorType errorType)
     : this(ExcelErrorValue.Create(errorType))
 {
     
 }
Example #25
0
 /// <summary>
 /// Tries to convert a string to an <see cref="eErrorType"/>.
 /// </summary>
 /// <param name="candidate">The string to convert to an error value.</param>
 /// <param name="eErrorType">The converted <see cref="eErrorType"/>.</param>
 /// <returns>True if succesfully converted, otherwise false.</returns>
 public static bool TryGetErrorType(string candidate, out eErrorType eErrorType)
 {
     return(_values.TryGetValue(candidate, out eErrorType));
 }
 public ExcelErrorValueException(eErrorType errorType)
     : this(ExcelErrorValue.Create(errorType))
 {
 }
Example #27
0
 public CompileResult(eErrorType errorType)
 {
     Result = ExcelErrorValue.Create(errorType);
     DataType = DataType.ExcelError;
 }
Example #28
0
 /// <summary>
 /// Throws an <see cref="ExcelErrorValueException"/> with the given <paramref name="errorType"/> set.
 /// </summary>
 /// <param name="errorType"></param>
 protected void ThrowExcelErrorValueException(eErrorType errorType)
 {
     throw new ExcelErrorValueException("An excel function error occurred", ExcelErrorValue.Create(errorType));
 }
Example #29
0
 private ExcelErrorValue(eErrorType type)
 {
     Type=type; 
 }
Example #30
0
 /// <summary>
 /// Checks for a validation error.
 /// </summary>
 public abstract bool TryValidateObjValueIsNotNaNOrinfinity(object obj, out eErrorType error);
Example #31
0
 protected CompileResult CreateResult(eErrorType errorType)
 {
     return(CreateResult(ExcelErrorValue.Create(errorType), DataType.ExcelError));
 }
Example #32
0
 /// <summary>
 /// Throws an <see cref="ArgumentException"/> if <paramref name="condition"/> evaluates to true.
 /// </summary>
 /// <param name="condition"></param>
 /// <param name="errorType"></param>
 /// <exception cref="ExcelErrorValueException"></exception>
 protected void ThrowExcelErrorValueExceptionIf(Func<bool> condition, eErrorType errorType)
 {
     if (condition())
     {
         throw new ExcelErrorValueException("An excel function error occurred", ExcelErrorValue.Create(errorType));
     }
 }
 public FinanceCalcResult(eErrorType error)
 {
     HasError       = true;
     ExcelErrorType = error;
 }
Example #34
0
 public CompileResult(eErrorType errorType)
 {
     Result   = ExcelErrorValue.Create(errorType);
     DataType = DataType.ExcelError;
 }
Example #35
0
        public override void DrawWindow()
        {
            base.DrawWindow();
            Dialog DInstance = DialogEditor.Instance.currentDialog;

            windowTitle = "SubDialog:" + dialog.dialogName;

            bool isAcceptable = true;

            if (dialog.dialogName != "")
            {
                foreach (SubDialogNode sdNode in DInstance.SubDialogNodeList)
                {
                    if (sdNode != this && sdNode.dialog.dialogName == dialog.dialogName)
                    {
                        isAcceptable = false;
                        errorType    = eErrorType.Used;
                        break;
                    }
                }

                foreach (Dialog dialog in DialogEditor.Instance.loadedDialogs)
                {
                    if (dialog != this.dialog && dialog.dialogName == this.dialog.dialogName)
                    {
                        isAcceptable = false;
                        errorType    = eErrorType.Used;
                        break;
                    }
                }
            }
            else
            {
                isAcceptable = false;
                errorType    = eErrorType.NoName;
            }

            showError = !isAcceptable;

            EditorGUILayout.LabelField("Dialog name");

            EditorGUILayout.BeginHorizontal(GUILayout.ExpandWidth(true));
            dialog.dialogName = EditorGUILayout.TextField(dialog.dialogName, GUILayout.MinWidth(130.0f));

            if (GUILayout.Button("L", GUILayout.Width(19), GUILayout.Height(15)))
            {
                connection = null;
                DInstance.connectNodeClick   = true;
                DInstance.selectedNodeAnswer = -1;
                DInstance.selectedNodeToLink = this;
            }
            EditorGUILayout.EndHorizontal();

            if (showError)
            {
                EditorGUILayout.HelpBox(error[(int)errorType], MessageType.Error);
                if (windowRect.height < 105)
                {
                    windowRect.height = 105;
                }
            }
            else
            {
                windowRect.height = 60;
            }
        }