示例#1
0
            public override Cell Evaluate(SpoolSpace Memory)
            {
                this.CheckParameters();
                Cell x = this._Children[0].Evaluate(Memory);

                return(CellFunctions.ArcSin(x));
            }
示例#2
0
            public override Cell Evaluate(SpoolSpace Memory)
            {
                this.CheckParameters();
                Cell x = this._Children[0].Evaluate(Memory);
                Cell y = this._Children[1].Evaluate(Memory);

                return(CellFunctions.Round(x, y.valueINT));
            }
示例#3
0
            public override Cell Evaluate(SpoolSpace Memory)
            {
                this.CheckParameters();
                Cell a     = this._Children[0].Evaluate(Memory);
                Cell b     = this._Children[1].Evaluate(Memory);
                int  Start = (this._Children.Count == 2 ? 0 : this._Children[2].Evaluate(Memory).valueINT);

                return(CellFunctions.Position(a, b, Start));
            }
示例#4
0
            public override Cell Evaluate(SpoolSpace Memory)
            {
                this.CheckParameters();
                Cell x = this._Children[0].Evaluate(Memory);
                Cell y = this._Children[1].Evaluate(Memory);
                Cell z = this._Children[2].Evaluate(Memory);

                return(CellFunctions.ModPow(x, y, z));
            }
示例#5
0
 public override Cell AggRender(Cell Work)
 {
     if (Work[0].IsZero)
     {
         return(CellValues.Null(Work[1].Affinity));
     }
     Work[1] = Work[1] / Work[0];
     Work[2] = Work[2] / Work[0];
     return(CellFunctions.Power((Work[2] - Work[1] * Work[1]) * Work[0] / (Work[0] - CellValues.One(Work[1].Affinity)), new Cell(0.5)));
 }
示例#6
0
                public override Cell Accumulate(SpoolSpace Memory, Cell Work)
                {
                    Cell x = this._Children[0].Evaluate(Memory);

                    if (!x.IsNull)
                    {
                        return(CellFunctions.Max(Work, x));
                    }
                    return(Work);
                }
        public void OnPaint(DataGridViewCellPaintingEventArgs e)
        {
            //e.PaintBackground(e.ClipBounds, false);
            e.PaintBackground(e.ClipBounds, this.Selected);

            Graphics g   = e.Graphics;
            Image    img = this.Image;

            Point        pt      = Control.MousePosition;
            DataGridView _parent = base.DataGridView;

            if (_parent == null)
            {
                return;
            }

            pt = _parent.PointToClient(pt);
            Brush textColor = new SolidBrush(this.DefaultCellStyle.ForeColor);

            /*
             * if (e.CellBounds.Contains(pt)) textColor = CellFunctions.DrawHeaderBack(e.CellBounds, g, _parent.GridColor, true);
             * else textColor = CellFunctions.DrawHeaderBack(e.CellBounds, g, Color.WhiteSmoke, this.Selected);
             */
            if (_text != null && _text.Length > 0)
            {
                //Brush textColor = CellFunctions.DrawHeaderBack(e.CellBounds,g, _parent.GridColor, this.Selected);
                pt = CellFunctions.TextCenterInRact(e.CellBounds, g, _parent.Font, _text);
                pt = new Point(pt.X + img.Width / 2 + 1, pt.Y);

                g.DrawString(_text as String, _parent.Font, textColor, pt.X, pt.Y + 2);
                pt = new Point(pt.X - img.Width - 2, ((e.CellBounds.Height - img.Height) / 2) + e.CellBounds.Location.Y);
            }
            else
            {
                pt = new Point(((e.CellBounds.Width - img.Width) / 2) + e.CellBounds.Location.X, ((e.CellBounds.Height - img.Height) / 2) + e.CellBounds.Location.Y);
            }

            /*
             * g.FillPath(Brushes.Gainsboro, new GraphicsPath(
             *  new PointF[]{
             *      new PointF(e.CellBounds.Right-10, e.CellBounds.Top+4),
             *      new PointF(e.CellBounds.Right-10, e.CellBounds.Bottom -4),
             *      new PointF(e.CellBounds.Right-3, (e.CellBounds.Top + e.CellBounds.Bottom)/2)},
             *  new byte[]{
             *      (byte)PathPointType.Start,(byte)PathPointType.Line,(byte)PathPointType.Line}, FillMode.Winding));
             */



            e.Graphics.DrawImage(img, pt);

            e.Handled = true;
        }
