// <snippet2>
        void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            RenderingEventArgs args = (RenderingEventArgs)e;

            // It's possible for Rendering to call back twice in the same frame
            // so only render when we haven't already rendered in this frame.
            if (d3dimg.IsFrontBufferAvailable && _lastRender != args.RenderingTime)
            {
                IntPtr pSurface = IntPtr.Zero;
                HRESULT.Check(GetBackBufferNoRef(out pSurface));
                if (pSurface != IntPtr.Zero)
                {
                    // <snippet3>
                    d3dimg.Lock();
                    // Repeatedly calling SetBackBuffer with the same IntPtr is
                    // a no-op. There is no performance penalty.
                    d3dimg.SetBackBuffer(D3DResourceType.IDirect3DSurface9, pSurface);
                    HRESULT.Check(Render());
                    d3dimg.AddDirtyRect(new Int32Rect(0, 0, d3dimg.PixelWidth, d3dimg.PixelHeight));
                    d3dimg.Unlock();
                    // </snippet3>

                    _lastRender = args.RenderingTime;
                }
            }
        }
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            RenderingEventArgs args = (RenderingEventArgs)e;

            // It's possible for Rendering to call back twice in the same frame
            // so only render when we haven't already rendered in this frame.

            if (_d3dImage.IsFrontBufferAvailable && _lastRender != args.RenderingTime)
            {
                bool newSurfaceArrived;
                _pvpPresenter.HasNewSurfaceArrived(out newSurfaceArrived);
                if (newSurfaceArrived)
                {
                    _d3dImage.Lock();

                    IntPtr pSurface;
                    _pvpPresenter.GetBackBufferNoRef(out pSurface);

                    if (pSurface != null)
                    {
                        // Repeatedly calling SetBackBuffer with the same IntPtr is
                        // a no-op. There is no performance penalty.
                        _d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, pSurface);

                        _d3dImage.AddDirtyRect(new Int32Rect(0, 0, _d3dImage.PixelWidth, _d3dImage.PixelHeight));
                    }

                    _d3dImage.Unlock();
                }

                _lastRender = args.RenderingTime;
                //System.Diagnostics.Debug.WriteLine("{0} : Repaint: {1}", args.RenderingTime, newSurfaceArrived);
            }
        }
 /// <summary>
 /// The compositiontarget rendering.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="e">
 /// The event arguments.
 /// </param>
 protected override void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
 {
     if (this.IsEnabled)
     {
         this.ApplyCuttingPlanes();
     }
 }
Example #4
0
 //---------------------------------------------------------------------------------------------------------
 /// <summary>
 /// Обновление анимации
 /// </summary>
 /// <param name="sender">Источник события</param>
 /// <param name="args">Аргументы события</param>
 //---------------------------------------------------------------------------------------------------------
 private void CompositeHelper_Rendering(Object sender, RenderingEventArgs args)
 {
     if (mAnimationUpdater != null)
     {
         mAnimationUpdater.Update(Stopwatch.GetTimestamp(), Stopwatch.Frequency);
     }
 }
Example #5
0
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            RenderingEventArgs renderingEventArgs = e as RenderingEventArgs;

            if (renderingEventArgs != null)
            {
                double t     = (0.25 * renderingEventArgs.RenderingTime.TotalSeconds) % 1;
                double scale = t < 0.5 ? 2 * t : 2 - 2 * t;
                tbTime.FontSize = 1 + scale * 143;

                byte  gray = (byte)(255 * t);
                Color clr  = Color.FromArgb(255, gray, gray, gray);
                gridBackgroundBrush.Color = clr;
                //contentGrid.Background = new SolidColorBrush(clr);



                gray = (byte)(255 - gray);
                clr  = Color.FromArgb(255, gray, gray, gray);
                tbForegroundBrush.Color = clr;
                //tbTime.Foreground = new SolidColorBrush(clr);


                tbRainbow.FontSize = 1 + (ActualHeight / 8);
                for (int index = 0; index < gradientBrush.GradientStops.Count; index++)
                {
                    gradientBrush.GradientStops[index].Offset = index / 7.0 - t;
                }
            }
        }
        void OnRendering(object sender, EventArgs e)
        {
            try
            {
                if (!IsLoaded) // We register only in OnLoaded. No harm to check as well.
                {
                    return;
                }

                RenderingEventArgs args = (RenderingEventArgs)e;
                // We may be called back twice for the same frame
                if (_lastCompositionTargetRender == args.RenderingTime)
                {
                    return;
                }
                _lastCompositionTargetRender = args.RenderingTime;

                // Low frequency updates
                if ((_lastCompositionTargetRender - _lastCompositionTargetSlowFreq).TotalMilliseconds > c_compositionTargetSlowPeriod)
                {
                    _lastCompositionTargetSlowFreq = _lastCompositionTargetRender;
                }
            }
            catch (Exception ex)
            {
                Diagnostics.LogLowPriException(ex);
            }
        }
