Beispiel #1
0
        /// <summary>
        /// Gets the executed command text from the sender object
        /// </summary>
        /// <param name="sender">Sender object</param>
        /// <param name="e">Routed event arguments</param>
        /// <returns>Executed command text (or empty string if something...)</returns>
        private string GetCommandText(object sender, RoutedEventArgs e)
        {
            Window senderWindow = sender as Window;

            if (sender == null)
            {
                return("");                    //sender is not a window
            }
            if (senderWindow.Title != Title)
            {
                return("");                                //sender window is not the calc window
            }
            ExecutedRoutedEventArgs executedArgs = e as ExecutedRoutedEventArgs;

            if (e == null)
            {
                return("");
            }
            CalcCommand executedCommand = executedArgs.Command as CalcCommand;

            if (executedCommand == null)
            {
                return("");
            }
            if (executedCommand.Operation == null)
            {
                return("");
            }
            return(executedCommand.Operation);
        }
Beispiel #2
0
        /// <summary>
        /// Adds the operation to the ExpressionReader
        /// </summary>
        /// <param name="name">Operation name (according to the commands in the Window resources</param>
        /// <param name="operation">Operation invokation expression</param>
        private void AddOperation(string name, Func <IExpression> operation)
        {
            CalcCommand command = Resources[name] as CalcCommand;

            ExpressionReader.AddOperation(command.Operation, operation, command.Priority);
        }