示例#8
0
 private static void populateClusterTables()
 {
     foreach (CellGroup cluster in PublicParameters.networkCells)
     {
         foreach (Sensor sensor in cluster.getClusterNodes())
         {
             sensor.inCell = cluster.getID();
             sensor.TuftNodeTable.isEncapsulated = true;
             sensor.TuftNodeTable.myCellHeader   = cluster.CellTable.CellHeader;;
         }
     }
     CellFunctions.FillOutsideSensnors();
 }
示例#9
0
 public override Cell AggRender(Cell Work)
 {
     if (Work[0].IsZero)
     {
         return(CellValues.Null(Work[1].Affinity));
     }
     Work[1] = Work[1] / Work[0];                     // avgx
     Work[2] = Work[2] / Work[0] - Work[1] * Work[1]; // varx
     Work[3] = Work[3] / Work[0];                     // avgy
     Work[4] = Work[4] / Work[0] - Work[3] * Work[3]; // vary
     Work[5] = Work[5] / Work[0];
     return((Work[5] - Work[1] * Work[3]) / CellFunctions.Sqrt(Work[2] * Work[4]));
 }
示例#10
0
        protected override void Paint(Graphics g, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            //if (cellBounds.Y == 0) return;
            //CellFunctions.DrawPlainBackground(this, this.Enabled, cellBounds, g, rowIndex, this.Selected, this.DataGridView.GridColor);

            if (_visible)
            {
                if (_imageLayout != System.Windows.Forms.ImageLayout.Stretch && _imageLayout != System.Windows.Forms.ImageLayout.Zoom && (ImageFixedWidth > 0 || ImageFixedHeight > 0))
                {
                    paintParts = DataGridViewPaintParts.Background | DataGridViewPaintParts.Border | DataGridViewPaintParts.SelectionBackground | DataGridViewPaintParts.Focus;
                    base.Paint(g, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);


                    if (_selectedIndex > 0)
                    {
                        if (_imageLayout == System.Windows.Forms.ImageLayout.Center)
                        {
                            int wid = (ImageFixedWidth == 0) ? this.Images.ElementAt(_selectedIndex).Width : ImageFixedWidth;
                            int hig = (ImageFixedHeight == 0) ? this.Images.ElementAt(_selectedIndex).Height : ImageFixedHeight;
                            int x   = cellBounds.Location.X + (cellBounds.Width + wid) / 2;
                            int y   = cellBounds.Location.Y + (cellBounds.Height + hig) / 2;
                            g.DrawImage(this.Images.ElementAt(_selectedIndex), new Rectangle(x, y, wid, hig));
                        }
                        else
                        {
                            int wid = (ImageFixedWidth == 0) ? this.Images.ElementAt(_selectedIndex).Width : ImageFixedWidth;
                            int hig = (ImageFixedHeight == 0) ? this.Images.ElementAt(_selectedIndex).Height : ImageFixedHeight;
                            int x   = cellBounds.Location.X;
                            int y   = cellBounds.Location.Y + (cellBounds.Height + hig) / 2;
                            g.DrawImage(this.Images.ElementAt(_selectedIndex), new Rectangle(x, y, wid, hig));
                        }
                    }
                }
                else
                {
                    //CellFunctions.DrawPlainBackground(this, _enabled, cellBounds, g, rowIndex, Selected, _parent.GridColor);
                    //this.Style.SelectionBackColor = CellFunctions.BackColor(this, this.RowIndex);
                    cellStyle.SelectionBackColor = CellFunctions.BackColor(this);
                    //this.Style.BackColor = CellFunctions.BackColor(this,this.RowIndex);
                    cellStyle.BackColor = CellFunctions.BackColor(this);
                    //paintParts = DataGridViewPaintParts.ContentForeground;
                    paintParts = DataGridViewPaintParts.All;//.Background | DataGridViewPaintParts.Border | DataGridViewPaintParts.SelectionBackground | DataGridViewPaintParts.Focus|DataGridViewPaintParts.ContentForeground;
                    base.Paint(g, clipBounds, cellBounds, rowIndex, elementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);
                }
            }
            else
            {
                //CellFunctions.DrawPlainBackground(this, this.Enabled, cellBounds, g, rowIndex, this.Selected, Color.Transparent);
            }
        }