Example #7
0
        private void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
        {
            double delta = watch.ElapsedMilliseconds * 0.001;

            RotationAngle += 360 * RotationSpeed / 60 * delta;
            watch.Restart();
        }
Example #8
0
        private void Render(object sender, EventArgs e)
        {
            RenderingEventArgs args = (RenderingEventArgs)e;

            if (args.RenderingTime == _lastUpdateTime)
            {
                return;
            }

            var deltaUpdateSeconds    = (args.RenderingTime - _lastUpdateTime).TotalSeconds;
            var deltaRenderingSeconds = (args.RenderingTime - _lastRenderingTime).TotalSeconds;

            _controller.Update(deltaUpdateSeconds);

            if (deltaRenderingSeconds > 1.0 / _frameRate)
            {
                GL.Viewport(0, 0, (int)_glControl.Width, (int)_glControl.Height);
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                _controller.Render(deltaRenderingSeconds);

                GL.Flush();
                _glControl.SwapBuffers();

                _lastRenderingTime = args.RenderingTime;
            }
            _lastUpdateTime = args.RenderingTime;
        }
Example #9
0
        //-------------------------------------------------------------------------------------
        /// <summary>
        /// DrawFrame
        /// </summary>
        //-------------------------------------------------------------------------------------
        private void DrawFrame(object sender, EventArgs e)
        {
            _earthTransform.Children.Clear();
            double r = PhysicalConstants.EARTHRADIUS_METERS / 1000;

            _earthTransform.Children.Add(new ScaleTransform3D(r, r, r));
            _earthTransform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), _mainModel.EarthRotationDegrees)));

            _coverageTransform.Children.Clear();
            _coverageTransform.Children.Add(new ScaleTransform3D(r, r, r));

            _worldTransform.Children.Clear();
            _worldTransform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(0, 1, 0), _rotationZ)));
            _worldTransform.Children.Add(new RotateTransform3D(new AxisAngleRotation3D(new Vector3D(1, 0, 0), _rotationX)));
            RenderingEventArgs renderArgs = (RenderingEventArgs)e;

            _mainModel.RenderToHeatMap(12);

            foreach (var item in _mainModel.Satellites)
            {
                // Make sure the satellite has a 3D model and render it
                if (item.Model == null)
                {
                    item.Model          = ModelHelper.CreateSatelliteModel(mainGroup);
                    item.Model.Material = new DiffuseMaterial(Brushes.Red);
                    mainGroup.Children.Add(item.Model);
                }
                var itemTransform = new Transform3DGroup();
                itemTransform.Children.Add(new ScaleTransform3D(1000, 1000, 1000));
                itemTransform.Children.Add(new TranslateTransform3D(item.Location.X / 1000, item.Location.Y / 1000, item.Location.Z / 1000));
                item.Model.Transform = itemTransform;
            }
        }
Example #10
0
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            RenderingEventArgs x = (RenderingEventArgs)e;

            elapsed = x.RenderingTime.Ticks;
            frames++;
        }
        private void UpdateRectangle(object sender, EventArgs e)
        {
            RenderingEventArgs renderArgs = (RenderingEventArgs)e;
            Double             deltaTime  = (renderArgs.RenderingTime - _lastRender).TotalSeconds;

            _lastRender = renderArgs.RenderingTime;

            Point location = new Point(Canvas.GetLeft(followRectangle), Canvas.GetTop(followRectangle));

            //find vector toward mouse location
            Vector toMouse = _lastMousePosition - location;

            //add a force toward the mouse to the rectangles velocity
            double followForce = 1.00;

            _rectangleVelocity += toMouse * followForce;

            //dampen the velocity to add stability
            double drag = 0.9;

            _rectangleVelocity *= drag;

            //update the new location from the velocity
            location += _rectangleVelocity * deltaTime;

            //set new position
            Canvas.SetLeft(followRectangle, location.X);
            Canvas.SetTop(followRectangle, location.Y);
        }
 private void Overlay_Drawing(object sender, RenderingEventArgs e)
 {
     fps.Add((float)(1.0 / e.Delta.TotalSeconds));
     performanceLabel.Text = string.Format(
         "[INFO]\n{0} FPS\n{1} read\n{2} write",
         AverageFPS.ToString("0.00"), FormatBytes(this.Memory.BytesRead), FormatBytes(this.Memory.BytesWrite));
     OnOverlayDrawing(e);
 }
        /// <summary>
        ///     Expand text size between 1 and 144 and back again every 4 seconds.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CompositionTarget_Rendering(object sender, object e)
        {
            RenderingEventArgs args  = e as RenderingEventArgs;
            double             t     = (0.25 * args.RenderingTime.TotalSeconds) % 1;
            double             scale = t < 0.5 ? 2 * t : 2 - 2 * t;

            Block.FontSize = 1 + scale * 143;
        }
 /// <summary>
 /// Called when the composition target rendering event is raised.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="RenderingEventArgs"/> instance containing the event data.</param>
 protected override void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
 {
     // TODO: Find a better way to handle this...
     if (this.IsEnabled)
     {
         this.ApplyCuttingGeometries();
     }
 }
