Measure the top horizontal span of the window opening, along the inner edge of the casing.
Mark out that measurement on a length of trim, with two marks and the measured span between them.
Place the trim on the miter saw, face up, so the bottom edge is against the back rail. Move the trim to put one mark is in front of the blade. Move the blade to point 45 degrees out (away from the trim). Make the cut.
Slide the trim to put the second mark under the blade. Turn the blade to again point 45 degrees away from the trim.
Hold the trim to the top of the window opening, with the two mitered ends coming off the two upper corners. Shoot finish nails along the top and bottom edges of the trim with your finishing nailer, every foot or so.
Repeat the process for the remaining three edges of the window. Butt the mitered ends of the trim pieces tightly to each other at the corners to make the right angles.