示例#11
0
 private static void addIdsToSensorFinal()
 {
     foreach (Sensor sen in PublicParameters.myNetwork)
     {
         sen.inCell = -1;
     }
     foreach (CellGroup cluster in PublicParameters.networkCells)
     {
         foreach (Sensor sensor in cluster.getClusterNodes())
         {
             sensor.inCell = cluster.getID();
             sensor.TuftNodeTable.isEncapsulated = true;
             sensor.TuftNodeTable.myCellHeader   = cluster.CellTable.CellHeader;
             sensor.TuftNodeTable.CellNumber     = cluster.getID();
         }
     }
     CellFunctions.FillOutsideSensnors();
 }
 public void OnPaint(DataGridViewCellPaintingEventArgs e)
 {
     if (_enabled && _visible)
     {
         Point pt = this.DataGridView.PointToClient(Control.MousePosition);
         if (e.CellBounds.Contains(pt) && _visible && _enabled)
         {
             CellFunctions.DrawPlainBackground(this, this.Enabled, e.CellBounds, e.Graphics, e.RowIndex, true, this.DataGridView.GridColor);
             //_refreshTimer.Start();
         }
         else
         {
             CellFunctions.DrawPlainBackground(this, this.Enabled, e.CellBounds, e.Graphics, e.RowIndex, false, this.DataGridView.GridColor);
             //_refreshTimer.Stop();
         }
         PaintCell(e.CellBounds, e.Graphics);
         e.Handled = true;
     }
 }
        public void OnPaint(DataGridViewCellPaintingEventArgs e)
        {
            if (_columnTextAlignMode == TextAlignModes.Center)
            {
                Graphics g = e.Graphics;

                Point        pt      = Control.MousePosition;
                DataGridView _parent = base.DataGridView;
                if (_parent == null)
                {
                    return;
                }

                pt = _parent.PointToClient(pt);
                Brush textColor;

                if (e.CellBounds.Contains(pt))
                {
                    textColor = CellFunctions.DrawHeaderBack(e.CellBounds, g, _parent.GridColor, true);
                }
                else
                {
                    textColor = CellFunctions.DrawHeaderBack(e.CellBounds, g, Color.WhiteSmoke, this.Selected);
                }

                //Brush textColor = CellFunctions.DrawHeaderBack(e.CellBounds,g, _parent.GridColor, this.Selected);
                pt = CellFunctions.TextCenterInRact(e.CellBounds, g, _parent.Font, base.HeaderText);
                g.DrawString(base.HeaderText as String, _parent.Font, textColor, pt.X, pt.Y + 2);

                /*
                 * g.FillPath(Brushes.Gainsboro, new GraphicsPath(
                 *  new PointF[]{
                 *      new PointF(e.CellBounds.Right-10, e.CellBounds.Top+4),
                 *      new PointF(e.CellBounds.Right-10, e.CellBounds.Bottom -4),
                 *      new PointF(e.CellBounds.Right-3, (e.CellBounds.Top + e.CellBounds.Bottom)/2)},
                 *  new byte[]{
                 *      (byte)PathPointType.Start,(byte)PathPointType.Line,(byte)PathPointType.Line}, FillMode.Winding));
                 */
                e.Handled = true;
            }
        }
        protected override void Paint(System.Drawing.Graphics g, System.Drawing.Rectangle clipBounds, System.Drawing.Rectangle cellBounds, int rowIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts)
        {
            if (_visible)
            {
                if (_enabled == false)
                {
                    g.FillRectangle(new SolidBrush(Color.WhiteSmoke), cellBounds);
                    //g.DrawRectangle(new Pen(Color.Gray, 0.5f), cellBounds);
                    //int textY = CellFunctions.TextCenterYInRact(cellBounds, g, _font);// cellBounds.Y + (int)((cellBounds.Height - textSize.Height) / 2.0);
                    Point textPos = CellFunctions.TextCenterInRact(cellBounds, g, _font, this.Text);
                    g.DrawString(Text, _font, _fontColor, textPos.X, textPos.Y);
                    g.DrawLine(new Pen(_parent.GridColor, 0.1f), cellBounds.X, cellBounds.Y + cellBounds.Height - 1, cellBounds.X + cellBounds.Width, cellBounds.Y + cellBounds.Height - 1);
                    g.DrawLine(new Pen(Color.FromArgb(200, 200, 200), 0.1f), cellBounds.X + cellBounds.Width - 1, cellBounds.Y, cellBounds.X + cellBounds.Width - 1, cellBounds.Y + cellBounds.Height - 1);
                }
                else
                {
                    Brush textColor = CellFunctions.DrawLensBack(this, cellBounds, g, _parent.GridColor, this.Selected, _enabled);
                    Point pt        = CellFunctions.TextCenterInRact(cellBounds, g, _parent.Font, this.Text);
                    g.DrawString(this.Text as String, _parent.Font, textColor, pt.X, pt.Y);
                }
            }
            else
            {
                CellFunctions.DrawPlainBackground(this, Enabled, cellBounds, g, rowIndex, Selected, DataGridView.GridColor);
            }
            paintParts = DataGridViewPaintParts.None;

            base.Paint(g, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, paintParts);

            /*
             * g.FillPath(Brushes.Gainsboro, new GraphicsPath(
             *  new PointF[]{
             *      new PointF(e.CellBounds.Right-10, e.CellBounds.Top+4),
             *      new PointF(e.CellBounds.Right-10, e.CellBounds.Bottom -4),
             *      new PointF(e.CellBounds.Right-3, (e.CellBounds.Top + e.CellBounds.Bottom)/2)},
             *  new byte[]{
             *      (byte)PathPointType.Start,(byte)PathPointType.Line,(byte)PathPointType.Line}, FillMode.Winding));
             */
            //e.Handled = true;
        }