Example #15
0
        void OnCompositionTargetRendering(object sender, object args)
        {
            RenderingEventArgs renderArgs = args as RenderingEventArgs;
            double             t          = (0.25 * renderArgs.RenderingTime.TotalSeconds) % 1;
            double             scale      = t < 0.5 ? 2 * t : 2 - 2 * t;

            txtblk.FontSize = 1 + scale * 143;
        }
Example #16
0
        private void OnPreRender(object sender, RenderingEventArgs e)
        {
            if (!Context.IsPlayerFree || progressBarsRenderer == null)
            {
                return;
            }

            progressBarsRenderer.Render();
        }
Example #17
0
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            RenderingEventArgs args = (RenderingEventArgs)e;

            if (args.RenderingTime == _last)
            {
                return;
            }
            _last = args.RenderingTime; _FrameUpdating(sender, args);
        }
        void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            RenderingEventArgs args = (RenderingEventArgs)e;

            if (lastRender != args.RenderingTime)
            {
                InteropImage.RequestRender();
                lastRender = args.RenderingTime;
            }
        }
        static void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            RenderingEventArgs args = e as RenderingEventArgs;

            if (args.RenderingTime != _last)
            {
                _last = args.RenderingTime;
                _FrameUpdating(sender, args);
            }
        }
Example #20
0
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            if (!initialized)
            {
                logger.Warn("CompositionTarget_Rendering(...) " + initialized);
                return;
            }

            try
            {
                RenderingEventArgs args = (RenderingEventArgs)e;

                //if (VideoSource.IsFrontBufferAvailable && lastRender != args.RenderingTime)//
                if (lastRender != args.RenderingTime)
                { //VideoSource.IsFrontBufferAvailable - не работает через RDP
                    if (needRedraw)
                    {
                        var pSurface = d3dProvider.GetSurfacePointer();

                        if (pSurface != IntPtr.Zero)
                        {
                            VideoSource.Lock();
                            // Repeatedly calling SetBackBuffer with the same IntPtr is
                            // a no-op. There is no performance penalty.
                            VideoSource.SetBackBuffer(D3DResourceType.IDirect3DSurface9, pSurface, EnableSoftwareFallback);

                            var rect = new Int32Rect(0, 0, VideoSource.PixelWidth, VideoSource.PixelHeight);
                            VideoSource.AddDirtyRect(rect);

                            VideoSource.Unlock();
                        }

                        needRedraw = false;
                    }
                    else
                    {
                        // logger.Debug("needRedraw == false");
                    }

                    lastRender = args.RenderingTime;
                }
                else
                {
                    logger.Debug("lastRender != args.RenderingTime");
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex);

                Shutdown();

                errorCode = ErrorCode.Unexpected;
            }
        }
Example #21
0
 protected override void OnCompositionTargetRendering(object sender, RenderingEventArgs e)
 {
     if (_isRendering)
     {
         if (this.UpdateTransform() || this.updateForcely)
         {
             this.Update();
             this.updateForcely = false;
         }
     }
 }
 private void ChangeWater(object sender, RenderingEventArgs e)
 {
     if (Farm is null)
     {
         return;
     }
     if (Farm.waterColor.Value != this.Config.waterColor)
     {
         this.Farm.waterColor.Value = this.Config.waterColor;
     }
 }
Example #23
0
        static void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            RenderingEventArgs args = (RenderingEventArgs)e;

            if (args.RenderingTime - _last < TimeSpan.FromMilliseconds(25))
            {
                return;
            }
            _last = args.RenderingTime;
            _FrameUpdating(sender, args);
        }
