コード例 #1
0
		public GraphicStyleDecorator(BaseShape shape):base()
		{
			if (shape == null) {
				throw new ArgumentNullException("shape");
			}
			this.shape = shape;
		}
コード例 #2
0
		public GraphicStyleDecorator(BaseShape shape):base()
		{
			if (shape == null) {
				throw new ArgumentNullException("shape");
			}
			this.Shape = shape;
			Thickness = 1;
			DashStyle = DashStyle.Solid;
		}
コード例 #3
0
        public static int GetAppropriateLevel(RectangleShape extent, BaseShape shape)
        {
            RectangleShape currentBoundingBox = SquaredExtent(extent);
            RectangleShape shapeBoundingBox = shape.GetBoundingBox();

            int level = 0;

            if (shapeBoundingBox.IsWithin(currentBoundingBox))
            {
                while (true)
                {
                    level++;
                    RectangleShape upperLeft = GetUpperLeftQuater(currentBoundingBox);
                    RectangleShape uppperRight = GetUpperRightQuater(currentBoundingBox);
                    RectangleShape lowerLeft = GetLowerLeftQuater(currentBoundingBox);
                    RectangleShape lowerRight = GetLowerRightQuater(currentBoundingBox);

                    if (shapeBoundingBox.IsWithin(upperLeft))
                    {
                        currentBoundingBox = upperLeft;
                    }
                    else if (shapeBoundingBox.IsWithin(uppperRight))
                    {
                        currentBoundingBox = uppperRight;
                    }
                    else if (shapeBoundingBox.IsWithin(lowerLeft))
                    {
                        currentBoundingBox = lowerLeft;
                    }
                    else if (shapeBoundingBox.IsWithin(lowerRight))
                    {
                        currentBoundingBox = lowerRight;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            return level;
        }
コード例 #4
0
 public override void Visit(BaseShape shape)
 {
     shape.width  = Convert.ToInt32(width);
     shape.height = Convert.ToInt32(height);
 }
コード例 #5
0
        /// <summary>
        /// gets the center of the square
        /// </summary>
        /// <param name="baseShape">base shape</param>
        /// <returns>vector of square</returns>
        public Vector GetCenter(BaseShape baseShape)
        {
            var center = new Vector((Canvas.GetLeft(baseShape) + (this.Width / 2)), Canvas.GetTop(baseShape) + (this.Height / 2));

            return(center);
        }
コード例 #6
0
 /// <summary>
 /// visit the vistor with square
 /// </summary>
 /// <param name="visitor">the past visitor </param>
 /// <param name="baseShape">base shape</param>
 public void Accept(IVisitor visitor, BaseShape baseShape)
 {
     visitor.VisitSquare(baseShape);
 }
コード例 #7
0
		/// <summary>
		/// Draw the Backround <see cref="BaseStyleDecorator"></see>
		/// </summary>
		/// <param name="graphics">a valid graphics object</param>
		/// <param name="shape">the shape to fill</param>
		/// 
		protected virtual void FillShape (Graphics graphics,BaseShape shape)
		{
			if (graphics == null) {
				throw new ArgumentNullException("graphics");
			}
			if (shape == null) {
				throw new ArgumentNullException("shape");
			}
			
			shape.FillShape(graphics,
			                new SolidFillPattern(this.styleDecorator.BackColor),
			                this.styleDecorator.DisplayRectangle);
			
		}
コード例 #8
0
        private void SimplifyShapeFile()
        {
            var args          = new UpdatingTaskProgressEventArgs(TaskState.Updating);
            var currentSource = (ShapeFileFeatureSource)FeatureSource;

            if (!currentSource.IsOpen)
            {
                currentSource.Open();
            }

            var canceled      = false;
            var shapeFileType = currentSource.GetShapeFileType();
            var projectionWkt = Proj4Projection.ConvertProj4ToPrj(DisplayProjectionParameters);
            var helper        = new ShapeFileHelper(shapeFileType, outputPathFileName, currentSource.GetColumns(), projectionWkt);

            try
            {
                helper.ForEachFeatures(currentSource, (f, currentProgress, upperBound, percentage) =>
                {
                    try
                    {
                        if (f.GetWellKnownBinary() != null)
                        {
                            SimplificationType simType = SimplificationType.DouglasPeucker;
                            if (preserveTopology)
                            {
                                simType = SimplificationType.TopologyPreserving;
                            }

                            var shape                 = f.GetShape();
                            var areaShape             = shape as AreaBaseShape;
                            var lineShape             = shape as LineBaseShape;
                            BaseShape simplifiedShape = null;
                            if (areaShape != null)
                            {
                                if (selectedDistanceUnit == "Decimal Degrees")
                                {
                                    simplifiedShape = areaShape.Simplify(simplificationTolerance, simType);
                                }
                                else
                                {
                                    simplifiedShape = areaShape.Simplify(mapUnit, simplificationTolerance, (DistanceUnit)converter.ConvertBack(selectedDistanceUnit, null, null, null), simType);
                                }
                            }
                            else if (lineShape != null)
                            {
                                if (selectedDistanceUnit == "Decimal Degrees")
                                {
                                    simplifiedShape = lineShape.Simplify(simplificationTolerance, simType);
                                }
                                else
                                {
                                    simplifiedShape = lineShape.Simplify(mapUnit, simplificationTolerance, (DistanceUnit)converter.ConvertBack(selectedDistanceUnit, null, null, null), simType);
                                }
                            }
                            if (simplifiedShape != null)
                            {
                                Feature feature = new Feature(simplifiedShape);
                                foreach (var item in f.ColumnValues)
                                {
                                    feature.ColumnValues[item.Key] = item.Value;
                                }
                                helper.Add(feature);
                            }
                        }

                        args            = new UpdatingTaskProgressEventArgs(TaskState.Updating, percentage);
                        args.Current    = currentProgress;
                        args.UpperBound = upperBound;
                        OnUpdatingProgress(args);

                        canceled = args.TaskState == TaskState.Canceled;
                        return(canceled);
                    }
                    catch (Exception e)
                    {
                        GisEditor.LoggerManager.Log(LoggerLevel.Debug, e.Message, new ExceptionInfo(e));
                        return(false);
                    }
                });
            }
            finally
            {
                helper.Commit();
            }
        }
コード例 #9
0
ファイル: UCGraph.Ex.cs プロジェクト: s7loves/mypowerscgl
 private Connector getTo(BaseShape shp, int tograde) {
     Connector con = shp.Connectors[0];
     string type = shp.DeviceType;
     if (type == "05") {
         con = shp.Connectors[2];
         shp.Angle = 180;
     } else if (type == "01") {//母线
         if (shapenumdic.ContainsKey(shp)) {
             shapenumdic[shp]++;
         } else {
             shapenumdic.Add(shp, 1);
         }
         con = shp.Connectors["bottom" + shapenumdic[shp]];            
     }
     else if (type == "56" || type == "57" || type == "58")
     {
         if (shapenumdic.ContainsKey(shp))
         {
             shapenumdic[shp]++;
         }
         else
         {
             shapenumdic.Add(shp, 1);
         }
         con = shp.Connectors["bottom" + shapenumdic[shp]]; 
     
     }
     else {
         //if (OddEven.IsEven(tograde)) {
         //    con = shp.Connectors["leftconnector"];
         //} else {
         //    con = shp.Connectors["topconnector"];
         //}
     }
     return con;
 }
コード例 #10
0
ファイル: UCGraph.Ex.cs プロジェクト: s7loves/mypowerscgl
 private Connector getForm(BaseShape shp, int tograde) {
     Connector con = shp.Connectors[0];
     string type = shp.DeviceType;
     if (type == "05") {
         con = shp.Connectors[3];
     } else if (type == "01") {//母线
         if (shapenumdic.ContainsKey(shp)) {
             shapenumdic[shp]++;
         } else {
             shapenumdic.Add(shp, 1);
         }
         con = shp.Connectors["bottom" + shapenumdic[shp]];
     }
     else if (type == "56" || type == "57" || type == "58")
     {
         if (shapenumdicmx.ContainsKey(shp))
         {
             //shapenumdic[shp]++;
             shapenumdicmx[shp]++;
         }
         else
         {
             shapenumdicmx.Add(shp, 1);
         }
         int n = 5 - shapenumdicmx[shp] + 1;
         con = shp.Connectors["bottom" + n.ToString()]; 
     }
     else {
         //if (OddEven.IsEven(tograde)) {
         //    con = shp.Connectors["rightconnector"];
         //} else {
         //    con = shp.Connectors["bottomconnector"];
         //}
     }
     return con;
 }
コード例 #11
0
 /// <summary>
 /// Initialize new instance of <see cref="CubicBezierSelection"/> class.
 /// </summary>
 /// <param name="layer">The selection shapes layer.</param>
 /// <param name="shape">The selected shape.</param>
 /// <param name="style">The selection shapes style.</param>
 /// <param name="point">The selection point shape.</param>
 public CubicBezierSelection(XLayer layer, ICubicBezier shape, ShapeStyle style, BaseShape point)
 {
     _layer       = layer;
     _cubicBezier = shape;
     _style       = style;
     _point       = point;
 }
コード例 #12
0
ファイル: ChartExtend2.cs プロジェクト: hanwenzh/owchart1
        /// <summary>
        /// 初始化控件
        /// </summary>
        public void InitControl()
        {
            indicators.Clear();
            RemoveAll();
            if (minuteMode)
            {
                AllowDrag = false;
                DataSource.SetColsCapacity(20);
                IsMinute                      = true;
                AutoFillXScale                = true;
                ScrollAddSpeed                = true;
                XFieldText                    = "日期";
                CanMoveShape                  = true;
                LeftYScaleWidth               = 80;
                RightYScaleWidth              = 80;
                XScalePixel                   = 21;
                mainDiv                       = AddChartDiv(70);
                mainDiv.ShowVGrid             = true;
                MinuteLineMax                 = 0;
                MinuteLineMin                 = 0;
                mainDiv.LeftYScale.ScaleType  = YScaleType.EqualRatio;
                mainDiv.RightYScale.ScaleType = YScaleType.EqualRatio;
                mainDiv.Title                 = "分时线";
                mainDiv.XScale.Visible        = false;
                List <double> scaleSteps = new List <double>();
                scaleSteps.Add(LbCommon.GetDateNum(1970, 1, 1, 10, 0, 0, 0));
                scaleSteps.Add(LbCommon.GetDateNum(1970, 1, 1, 10, 30, 0, 0));
                scaleSteps.Add(LbCommon.GetDateNum(1970, 1, 1, 11, 0, 0, 0));
                scaleSteps.Add(LbCommon.GetDateNum(1970, 1, 1, 11, 30, 0, 0));
                scaleSteps.Add(LbCommon.GetDateNum(1970, 1, 1, 13, 30, 0, 0));
                scaleSteps.Add(LbCommon.GetDateNum(1970, 1, 1, 14, 0, 0, 0));
                scaleSteps.Add(LbCommon.GetDateNum(1970, 1, 1, 14, 30, 0, 0));
                mainDiv.XScale.ScaleSteps = scaleSteps;
                mainDiv.PaddingBottom     = 10;
                mainDiv.PaddingTop        = 10;
                LineShape lineShape = AddLine("分时线", COLUMN_CLOSE, mainDiv);
                lineShape.LineColor = Color.White;
                //成交量
                volumeDiv = AddChartDiv(30);
                volumeDiv.LeftYScale.Distance = 60;
                volumeDiv.Title = "成交量";
                volumeDiv.RightYScale.Distance = 60;
                volumeDiv.XScale.ScaleSteps    = scaleSteps;
                BarShape barShape = AddBar("成交量", COLUMN_VOLUME, volumeDiv);
                volumeDiv.XScale.Format = "hh:mm";
                barShape.Title          = "";
                barShape.BarStyle       = BarStyle.Line;
                SetBar("成交量", System.Drawing.Color.FromArgb(255, 255, 80), System.Drawing.Color.FromArgb(255, 255, 80));
                if (!blackOrWhite)
                {
                    mainDiv.ForeColor = Color.Black;
                    mainDiv.BackColor = Color.White;
                    mainDiv.LeftYScale.TipForeColor    = Color.White;
                    mainDiv.RightYScale.TipForeColor   = Color.White;
                    volumeDiv.LeftYScale.TipForeColor  = Color.White;
                    volumeDiv.RightYScale.TipForeColor = Color.White;
                    volumeDiv.XScale.TipForeColor      = Color.White;
                    volumeDiv.BackColor              = Color.White;
                    mainDiv.BorderColor              = Color.Black;
                    volumeDiv.BorderColor            = Color.Black;
                    macdDiv.BorderColor              = Color.Black;
                    mainDiv.LeftYScale.ForeColor     = Color.Black;
                    mainDiv.RightYScale.ForeColor    = Color.Black;
                    mainDiv.LeftYScale.ScaleColor    = Color.Black;
                    mainDiv.RightYScale.ScaleColor   = Color.Black;
                    volumeDiv.LeftYScale.ForeColor   = Color.Black;
                    volumeDiv.RightYScale.ForeColor  = Color.Black;
                    volumeDiv.LeftYScale.ScaleColor  = Color.Black;
                    volumeDiv.RightYScale.ScaleColor = Color.Black;
                    mainDiv.GridColor           = Color.Black;
                    volumeDiv.GridColor         = Color.Black;
                    lineShape.LineColor         = Color.Black;
                    barShape.UpColor            = Color.Black;
                    barShape.DownColor          = Color.Black;
                    volumeDiv.XScale.ForeColor  = Color.Black;
                    volumeDiv.XScale.ScaleColor = Color.Black;
                }
            }
            else
            {
                AllowDrag = true;
                DataSource.SetColsCapacity(20);
                IsMinute               = false;
                AutoFillXScale         = false;
                ScrollAddSpeed         = true;
                XFieldText             = "日期";
                CanMoveShape           = true;
                LeftYScaleWidth        = 80;
                RightYScaleWidth       = 80;
                XScalePixel            = 11;
                mainDiv                = AddChartDiv(60);
                mainDiv.Title          = "日线";
                mainDiv.XScale.Visible = false;
                mainDiv.PaddingBottom  = 10;
                mainDiv.PaddingTop     = 10;
                //mainDiv.LeftYScale.System = VScaleSystem.Logarithmic;
                mainDiv.RightYScale.ScaleType = YScaleType.Percent;
                CandleShape candleShape = AddCandle("K线", COLUMN_OPEN, COLUMN_HIGH, COLUMN_LOW, COLUMN_CLOSE, mainDiv);
                candleShape.UpColor     = Color.FromArgb(255, 80, 80);
                candleShape.DownColor   = Color.FromArgb(80, 255, 255);
                candleShape.CandleStyle = CandleStyle.CloseLine;
                candleShape.StyleField  = CTableEx.AutoField;
                candleShape.ColorField  = CTableEx.AutoField;
                dataSource.AddColumn(candleShape.StyleField);
                dataSource.AddColumn(candleShape.ColorField);
                IndicatorMovingAverage indBoll = (IndicatorMovingAverage)AddIndicator("MA");
                indBoll.SetParam(COLUMN_CLOSE, mainDiv);
                //成交量
                volumeDiv = AddChartDiv(15);
                volumeDiv.XScale.Visible        = false;
                volumeDiv.LeftYScale.Magnitude  = 10000;
                volumeDiv.RightYScale.Magnitude = 10000;
                volumeDiv.LeftYScale.Digit      = 0;
                volumeDiv.RightYScale.Digit     = 0;
                BarShape barShape = AddBar("成交量", COLUMN_VOLUME, volumeDiv);
                barShape.Title      = "成交量";
                barShape.BarStyle   = BarStyle.Bar;
                barShape.Digit      = 0;
                barShape.StyleField = CTableEx.AutoField;
                barShape.ColorField = CTableEx.AutoField;
                dataSource.AddColumn(barShape.StyleField);
                dataSource.AddColumn(barShape.ColorField);
                SetBar("成交量", System.Drawing.Color.FromArgb(255, 255, 80), System.Drawing.Color.FromArgb(125, 206, 235));
                macdDiv = AddChartDiv(25);
                macdDiv.XScale.Format = "hh:mm";
                div2Indicator         = ChangeIndicator(indicatorName);
                indicators.Add(indBoll);
                indicators.Add(div2Indicator);
                if (!blackOrWhite)
                {
                    mainDiv.LeftYScale.TipForeColor    = Color.White;
                    mainDiv.RightYScale.TipForeColor   = Color.White;
                    volumeDiv.LeftYScale.TipForeColor  = Color.White;
                    volumeDiv.RightYScale.TipForeColor = Color.White;
                    mainDiv.ForeColor                = Color.Black;
                    mainDiv.BackColor                = Color.White;
                    volumeDiv.BackColor              = Color.White;
                    macdDiv.BackColor                = Color.White;
                    mainDiv.BorderColor              = Color.Black;
                    volumeDiv.BorderColor            = Color.Black;
                    macdDiv.BorderColor              = Color.Black;
                    mainDiv.LeftYScale.ForeColor     = Color.Black;
                    mainDiv.RightYScale.ForeColor    = Color.Black;
                    mainDiv.LeftYScale.ScaleColor    = Color.Black;
                    mainDiv.RightYScale.ScaleColor   = Color.Black;
                    volumeDiv.LeftYScale.ForeColor   = Color.Black;
                    volumeDiv.RightYScale.ForeColor  = Color.Black;
                    volumeDiv.LeftYScale.ScaleColor  = Color.Black;
                    volumeDiv.RightYScale.ScaleColor = Color.Black;
                    macdDiv.LeftYScale.ForeColor     = Color.Black;
                    macdDiv.RightYScale.ForeColor    = Color.Black;
                    macdDiv.LeftYScale.ScaleColor    = Color.Black;
                    macdDiv.RightYScale.ScaleColor   = Color.Black;
                    macdDiv.XScale.ForeColor         = Color.Black;
                    macdDiv.XScale.ScaleColor        = Color.Black;
                    mainDiv.GridColor                = Color.Black;
                    volumeDiv.GridColor              = Color.Black;
                    macdDiv.GridColor                = Color.Black;

                    candleShape.UpColor   = Color.Black;
                    candleShape.DownColor = Color.Black;
                    barShape.UpColor      = Color.Black;
                    barShape.DownColor    = Color.Black;

                    candleShape.HighTitleColor  = Color.Black;
                    candleShape.LowTitleColor   = Color.Black;
                    candleShape.CloseTitleColor = Color.Black;
                    candleShape.OpenTitleColor  = Color.Black;
                    List <BaseShape> shapes = indBoll.GetShapeList();
                    for (int i = 0; i < shapes.Count; i++)
                    {
                        BaseShape bShape = shapes[i] as BaseShape;
                        if (bShape is BarShape)
                        {
                            (bShape as BarShape).DownColor = Color.Black;
                            (bShape as BarShape).UpColor   = Color.Black;
                        }
                        else if (bShape is LineShape)
                        {
                            (bShape as LineShape).LineColor = Color.Black;
                        }
                    }
                }
            }
        }
コード例 #13
0
        public static void DoTick()
        {
            if (playing)
            {

                DrawNextShape();

                if (CheckCol() == false && (_yOffset * _bs < _height * _bs - (_actualShape.GetHeight() * _bs)))
                {
                    _yOffset = _yOffset + 1;
                }
                else
                {
                    bool[,] tmp = _actualShape.GetMatrix();

                    for (int i = 0; i < _width; i++)
                    {
                        for (int j = 0; j < _height; j++)
                        {
                            if ((i < 4 && j < 4) && tmp[i, j] == true)
                            {
                                _collisionBox[i + _xOffset, j + _yOffset] = true;

                            }
                        }
                    }

                    ScoreDlg(CountScore());

                    _xOffset = 0;
                    _yOffset = 0;

                    _actualShape = _nextShape;
                    GetNextShape();

                }
            }
        }
コード例 #14
0
 public override void OnCollision(BaseShape other)
 {
     // Do nothing
 }
コード例 #15
0
        private static void GetNextShape()
        {
            Random rnd = new Random();
            int brick = rnd.Next(_brickTypeNum);

            for(int i=0; i < DateTime.Now.Second; i++)
                brick = rnd.Next(_brickTypeNum);

            _nextShape = ShapeQueue.GetShape(brick);
            DrawNextShape();
        }
コード例 #16
0
        public static void StartGame()
        {
            // Create actual shape
            Random rnd = new Random();
            int brick = rnd.Next(_brickTypeNum);
            _actualShape = ShapeQueue.GetShape(brick);

            // Init
            playing = true;
            _collisionBox = new bool[_width, _height];
            _xOffset = 0;
            _yOffset = 0;

            GetNextShape();                                 // for shape preview
            DrawShape();                                    // draw actual shape before first tick
        }
コード例 #17
0
        public static void LoadGame(string fileName)
        {
            string[] getLines = File.ReadAllLines(fileName);
            string[] tmpArr = Encoding.UTF8.GetString(Convert.FromBase64String(getLines[0])).Split(',');

            for (int i = 0; i < _height; i++)
            {
                string[] getData = tmpArr[i].Split(';');
                for (int j = 0; j < _width; j++)
                {
                    _collisionBox[j, i] = Convert.ToBoolean(getData[j]);
                }
            }

            _actualShape = ShapeQueue.GetShape(Int32.Parse(getLines[1]));
            _xOffset = Int32.Parse(getLines[2]);
            _yOffset = Int32.Parse(getLines[3]);
        }
コード例 #18
0
    // Update is called once per frame
    void Update()
    {
        if (_needRestart)
        {
            if (Input.GetKeyDown(KeyCode.R))
            {
                InitialMap();
                _currentShape = null;
                _needRestart  = false;
            }
            else
            {
                return;
            }
        }

        if (_currentShape == null)
        {
            _currentDownList.Clear();
            _currentShape       = _nextOnesList[0];
            _currentDownColor   = _currentShape.ShapeColor;
            _currentDownList    = _currentShape.GetMapDownSquareListByOrigin(_currentShape.StartOffSet);
            _currentShapeOrigin = _currentShape.StartOffSet;

            //产生一个新的图形来补充到接下来的图形列表当中
            _nextOnesList.RemoveAt(0);
            BaseShape bs = ShapeManager.Instance.GetNextShape();
            bs.ResetStartShapeAndColor();
            _nextOnesList.Add(bs);

            //刷新接下来图形的显示界面
            //将所有的接下来形状显示区域刷新为黑色
            for (int i = 0; i < _nextOnesSquareList.Count; i++)
            {
                _nextOnesSquareList[i].GetComponent <Renderer>().material.color = Color.black;
            }
            //将每一个接下来图形显示出来
            for (int index = 0; index < 4; index++)
            {
                List <Vector2> shapeList = _nextOnesList[index].GetMapDownSquareListByOrigin(Vector2.zero);
                for (int i = 0; i < shapeList.Count; i++)
                {
                    GetNextSquareByIndex(index, (int)shapeList[i].x, (int)shapeList[i].y).GetComponent <Renderer>().material.color = _nextOnesList[index].ShapeColor;
                }
            }


            for (int i = 0; i < _currentDownList.Count; i++)
            {
                if ((int)_currentDownList[i].x >= 0)
                {
                    if (CheckValidByIndex((int)_currentDownList[i].x, (int)_currentDownList[i].y))
                    {
                        GetSquareByIndex((int)_currentDownList[i].x, (int)_currentDownList[i].y).SetActive(true);
                        GetSquareByIndex((int)_currentDownList[i].x, (int)_currentDownList[i].y).GetComponent <Renderer>().material.color = _currentDownColor;
                    }
                    else
                    {
                        Debug.Log("Game Over");
                        UIManager.Instance.GameMessageText.text = "Game Over";
                        _needRestart = true;
                        return;
                    }
                }
            }

            _fallDownTimeAccumulation = 0f;
        }
        else
        {
            _fallDownTimeAccumulation += Time.deltaTime;
            if (_fallDownTimeAccumulation > _fallDownTimeLimit)
            {
                _fallDownTimeAccumulation -= _fallDownTimeLimit;
                //检查碰撞
                if (!CheckDownMove())
                {
                    //将已落下的方块稳定下来,重新生成另外一个方块
                    for (int i = 0; i < _currentDownList.Count; i++)
                    {
                        if ((int)_currentDownList [i].x >= 0)
                        {
                            _stableMatrix [(int)_currentDownList [i].x, (int)_currentDownList [i].y] = true;
                        }
                    }

                    //重置参数
                    _fallDownTimeAccumulation = 0f;
                    _currentShape             = null;

                    //消除填满的格子
                    //检查已经填满的行
                    _fullRowIndexList.Clear();
                    for (int i = MAP_ROW_COUNT - 1; i >= 0; i--)
                    {
                        bool isFull = true;
                        for (int j = 0; j < MAP_COL_COUNT; j++)
                        {
                            if (!_stableMatrix[i, j])
                            {
                                isFull = false;
                                break;
                            }
                        }
                        if (isFull)
                        {
                            //消除满行
                            for (int j = 0; j < MAP_COL_COUNT; j++)
                            {
                                _stableMatrix [i, j] = false;
//                                Sequence sequence = DOTween.Sequence();
//                                sequence.AppendCallback(()=>{
//                                    GetSquareByIndex (i, j).transform.DOScale(0, 1.3f);
//                                });
//                                sequence.AppendInterval(1.3f);
//                                sequence.AppendCallback(()=>{
//                                    GetSquareByIndex (i, j).transform.localScale = Vector3.one;
//                                });
//                                sequence.Play();
                                GetSquareByIndex(i, j).SetActive(false);
                            }
                            _fullRowIndexList.Add(i);
                        }
                    }

                    //如果有满行,执行清除动作
                    if (_fullRowIndexList.Count > 0)
                    {
                        //找到当前棋盘的山顶
                        int summit;
                        for (summit = 0; summit < MAP_ROW_COUNT; summit++)
                        {
                            bool isSummit = false;
                            for (int j = 0; j < MAP_COL_COUNT; j++)
                            {
                                if (_stableMatrix [summit, j])
                                {
                                    isSummit = true;
                                    break;
                                }
                            }
                            if (isSummit)
                            {
                                break;
                            }
                        }

                        int fullRowIndex = 0;
                        for (int row = MAP_ROW_COUNT - 1; row >= summit; row--)
                        {
                            while (fullRowIndex < _fullRowIndexList.Count && row == _fullRowIndexList[fullRowIndex])
                            {
                                row--;
                                fullRowIndex++;
                            }
                            if (fullRowIndex > 0)
                            {
                                for (int col = 0; col < MAP_COL_COUNT; col++)
                                {
                                    _stableMatrix[row + fullRowIndex, col] = _stableMatrix[row, col];
                                    GetSquareByIndex(row + fullRowIndex, col).SetActive(_stableMatrix [row + fullRowIndex, col]);
                                    if (_stableMatrix[row, col])
                                    {
                                        GetSquareByIndex(row + fullRowIndex, col).GetComponent <Renderer>().material.color = GetSquareByIndex(row, col).GetComponent <Renderer>().material.color;
                                    }
                                    //将当前行清空
                                    _stableMatrix[row, col] = false;
                                    GetSquareByIndex(row, col).SetActive(false);
                                }
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < _currentDownList.Count; i++)
                    {
                        //隐藏之前的位置
                        if ((int)_currentDownList[i].x >= 0)
                        {
                            GetSquareByIndex((int)_currentDownList[i].x, (int)_currentDownList[i].y).SetActive(false);
                        }
                        //下落一格子
                        _currentDownList [i] = new Vector2(_currentDownList[i].x + 1, _currentDownList[i].y);
                    }
                    _currentShapeOrigin += new Vector2(1, 0);

                    //重新显示下降的方块
                    for (int i = 0; i < _currentDownList.Count; i++)
                    {
                        if ((int)_currentDownList[i].x >= 0)
                        {
                            GetSquareByIndex((int)_currentDownList[i].x, (int)_currentDownList[i].y).SetActive(true);
                            GetSquareByIndex((int)_currentDownList[i].x, (int)_currentDownList[i].y).GetComponent <Renderer>().material.color = _currentDownColor;
                        }
                    }
                }
            }
        }

        //玩家输入
        //向左移动
        if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A))
        {
            MoveLeft();
            _leftTimeAccumulation = 0f;
        }
        if (Input.GetKey(KeyCode.LeftArrow) || Input.GetKey(KeyCode.A))
        {
            _leftTimeAccumulation += Time.deltaTime;
            if (_leftTimeAccumulation > _horizonTimeLimit)
            {
                _leftTimeAccumulation -= _horizonTimeLimit;
                MoveLeft();
            }
        }

        //向右移动
        if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D))
        {
            MoveRight();
            _rightTimeAccumulation = 0f;
        }
        if (Input.GetKey(KeyCode.RightArrow) || Input.GetKey(KeyCode.D))
        {
            _rightTimeAccumulation += Time.deltaTime;
            if (_rightTimeAccumulation > _horizonTimeLimit)
            {
                _rightTimeAccumulation -= _horizonTimeLimit;
                MoveRight();
            }
        }

        //加速下降
        if (Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.DownArrow))
        {
            //找到最后的位置,直接落下
            int downCount = 0;
            while (CheckDownMove(downCount))
            {
                downCount++;
            }
            downCount--;

            if (downCount > 0)
            {
                for (int i = 0; i < _currentDownList.Count; i++)
                {
                    if ((int)_currentDownList [i].x >= 0)
                    {
                        GetSquareByIndex((int)_currentDownList [i].x, (int)_currentDownList [i].y).SetActive(false);
                    }
                    _currentDownList [i] = new Vector2(_currentDownList [i].x + downCount, _currentDownList [i].y);
                }
                //重新显示方块
                for (int i = 0; i < _currentDownList.Count; i++)
                {
                    if ((int)_currentDownList[i].x >= 0)
                    {
                        GetSquareByIndex((int)_currentDownList[i].x, (int)_currentDownList[i].y).SetActive(true);
                        GetSquareByIndex((int)_currentDownList[i].x, (int)_currentDownList[i].y).GetComponent <Renderer>().material.color = _currentDownColor;
                    }
                }
                _currentShapeOrigin      += new Vector2(downCount, 0);
                _fallDownTimeAccumulation = 0f;
            }
        }

        //变形
        if (Input.GetKeyDown(KeyCode.W) || Input.GetKeyDown(KeyCode.UpArrow))
        {
            //按照一定形状将下落的方块变形,如果不能变形,则没有效果
//            _currentShape.GetSwiftShapeMatrix();
            List <Vector2> tempList     = _currentShape.GetSwiftDownSquareListByOrigin(_currentShapeOrigin);
            bool           isValidSwift = true;
            for (int i = 0; i < tempList.Count; i++)
            {
                if (!CheckValidByIndex((int)tempList[i].x, (int)tempList[i].y))
                {
                    isValidSwift = false;
                    break;
                }
            }
            if (isValidSwift)
            {
                //隐藏原来的
                for (int i = 0; i < _currentDownList.Count; i++)
                {
                    if ((int)_currentDownList [i].x >= 0)
                    {
                        GetSquareByIndex((int)_currentDownList [i].x, (int)_currentDownList [i].y).SetActive(false);
                    }
                }

                _currentShape.Swift();
                _currentDownList = _currentShape.GetMapDownSquareListByOrigin(_currentShapeOrigin);
                //显示变形之后的下落方块
                for (int i = 0; i < _currentDownList.Count; i++)
                {
                    if ((int)_currentDownList [i].x >= 0)
                    {
                        GetSquareByIndex((int)_currentDownList [i].x, (int)_currentDownList [i].y).SetActive(true);
                        GetSquareByIndex((int)_currentDownList[i].x, (int)_currentDownList[i].y).GetComponent <Renderer>().material.color = _currentDownColor;
                    }
                }
            }
        }
    }
