\documentclass[10pt]{Book}
\usepackage{graphicx}\usepackage{keyval,color}
\usepackage[Kashida]{xepersian}

\makeatletter
\define@key{mydefinitionbox}{width}{\def\@mydefinitionboxwidth{#1}}
\define@key{mydefinitionbox}{theorem name}{\def\@mytheoremname{#1}}
\define@key{mydefinitionbox}{background color}{\def\@mybackgroundcolor{#1}}
\define@key{mydefinitionbox}{rule color}{\def\@myrulecolor{#1}}
\define@key{mydefinitionbox}{rule width}{\def\@myfboxrulewidth{#1}}
\define@key{mydefinitionbox}{paragraph indentation}{\def\@myparagraphindentation{#1}}
\newsavebox\mydefinitionbox
\@definecounter{mydefinition}
\newenvironment{definitionb}[1][]{%
\setkeys{mydefinitionbox}{width=\textwidth,theorem name={},background color=white,rule color=black,rule width=0.4pt
,paragraph indentation=0cm,
#1}
\setlength{\fboxrule}{\@myfboxrulewidth}%
\begin{lrbox}{\mydefinitionbox}%
%\begin{center}
\begin{minipage}{\dimexpr(\@mydefinitionboxwidth-2\fboxsep-2\fboxrule)}%
\setlength{\parindent}{\@myparagraphindentation}
\refstepcounter{mydefinition}%
\setlength{\fboxrule}{0.4pt}
%\fbox{\themydefinition}
\textbf{\@mytheoremname}
}{%
\end{minipage}%\end{center}%
\end{lrbox}%
\vskip5pt
\noindent\fcolorbox{\@myrulecolor}{\@mybackgroundcolor}{\usebox\mydefinitionbox}%
\vskip5pt}
\makeatother
\def\bkad{\begin{definitionb}}
\def\ekad{\end{definitionb}}
\def\bc{\begin{center}}
\def\ec{\end{center}}
\begin{document}
نمونه متن داخل کادر
\fboxsep=2mm
\bc\bkad[width=10cm, theorem name={},background color=yellow, rule color=black,rule width=1pt,]
{\Large \rm حالت ۲:}
 اگر $Q(x)$ به فرم $a\sin\beta x$ یا $b\cos\beta x$ یا ترکیبی از این دو باشد که در اینجا  $a$ و $b$ اعداد
حقیقی ثابت و $\beta i$ ریشه معادله مفسر از مرتبه $r$ باشد. آنگاه $y_{p}=x^{r}(A\sin\beta x+B\cos\beta x)$ جواب
خصوصی معادله است، توجه کنید که در اینجا $A$ و $B$ ثابت‌هایی مجهول هستند و باید محاسبه شوند.
\ekad\ec 
کادر خاکستری
\bc\bkad[width=10cm, theorem name={},background color=لقشغ, rule color=black,rule width=1pt,]
{\Large \rm حالت ۲:}
 اگر $Q(x)$ به فرم $a\sin\beta x$ یا $b\cos\beta x$ یا ترکیبی از این دو باشد که در اینجا  $a$ و $b$ اعداد
حقیقی ثابت و $\beta i$ ریشه معادله مفسر از مرتبه $r$ باشد. آنگاه $y_{p}=x^{r}(A\sin\beta x+B\cos\beta x)$ جواب
خصوصی معادله است، توجه کنید که در اینجا $A$ و $B$ ثابت‌هایی مجهول هستند و باید محاسبه شوند.
\ekad\ec 
\end{document}