Example #24
0
        void OnCompositionTargetRendering(object sender, object args)
        {
            RenderingEventArgs renderArgs = args as RenderingEventArgs;

            // 0~1 までの繰り返し
            double t = (0.25 * renderArgs.RenderingTime.TotalSeconds) % 1;
            // 0~1~0 の繰り返し
            double scale = t < 0.5 ? (2 * t) : (2 - 2 * t);

            // 1~144~1 までの繰り返し
            txtblk.FontSize = 1 + scale * 143;
        }
        /// <summary>
        /// Handler for the rendering event
        /// Updates the positions of the Bodies
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            //Casting to RenderingEventArgs to get the rendering time
            RenderingEventArgs renderArgs = (RenderingEventArgs)e;

            //Gets the time until next render
            double dt = (renderArgs.RenderingTime - lastRender).TotalSeconds;

            lastRender = renderArgs.RenderingTime;

            ExecuteFrame(dt, bodies);
        }
Example #26
0
            /// <summary>
            /// Called when [rendering].
            /// </summary>
            /// <param name="sender">The sender.</param>
            /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
            private static void OnRendering(object sender, EventArgs e)
            {
                RenderingEventArgs args = (RenderingEventArgs)e;

                if (args.RenderingTime == last)
                {
                    return;
                }

                last = args.RenderingTime;
                UnsafeFrameUpdating(sender, args);
            }
        public void Window_Loaded(object sender, RenderingEventArgs e)
        {
            db = new AdventureLiteEntities();

            var query = from o in db.SalesOrderDetails
                        select o.customer
                        //select o.Customer.CompanyName;

                        var result = query.ToList();

            lbxCustomers.ItemsSource = query.ToList().Distinct();
        }
        private void UpdatePosition(object sender, EventArgs e)
        {
            RenderingEventArgs renderingArgs = (RenderingEventArgs)e;

            double deltaTime = (renderingArgs.RenderingTime - _lastRender).TotalSeconds;

            _lastRender = renderingArgs.RenderingTime;

            if (_parentCanvas == null)
            {
                _parentCanvas = VisualTreeHelper.GetParent(this) as Canvas;
                if (_parentCanvas == null)
                {
                    //parent isnt canvas so just abort trying to follow mouse
                    CompositionTarget.Rendering -= UpdatePosition;
                }
                else
                {
                    //parent is canvas, so track mouse position and time
                    _parentCanvas.PreviewMouseMove += UpdateLastMousePosition;
                }
            }


            //get location
            Point location = new Point(Canvas.GetLeft(this), Canvas.GetTop(this));

            //check for NaN's and replace with 0,0
            if (double.IsNaN(location.X) || double.IsNaN(location.Y))
            {
                location = new Point(0, 0);
            }

            //find vector toward mouse location
            Vector toMouse = _parentLastMousePosition - location;

            //add a force toward the mouse to the rectangles velocity
            double followForce = 1.0;

            _velocity += toMouse * followForce;

            //dampen the velocity to add stability
            double drag = 0.95;

            _velocity *= drag;

            //update the new location from the velocity
            location += _velocity * deltaTime;

            //set new position
            Canvas.SetLeft(this, location.X);
            Canvas.SetTop(this, location.Y);
        }
        private void OnRendering(object sender, RenderingEventArgs e)
        {
            if (!_animateTo.HasValue)
            {
                return;
            }

            var delta = (DateTime.Now - _previous).TotalMilliseconds / AnimationSpeed;

            _previous = DateTime.Now;
            SetPosition(_animateTo.Value < _position ? _position - delta : _position + delta);
        }