コード例 #19
0
 public void Visit(BaseShape shape)
 {
     WriteToFile(shape);
 }
コード例 #20
0
ファイル: OrchViewer.cs プロジェクト: riha/btswebdoc
        private static OrchShape CreateOrchShape(BaseShape bc)
        {
            OrchShape os = null;

            var data = bc.Relationship as XLANGView.TrkMetadata;

            if (data != null)
            {
                os = new OrchShape { Text = bc.Text, Id = data.ShapeID };

                var selRect = new Rectangle(
                    bc.DesignSurfaceClientLocation.X - 5,
                    bc.DesignSurfaceClientLocation.Y - 7,
                    bc.Width,
                    bc.Height);

                os.SelectionArea = new SelectionArea(
                    selRect.X,
                    selRect.Y,
                    selRect.Width,
                    selRect.Height);

                switch (bc.GetType().ToString())
                {
                    case "Microsoft.VisualStudio.EFT.SendShape": os.ShapeType = ShapeType.SendShape; break;
                    case "Microsoft.VisualStudio.EFT.ReceiveShape": os.ShapeType = ShapeType.ReceiveShape; break;
                    case "Microsoft.VisualStudio.EFT.VariableAssignmentShape": os.ShapeType = ShapeType.VariableAssignment; break;
                    case "Microsoft.VisualStudio.EFT.MessageAssignmentShape": os.ShapeType = ShapeType.MessageAssignment; break;
                }
            }

            return os;
        }
 public void AddInputShape(BaseShape shape)
 {
     AddInputShapeCore(shape);
 }
