예제 #1
0
        /// <summary>
        /// Loads a sketch into this Panel.
        ///
        /// Precondition: filepath is not null
        /// </summary>
        /// <param name="newSketch">The Sketch to load</param>
        /// <param name="rescale">True iff the sketch should be resized</param>
        /// <param name="reset">True iff the panel should be reinitialized</param>
        public void loadSketch(string filepath)
        {
            StrokeCollection strokes = new StrokeCollection();

            this.setDefaultInkPicProps();

            // Load the Sketch into the InkPicture

#if DEBUG
            strokes = inkSketch.LoadSketch(filepath);
#else
            try
            {
                strokes = inkSketch.LoadSketch(filepath);
            }
            catch
            {
                // ignore all exceptions!
            }
#endif

            // If the sketch had no strokes, we can stop.
            if (strokes == null || strokes.Count == 0)
            {
                Console.WriteLine("ERR: Given sketch had no strokes.");
                return;
            }
        }
예제 #2
0
        /// <summary>
        /// Loads a sketch file into the panel.
        ///
        /// Precondition: given file path is valid, readable AND NOT NULL.
        /// </summary>
        /// <param name="filepath">Reads from this file path.</param>
        public void LoadSketch(string filepath, Delegate updateSim)
        {
            if (filepath == null)
            {
                throw new Exception("Why'd you give me an empty filepath, jerk?");
            }

            inkSketch.LoadSketch(filepath);

            updateSim.DynamicInvoke();

            // See whether the sketch is recognized or not
            recognized = true;
            foreach (Substroke sub in Sketch.Substrokes)
            {
                if (sub.Type == new Domain.ShapeType())
                {
                    recognized = false;
                    break;
                }
            }

            if (SketchFileLoaded != null)
            {
                SketchFileLoaded();
            }
        }