Example #30
0
        void CompositionTarget_Rendering(object sender, EventArgs e)
        {
            RenderingEventArgs args = (RenderingEventArgs)e;

            // It's possible for Rendering to call back twice in the same frame
            // so only render when we haven't already rendered in this frame.
            if (this.lastRender != args.RenderingTime)
            {
                InteropImage.RequestRender();
                this.lastRender = args.RenderingTime;
            }
        }
		/// <summary>
		/// Renders the text content after encoding it
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

			IScriptWriter writer = e.Writer;


			if (this.Layout == ScriptLayout.Block && this.HasRenderContent)
				writer.WriteNewLineAndIndent();

            // as we have to process the contents we will have to render it seperately
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, e.Writer); // use same format provider

            sw.Write(this.Text);

            string text = tw.ToString();

            writer.Write(Encode(text));
		}
		/// <summary>
		/// Renders the cdata section
		/// Special handing is done to cope if the data contains the illegal closing cdata character sequence (which I can't use here!)
		/// </summary>
		/// <param name="e">includes the script writer to render content to</param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

			IScriptWriter writer = e.Writer;

			if (this.Layout == ScriptLayout.Block && this.HasRenderContent)
				writer.WriteNewLineAndIndent();

            // as we have to process the contents we will have to render it seperately
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, e.Writer); // use same format provider

            sw.Write(this.Data);

            string text = tw.ToString();


            text = text.Replace("]]>", "]]>]]&gt;<![CDATA["); // resolve embedded ]]> by changing to two cdatas with a text node

			writer.Write("<![CDATA[");
            writer.Write(text);
			writer.Write("]]>");
		}
		/// <summary>
		/// renders the component
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

            Script script = Sb.Script();

            // work out the component name
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, e.Writer); // use same format provider

            sw.Write(this.ComponentName);

            string componentName = tw.ToString();


            string nameSpace = ExtJs.GetNamespace(componentName);

			// namespace script
			if (!String.IsNullOrEmpty(nameSpace))
                script.Add(Js.Statement(Js.Call("Ext.ns", Js.Q(nameSpace)))); // register namespace

			// component script
            script.Add(
                Js.Statement(ComponentName, " = ",
                    Js.Call(ScriptLayout.InlineBlock,"Ext.extend",
                        Js.List(
                            this.BaseComponent,
							Js.Object(ScriptLayout.InlineBlock,
								this.Object
							)
                        )
                    )
                )
			);

			// register script
            if (!String.IsNullOrEmpty(this.RegistryName))
                script.Add(Js.Statement(Js.Call("Ext.reg", Js.Q(this.RegistryName), this.ComponentName))); // register xtype

            e.Writer.Write(script);

		}