示例#15
0
文件: Tree.xaml.cs 项目: howbani/Tuft
        public static void changeTree(int nearClusterID)
        {
            if (nearClusterID != rootClusterID)
            {
                // PublicParamerters.currentNetworkTree.clusterTree.Clear();
                // The near cluster will be come the new root
                CellGroup oldRoot = CellGroup.getClusterWithID(rootClusterID);
                CellGroup newRoot = CellGroup.getClusterWithID(nearClusterID);
                // oldRoot.clusterHeader.headerSensor.ClusterHeader.SinkAgent = null;
                //Edit the old root cluster's children & parent
                oldRoot.parentCluster = newRoot;
                oldRoot.childrenClusters.Remove(newRoot);
                //Edit the new root cluster's children & parent
                newRoot.parentCluster = null;
                newRoot.childrenClusters.Add(oldRoot);
                rootCluster            = newRoot;
                rootClusterID          = newRoot.getID();
                MobileModel.rootTreeID = rootClusterID;
                changeRootChildren();
                //Here we need to send to all the new headers the new parametrs in it
                // oldRoot.clusterHeader.headerSensor.CellHeader.hasSinkPosition = false;
                // oldRoot.clusterHeader.headerSensor.CellHeader.isRootHeader = false;
                // oldRoot.clusterHeader.headerSensor.CellHeader.ClearBuffer();

                oldRoot.CellTable.CellHeader.TuftNodeTable.CellHeaderTable.hasSinkPosition = false;
                oldRoot.CellTable.CellHeader.TuftNodeTable.CellHeaderTable.isRootHeader    = false;
                oldRoot.CellTable.CellHeader.ClearCellHeaderBuffer();

                newRoot.CellTable.CellHeader.TuftNodeTable.CellHeaderTable.hasSinkPosition = false;
                newRoot.CellTable.CellHeader.TuftNodeTable.CellHeaderTable.SinkAgent       = null;
                newRoot.CellTable.CellHeader.TuftNodeTable.CellHeaderTable.isRootHeader    = true;
                // newRoot.CellTable.CellHeader.GenerateTreeChange(oldRoot.CellTable.CellHeader);

                CellFunctions.ChangeTreeLevels();
            }
        }
