Пример #1
0
        private void DoShapeStateChanged(IShape sender, ShapeState state)
        {
            switch (state)
            {
            case ShapeState.Draw:
                button_append_line.Enabled    = false;
                button_append_polygon.Enabled = false;
                button_delete.Enabled         = true;
                break;

            case ShapeState.Select:
                button_append_line.Enabled    = false;
                button_append_polygon.Enabled = false;
                button_delete.Enabled         = true;
                break;

            default:
                button_append_line.Enabled    = true;
                button_append_polygon.Enabled = true;
                button_delete.Enabled         = false;
                break;
            }

            if (OnShapeStateChanged != null)
            {
                OnShapeStateChanged(sender, state);
            }
        }
Пример #2
0
        public void Flags_On_Set_Notify_Events_Are_Raised()
        {
            var state  = new ShapeState();
            var target = new PropertyChangedObserver(state);

            state.Flags =
                ShapeStateFlags.Visible
                | ShapeStateFlags.Printable
                | ShapeStateFlags.Standalone;

            Assert.Equal(
                ShapeStateFlags.Visible
                | ShapeStateFlags.Printable
                | ShapeStateFlags.Standalone, state.Flags);
            Assert.Equal(10, target.PropertyNames.Count);

            var propertyNames = new string[]
            {
                nameof(ShapeState.Flags),
                nameof(ShapeState.Default),
                nameof(ShapeState.Visible),
                nameof(ShapeState.Printable),
                nameof(ShapeState.Locked),
                nameof(ShapeState.Connector),
                nameof(ShapeState.None),
                nameof(ShapeState.Standalone),
                nameof(ShapeState.Input),
                nameof(ShapeState.Output)
            };

            Assert.Equal(propertyNames, target.PropertyNames);
        }
Пример #3
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         State = ShapeState.Tuched;
     }
 }
Пример #4
0
 public void EndDraw()
 {
     if (State != ShapeState.FinishDraw)
     {
         State = ShapeState.FinishDraw;
     }
 }
Пример #5
0
        public void ApplyState(ShapeState st)
        {
            if (st.bytes != null)
            {
                using (var s = new MemoryStream(st.bytes))
                {
                    using (var br = new BinaryReader(s))
                    {
                        Text = br.ReadString();
                    }
                }
            }

            Matrix m = new Matrix();

            m.M11     = st.doubles[2];
            m.M12     = st.doubles[3];
            m.M21     = st.doubles[4];
            m.M22     = st.doubles[5];
            m.OffsetX = st.doubles[6];
            m.OffsetY = st.doubles[7];

            _textEnterUC.RenderTransform = new MatrixTransform(m);

            updateUserCursor();
        }
Пример #6
0
 private void OnTriggerExit(Collider other)
 {
     if (other.CompareTag("Player"))
     {
         State = ShapeState.Idle;
     }
 }
Пример #7
0
        public void ApplyState(ShapeState st)
        {
            if (st.bytes != null)
            {
                using (var s = new MemoryStream(st.bytes))
                {
                    using (var br = new BinaryReader(s))
                    {
                        Text = br.ReadString();
                    }
                }
            }

            var m = new Matrix
            {
                M11     = st.doubles[2],
                M12     = st.doubles[3],
                M21     = st.doubles[4],
                M22     = st.doubles[5],
                OffsetX = st.doubles[6],
                OffsetY = st.doubles[7]
            };

            _textEnterUC.RenderTransform = new MatrixTransform(m);

            _scene.Dispatcher.BeginInvoke(DispatcherPriority.Background,
                                          (Action)SetBounds);
        }
Пример #8
0
 public void BeginDraw()
 {
     if (State != ShapeState.Draw)
     {
         State = ShapeState.Draw;
     }
 }
Пример #9
0
 /// <inheritdoc/>
 public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
 {
     if (objectType == typeof(ShapeState))
     {
         return(ShapeState.Parse((string)reader.Value));
     }
     throw new ArgumentException("objectType");
 }
Пример #10
0
        public void Parse_ShapeStateFlags_String()
        {
            var target = ShapeState.Parse("Visible, Printable, Standalone");

            Assert.Equal(
                ShapeStateFlags.Visible
                | ShapeStateFlags.Printable
                | ShapeStateFlags.Standalone, target.Flags);
        }
Пример #11
0
        private void DoShapeStateChanged(ShapeState state)
        {
            //System.Console.Out.WriteLine("CShape.DoShapeStateChanged State = " + state);

            if (OnShapeStateChanged != null)
            {
                OnShapeStateChanged(this, mState);
            }
        }