コード例 #22
0
        public static ulong GetLocation(RectangleShape extent, BaseShape shape, int level)
        {
            RectangleShape extentBoundingBox = SquaredExtent(extent);
            RectangleShape shapeBoundingBox = shape.GetBoundingBox();

            ulong location = 1;

            if (shapeBoundingBox.IsWithin(extentBoundingBox))
            {
                int currentlevel = 1;

                while (currentlevel < level)
                {
                    RectangleShape upperLeft = GetUpperLeftQuater(extentBoundingBox);
                    RectangleShape uppperRight = GetUpperRightQuater(extentBoundingBox);
                    RectangleShape lowerLeft = GetLowerLeftQuater(extentBoundingBox);
                    RectangleShape lowerRight = GetLowerRightQuater(extentBoundingBox);

                    if (shapeBoundingBox.IsWithin(upperLeft))
                    {
                        location = (location << 1) | 1;
                        currentlevel++;
                        extentBoundingBox = upperLeft;
                    }
                    else if (shapeBoundingBox.IsWithin(uppperRight))
                    {
                        location = (location << 2) | 1;
                        currentlevel++;
                        extentBoundingBox = uppperRight;
                    }
                    else if (shapeBoundingBox.IsWithin(lowerLeft))
                    {
                        location = (location << 3) | 1;
                        currentlevel++;
                        extentBoundingBox = lowerLeft;
                    }
                    else if (shapeBoundingBox.IsWithin(lowerRight))
                    {
                        location = (location << 4) | 1;
                        currentlevel++;
                        extentBoundingBox = lowerRight;
                    }
                    else
                    {
                        break;
                    }
                }
            }

            return location;
        }