示例#16
0
 public void PercentAndFraction(int num, int denom, string result)
 {
     Assert.Equal(result, CellFunctions.PercentAndFraction(num, denom));
 }
        void PaintCell(Rectangle initCellBounds, Graphics g)
        {
            System.Drawing.Drawing2D.GraphicsContainer con = g.BeginContainer();
            Rectangle cellBounds = initCellBounds;

            //Rectangle drawRect = initCellBounds;
            #region test

            /*
             * if (ColSpan > 1)
             * {
             *  cellBounds = new Rectangle(cellBounds.X, cellBounds.Y, 0, cellBounds.Height);
             *  cellBounds.Width = _parent.GetColumnSize(this.ColumnIndex, ColSpan);
             *
             * }
             * if (RowSpan > 1)
             * {
             *  int firstRow = RowIndex;
             *  int lastRow = RowIndex + RowSpan-1;
             *  int minus = 0;
             *  if (RowIndex < _parent.FirstDisplayedCell.RowIndex)
             *  {
             *      firstRow = _parent.FirstDisplayedCell.RowIndex;
             *      minus = _parent.GetRowsSize(RowIndex, firstRow - RowIndex);// RowIndex - _parent.FirstDisplayedCell.RowIndex;
             *  }
             *  if (lastRow > (_parent.FirstDisplayedCell.RowIndex + _parent.DisplayedRowCount(true)))
             *  {
             *      lastRow = (_parent.FirstDisplayedCell.RowIndex + _parent.DisplayedRowCount(true))-1;
             *  }
             *  Rectangle firstRect = _parent.GetCellDisplayRectangle(this.ColumnIndex, firstRow, true);
             *  Rectangle lastRect = _parent.GetCellDisplayRectangle(this.ColumnIndex, lastRow, true);
             *  drawRect = new Rectangle(firstRect.X, firstRect.Y, firstRect.Width, lastRect.Y - firstRect.Y + lastRect.Height);
             *
             *  cellBounds = new Rectangle(drawRect.X, drawRect.Y-minus, drawRect.Width, _parent.GetRowsSize(RowIndex, RowSpan));
             *
             * }
             *
             * if (ColSpan > 1 || RowSpan > 1)
             * {
             *  CellFunctions.DrawPlainBackground(this, _enabled, drawRect, g, this.RowIndex, false, _parent.GridColor);
             *
             *
             * }
             * else
             * {
             *  CellFunctions.DrawPlainBackground(this, _enabled, drawRect, g, this.RowIndex, this.Selected, _parent.GridColor);
             * }
             */
            #endregion

            int textY      = CellFunctions.TextCenterYInRact(cellBounds, g, _font);// cellBounds.Y + (int)((cellBounds.Height - textSize.Height) / 2.0);
            int textMargin = _textMargin;

            SizeF textSize = g.MeasureString(Text, _font);
            textSize.Width -= textMargin;

            if (textY < cellBounds.Y) //|| (textY + textSize.Height) > (cellBounds.Y + cellBounds.Height))
            {
                //don't draw text..
            }
            else
            {
                if (TextViewMode == TextViewModes.ResizeForCellWid)
                {
                    CellFunctions.DrawPlainBackground(this, _enabled, cellBounds, g, this.RowIndex, this.Selected, _parent.GridColor);

                    DrawStringResizedForCellWid(textSize, cellBounds, textMargin, textY, g);
                }
                else if (TextViewMode == TextViewModes.MultiLines)
                {
                    int newHeight = (OwningRow as EasyGridRow).SetRowHeight();
                    cellBounds.Height = newHeight;
                    CellFunctions.DrawPlainBackground(this, _enabled, cellBounds, g, this.RowIndex, this.Selected, _parent.GridColor);

                    DrawStringMultiLines(cellBounds, textMargin, textY, g);
                }
                else //default.. single line..
                {
                    CellFunctions.DrawPlainBackground(this, _enabled, cellBounds, g, this.RowIndex, this.Selected, _parent.GridColor);
                    DrawSingleLine(cellBounds, g, textSize, textY, textMargin);
                    //DrawStringNormal(size, cellBounds, textMargin, textY, g);
                    //g.DrawString(Text, _font, _fontColor, cellBounds.X + 2, textY);
                }
                //int y = drawRect.Y + drawRect.Height - 1;
                //g.DrawLine(new Pen(_parent.GridColor, 0.1f), drawRect.X, y, drawRect.X + drawRect.Width, y);
            }

            g.EndContainer(con);
            g.Flush();
        }