Пример #12
0
 public void Redo()
 {
     if (State != ShapeState.Balance)
     {
         Y = _originY;
     }
     Console.WriteLine(Text + " REDO TO BALANCE");
     State = ShapeState.Balance;
 }
Пример #13
0
        public void ToString_Should_Return_Flags_String()
        {
            var target = ShapeState.Create(
                ShapeStateFlags.Visible
                | ShapeStateFlags.Printable
                | ShapeStateFlags.Standalone);

            Assert.Equal("Visible, Printable, Standalone", target.ToString());
        }
Пример #14
0
        private void syncStateEvent(ShapeState state)
        {
            if (state.topicId != _doc.TopicId)
            {
                return;
            }

            PlaySyncStateEvent(state);
        }
Пример #15
0
 public void ApplyState(ShapeState st)
 {
     line.X1 = st.doubles[0];
     line.Y1 = st.doubles[1];
     line.X2 = st.doubles[2];
     line.Y2 = st.doubles[3];
     SetMarkers();
     updateUserCursor();
 }
Пример #16
0
 /// <summary>
 /// Creates a new <see cref="LineFixedLength"/> instance.
 /// </summary>
 /// <param name="flags">The line fixed length flags.</param>
 /// <param name="startTrigger">The line start point state trigger.</param>
 /// <param name="endTrigger">The line end point state trigger.</param>
 /// <param name="length">The line fixed length.</param>
 /// <returns>he new instance of the <see cref="LineFixedLength"/> class.</returns>
 public static LineFixedLength Create(LineFixedLengthFlags flags = LineFixedLengthFlags.Disabled, ShapeState startTrigger = null, ShapeState endTrigger = null, double length = 15.0)
 {
     return(new LineFixedLength()
     {
         Flags = flags,
         StartTrigger = startTrigger ?? ShapeState.Create(ShapeStateFlags.Connector | ShapeStateFlags.Output),
         EndTrigger = endTrigger ?? ShapeState.Create(ShapeStateFlags.Connector | ShapeStateFlags.Input),
         Length = length
     });
 }
Пример #17
0
        public void Connector_Property()
        {
            var target = new ShapeState();

            target.Connector = true;
            Assert.Equal(ShapeStateFlags.Connector, target.Flags);

            target.Connector = false;
            Assert.Equal(ShapeStateFlags.Default, target.Flags);
        }
Пример #18
0
        public void Printable_Property()
        {
            var target = new ShapeState();

            target.Printable = true;
            Assert.Equal(ShapeStateFlags.Printable, target.Flags);

            target.Printable = false;
            Assert.Equal(ShapeStateFlags.Default, target.Flags);
        }
Пример #19
0
        public void Default_Property()
        {
            var target = new ShapeState();

            target.Default = true;
            Assert.Equal(ShapeStateFlags.Default, target.Flags);

            target.Default = false;
            Assert.Equal(ShapeStateFlags.Default, target.Flags);
        }
Пример #20
0
        public void Standalone_Property()
        {
            var target = new ShapeState();

            target.Standalone = true;
            Assert.Equal(ShapeStateFlags.Standalone, target.Flags);

            target.Standalone = false;
            Assert.Equal(ShapeStateFlags.Default, target.Flags);
        }
Пример #21
0
        public void Locked_Property()
        {
            var target = new ShapeState();

            target.Locked = true;
            Assert.Equal(ShapeStateFlags.Locked, target.Flags);

            target.Locked = false;
            Assert.Equal(ShapeStateFlags.Default, target.Flags);
        }
Пример #22
0
        private void DoShapeStateChanged(IShape sender, ShapeState state)
        {
            System.Console.Out.WriteLine("CShapeManager.DoShapeStateChanged State = " + state + ", ShapeIndex = " + mShapeList.IndexOf((I)mActiveShape) + ", ShapeCount = " + ShapeCount);

            DoRefreshShow(sender);

            if (OnShapeStateChanged != null)
            {
                OnShapeStateChanged(sender, state);
            }
        }
Пример #23
0
 public void LoadContent(ContentManager content)
 {
     texture   = content.Load <Texture2D>(System.IO.Path.Combine(@"Textures\Shapes", textureContentName));
     textureHL = content.Load <Texture2D>(System.IO.Path.Combine(@"Textures\Shapes", textureContentName + "HL"));
     currentMatrixDimensions = baseMatrixDimensions;
     currentMatrix           = baseMatrix.Clone() as int[][];
     baseOrigin = new Vector2(currentMatrixDimensions.X * tileSize.X / 2,
                              currentMatrixDimensions.Y * tileSize.Y / 2);
     shapeOrigin = baseOrigin;
     state       = ShapeState.Waiting;
 }