コード例 #23
0
ファイル: DeleteHelper.cs プロジェクト: thedeveus/Core2D
        public static bool TryToDelete(ILayerContainer container, IEnumerable <PathShape> paths, BaseShape shape)
        {
            foreach (var path in paths)
            {
                foreach (var figure in path.Figures)
                {
                    if (figure.Shapes.Contains(shape))
                    {
                        figure.Shapes.Remove(shape);
                        figure.MarkAsDirty(true);

                        if (figure.Shapes.Count <= 0)
                        {
                            path.Figures.Remove(figure);
                            path.MarkAsDirty(true);

                            if (path.Figures.Count <= 0)
                            {
                                container.Shapes.Remove(path);
                            }
                        }

                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #24
0
ファイル: ChartExtend2.cs プロジェクト: hanwenzh/owchart1
        /// <summary>
        /// 添加指标公式
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public BaseIndicator ChangeIndicator(String text)
        {
            indicatorName = text;
            BaseIndicator indicator = AddIndicator(text);

            if (div2Indicator != null)
            {
                DeleteIndicator(div2Indicator);
                switch (text)
                {
                case "ASI":
                    (indicator as IndicatorAccumulationSwingIndex).SetParam(COLUMN_OPEN, COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 6, macdDiv);
                    break;

                case "ADTM":
                    (indicator as IndicatorADTM).SetParam(COLUMN_OPEN, COLUMN_HIGH, COLUMN_LOW, 23, 8, macdDiv);
                    break;

                case "ATR":
                    (indicator as IndicatorAverageTrueRange).SetParam(COLUMN_HIGH, COLUMN_LOW, 14, macdDiv);
                    break;

                case "BBI":
                    (indicator as IndicatorBullandBearIndex).SetParam(COLUMN_CLOSE, 3, 6, 12, 24, macdDiv);
                    break;

                case "BIAS":
                    (indicator as IndicatorBIAS).SetParam(COLUMN_CLOSE, 6, macdDiv);
                    break;

                case "BOLL":
                    (indicator as IndicatorBollingerBands).SetParam(COLUMN_CLOSE, 20, 2, macdDiv);
                    break;

                case "CCI":
                    (indicator as IndicatorCommodityChannelIndex).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 14, macdDiv);
                    break;

                case "CHAIKIN":
                    (indicator as IndicatorChaikinOscillator).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, COLUMN_VOLUME, 10, 20, 6, macdDiv);
                    break;

                case "DDI":
                    (indicator as IndicatorDirectionDeviationIndex).SetParam(COLUMN_HIGH, COLUMN_LOW, 13, 30, 10, 5, macdDiv);
                    break;

                case "DMA":
                    (indicator as IndicatorDifferentOfMovingAverage).SetParam(COLUMN_CLOSE, 10, 50, 10, macdDiv);
                    break;

                case "DMI":
                    (indicator as IndicatorDirectionalMovementIndex).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 14, 6, macdDiv);
                    break;

                case "DPO":
                    (indicator as IndicatorDetrendedPriceOscillator).SetParam(COLUMN_CLOSE, 20, 11, 6, macdDiv);
                    break;

                case "EMA":
                    (indicator as IndicatorExponentialMovingAverage).SetParam(COLUMN_CLOSE, 5, macdDiv);
                    break;

                case "KDJ":
                    (indicator as IndicatorStochasticOscillator).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 9, 3, 3, macdDiv);
                    break;

                case "LWR":
                    (indicator as IndicatorLWR).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 9, 3, 3, macdDiv);
                    break;

                case "MACD":
                    (indicator as IndicatorMACD).SetParam(COLUMN_CLOSE, 12, 26, 9, macdDiv);
                    break;

                case "MASS":
                    (indicator as IndicatorMassIndex).SetParam(COLUMN_HIGH, COLUMN_LOW, 25, 9, macdDiv);
                    break;

                case "MTM":
                    (indicator as IndicatorMomentumIndex).SetParam(COLUMN_CLOSE, 12, 6, macdDiv);
                    break;

                case "NVI":
                    (indicator as IndicatorNegativeVolumeIndex).SetParam(COLUMN_VOLUME, COLUMN_CLOSE, 72, macdDiv);
                    break;

                case "OBV":
                    (indicator as IndicatorOnBalanceVolume).SetParam(COLUMN_CLOSE, COLUMN_VOLUME, macdDiv);
                    break;

                case "OSC":
                    (indicator as IndicatorOscillator).SetParam(COLUMN_CLOSE, 10, 6, macdDiv);
                    break;

                case "PBX":
                    (indicator as IndicatorPBX).SetParam(COLUMN_CLOSE, 4, macdDiv);
                    break;

                case "PSY":
                    (indicator as IndicatorPsychologicalLine).SetParam(COLUMN_CLOSE, 12, macdDiv);
                    break;

                case "PVI":
                    (indicator as IndicatorPositiveVolumeIndex).SetParam(COLUMN_VOLUME, COLUMN_CLOSE, 72, macdDiv);
                    break;

                case "ROC":
                    (indicator as IndicatorRateOfChange).SetParam(COLUMN_CLOSE, 12, 6, macdDiv);
                    break;

                case "RSI":
                    (indicator as IndicatorRelativeStrengthIndex).SetParam(COLUMN_CLOSE, 6, macdDiv);
                    break;

                case "SAR":
                    (indicator as IndicatorStopAndReveres).SetParam(COLUMN_HIGH, COLUMN_LOW, 4, 2, 20, macdDiv);
                    break;

                case "SD":
                    (indicator as IndicatorStandardDeviation).SetParam(COLUMN_CLOSE, 14, 2, macdDiv);
                    break;

                case "SLOWKD":
                    (indicator as IndicatorSlowStochasticOscillator).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 9, 3, 3, 3, macdDiv);
                    break;

                case "MA":
                    (indicator as IndicatorMovingAverage).SetParam(COLUMN_CLOSE, macdDiv);
                    break;

                case "SMA":
                    (indicator as IndicatorSimpleMovingAverage).SetParam(COLUMN_CLOSE, 5, 1, macdDiv);
                    break;

                case "TRIX":
                    (indicator as IndicatorTripleExponentiallySmoothedMovingAverage).SetParam(COLUMN_CLOSE, 12, 12, macdDiv);
                    break;

                case "VR":
                    (indicator as IndicatorVolumeRatio).SetParam(COLUMN_CLOSE, COLUMN_VOLUME, 26, 6, macdDiv);
                    break;

                case "WR":
                    (indicator as IndicatorWilliamsAndRate).SetParam(COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, 10, macdDiv);
                    break;

                case "WVAD":
                    (indicator as IndicatorWVAD).SetParam(COLUMN_VOLUME, COLUMN_CLOSE, COLUMN_HIGH, COLUMN_LOW, COLUMN_OPEN, 24, 6, macdDiv);
                    break;
                }
                indicators.Remove(indicator);
                div2Indicator = indicator;
                indicators.Add(div2Indicator);
                div2Indicator.OnCalculate(0);
                RefreshGraph();
            }
            if (!blackOrWhite)
            {
                List <BaseShape> shapes = indicator.GetShapeList();
                for (int i = 0; i < shapes.Count; i++)
                {
                    BaseShape bShape = shapes[i] as BaseShape;
                    if (bShape is BarShape)
                    {
                        (bShape as BarShape).DownColor = Color.Black;
                        (bShape as BarShape).UpColor   = Color.Black;
                    }
                    else if (bShape is LineShape)
                    {
                        (bShape as LineShape).LineColor = Color.Black;
                    }
                }
            }
            return(indicator);
        }