示例#18
0
 public void PercentAndFractionByCollections()
 {
     Assert.Equal("13.7% (32/234)", CellFunctions.PercentAndFraction(new int[32], new int[234]));
 }
示例#19
0
        protected virtual void PaintCell(Graphics g, Rectangle cellBounds)
        {
            //Graphics g = Graphics.FromHdcInternal(_hdc);
            // if (_items.Count == 0) return;

            //g.DrawString(_items.RefCount.ToString(), _font, Brushes.Blue, 10, cellBounds.Y);
            //g.FillRectangle(Brushes.Red, new Rectangle(cellBounds.X + 0, cellBounds.Y + 0, 10, 10));
            Brush fontColor = CellFunctions.DrawPlainBackground(this, _enabled, cellBounds, g, this.RowIndex, this.Selected, _parent.GridColor);

            //g.FillRectangle(Brushes.Blue, new Rectangle(cellBounds.X + 0, cellBounds.Y + 0, 10, 10));

            if (_orientation == EasyGridRadioBoxOrientation.Horizontal)
            {
                //Point p = new Point(cellBounds.Left, cellBounds.Top+3);

                SizeF textSize   = TextSize(_items[0].Text, g);
                int   textOffset = (textSize.Height < _images[0].Height) ? (int)((_images[0].Height - textSize.Height)) / 2 : 0;
                int   imgOffset  = (textSize.Height >= _images[0].Height) ? (int)(textSize.Height - (_images[0].Height)) / 2 : 0;

                int textY = cellBounds.Y + (int)((cellBounds.Height - textSize.Height) / 2.0);

                int imgY = cellBounds.Y + (int)((cellBounds.Height - _images[0].Height) / 2.0);
                int top  = (textY < imgY) ? textY : imgY;
                //int bottom = (textSize.Height < _images[0].Height) ? _images[0].Height : (int) textSize.Height;
                int x = cellBounds.Left + 3;
                //Point p = new Point(cellBounds.Left, textY);
                //float height = (textSize.Height < _images[0].Height) ? _images[0].Height : (textSize.Height);


                for (int i = 0; i < _items.Count; i++)
                {
                    DrawCheckBox(g, x, top, _items[i], textOffset, imgOffset, fontColor);


                    x += _items[i].Width + 3;
                }
            }
            else if (_orientation == EasyGridRadioBoxOrientation.Vertical)
            {
                SizeF textSize   = TextSize(_items[0].Text, g);
                int   textOffset = (textSize.Height < _images[0].Height) ? (int)((_images[0].Height - textSize.Height)) / 2 : 0;
                int   imgOffset  = (textSize.Height >= _images[0].Height) ? (int)(textSize.Height - (_images[0].Height)) / 2 : 0;
                float height     = (textSize.Height < _images[0].Height) ? _images[0].Height : (textSize.Height);
                int   top        = cellBounds.Y + (int)((cellBounds.Height - height * _items.Count) / 2.0);
                int   bottom     = top + (int)(height * _items.Count);

                int y        = top;
                int x        = cellBounds.X + 3;
                int imgWidth = _images[0].Width + 2;

                for (int i = 0; i < _items.Count; i++)
                {
                    y = top + (int)(height * i);
                    DrawCheckBox(g, x, y, _items[i], textOffset, imgOffset, fontColor);
                }
            }
            else
            {
                SizeF textSize   = TextSize(_items[0].Text, g);
                int   textOffset = (textSize.Height < _images[0].Height) ? (int)((_images[0].Height - textSize.Height)) / 2 : 0;
                int   imgOffset  = (textSize.Height >= _images[0].Height) ? (int)(textSize.Height - (_images[0].Height)) / 2 : 0;
                float height     = (textSize.Height < _images[0].Height) ? _images[0].Height : (textSize.Height);

                int maxCount = (_items.Count < 2) ? _items.Count : 2;
                int top      = cellBounds.Y + (int)((cellBounds.Height - height * maxCount) / 2.0);
                int bottom   = top + (int)(height * maxCount);

                int y        = top;
                int x        = cellBounds.X + 3;
                int imgWidth = _images[0].Width + 2;

                for (int i = 0; i < _items.Count; i++)
                {
                    y = top + (int)(height * (i % 2));
                    DrawCheckBox(g, x, y, _items[i], textOffset, imgOffset, fontColor);

                    if (i % 2 == 1)
                    {
                        x += _items[i].Width + 5;
                    }
                }
            }
        }