Пример #24
0
        //public void SendApplyPoint(int ownerId, int shapeId, double x, double y)
        //{
        //    if (peer == null || peer.PeerState != PeerStateValue.Connected)
        //        return;

        //    peer.OpCustom((byte)DiscussionOpCode.ApplyPointRequest,
        //                   PointMove.Write(ownerId, shapeId, x, y),
        //                   false);
        //}

        public void SendSyncState(int shapeId, ShapeState st)
        {
            if (peer == null || peer.PeerState != PeerStateValue.Connected)
            {
                return;
            }

            peer.OpCustom((byte)DiscussionOpCode.StateSyncRequest,
                          st.ToDict(),
                          true);
            Service();
        }
Пример #25
0
        private void PlaySyncStateEvent(ShapeState state)
        {
            var sh = _doc.IdToShape(state.shapeId);

            if (sh == null)
            {
                //error of initialization (not all existing shapes were loaded to local station)
                return;
            }

            sh.ApplyState(state);
        }
Пример #26
0
        public ShapeRecord(SwfStream swf, bool hasAlpha, bool isExtended, bool extendedStyles, ShapeState state)
        {
            int f0 = 0, f1 = 0, l = 0;

            mFlags = swf.ReadBitUInt(6);

            Type = ConvertType(mFlags);
            switch (Type)
            {
                case ShapeRecordType.StyleChange:
                    {
                        if (NewMoveTo)
                        {
                            int bits = (int)swf.ReadBitUInt(5);
                            MoveDeltaX = swf.ReadBitInt(bits);
                            MoveDeltaY = swf.ReadBitInt(bits);
                        }
                        if (NewFillStyle0) f0 = ((int)swf.ReadBitUInt(state.FillBits));
                        if (NewFillStyle1) f1 = ((int)swf.ReadBitUInt(state.FillBits));
                        if (NewLineStyle) l = ((int)swf.ReadBitUInt(state.LineBits));
                        if (NewStyles && extendedStyles)
                        {
                            state.FillStyles = new FillStyleArray(swf, hasAlpha);
                            state.LineStyles = new LineStyleArray(swf, hasAlpha, isExtended);
                            state.FillBits = (int)swf.ReadBitUInt(4);
                            state.LineBits = (int)swf.ReadBitUInt(4);
                        }
                        if (NewFillStyle0) FillStyle0 = state.GetFill(f0);
                        if (NewFillStyle1) FillStyle1 = state.GetFill(f1);
                        if (NewLineStyle) LineStyle = state.GetLine(l);
                    }
                    break;
                case ShapeRecordType.StraightEdge:
                    {
                        int bits = 2 + (int)(mFlags & 0x0F);
                        bool general = swf.ReadBit();
                        bool vert = general || swf.ReadBit();
                        DrawDeltaX = (general || !vert) ? swf.ReadBitInt(bits) : 0;
                        DrawDeltaY = (general ||  vert) ? swf.ReadBitInt(bits) : 0;
                    }
                    break;
                case ShapeRecordType.CurvedEdge:
                    {
                        int bits = 2 + (int)(mFlags & 0x0F);
                        DrawControlX = swf.ReadBitInt(bits);
                        DrawControlY = swf.ReadBitInt(bits);
                        DrawDeltaX = swf.ReadBitInt(bits);
                        DrawDeltaY = swf.ReadBitInt(bits);
                    }
                    break;
            }
        }
Пример #27
0
 public void Down(double delta)
 {
     if (State == ShapeState.Down)
     {
         Console.WriteLine(Text + " CURRENT STATUS: DOWN");
     }
     if (State == ShapeState.Balance)
     {
         Console.WriteLine(Text + " CURRENT STATUS: BALANCE");
         _originY = Y;
         State    = ShapeState.Down;
         Y       += delta;
     }
 }