コード例 #25
0
		public LineDecorator(BaseShape shape) : base(shape)
		{

		}
コード例 #26
0
 /// <summary>
 /// the visitor method for Triangle
 /// </summary>
 /// <param name="visitor">the past visitor</param>
 /// <param name="baseShape">base shape</param>
 public void Accept(IVisitor visitor, BaseShape baseShape)
 {
     visitor.VisitTriangle(baseShape);
 }
コード例 #27
0
 /// <summary>
 /// Visitor Function for line
 /// </summary>
 /// <param name="line">Selected Shape</param>
 public void VisitLine(BaseShape line)
 {
     MainWindow.AppWindow.RemoveShape(line);
 }
 protected abstract void AddInputShapeCore(BaseShape shape);
コード例 #29
0
 /// <summary>
 /// Visitor Function for square
 /// </summary>
 /// <param name="square">Selected Shape</param>
 public void VisitSquare(BaseShape square)
 {
     MainWindow.AppWindow.RemoveShape(square);
 }
コード例 #30
0
ファイル: DeleteHelper.cs プロジェクト: thedeveus/Core2D
        public static bool TryToDelete(ILayerContainer container, IEnumerable <GroupShape> groups, BaseShape shape)
        {
            foreach (var group in groups)
            {
                if (group.Shapes.Contains(shape))
                {
                    group.Shapes.Remove(shape);
                    group.MarkAsDirty(true);

                    if (group.Shapes.Count <= 0)
                    {
                        container.Shapes.Remove(group);
                    }

                    return(true);
                }
            }

            return(false);
        }