示例#20
0
            public LUDecomposition(CellArray A)
            {
                // Use a "left-looking", dot-product, Crout/Doolittle algorithm.

                LU  = CellArray.Clone(A);
                m   = A.Count;
                n   = ColumnCount(A);
                piv = new int[m];
                for (int i = 0; i < m; i++)
                {
                    piv[i] = i;
                }
                pivsign = 1;
                Cell[] LUcolj = new Cell[m];

                // Outer loop.

                for (int j = 0; j < n; j++)
                {
                    // Make a copy of the j-th column to localize references.

                    for (int i = 0; i < m; i++)
                    {
                        LUcolj[i] = LU[i].ARRAY[j];
                    }

                    // Apply previous transformations.

                    for (int i = 0; i < m; i++)
                    {
                        // Most of the time is spent in the following dot product.

                        int  kmax = Math.Min(i, j);
                        Cell s    = this._zero;
                        for (int k = 0; k < kmax; k++)
                        {
                            s += LU[i].ARRAY[k] * LUcolj[k];
                        }

                        LU[i].ARRAY[j] = LUcolj[i] -= s;
                    }

                    // Find pivot and exchange if necessary.

                    int p = j;
                    for (int i = j + 1; i < m; i++)
                    {
                        if (CellFunctions.Abs(LUcolj[i]) > CellFunctions.Abs(LUcolj[p]))
                        {
                            p = i;
                        }
                    }
                    if (p != j)
                    {
                        for (int k = 0; k < n; k++)
                        {
                            Cell t = LU[p, k];
                            LU[p].ARRAY[k] = LU[j].ARRAY[k];
                            LU[j].ARRAY[k] = t;
                        }
                        int l = piv[p];
                        piv[p]  = piv[j];
                        piv[j]  = l;
                        pivsign = -pivsign;
                    }

                    // Compute multipliers.

                    if (j < m && LU[j].ARRAY[j] != this._zero)
                    {
                        for (int i = j + 1; i < m; i++)
                        {
                            LU[i].ARRAY[j] /= LU[j].ARRAY[j];
                        }
                    }
                }
            }
