~ubuntu-branches/ubuntu/natty/pdfmod/natty

« back to all changes in this revision

Viewing changes to lib/PdfSharp/PdfSharp.Drawing/XLinearGradientBrush.cs

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2010-09-29 17:34:49 UTC
  • mfrom: (2.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20100929173449-4ezagrzettatjk36
Tags: 0.9.0-1
* New upstream release
* debian/copyright: Document PdfSharp.SharpZipLib/*
* Drop all patches: committed upstream
* No change bump of Standards-Version from 3.8.4 to 3.9.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
// Authors:
4
4
//   Stefan Lange (mailto:Stefan.Lange@pdfsharp.com)
5
5
//
6
 
// Copyright (c) 2005-2008 empira Software GmbH, Cologne (Germany)
 
6
// Copyright (c) 2005-2009 empira Software GmbH, Cologne (Germany)
7
7
//
8
8
// http://www.pdfsharp.com
9
9
// http://sourceforge.net/projects/pdfsharp
38
38
using System.Windows;
39
39
using System.Windows.Media;
40
40
#endif
 
41
using PdfSharp;
41
42
using PdfSharp.Internal;
42
43
 
43
44
namespace PdfSharp.Drawing
109
110
#endif
110
111
 
111
112
#if WPF
 
113
    /// <summary>
 
114
    /// Initializes a new instance of the <see cref="XLinearGradientBrush"/> class.
 
115
    /// </summary>
112
116
    public XLinearGradientBrush(Rect rect, XColor color1, XColor color2, XLinearGradientMode linearGradientMode)
113
117
      : this(new XRect(rect), color1, color2, linearGradientMode)
114
118
    {
212
216
    }
213
217
 
214
218
    /// <summary>
215
 
    /// Multiplay the brush tranformation matrix with the specified matrix.
 
219
    /// Multiply the brush transformation matrix with the specified matrix.
216
220
    /// </summary>
217
221
    public void MultiplyTransform(XMatrix matrix)
218
222
    {
220
224
    }
221
225
 
222
226
    /// <summary>
223
 
    /// Multiplay the brush tranformation matrix with the specified matrix.
 
227
    /// Multiply the brush transformation matrix with the specified matrix.
224
228
    /// </summary>
225
229
    public void MultiplyTransform(XMatrix matrix, XMatrixOrder order)
226
230
    {
228
232
    }
229
233
 
230
234
    /// <summary>
231
 
    /// Resets the brush tranformation matrix with identity matrix.
 
235
    /// Resets the brush transformation matrix with identity matrix.
232
236
    /// </summary>
233
237
    public void ResetTransform()
234
238
    {
235
 
      this.matrix = XMatrix.Identity;
 
239
      this.matrix = new XMatrix();  //XMatrix.Identity;
236
240
    }
237
241
 
238
242
    //public void SetBlendTriangularShape(double focus);
291
295
      System.Windows.Media.LinearGradientBrush brush;
292
296
      if (this.useRect)
293
297
      {
 
298
#if !SILVERLIGHT
294
299
        brush = new System.Windows.Media.LinearGradientBrush(this.color1.ToWpfColor(), this.color2.ToWpfColor(), new System.Windows.Point(0, 0), new System.Windows.Point(1,1));// this.rect.TopLeft, this.rect.BottomRight);
295
300
        //brush = new System.Drawing.Drawing2D.LinearGradientBrush(this.rect.ToRectangleF(),
296
301
        //  this.color1.ToGdiColor(), this.color2.ToGdiColor(), (LinearGradientMode)this.linearGradientMode);
 
302
#else
 
303
        GradientStop gs1 = new GradientStop();
 
304
        gs1.Color = this.color1.ToWpfColor();
 
305
        gs1.Offset = 0;
 
306
 
 
307
        GradientStop gs2 = new GradientStop();
 
308
        gs2.Color = this.color2.ToWpfColor();
 
309
        gs2.Offset = 1;
 
310
 
 
311
        GradientStopCollection gsc = new GradientStopCollection();
 
312
        gsc.Add(gs1);
 
313
        gsc.Add(gs2);
 
314
 
 
315
        brush = new LinearGradientBrush(gsc, 0);
 
316
        brush.StartPoint = new Point(0, 0);
 
317
        brush.EndPoint = new Point(1, 1);
 
318
#endif
297
319
      }
298
320
      else
299
321
      {
 
322
#if !SILVERLIGHT
300
323
        brush = new System.Windows.Media.LinearGradientBrush(this.color1.ToWpfColor(), this.color2.ToWpfColor(), this.point1, this.point2);
301
324
        //brush = new System.Drawing.Drawing2D.LinearGradientBrush(
302
325
        //  this.point1.ToPointF(), this.point2.ToPointF(),
303
326
        //  this.color1.ToGdiColor(), this.color2.ToGdiColor());
 
327
#else
 
328
        GradientStop gs1 = new GradientStop();
 
329
        gs1.Color = this.color1.ToWpfColor();
 
330
        gs1.Offset = 0;
 
331
 
 
332
        GradientStop gs2 = new GradientStop();
 
333
        gs2.Color = this.color2.ToWpfColor();
 
334
        gs2.Offset = 1;
 
335
 
 
336
        GradientStopCollection gsc = new GradientStopCollection();
 
337
        gsc.Add(gs1);
 
338
        gsc.Add(gs2);
 
339
 
 
340
        brush = new LinearGradientBrush(gsc, 0);
 
341
        brush.StartPoint = this.point1;
 
342
        brush.EndPoint = this.point2;
 
343
#endif
304
344
      }
305
345
      if (!this.matrix.IsIdentity)
 
346
      {
 
347
#if !SILVERLIGHT
306
348
        brush.Transform = new MatrixTransform(this.matrix.ToWpfMatrix());
 
349
#else
 
350
        MatrixTransform transform = new MatrixTransform();
 
351
        transform.Matrix = this.matrix.ToWpfMatrix();
 
352
        brush.Transform = transform;
 
353
#endif
 
354
      }
307
355
      return brush;  //this.brush;
308
356
    }
309
357
#endif
322
370
    internal XRect rect;
323
371
    internal XLinearGradientMode linearGradientMode;
324
372
 
325
 
    internal XMatrix matrix = XMatrix.Identity;
 
373
    internal XMatrix matrix;
326
374
    //bool dirty = true;
327
375
    //LinearGradientBrush brush;
328
376
  }