コード例 #31
0
 /// <summary>
 /// Visitor Function for triangle
 /// </summary>
 /// <param name="triangle">Selected Shape</param>
 public void VisitTriangle(BaseShape triangle)
 {
     MainWindow.AppWindow.RemoveShape(triangle);
 }
コード例 #32
0
        private void SimplifyAllFeatures()
        {
            UpdatingTaskProgressEventArgs args = null;

            var features = GetFeaturesFromTempFile().ToArray();
            int index    = 1;
            int count    = features.Count();

            SimplificationType simType = SimplificationType.DouglasPeucker;

            if (preserveTopology)
            {
                simType = SimplificationType.TopologyPreserving;
            }

            Collection <Feature> simplifiedFeatures = new Collection <Feature>();

            foreach (Feature feature in features)
            {
                try
                {
                    var       shape           = feature.GetShape();
                    var       areaShape       = shape as AreaBaseShape;
                    var       lineShape       = shape as LineBaseShape;
                    BaseShape simplifiedShape = null;

                    if (areaShape != null)
                    {
                        if (selectedDistanceUnit == "Decimal Degrees")
                        {
                            simplifiedShape = areaShape.Simplify(simplificationTolerance, simType);
                        }
                        else
                        {
                            simplifiedShape = areaShape.Simplify(mapUnit, simplificationTolerance, (DistanceUnit)converter.ConvertBack(selectedDistanceUnit, null, null, null), simType);
                        }
                    }
                    else if (lineShape != null)
                    {
                        if (selectedDistanceUnit == "Decimal Degrees")
                        {
                            simplifiedShape = lineShape.Simplify(simplificationTolerance, simType);
                        }
                        else
                        {
                            simplifiedShape = lineShape.Simplify(mapUnit, simplificationTolerance, (DistanceUnit)converter.ConvertBack(selectedDistanceUnit, null, null, null), simType);
                        }
                    }

                    if (simplifiedShape != null)
                    {
                        Feature newFeature = new Feature(simplifiedShape.GetWellKnownBinary(), feature.Id, feature.ColumnValues);
                        newFeature.Tag = feature.Tag;
                        simplifiedFeatures.Add(newFeature);
                    }
                }
                catch (Exception ex)
                {
                    args         = new UpdatingTaskProgressEventArgs(TaskState.Error);
                    args.Message = feature.Id;
                    args.Error   = new ExceptionInfo(ex.Message, ex.StackTrace, ex.Source);
                    GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                    OnUpdatingProgress(args);
                    continue;
                }

                var progressPercentage = index * 100 / count;
                args            = new UpdatingTaskProgressEventArgs(TaskState.Updating, progressPercentage);
                args.Current    = index;
                args.UpperBound = count;
                OnUpdatingProgress(args);
                isCanceled = args.TaskState == TaskState.Canceled;
                if (isCanceled)
                {
                    break;
                }
                index++;
            }
            if (!isCanceled)
            {
                args         = new UpdatingTaskProgressEventArgs(TaskState.Updating);
                args.Message = "Creating File";
                OnUpdatingProgress(args);

                FileExportInfo info = new FileExportInfo(simplifiedFeatures, GetColumns(), outputPathFileName, displayProjectionParameters);
                Export(info);
            }
            //args = new UpdatingProgressLongRunningTaskPluginEventArgs(LongRunningTaskState.Completed);
            //args.Message = "Finished";
            //OnUpdatingProgress(args);
        }
