Ejemplo n.º 1
0
 public void SetBackgroundType(CanvasBackgroundTypes value)
 {
     if (value == CanvasBackgroundTypes.Gradient)
     {
         BuildGradientBrush();
     }
 }
Ejemplo n.º 2
0
        public Ambience(Model model)
        {
            if (model == null)
                throw new ArgumentNullException("The Model is 'null'");

            //set default ambience
            mBackgroundColor = Color.WhiteSmoke;
            mBackgroundType = CanvasBackgroundTypes.FlatColor;
            mGradientColor1 = Color.WhiteSmoke;
            mGradientColor2 = Color.SteelBlue;
            mModel = model;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the type of the background.
 /// </summary>
 /// <param name="value">The value.</param>
 public void SetBackgroundType(CanvasBackgroundTypes value)
 {
     if (value == CanvasBackgroundTypes.Gradient)
     {
         BuildGradientBrush();
     }
     else if (value == CanvasBackgroundTypes.FlatColor)
     {
         RaiseOnBackColorChange(Model.CurrentPage.Ambience.BackgroundColor);
     }
     //BuildSolidBrush();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="page">The page.</param>
        public Ambience(IPage page)
        {
            if (page == null)
                throw new ArgumentNullException("The page paramter cannot be 'null'");
            if (page.Model == null)
                throw new ArgumentNullException("The Model is 'null'");

            //set default ambience
            mBackgroundColor = Color.LightSlateGray;
            mBackgroundType = CanvasBackgroundTypes.FlatColor;
            mGradientColor1 = Color.WhiteSmoke;
            mGradientColor2 = Color.LightSlateGray;
            mModel = page.Model;
        }
Ejemplo n.º 5
0
        public Ambience(Model model)
        {
            if (model == null)
            {
                throw new ArgumentNullException("The Model is 'null'");
            }

            //set default ambience
            mBackgroundColor = Color.WhiteSmoke;
            mBackgroundType  = CanvasBackgroundTypes.FlatColor;
            mGradientColor1  = Color.WhiteSmoke;
            mGradientColor2  = Color.SteelBlue;
            mModel           = model;
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="page">The page.</param>
        public Ambience(IPage page)
        {
            if (page == null)
            {
                throw new ArgumentNullException("The page paramter cannot be 'null'");
            }
            if (page.Model == null)
            {
                throw new ArgumentNullException("The Model is 'null'");
            }

            //set default ambience
            mBackgroundColor = Color.LightSlateGray;
            mBackgroundType  = CanvasBackgroundTypes.FlatColor;
            mGradientColor1  = Color.WhiteSmoke;
            mGradientColor2  = Color.LightSlateGray;
            mModel           = page.Model;
        }
Ejemplo n.º 7
0
        // ------------------------------------------------------------------
        /// <summary>
        /// Default constructor
        /// </summary>
        /// <param name="page">The page.</param>
        // ------------------------------------------------------------------
        public Ambience(IPage page)
        {
            if (page == null)
            {
                throw new ArgumentNullException(
                          "The page paramter cannot be 'null'");
            }
            if (page.Model == null)
            {
                throw new ArgumentNullException("The Model is 'null'");
            }

            //set default ambience
            //mBackgroundColor = Color.FromArgb(116, 118, 124);
            mBackgroundColor    = ArtPalette.DefaultPageBackgroundColor;
            mBackgroundType     = CanvasBackgroundTypes.FlatColor;
            mGradientColor1     = Color.WhiteSmoke;
            mGradientColor2     = Color.LightSlateGray;
            mPageBackgroundType = CanvasBackgroundTypes.FlatColor;
            mPageColor          = ArtPalette.DefaultPageColor;
            mPageGradientColor1 = Color.WhiteSmoke;
            mPageGradientColor2 = Color.Silver;
            mModel = page.Model;
        }
Ejemplo n.º 8
0
    // ------------------------------------------------------------------
    /// <summary>
    /// Default constructor
    /// </summary>
    /// <param name="page">The page.</param>
    // ------------------------------------------------------------------
    public Ambience(IPage page) {
      if (page == null)
        throw new ArgumentNullException(
            "The page paramter cannot be 'null'");
      if (page.Model == null)
        throw new ArgumentNullException("The Model is 'null'");

      //set default ambience
      //mBackgroundColor = Color.FromArgb(116, 118, 124);
      mBackgroundColor = ArtPalette.DefaultPageBackgroundColor;
      mBackgroundType = CanvasBackgroundTypes.FlatColor;
      mGradientColor1 = Color.WhiteSmoke;
      mGradientColor2 = Color.LightSlateGray;
      mPageBackgroundType = CanvasBackgroundTypes.FlatColor;
      mPageColor = ArtPalette.DefaultPageColor;
      mPageGradientColor1 = Color.WhiteSmoke;
      mPageGradientColor2 = Color.Silver;
      mModel = page.Model;
    }
        /// <summary>
        /// Sets the values passed by the property grid
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected virtual void SetPropertyBagValue(object sender, PropertySpecEventArgs e)
        {
            switch(e.Property.Name)
            {
                case "AutomataPulse":
                    this.AutomataPulse = (int) e.Value;
                    break;
                case "BackgroundColor":
                    this.mBackgroundColor = (Color) e.Value;
                    this.Invalidate();
                    break;
                case "BackgroundImagePath":
                    this.mBackgroundImagePath = (string) e.Value;
                    this.Invalidate();
                    break;
                case "DefaultConnectionPath":
                    this.connectionPath = (string) e.Value;
                    break;
                case "DefaultLineEnd":
                    this.connectionEnd = (ConnectionEnds) e.Value;
                    break;
                case "EnableContextMenu":
                    this.EnableContextMenu = (bool) e.Value;
                    this.Invalidate();
                    break;
                case "EnableLayout":
                    this.EnableLayout = (bool) e.Value;
                    break;
                case "GradientBottom":
                    this.mGradientBottom = (Color) e.Value;
                    this.Invalidate();
                    break;
                case "GradientTop":
                    this.mGradientTop = (Color) e.Value;
                    this.Invalidate();
                    break;
                case "GraphLayoutAlgorithm":
                    this.layoutFactory.GraphLayoutAlgorithm = (GraphLayoutAlgorithms) e.Value;
                    break;
                case "GridSize":
                    this.mGridSize = (int) e.Value;
                    this.Invalidate();
                    break;
                case "RestrictToCanvas":
                    this.mRestrictToCanvas = (bool) e.Value;
                    break;
                case "ShowGrid":
                    this.mShowGrid = (bool) e.Value;
                    this.Invalidate();
                    break;
                case "Snap":
                    this.mSnap = (bool) e.Value;
                    this.Invalidate();
                    break;
                case "BackgroundType":
                    this.mBackgroundType= (CanvasBackgroundTypes) e.Value;
                    this.Invalidate();
                    break;
                case "AllowAddShape":
                    this.mAllowAddShape = (bool) e.Value;
                    break;
                case "AllowAddConnection":
                    this.mAllowAddConnection = (bool) e.Value;
                    break;
                case "AllowDeleteShape":
                    this.mAllowDeleteShape = (bool) e.Value;
                    break;
                case "AllowMoveShape":
                    this.mAllowMoveShape = (bool) e.Value;
                    break;

            }
        }
        /// <summary>
        /// Paints the background of the canvas, could have been done in the paint handler as well.
        /// This is not clear in the .Net doc.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnPaintBackground(PaintEventArgs e)
        {
            Graphics g=e.Graphics;

            Rectangle r;
            switch (this.mBackgroundType)
            {
                case CanvasBackgroundTypes.Image:
                    if (mBackgroundImagePath==null) return;
                    if(mBackgroundImagePath.Trim()==string.Empty) return;
                    try
                    {
                        Image im=Image.FromFile(BackgroundImagePath);
                        g.DrawImage(im,0,0,Size.Width,Size.Height);
                        if(mShowGrid)
                        {
                            r = this.ClientRectangle;
                            ControlPaint.DrawGrid(g,r,new Size(mGridSize,mGridSize),Color.Wheat);
                        }
                    }
                    catch (System.IO.FileNotFoundException exc)
                    {
                        this.mBackgroundType = CanvasBackgroundTypes.FlatColor;
                        MessageBox.Show("The path to the background image was not found.","Error",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                        Trace.WriteLine(exc.Message);
                    }
                    break;
                case CanvasBackgroundTypes.FlatColor:

                    g.SmoothingMode=SmoothingMode.AntiAlias;
                    r = this.ClientRectangle;
                    g.FillRectangle(new SolidBrush(mBackgroundColor), r);
                    if(mShowGrid)
                        ControlPaint.DrawGrid(g,r,new Size(mGridSize,mGridSize),Color.Wheat);
                    break;
                case CanvasBackgroundTypes.Gradient:

                    g.SmoothingMode=SmoothingMode.AntiAlias;
                    r = this.ClientRectangle;
                    //g.FillRectangle(new SolidBrush(Color.White), r);

                    LinearGradientMode lgm =LinearGradientMode.Vertical;
                    LinearGradientBrush lgb = new LinearGradientBrush(r,this.mGradientTop,this.mGradientBottom,lgm);
                    g.FillRectangle(lgb,r);
                    if(mShowGrid)
                        ControlPaint.DrawGrid(g,r,new Size(mGridSize,mGridSize),Color.Wheat);
                    //some text on the canvas
                    //g.DrawString("Netron", new Font("Verdana", 100,FontStyle.Bold),new SolidBrush(Color.White),55,55);

                    break;

            }
            //the ControlPaint class has interesting stuff, have a look at it!
            //ControlPaint.DrawBorder3D(g,0,0,workingSize.Width,workingSize.Height);
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Sets the type of the background.
 /// </summary>
 /// <param name="value">The value.</param>
 public void SetBackgroundType(CanvasBackgroundTypes value)
 {
     if(value == CanvasBackgroundTypes.Gradient)
         BuildGradientBrush();
     else if(value == CanvasBackgroundTypes.FlatColor)
         RaiseOnBackColorChange(Model.CurrentPage.Ambience.BackgroundColor);
         //BuildSolidBrush();
 }
Ejemplo n.º 12
0
 public void SetBackgroundType(CanvasBackgroundTypes value)
 {
     if (value == CanvasBackgroundTypes.Gradient)
         BuildGradientBrush();
 }