示例#21
0
 private void InformNewCellHeader()
 {
     CellFunctions.ChangeOuterCycleFormation(EncapsulatingCell);
     // Generate a Control Packet Towards the New Encapsulating Cell
     PublicParameters.SinkNode.GenerateSinkCellHeaderInfo(EncapsulatingCell.CellTable.CellHeader);
 }
示例#22
0
 private static void InformNewCell()
 {
     //   CellFunctions.ChangeCellHeader(EncapsulatingCell.CellTable.CellHeader);
     CellFunctions.ChangeOuterCycleFormation(EncapsulatingCell);
     PublicParameters.SinkNode.GenerateSinkCellHeaderInfo(EncapsulatingCell.CellTable.CellHeader);
 }
示例#23
0
        protected virtual void PaintCell(Graphics g, Rectangle cellBounds)
        {
            if (CellFunctions.MouseHitTest(_parent, cellBounds))
            {
                OpenPopup();
            }
            else
            {
                ClosePopup();
            }

            Brush fontColor = new SolidBrush(this.Style.ForeColor);// CellFunctions.DrawPlainBackground(this, _enabled, cellBounds, g, this.RowIndex, this.Selected, _parent.GridColor);

            //SizeF textSize = TextSize("Text", g);
            //_fontHeight = (int)textSize.Height;
            //String allText = "";
            Items.SetNormalFontColor(fontColor);
            String text         = "";
            int    remainedSize = cellBounds.Width;

            for (int i = 0; i < Items.Count; i++)
            {
                text += Items.Keys.ElementAt(i) + ":" + Items.Values.ElementAt(i);
                if (i != 0)
                {
                    text = "," + text;
                }
                //allText += text;
                //textSize = TextSize(text, g);
                //if (_maxWidth < textSize.Width) _maxWidth = textSize.Width;

                /*
                 * if (_enabled)
                 * {
                 *  fontColor = Items.FontColor(Items.Keys.ElementAt(i));
                 * }
                 * else
                 * {
                 *  fontColor = Brushes.DarkSlateGray;
                 * }
                 * if (textSize.Width >= remainedSize)
                 * {
                 *  float over = textSize.Width - remainedSize;
                 *  float rate = (remainedSize - over) / remainedSize;
                 *  int remained = (int)(text.Length * rate);
                 *  if (remained >= 3)
                 *  {
                 *      text = text.Substring(0, remained - 1);
                 *      text += "...";
                 *  }
                 *  else
                 *  {
                 *      text = "...";
                 *  }
                 *
                 *  g.DrawString(text, _font, fontColor, cellBounds.X+(cellBounds.Width-remainedSize), cellBounds.Y + (cellBounds.Height - textSize.Height) / 2);
                 *  break;
                 * }
                 * else
                 * {
                 *  g.DrawString(text, _font, fontColor, cellBounds.X + (cellBounds.Width - remainedSize), cellBounds.Y + (cellBounds.Height - textSize.Height) / 2);
                 * }
                 * remainedSize -= (int)textSize.Width;
                 */
            }
            base.Value = text;
        }
示例#24
0
 public override Cell Evaluate(SpoolSpace Memory)
 {
     return(CellFunctions.Power(this._Children[0].Evaluate(Memory), this._Children[1].Evaluate(Memory)));
 }