コード例 #33
0
 /// <summary>
 /// Visitor Function for ellipse
 /// </summary>
 /// <param name="ellipse">Selected Shape</param>
 public void VisitEllipse(BaseShape ellipse)
 {
     MainWindow.AppWindow.RemoveShape(ellipse);
 }
コード例 #34
0
 /// <summary>
 /// gets the string of the square
 /// </summary>
 /// <param name="baseShape">base shape</param>
 /// <returns>the string of square</returns>
 public string GetString(BaseShape baseShape)
 {
     return($"Rectangle {Canvas.GetLeft(baseShape)} {Canvas.GetTop(baseShape)} {Width} {Height}");
 }
コード例 #35
0
ファイル: HitTestBase.cs プロジェクト: lenkasetGitHub/Draw2D
 public abstract PointShape TryToGetPoint(BaseShape shape, Point2 target, double radius, IHitTest hitTest);
コード例 #36
0
ファイル: BaseIntersect.cs プロジェクト: zhang8153119/Nest
 /// <summary>
 /// 判断顺序,Line,Circle,Arc ,Ellipse,返回交点,不存在则交点为0,不存在判断则返回null
 /// </summary>
 /// <param name="bsOne"></param>
 /// <param name="bsTwo"></param>
 /// <returns></returns>
 protected List <PointF> intersect(BaseShape bsOne, BaseShape bsTwo)
 {
     listPoint.Clear();
     #region Line和其他线的交点,Line,Circle,Arc,Ellipse
     if ("Line".Equals(bsOne.ShapeClass) && "Line".Equals(bsTwo.ShapeClass))
     {
         lineWithLine((Line)bsOne, (Line)bsTwo);
         return(listPoint);
     }
     else if ("Line".Equals(bsOne.ShapeClass) && "Circle".Equals(bsTwo.ShapeClass))
     {
         lineWithCircle((Line)bsOne, (Circle)bsTwo);
         return(listPoint);
     }
     else if ("Line".Equals(bsOne.ShapeClass) && "Arc".Equals(bsTwo.ShapeClass))
     {
         lineWithArc((Line)bsOne, (Arc)bsTwo);
         return(listPoint);
     }
     else if ("Line".Equals(bsOne.ShapeClass) && "Ellipse".Equals(bsTwo.ShapeClass) && ((Ellipse)bsTwo).Complete)
     {
         lineWithEllipse((Line)bsOne, (Ellipse)bsTwo);
         return(listPoint);
     }
     else if ("Line".Equals(bsOne.ShapeClass) && "Ellipse".Equals(bsTwo.ShapeClass) && !((Ellipse)bsTwo).Complete)
     {
         lineWithEllipseArc((Line)bsOne, (Ellipse)bsTwo);
         return(listPoint);
     }
     #endregion
     #region Circle 和其他线的交点 ,Circle,Arc,Ellipse
     else if ("Circle".Equals(bsOne.ShapeClass) && "Circle".Equals(bsTwo.ShapeClass))
     {
         circleWithCircle((Circle)bsOne, (Circle)bsTwo);
         return(listPoint);
     }
     else if ("Circle".Equals(bsOne.ShapeClass) && "Arc".Equals(bsTwo.ShapeClass))
     {
         circleWithArc((Circle)bsOne, (Arc)bsTwo);
         return(listPoint);
     }
     else if ("Circle".Equals(bsOne.ShapeClass) && "Ellipse".Equals(bsTwo.ShapeClass) && ((Ellipse)bsTwo).Complete)
     {
         circleWithEllipse((Circle)bsOne, (Ellipse)bsTwo);
         return(listPoint);
     }
     else if ("Circle".Equals(bsOne.ShapeClass) && "Ellipse".Equals(bsTwo.ShapeClass) && !((Ellipse)bsTwo).Complete)
     {
         return(circleWithEllipseArc((Circle)bsOne, (Ellipse)bsTwo));
     }
     #endregion
     #region Arc 和其他线的交点 ,Arc,Ellipse
     else if ("Arc".Equals(bsOne.ShapeClass) && "Arc".Equals(bsTwo.ShapeClass))
     {
         arcWithArc((Arc)bsOne, (Arc)bsTwo);
         return(listPoint);
     }
     else if ("Arc".Equals(bsOne.ShapeClass) && "Ellipse".Equals(bsTwo.ShapeClass) && ((Ellipse)bsTwo).Complete)
     {
         return(arcWithEllipse((Arc)bsOne, (Ellipse)bsTwo));
     }
     else if ("Arc".Equals(bsOne.ShapeClass) && "Ellipse".Equals(bsTwo.ShapeClass) && !((Ellipse)bsTwo).Complete)
     {
         return(arcWithEllipseArc((Arc)bsOne, (Ellipse)bsTwo));
     }
     #endregion
     #region Ellipse 和其他线的交点 Ellipse
     else if ("Ellipse".Equals(bsOne.ShapeClass) && ((Ellipse)bsOne).Complete && "Ellipse".Equals(bsTwo.ShapeClass) && ((Ellipse)bsTwo).Complete)
     {
         return(ellipseWithEllipse((Ellipse)bsOne, (Ellipse)bsTwo));
     }
     else if ("Ellipse".Equals(bsOne.ShapeClass) && ((Ellipse)bsOne).Complete && "Ellipse".Equals(bsTwo.ShapeClass) && !((Ellipse)bsTwo).Complete)
     {
         return(ellipseWithEllipseArc((Ellipse)bsOne, (Ellipse)bsTwo));
     }
     #endregion
     #region Ellipse 和其他线的交点 Ellipse
     else if ("Ellipse".Equals(bsOne.ShapeClass) && !((Ellipse)bsOne).Complete && "Ellipse".Equals(bsTwo.ShapeClass) && !((Ellipse)bsTwo).Complete)
     {
         return(ellipseArcWithEllipseArc((Ellipse)bsOne, (Ellipse)bsTwo));
     }
     #endregion
     else
     {
         //不属于上述类型的相交判断时返回null值
         return(null);
     }
 }