Example #34
0
		/// <summary>
		/// Render the if clause
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

			IScriptWriter writer = e.Writer;


			if (this.Layout == ScriptLayout.Block)
				writer.WriteNewLineAndIndent();

			writer.Write("if (");

			try
			{
				writer.BeginIndent();

				writer.Write(Condition);
			}
			finally
			{
				writer.EndIndent();
			}

			writer.Write(") ");

			writer.Write(this.TrueBlock);


			if (Sb.HasRenderContent(this._FalseBlock))
			{
				writer.Write(" else ");
				writer.Write(this.FalseBlock);
			}
		}
		/// <summary>
		/// Render the xml element
		/// detects XsAttributes form within its collection and renders appropriately
		/// non IXmlRenderer objects are wrapped within XsText rendering i.e. encoded 
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{

			IScriptWriter writer = e.Writer;


			// this uses EncodeName which means the name can include the namespace
			// Iif we implement namespace as a seperate entitiy we should use EncodeLocalName

			List<XsAttribute> attributes = new List<XsAttribute>();
			bool hasInnerNodes = false;
			bool hasElements = false;

			foreach (object o in this)
			{
				if (o is XsAttribute)
				{
					attributes.Add((XsAttribute)o);
				}
				else
					hasInnerNodes = true;

				if (o is XsElement)
					hasElements = true;
			}

			if (hasElements)
				this.TrySetLayout(ScriptLayout.Block);

			// do the tag and attributes
			if (this.Layout == ScriptLayout.Block && this.HasRenderContent)
				writer.WriteNewLineAndIndent();

			writer.Write("<" + XmlConvert.EncodeName(Name));

			foreach (XsAttribute a in attributes)
			{
				writer.Write(" ");
				writer.Write(a);
			}

			if (hasInnerNodes)
			{
				writer.Write(">");

				if (this.Layout == ScriptLayout.InlineBlock)
					writer.WriteNewLineAndIndent();

				writer.BeginIndent();

				base.OnRender(e); // does inner items

				writer.EndIndent();

				if (this.Layout == ScriptLayout.InlineBlock || this.Layout == ScriptLayout.Block)
					writer.WriteNewLineAndIndent();

				// do the end tag
				writer.Write("</" + XmlConvert.EncodeName(Name) + ">");
			}
			else
			{
				writer.Write("/>");
			}
		}
		/// <summary>
		/// render the applyIf statement
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);
			IScriptWriter writer = e.Writer;

			if (HasRenderContent)
			{
				JsArguments arguments = Js.Arguments(Receiver, Config);

				if (this.Defaults.HasRenderContent)
					arguments.Add(this.Defaults);

				writer.Write(Js.Statement(Js.Call("Ext.applyIf", arguments)));
			}
		}
		/// <summary>
		/// render the function
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
        {
			base.OnRender(e);

			IScriptWriter writer = e.Writer;

			// default the block layout based on the parameters layout if possible
			if (BlockLayout == ScriptLayout.NotAlreadyEstablished)
			{
				if (Parameters.List.Layout != ScriptLayout.Inline)
					Block.TrySetLayout(ScriptLayout.Block);
				else
					Block.TrySetLayout(ScriptLayout.InlineBlock);
			}
			else
				Block.TrySetLayout(BlockLayout);



			if (this.Layout == ScriptLayout.Block)
                writer.WriteNewLineAndIndent();

			
			if (!String.IsNullOrEmpty(Name))
			{
				writer.Write("function "+Name); // named function
			}
			else
			{
				writer.Write("function"); // anonymous function
			}

			try
			{
				writer.BeginIndent();

				writer.Write(Parameters);
			}
			finally
			{
				writer.EndIndent();
			}


			writer.Write(" ");



			writer.Write(Block);

		//	if (Block.MultiLine && !Block.IsNothing)
      //          writer.WriteNewLineAndIndent();

		}
		/// <summary>
		/// Rneders as
		/// name: value
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
        {
			base.OnRender(e);

			IScriptWriter writer = e.Writer;


            if (this.Layout == ScriptLayout.Block)
                writer.WriteNewLineAndIndent();

			// TODO: it looks like names can be quoted (single or double). not sure when that is required or if any escaping is needed!

            writer.Write(Name);

            writer.Write(": ");

            writer.Write(Value);
        }
		/// <summary>
		/// render the class
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

            // work out the class name
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, e.Writer); // use same format provider

            sw.Write(this.ClassName);

            string className = tw.ToString();

            Script script = Sb.Script();

            string nameSpace = ExtJs.GetNamespace(className);

			Script constructor = Sb.Script();

			if (!String.IsNullOrEmpty(nameSpace))
                script.Add(Js.Statement(Js.Call("Ext.ns", Js.Q(nameSpace)))); // register namespace

            script.AddRange(
                Js.Statement(ClassName, " = ",
					Js.Function(ScriptLayout.InlineBlock,
						Parameters,
						Constructor
					)
				),
				Js.Statement(Js.Call("Ext.extend",ClassName,BaseClass)) // make it inherit from base class
			
            );

            e.Writer.Write(script);
		}
		/// <summary>
		/// render the parameters
		/// (param, param, param)
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

			Sb.TrySetLayout(List, ListLayout);

		}
		/// <summary>
		/// Wraps the quotes around the rendering of the text object
		/// escapes internal quotes and new lines
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
        {
			base.OnRender(e);

			IScriptWriter writer = e.Writer;


			if (this.Layout == ScriptLayout.Block)
                writer.WriteNewLineAndIndent();

            string quote = this.DoubleQuotes ? "\"" : "'";
            if (Text == null)
                writer.Write(quote + quote);

            // as we have to process the contents we will have to render it seperately
            StringWriter tw = new StringWriter();
            ScriptWriter sw = new ScriptWriter(tw, e.Writer); // use same format provider
            
            sw.Write(this.Text);

            string text = tw.ToString();

            // now process it
			text = text.Replace(quote, @"\" + quote);

			text = text.Replace(Environment.NewLine, "\\n\\r");

			writer.Write(quote + text + quote);
		}
		/// <summary>
		/// Renders new syntax:
		/// new className(arg, arg, arg)
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
		{
			base.OnRender(e);

			IScriptWriter writer = e.Writer;


			if (this.Layout == ScriptLayout.Block)
				writer.WriteNewLineAndIndent();

			writer.Write("new ");

			writer.Write(Call);

		}
		/// <summary>
		/// render the call
		/// functionName(arg, arg, arg)
		/// </summary>
		/// <param name="e"></param>
		protected override void OnRender(RenderingEventArgs e)
        {
			base.OnRender(e);

			IScriptWriter writer = e.Writer;


			if (this.Layout == ScriptLayout.Block)
                writer.WriteNewLineAndIndent();

            writer.Write(FunctionName);

			try
			{
				writer.BeginIndent();

				writer.Write(Arguments);
			}
			finally
			{
				writer.EndIndent();
			}

		//	if (this.MultiLine && !Parameters.IsNothing)
        //        writer.WriteNewLineAndIndent();

		}