Exemple #1
0
        /// <summary>
        /// Get the image uri given a specified instruction
        /// </summary>
        private Uri GetPathFromInstruction(Instruction ins)
        {
            string picPath = "/iRobotGUI;component/pic/";
            string picName = PictureDiscription.GetPictureName(ins);

            return(new Uri(picPath + picName, UriKind.Relative));
        }
Exemple #2
0
        public void GetPictureNameTest()
        {
            string ValidOpcodeStr   = "LED";
            string InvalidOpcodeStr = "MOV";

            try
            {
                var    ins          = new Instruction(InvalidOpcodeStr);
                string actualResult = PictureDiscription.GetPictureName(ins);
                Assert.IsNull(actualResult);
            }
            catch (InvalidOpcodeException)
            {
                Console.WriteLine(InvalidOpcodeStr + ": Invalid");
            }

            try
            {
                var    ins          = new Instruction(ValidOpcodeStr);
                string actualResult = PictureDiscription.GetPictureName(ins);
                Assert.IsNotNull(actualResult);
            }
            catch (InvalidOpcodeException)
            {
                Assert.Fail("In Valid instruction string");
            }
        }
Exemple #3
0
        /// <summary>
        /// Get the corresponding image from a specific instruction
        /// </summary>
        /// <param name="ins"> The Instruction </param>
        private Image GetImageFromInstruction(Instruction ins)
        {
            string      picPath = "/iRobotGUI;component/pic/";
            Image       im      = new Image();
            BitmapImage bi      = new BitmapImage();

            bi.BeginInit();
            string picName = PictureDiscription.GetPictureName(ins);

            bi.UriSource = new Uri(picPath + picName, UriKind.Relative);
            if (bi.UriSource == null)
            {
                return(null);
            }
            bi.EndInit();

            im.Stretch = Stretch.Fill;
            im.Source  = bi;
            im.Width   = 45;
            im.Height  = 45;
            return(im);
        }