コード例 #37
0
ファイル: HitTestBase.cs プロジェクト: lenkasetGitHub/Draw2D
 public abstract BaseShape Contains(BaseShape shape, Point2 target, double radius, IHitTest hitTest);
コード例 #38
0
        /// <inheritdoc/>
        public override void Move(BaseShape shape)
        {
            base.Move(shape);

            _selection.Move();
        }
コード例 #39
0
ファイル: HitTestBase.cs プロジェクト: lenkasetGitHub/Draw2D
 public abstract BaseShape Overlaps(BaseShape shape, Rect2 target, double radius, IHitTest hitTest);
コード例 #40
0
 protected void OnQueryAreaChanged(BaseShape queringArea)
 {
     EventHandler<QueryAreaChangedMapModelEventArgs> handler = QueryAreaChanged;
     if (handler != null) handler(this, new QueryAreaChangedMapModelEventArgs(new Feature(queringArea)));
 }
コード例 #41
0
ファイル: TextHelper.cs プロジェクト: lenkasetGitHub/Draw2D
 public override void Draw(object dc, ShapeRenderer renderer, BaseShape shape, ISelection selection, double dx, double dy)
 {
 }
コード例 #42
0
ファイル: OrchViewer.cs プロジェクト: riha/btswebdoc
        private static void GetSelectionAreas(Graphics g, BaseShape shape, OrchestrationOverviewImage orchestration)
        {
            try
            {
                foreach (BaseShape bc in shape.Shapes)
                {
                    if (bc is ReceiveShape ||
                        bc is SendShape ||
                        bc is MessageAssignmentShape ||
                        bc is VariableAssignmentShape)
                    {
                        OrchShape os = CreateOrchShape(bc);

                        if (os != null)
                        {
                            if (orchestration.ShapeMap != null)
                            {
                                orchestration.ShapeMap.Add(os);
                            }
                            //if (drawHotspots)
                            //{
                            //    DrawDebugRect(g, os.SelectionArea.GetRectangle());
                            //}
                        }
                    }

                    GetSelectionAreas(g, bc, orchestration);
                }
            }
            catch (Exception ex)
            {
                string message = ex.Message;
            }
        }
コード例 #43
0
 public override void Visit(BaseShape shape)
 {
     WriteToFile(shape);
 }
コード例 #44
0
        public static Collection<QuadCell> GetIntersectingCells(RectangleShape extent, BaseShape shape, int startLevel, int endLevel)
        {
            RectangleShape extentBoundingBox = SquaredExtent(extent);
            RectangleShape shapeBoundingBox = shape.GetBoundingBox();

            Collection<QuadCell> result = new Collection<QuadCell>();

            if (shapeBoundingBox.Intersects(extentBoundingBox))
            {
                ulong location = GetLocation(extentBoundingBox, shape, int.MaxValue);
                ulong reversedResult = Reverse(location);
                ulong temporaryValue = reversedResult;
                temporaryValue >>= 1;

                int locationLength = GetLevelsCount(temporaryValue);
                if (startLevel <= locationLength)
                {
                    int index = startLevel;
                    while (index <= endLevel)
                    {
                        ulong temporaryLocation = temporaryValue;
                        if (index <= locationLength)
                        {
                            MovePositionByIndex(ref temporaryLocation, index);
                            if (locationLength > 1)
                            {
                                result.Add(GetCellByLocation(extentBoundingBox, temporaryLocation));
                            }
                            else
                            {
                                result.Add(GetCellByLocation(extentBoundingBox, 0));
                            }
                        }
                        index++;
                    }
                }
                if (endLevel > locationLength)
                {
                    Queue<ulong> locationsToProcess = new Queue<ulong>();
                    locationsToProcess.Enqueue(location);

                    while (locationsToProcess.Count > 0)
                    {
                        ulong currentLocation = locationsToProcess.Dequeue();

                        for (int k = 1; k <= 4; k++)
                        {
                            ulong newLocation = (currentLocation << k) | 1;
                            result.Add(GetCellByLocation(extentBoundingBox, newLocation));
                            int newLocationsCount = GetLevelsCount(newLocation);
                            if (newLocationsCount < endLevel)
                            {
                                locationsToProcess.Enqueue(newLocation);
                            }
                        }
                    }
                }
            }
            //if (result.Count == 0)
            //{
            //    result.Add(GetCellByLocation(extentBoundingBox, "01"));
            //    result.Add(GetCellByLocation(extentBoundingBox, "02"));
            //    result.Add(GetCellByLocation(extentBoundingBox, "03"));
            //    result.Add(GetCellByLocation(extentBoundingBox, "04"));
            //}
            return result;
        }
コード例 #45
0
 public abstract void Find(IToolContext context, BaseShape shape);
コード例 #46
0
ファイル: Linedecorator.cs プロジェクト: kleinux/SharpDevelop
 public LineDecorator(BaseShape shape) : base(shape)
 {
 }
コード例 #47
0
ファイル: UCGraph.Ex.cs プロジェクト: s7loves/mypowerscgl
 private void createconnect(BaseShape preshape, BaseShape shape,int level) {
     int mod = level % 2;
     Connector confrom = preshape.Connectors[3];
     Connector conto = shape.Connectors[1];
     graphControl1.AddConnection(confrom, conto);
 }