Пример #28
0
        public void HandleBadgeCreated(int argPointId,
                                       LitePeer peer,
                                       OperationRequest operationRequest,
                                       SendParameters sendParameters)
        {
            var ctx = new DiscCtx(Discussions.ConfigManager.ConnStr);
            var ap  = ctx.ArgPoint.FirstOrDefault(ap0 => ap0.Id == argPointId);

            if (ap == null)
            {
                throw new NotSupportedException("cannot find badge in db!");
            }

            var badgeSh = new ServerBaseVdShape(_doc.BadgeIdGen.NextId(), ap.Person.Id, VdShapeType.Badge, argPointId);

            _doc.AddShape(badgeSh);
            _topology.CreateBadge(badgeSh.Id());

            //get position
            double x;
            double y;

            GetBadgeSmartLocation(ap.Person.Id, out x, out y);

            //set initial badge state
            var st = new ShapeState(VdShapeType.Badge,
                                    ap.Person.Id,
                                    badgeSh.Id(),
                                    null,
                                    null,
                                    new double[] { x, y },
                                    _topicId);

            badgeSh.ApplyState(st);

            var badgeCreateEv = CreateShape.Write(ap.Person.Id, badgeSh.Id(),
                                                  VdShapeType.Badge,
                                                  st.doubles[0], st.doubles[1], false,
                                                  argPointId, _topicId);

            //include self, badge is created in private board, and if our public board is open, we want to play new badge
            _room.Broadcast(peer,
                            badgeCreateEv,
                            sendParameters,
                            (byte)DiscussionEventCode.CreateShapeEvent,
                            BroadcastTo.RoomAll);

            _pendingChanges = true;
        }
Пример #29
0
        public ShapeState GetState(int topicId)
        {
            var res = new ShapeState(ShapeCode(),
                                     InitialOwner(),
                                     Id(),
                                     null,
                                     new int [] { _captions.GetTextId(), _captions.GetFreeDrawId() },
                                     new double[] { _dx, _dy, _captions.textX, _captions.textY,
                                                    _captions.freeDrawX, _captions.freeDrawY },
                                     topicId);

            _dx = 0;
            _dy = 0;
            return(res);
        }
Пример #30
0
        public void ApplyState(ShapeState st)
        {
            _bounds.X      = st.doubles[0];
            _bounds.Y      = st.doubles[1];
            _bounds.Width  = st.doubles[2];
            _bounds.Height = st.doubles[3];

            if (st.bytes != null)
            {
                var s = new MemoryStream();
                s.Write(st.bytes, 0, st.bytes.Length);
                s.Position = 0;
                _strokes   = new System.Windows.Ink.StrokeCollection(s);
                extractGeomtry(_strokes, _bounds);
            }

            SetBounds();
            SetMarkers();
        }
Пример #31
0
        public void ApplyState(ShapeState st)
        {
            //bind caption shapes if not already bound
            if (st.ints[0] != -1 && _captions.text == null)
            {
                _captions.text = (VdText)_doc.IdToShape(st.ints[0]);
            }

            if (st.ints[1] != -1 && _captions.FreeDraw == null)
            {
                _captions.FreeDraw = (VdFreeForm)_doc.IdToShape(st.ints[1]);
            }

            //update relative caption positions
            _captions.textX     = st.doubles[0];
            _captions.textY     = st.doubles[1];
            _captions.freeDrawX = st.doubles[2];
            _captions.freeDrawY = st.doubles[3];
        }
Пример #32
0
        protected override void OnClick(EventArgs e)
        {
            base.OnClick(e);

            if (dragMethod == DragMethod.None)
            {
                switch (ShapeState)
                {
                    case ShapeState.Normal:
                        ShapeState = ShapeState.Selected;
                        //OnSelected();
                        break;
                    case ShapeState.Selected:
                        ShapeState = ShapeState.Normal;
                        break;
                    default:
                        break;
                }
            }
        }
Пример #33
0
 /// <summary>
 /// 初始化
 /// </summary>1
 /// <param name="画布源"></param>
 /// <param name="颜色"></param>
 /// <param name="背景色"></param>
 /// <param name="框架尺寸"></param>
 /// <param name="方块尺寸"></param>
 public void InitRussian(Graphics graSrc, Color shapeCol, Color backCol,Rectangle framRec, int squareSize)
 {
     // 画步
     this.graSrc = graSrc;
     // 颜色
     this.shapeColor = shapeCol;
     this.backColor = backCol;
     // 方块尺寸
     this.squareSize = squareSize;
     // 框架尺寸
     this.xLength = framRec.Width;
     this.yLength = framRec.Height;
     // 两轴方块个数
     this.xCount = framRec.Width / this.squareSize;
     this.yCount = framRec.Height / this.squareSize;
     // 初始步数
     this.xStep = this.xCount / 2;
     this.yStep = 0;
     // 初始位置
     this.xPosition = squareSize * this.xStep;
     this.yPosition = squareSize * (yStep - 1);
     // 随机获取方块状态
     this.shapeState = GetShpaeState();
     heapArr = new int[xCount + 1, yCount + 1];
 }
Пример #34
0
        public ShapeState GetShpaeState()
        {
            ShapeState shapeState;
            Random rd = new Random();
            int randIndex = rd.Next(1, 3);

            if (randIndex == 1)
            {
                shapeState = ShapeState.Up;
            }
            else
            {
                shapeState = ShapeState.Down;
            }

            return shapeState;
        }