Exemple #1
0
 private void HandleMouseDown(MouseEventArgs e, LinedPictureBox pb)
 {
     if (pbStartImage.Image != null && pbEndImage.Image != null)
     {
         PointF point = pb.TranslateImageToControl((PointF)e.Location);
         if (e.Button == MouseButtons.Left)
         {
             SetFoundPairAtPoint(pb.ImageNumber, point);
         }
         else
         {
             _lines.Add(Tuple.Create(
                            new Line(point, point),
                            new Line(point, point)));
             _currentLineImageNumber = pb.ImageNumber;
             _currentLineEnd         = 1;
             _lineCreationInProcess  = true;
         }
         pbStartImage.Refresh();
         pbEndImage.Refresh();
     }
 }
        /// <summary>Interpolates between the starting and ending morph lines.</summary>
        /// <param name="pairs">The morph lines to interpolate.</param>
        /// <param name="percent">The percent of the way through the morph.</param>
        /// <param name="interpolatedForwards">Resulting interpolated lines for the starting image.</param>
        /// <param name="interpolatedBackwards">Resulting interpolated lines for the ending image.</param>
        private Tuple <LinePairCollection, LinePairCollection> InterpolateLines(
            LinePairCollection pairs, double percent)
        {
            LinePairCollection interpolatedForwards = new LinePairCollection(), interpolatedBackwards = new LinePairCollection();

            foreach (Tuple <Line, Line> pair in pairs)
            {
                // Source line is the same as the original; dest line is the interpolated line
                // Add the new pair to the forwards list and the inverse to the backwards list.
                var newPair = Tuple.Create(
                    new Line(pair.Item1.Item1, pair.Item1.Item2),
                    new Line(
                        AddPoints(pair.Item1.Item1, ScalePoint(SubPoints(pair.Item2.Item1, pair.Item1.Item1), percent)),
                        AddPoints(pair.Item1.Item2, ScalePoint(SubPoints(pair.Item2.Item2, pair.Item1.Item2), percent))
                        ));
                interpolatedForwards.Add(newPair);
                interpolatedBackwards.Add(Tuple.Create(
                                              new Line(pair.Item2.Item1, pair.Item2.Item2),
                                              new Line(newPair.Item2.Item1, newPair.Item2.Item2)));
            }
            return(Tuple.Create(interpolatedForwards, interpolatedBackwards));
        }