예제 #1
0
        public Layout GenerateLayout()
		{
            int minFontSize = Settings.Default.MinFontHeight;
            int maxFontSize = Settings.Default.Font.Height;

            Size size = View.Default.Size;

            DOIValue[] weights = Model.Default.DOIStrategy.Weights;

            FocusArea focus = Model.Default.Focus;

            Layout layout = new Layout(size, Model.Default.Length);

            int centerPoint = View.Default.Size.Height / 2;

            if (maxFontSize * focus.Center < centerPoint || size.Height > maxFontSize * weights.Length)
                centerPoint = (int)(maxFontSize * focus.Center); 
            else if (maxFontSize * (weights.Length - focus.Center - 1) < centerPoint)
                centerPoint = (int)(size.Height - maxFontSize - maxFontSize * (weights.Length - focus.Center - 1));

			for	(int i = 0; i < weights.Length; i++)
			{
                layout.lines[i].y = centerPoint + maxFontSize * (i - focus.Center);
                layout.lines[i].x = Model.Default.Indentation[i] * Settings.Default.WhitespaceWidth;
                layout.lines[i].shown = (layout.lines[i].y + maxFontSize < 0 || layout.lines[i].y > size.Height) ? false : true;
                layout.lines[i].height = layout.lines[i].shown ? maxFontSize : 0f;
                layout.lines[i].focus = focus.IsInside(i) ? 1f : 0f;
			}
				
			return layout;
		}
예제 #2
0
        public static Layout Blend(Layout l1, Layout l2, float a)
        {
            Debug.Assert(l1.lines.Length == l2.lines.Length);

            Layout layout = new Layout(l1.size, l1.lines.Length);

            LineLayout[] lines = layout.lines;

            float y = 0;

            int lastshown1 = -1;
            int lastshown2 = -1;

            for (int i = 0; i < l1.lines.Length; i++)
            {
                lines[i] = Blend(l1.lines[i], l2.lines[i], a);
                
                if (layout.lines[i].shown)
                {
                    if (l1.lines[i].shown)
                    {
                        if (lastshown1 == -1)
                        {
                            y += (int)(l1.lines[i].y * (1f - a));
                            lastshown1 = i;
                        }
                        else
                        {
                            float space = (l1.lines[i].y - l1.lines[lastshown1].y - l1.lines[lastshown1].height) * (1f - a);
                            y += space;
                            lastshown1 = i;
                        }
                    }

                    if (l2.lines[i].shown)
                    {
                        if (lastshown2 == -1)
                        {
                            y += (int)(l2.lines[i].y * a);
                            lastshown2 = i;
                        }
                        else
                        {
                            float space = (l2.lines[i].y - l2.lines[lastshown2].y - l2.lines[lastshown2].height) * a;
                            y += space;
                            lastshown2 = i;
                        }
                    }

                    lines[i].y = y;
                    y += lines[i].height;
                }
            }

            return layout;
        }
예제 #3
0
        public void UpdateLayout(bool animateTransition)
        {
            _oldLayout = _layout;

            _layoutUpdateTime = DateTime.Now;

            if (Model.Default.DOIStrategy != null)
                _newLayout = Model.Default.RenderStrategy.GenerateLayout();
            
            _animateTransition = animateTransition;
        }
예제 #4
0
        private void RefreshLayout()
        {
            float a = (float)((TimeSpan)(DateTime.Now - _layoutUpdateTime)).TotalSeconds / _transitionSeconds;

            if (_oldLayout != null && _newLayout != null && a < 1f && _animateTransition)
            {
                _layout = Layout.Blend(_oldLayout, _newLayout, a);
            }
            else
            {
                _layout = _newLayout;
            }
        }
예제 #5
0
 public void ClearLayout()
 {
     _layout = null;
     _oldLayout = null;
     _newLayout = null;
 }
예제 #6
0
        protected override void OnPaint(PaintEventArgs e)
        {
            if (Model.Default.DOIStrategy == null || Model.Default.RenderStrategy == null || Model.Default.Document == null || View.Default.Layout == null)
            {
                //base.OnPaint(e);
                return;
            }

            _layout = View.Default.Layout;

            Graphics g = e.Graphics;
            Size s = this.Size;

            // Draw background
            using (Brush backBrush = new SolidBrush(Settings.Default.OverviewBackgroundColor))
            {
                Rectangle u = Rectangle.Union(_overviewRectangle, _connectionsRectangle);
                g.FillRectangle(backBrush, u);
                g.FillRectangle(backBrush, _slackRectangle);
            }

            // Drawing focus area rectangle in overview
            int fTop = TransformToScaled(Model.Default.Focus.Start);
            Rectangle focusAreaRectangle = new Rectangle(_overviewRectangle.X, fTop, Settings.OverviewWidth - 1, TransformToScaled(Model.Default.Focus.End) - fTop);
            g.FillRectangle(new SolidBrush(Settings.Default.FocusColor), focusAreaRectangle);

            DrawConnectors(g);

            if (_overviewSelectedLine != -1)
            {
                g.DrawLine(_selectedPen, _overviewRectangle.X, _overviewSelectedLine, this.Width, _overviewSelectedLine);
            }

            DrawOverview(e);
        }
예제 #7
0
        public void Render(float apptime)
        {
            if (device == null)
                return;

            // Clear the backbuffer to our backgrounds color 
            device.Clear(ClearFlags.Target, Settings.Default.BackgroundColor, 1.0f, 0);

            // Make device ready for drawing
            device.BeginScene();

            _layout = View.Default.Layout;

            if (_layout != null)
                DrawCodeview();

            // End drawing
            device.EndScene();

            // Flip backbuffers
            device.Present();
        }