Example #1
0
        private void checkedListBox_Click(object sender, EventArgs e)
        {
            if (checkedListBoxComplex.SelectedItem != null)
            {
                checkedListBoxComplex.SetItemChecked(checkedListBoxComplex.Items.IndexOf(checkedListBoxComplex.SelectedItem), false);
                checkedListBoxComplex.ClearSelected();
            }

            for (int i = 0; i < checkedListBox.Items.Count; i++)
            {
                if (checkedListBox.Items[i] != checkedListBox.SelectedItem)
                {
                    checkedListBox.SetItemChecked(checkedListBox.Items.IndexOf(checkedListBox.Items[i]), false);
                }
            }

            string     nameOfType     = checkedListBox.SelectedItem.ToString();
            MethodInfo factoryCreater = null;

            foreach (Type type in factoryTypesList)
            {
                if (type.ToString().Contains(nameOfType))
                {
                    factoryCreater = type.GetMethod("getInstance");
                    break;
                }
            }
            fabric = (CreateShape)factoryCreater.Invoke(null, new object[] { });
        }
 /// <summary>
 /// Occurs when this command is clicked
 /// </summary>
 public override void OnClick()
 {
     if (CreateShape.m_CurrentLayer != null)
     {
         CreateShape.UndoEdit(m_AxMapControl, CreateShape.m_CurrentLayer);
     }
 }
Example #3
0
 private void moveShape(object sender, EventArgs e)
 {
     angleVal.Hide();
     lblAngle.Hide();
     SetFlags(true, false, false);
     createShape = CreateShape.NONE;
 }
 /// <summary>
 /// Occurs when this command is clicked
 /// </summary>
 public override void OnClick()
 {
     if (CreateShape.m_CurrentLayer != null)
     {
         CreateShape.DeleteSelectedFeatures(m_AxMapControl, CreateShape.m_CurrentLayer);
         m_AxMapControl.ActiveView.Refresh();
     }
 }
Example #5
0
        private void createShapeEvent(CreateShape ev)
        {
            if (ev.topicId != TopicId)
            {
                return;
            }

            PlayCreateShape(ev.shapeType, ev.shapeId, ev.ownerId, ev.startX, ev.startY, ev.takeCursor, ev.tag);
        }
Example #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Choose a shape: square, circle, rectangle, parallelogram");
            string type = Console.ReadLine();
            Shape  obj  = CreateShape.getobject(type);

            Console.WriteLine(obj.Draw());
            Console.ReadLine();
        }
 /// <summary>
 /// Occurs when this command is clicked
 /// </summary>
 public override void OnClick()
 {
     if (m_hookHelper.FocusMap != null)
     {
         if (CreateShape.m_CurrentLayer != null)
         {
             CreateShape.StartEditing(CreateShape.m_CurrentLayer, m_strOperator);
         }
     }
 }
Example #8
0
        public void SendCreateShapeRequest(int ownerId, int shapeId, VdShapeType shapeType, bool takeCursor,
                                           double startX, double startY, int tag, int topicId)
        {
            if (peer == null || peer.PeerState != PeerStateValue.Connected)
            {
                return;
            }

            peer.OpCustom((byte)DiscussionOpCode.CreateShapeRequest,
                          CreateShape.Write(ownerId, shapeId, shapeType, startX, startY, takeCursor, tag, topicId),
                          true);
        }
Example #9
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;
        }
Example #10
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            if (checkedListBox.SelectedItem != null)
            {
                checkedListBox.SetItemChecked(checkedListBox.Items.IndexOf(checkedListBox.SelectedItem), false);
                checkedListBox.ClearSelected();
            }
            if (checkedListBoxComplex.SelectedItem != null)
            {
                checkedListBoxComplex.SetItemChecked(checkedListBoxComplex.Items.IndexOf(checkedListBoxComplex.SelectedItem), false);
                checkedListBoxComplex.ClearSelected();
            }
            string nameOfType = selectedShape.CurrentFigure.GetType().ToString();

            if (nameOfType.Contains("ComplexShape"))
            {
                ComplexShape       complexShape = (ComplexShape)selectedShape.CurrentFigure;
                CreateComplexShape factory      = new CreateComplexShape(complexShape.Shapes, complexShape.InitWidth, complexShape.InitHeight);
                fabric = factory;
            }
            else
            {
                nameOfType = nameOfType.Substring(nameOfType.LastIndexOf('.') + 1);
                MethodInfo factoryCreator = null;
                foreach (Type type in factoryTypesList)
                {
                    if (type.ToString().Contains(nameOfType))
                    {
                        factoryCreator = type.GetMethod("getInstance");
                        break;
                    }
                }
                fabric = (CreateShape)factoryCreator.Invoke(null, new object[] { });
            }

            shapeList.Remove(selectedShape);
            RedrawShapes();
            pen                    = new Pen(selectedShape.Color, selectedShape.Width);
            selectedShape          = null;
            textBoxPenWidth.Text   = pen.Width.ToString();
            buttonColor.ForeColor  = pen.Color;
            buttonEdit.Enabled     = false;
            buttonRelocate.Enabled = false;
        }
Example #11
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     fabric                 = null;
     shiftPressed           = false;
     moving                 = false;
     IsBeganCreate          = false;
     buttonRelocate.Enabled = false;
     buttonEdit.Enabled     = false;
     CountComplexShapes     = Directory.GetFiles(Application.StartupPath + "\\..\\..\\Libraries", "*.fig").Length;
     shapeList              = new List <Configs>();
     selectedFigures        = new List <Configs>();
     complexShapes          = new List <ComplexShape>();
     factoryTypesList       = new List <Type>();
     assembliesToSign       = new Dictionary <byte, string>();
     configs                = new Configs();
     pen = new Pen(configs.Color, configs.Width);
     InitLibraries();
     CleanField();
     ConfigWindow();
 }
Example #12
0
        public void HandleCreateShape(LitePeer peer,
                                      OperationRequest operationRequest,
                                      SendParameters sendParameters)
        {
            var req = CreateShape.Read(operationRequest.Parameters);

            var newSh = new ServerBaseVdShape(req.shapeId, req.ownerId, req.shapeType, req.tag);

            switch (req.shapeType)
            {
            case VdShapeType.Cluster:
                _topology.CreateCluster(newSh.Id());
                _doc.AddShape(newSh);
                break;

            case VdShapeType.FreeForm:
                _doc.AddShape(newSh);
                EventLogger.LogAndBroadcast(
                    new DiscCtx(Discussions.ConfigManager.ConnStr),
                    _room,
                    StEvent.FreeDrawingCreated,
                    req.ownerId,
                    _topicId);
                break;

            default:
                _doc.AddShapeAndLock(newSh);
                break;
            }

            _room.Broadcast(peer,
                            operationRequest,
                            sendParameters,
                            (byte)DiscussionEventCode.CreateShapeEvent,
                            BroadcastTo.RoomExceptSelf);
            //don't include self, we play shape creation locally without continuation

            _pendingChanges = true;
        }
Example #13
0
        private void checkedListBoxComplex_Click(object sender, EventArgs e)
        {
            if (checkedListBox.SelectedItem != null)
            {
                checkedListBox.SetItemChecked(checkedListBox.Items.IndexOf(checkedListBox.SelectedItem), false);
                checkedListBox.ClearSelected();
            }

            for (int i = 0; i < checkedListBoxComplex.Items.Count; i++)
            {
                if (checkedListBoxComplex.Items[i] != checkedListBoxComplex.SelectedItem)
                {
                    checkedListBoxComplex.SetItemChecked(checkedListBoxComplex.Items.IndexOf(checkedListBoxComplex.Items[i]), false);
                }
            }

            string             numberOfFigure = checkedListBoxComplex.SelectedItem.ToString().Substring(6);
            ComplexShape       complexShape   = complexShapes[Convert.ToInt32(numberOfFigure) - 1];
            CreateComplexShape factory        = new CreateComplexShape(complexShape.Shapes, complexShape.InitWidth, complexShape.InitHeight);

            fabric = factory;
        }
Example #14
0
        public void OnEvent(EventData eventData)
        {
            switch (eventData.Code)
            {
            case (byte)LiteEventCode.Join:
                int[] actNrs   = (int[])eventData.Parameters[(byte)ParameterKey.Actors];
                int   ActorNr  = (int)eventData.Parameters[(byte)ParameterKey.ActorNr];
                var   actProps = (Hashtable)eventData.Parameters[(byte)ParameterKey.ActorProperties];

                Console.WriteLine("Join event actors.len={0}", actNrs.Length);
                List <int> unknownPeersNrs = new List <int>();
                for (int i = 0; i < actNrs.Length; i++)
                {
                    if (!usersOnline.ContainsKey(actNrs[i]))
                    {
                        if (!unknownPeersNrs.Contains(actNrs[i]))
                        {
                            unknownPeersNrs.Add(actNrs[i]);
                        }
                    }
                }
                requestPeersInfo(unknownPeersNrs.ToArray());
                DbgPrintOnlineList();
                break;

            case (byte)EventCode.Leave:
                actNrs = (int[])eventData.Parameters[(byte)ParameterKey.Actors];
                int leftActNr = (int)eventData.Parameters[(byte)ParameterKey.ActorNr];
                Console.WriteLine("Leave event, actors.len={0}", actNrs.Length);
                if (usersOnline.ContainsKey(leftActNr))
                {
                    if (userLeaves != null)
                    {
                        DiscUser leaving = usersOnline[leftActNr];
                        userLeaves(leaving);
                    }
                    usersOnline.Remove(leftActNr);
                }
                DbgPrintOnlineList();
                break;

            case (byte)DiscussionEventCode.InstantUserPlusMinus:
                if (smbdLeaved != null)
                {
                    smbdLeaved();
                }
                break;

            case (byte)DiscussionEventCode.StructureChanged:
                int initiater = (int)eventData.Parameters[(byte)DiscussionParamKey.UserId];
                int devType   = (int)eventData.Parameters[(byte)DiscussionParamKey.DeviceType];
                if (eventData.Parameters.ContainsKey((byte)DiscussionParamKey.ForceSelfNotification))
                {
                    //topic updated
                    if (onStructChanged != null)
                    {
                        onStructChanged(Serializers.ReadChangedTopicId(eventData.Parameters),
                                        initiater, (DeviceType)devType);
                    }
                }
                else if (initiater != -1 && initiater != localUsr.ActNr)
                {
                    if (onStructChanged != null)
                    {
                        onStructChanged(Serializers.ReadChangedTopicId(eventData.Parameters),
                                        initiater, (DeviceType)devType);
                    }
                }
                break;

            case (byte)DiscussionEventCode.ArgPointChanged:
                var changeType = PointChangedType.Modified;
                int topicId;
                int personId;
                int argPointId = Serializers.ReadChangedArgPoint(eventData.Parameters, out changeType, out topicId, out personId);
                if (argPointChanged != null)
                {
                    argPointChanged(argPointId, topicId, changeType, personId);
                }
                break;

            case (byte)DiscussionEventCode.UserAccPlusMinus:
                if (userAccPlusMinus != null)
                {
                    userAccPlusMinus();
                }
                break;

            case (byte)DiscussionEventCode.StatsEvent:
                if (onStatsEvent != null)
                {
                    StEvent    e;
                    int        userId       = -1;
                    int        discussionId = -1;
                    int        statsTopicId = -1;
                    DeviceType devTyp;
                    Serializers.ReadStatEventParams(eventData.Parameters, out e, out userId, out discussionId,
                                                    out statsTopicId, out devTyp);
                    onStatsEvent(e, userId, discussionId, statsTopicId, devTyp);
                }
                break;

            case (byte)DiscussionEventCode.CursorEvent:
                if (cursorEvent != null)
                {
                    cursorEvent(CursorEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.CreateShapeEvent:
                if (createShapeEvent != null)
                {
                    createShapeEvent(CreateShape.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.UnselectAllEvent:
                if (unselectAll != null)
                {
                    unselectAll(UnselectAllEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.DeleteSingleShapeEvent:
                if (deleteSingleShape != null)
                {
                    deleteSingleShape(DeleteSingleShapeEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ApplyPointEvent:
                if (applyPoint != null)
                {
                    applyPoint(PointMove.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.StateSyncEvent:
                if (syncStateEvent != null)
                {
                    syncStateEvent(ShapeState.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.LinkCreateEvent:
                if (onLinkCreateEvent != null)
                {
                    onLinkCreateEvent(LinkCreateMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.UnclusterBadgeEvent:
                if (onUnclusterBadgeEvent != null)
                {
                    onUnclusterBadgeEvent(UnclusterBadgeMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ClusterBadgeEvent:
                if (onClusterBadgeEvent != null)
                {
                    onClusterBadgeEvent(ClusterBadgeMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.InkEvent:
                if (inkEvent != null)
                {
                    inkEvent(InkMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.SceneLoadingDone:
                if (loadingDoneEvent != null)
                {
                    loadingDoneEvent();
                }
                break;

            case (byte)DiscussionEventCode.DEditorReportEvent:
                if (dEditorReportResponse != null)
                {
                    dEditorReportResponse(DEditorStatsResponse.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ClusterStatsEvent:
                if (clusterStatsResponse != null)
                {
                    if (eventData.Parameters == null || eventData.Parameters.Count() == 0)
                    {
                        clusterStatsResponse(default(ClusterStatsResponse), false);
                    }
                    else
                    {
                        clusterStatsResponse(ClusterStatsResponse.Read(eventData.Parameters), true);
                    }
                }
                break;

            case (byte)DiscussionEventCode.LinkStatsEvent:
                if (linkStatsResponseEvent != null)
                {
                    if (eventData.Parameters == null || eventData.Parameters.Count() == 0)
                    {
                        linkStatsResponseEvent(default(LinkReportResponse), false);
                    }
                    else
                    {
                        linkStatsResponseEvent(LinkReportResponse.Read(eventData.Parameters), true);
                    }
                }
                break;

            case (byte)DiscussionEventCode.BadgeViewEvent:
                if (onBadgeViewRequest != null)
                {
                    onBadgeViewRequest(BadgeViewMessage.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.SourceViewEvent:
                if (onSourceViewRequest != null)
                {
                    onSourceViewRequest(ExplanationModeSyncMsg.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.CommentReadEvent:
                if (onCommentRead != null)
                {
                    onCommentRead(CommentsReadEvent.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.AttachLaserPointerEvent:
                if (onAttachLaserPointer != null)
                {
                    onAttachLaserPointer(LaserPointer.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.DetachLaserPointerEvent:
                if (onDetachLaserPointer != null)
                {
                    onDetachLaserPointer(LaserPointer.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.LaserPointerMovedEvent:
                if (onLaserPointerMoved != null)
                {
                    onLaserPointerMoved(LaserPointer.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.ImageViewerManipulatedEvent:
                if (onImageViewerManipulated != null)
                {
                    onImageViewerManipulated(ImageViewerMatrix.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.BrowserScrollChangedEvent:
                if (onBrowserScroll != null)
                {
                    onBrowserScroll(BrowserScrollPosition.Read(eventData.Parameters));
                }
                break;

            case (byte)DiscussionEventCode.PdfScrollChangedEvent:
                if (onPdfScroll != null)
                {
                    onPdfScroll(PdfScrollPosition.Read(eventData.Parameters));
                }
                break;

            default:
                Console.WriteLine("Unhandled event " + eventData.Code);
                break;
            }
        }
        public ReviewQuoteTests()
        {
            repoS = new FakeShapeRepository();
            quote = new Quote
            {
                QuoteID = 1
            };
            repoS.Quotes.Add(quote);
            shape = new Shape
            {
                ShapeID      = 1,
                BarSize      = 4,
                LegCount     = 3,
                Qty          = 30,
                NumCompleted = 0
            };
            cS = new CreateShape
            {
                Shape   = shape,
                QuoteID = quote.QuoteID
            };

            repoQ       = new FakeQuoteRepository();
            repoF       = new FakeFormulaRepository();
            repoC       = new FakeCostRepository();
            controllerQ = new QuotesController(repoQ, repoF, repoC, repoS);
            #region Mandrels
            mandrel1 = new Mandrel
            {
                MandrelID = 1,
                Name      = "Small",
                Radius    = 1
            };
            mandrel2 = new Mandrel
            {
                MandrelID = 2,
                Name      = "Medium",
                Radius    = 1.5m
            };
            #endregion
            #region Legs
            leg1 = new Leg
            {
                LegID   = 1,
                Length  = 36,
                Degree  = 90,
                Mandrel = mandrel2
            };
            leg2 = new Leg
            {
                LegID   = 2,
                Length  = 36,
                Degree  = 0,
                Mandrel = null
            };
            leg3 = new Leg
            {
                LegID   = 3,
                Length  = 12,
                Degree  = 90,
                Mandrel = mandrel2
            };
            leg4 = new Leg
            {
                LegID   = 4,
                Length  = 12,
                Degree  = 0,
                Mandrel = null
            };
            leg5 = new Leg
            {
                LegID   = 5,
                Length  = 30,
                Degree  = 90,
                Mandrel = mandrel1
            };
            leg6 = new Leg
            {
                LegID   = 6,
                Length  = 18,
                Degree  = 90,
                Mandrel = mandrel1
            };
            leg7 = new Leg
            {
                LegID   = 7,
                Length  = 30,
                Degree  = 0,
                Mandrel = null
            };
            #endregion
            #region Shapes
            shape2 = new Shape
            {
                ShapeID      = 2,
                BarSize      = 5,
                LegCount     = 2,
                Legs         = { leg1, leg2 },
                Qty          = 30,
                NumCompleted = 0
            };
            shape3 = new Shape
            {
                ShapeID      = 3,
                BarSize      = 5,
                LegCount     = 2,
                Legs         = { leg3, leg4 },
                Qty          = 60,
                NumCompleted = 0
            };
            shape4 = new Shape
            {
                ShapeID      = 4,
                BarSize      = 4,
                LegCount     = 3,
                Legs         = { leg5, leg6, leg7 },
                Qty          = 40,
                NumCompleted = 0
            };
            #endregion
            #region Costs
            cost1 = new Cost
            {
                CostID      = 1,
                Name        = KnownObjects.Bar4GlobalCost.Name,
                Price       = 10,
                LastChanged = new DateTime()
            };
            cost2 = new Cost
            {
                CostID      = 2,
                Name        = KnownObjects.Bar4CutCost.Name,
                Price       = 0.25m,
                LastChanged = new DateTime()
            };
            cost3 = new Cost
            {
                CostID      = 3,
                Name        = KnownObjects.Bar4BendCost.Name,
                Price       = 0.25m,
                LastChanged = new DateTime()
            };
            cost4 = new Cost
            {
                CostID      = 4,
                Name        = KnownObjects.Bar5GlobalCost.Name,
                Price       = 15,
                LastChanged = new DateTime()
            };
            cost5 = new Cost
            {
                CostID      = 5,
                Name        = KnownObjects.Bar5CutCost.Name,
                Price       = 0.33m,
                LastChanged = new DateTime()
            };
            cost6 = new Cost
            {
                CostID      = 6,
                Name        = KnownObjects.Bar5BendCost.Name,
                Price       = 0.33m,
                LastChanged = new DateTime()
            };
            cost7 = new Cost
            {
                CostID      = 7,
                Name        = KnownObjects.SetupCharge.Name,
                Price       = 15,
                LastChanged = new DateTime()
            };
            cost8 = new Cost
            {
                CostID      = 8,
                Name        = "4Bar",
                Price       = 10,
                LastChanged = new DateTime()
            };
            cost9 = new Cost
            {
                CostID      = 9,
                Name        = "4Cut",
                Price       = 0.25m,
                LastChanged = new DateTime()
            };
            cost10 = new Cost
            {
                CostID      = 10,
                Name        = "4Bend",
                Price       = 0.25m,
                LastChanged = new DateTime()
            };
            cost11 = new Cost
            {
                CostID      = 11,
                Name        = "5Bar",
                Price       = 15,
                LastChanged = new DateTime()
            };
            cost12 = new Cost
            {
                CostID      = 12,
                Name        = "5Cut",
                Price       = 0.33m,
                LastChanged = new DateTime()
            };
            cost13 = new Cost
            {
                CostID      = 13,
                Name        = "5Bend",
                Price       = 0.33m,
                LastChanged = new DateTime()
            };
            cost14 = new Cost
            {
                CostID      = 14,
                Name        = "Setup",
                Price       = 15,
                LastChanged = new DateTime()
            };
            #endregion
            #region Extra Costs
            cost15 = new Cost
            {
                CostID      = 15,
                Name        = KnownObjects.Bar3GlobalCost.Name,
                Price       = 10,
                LastChanged = new DateTime()
            };
            cost16 = new Cost
            {
                CostID      = 16,
                Name        = KnownObjects.Bar3CutCost.Name,
                Price       = 0.25m,
                LastChanged = new DateTime()
            };
            cost17 = new Cost
            {
                CostID      = 17,
                Name        = KnownObjects.Bar3BendCost.Name,
                Price       = 0.25m,
                LastChanged = new DateTime()
            };
            cost18 = new Cost
            {
                CostID      = 18,
                Name        = KnownObjects.Bar6GlobalCost.Name,
                Price       = 15,
                LastChanged = new DateTime()
            };
            cost19 = new Cost
            {
                CostID      = 19,
                Name        = KnownObjects.Bar6CutCost.Name,
                Price       = 0.33m,
                LastChanged = new DateTime()
            };
            cost20 = new Cost
            {
                CostID      = 20,
                Name        = KnownObjects.Bar6BendCost.Name,
                Price       = 0.33m,
                LastChanged = new DateTime()
            };
            #endregion
            quote2 = new Quote
            {
                QuoteID     = 2,
                Name        = "Bob's Concrete",
                OrderNum    = "123456",
                UseFormulas = true,
                Shapes      = { shape2, shape3, shape4 },
                Costs       = { cost8, cost9, cost10, cost11, cost12, cost13, cost14 },
                DateQuoted  = DateTime.Now,
                PickedUp    = false,
                Open        = false
            };
            repoC.AddCostAsync(cost1);
            repoC.AddCostAsync(cost2);
            repoC.AddCostAsync(cost3);
            repoC.AddCostAsync(cost4);
            repoC.AddCostAsync(cost5);
            repoC.AddCostAsync(cost6);
            repoC.AddCostAsync(cost7);
            repoC.AddCostAsync(cost15);
            repoC.AddCostAsync(cost16);
            repoC.AddCostAsync(cost17);
            repoC.AddCostAsync(cost18);
            repoC.AddCostAsync(cost19);
            repoC.AddCostAsync(cost20);
        }
Example #16
0
        protected override void OnMouseDown(MouseEventArgs e)
        {
            // track mouse position when down
            this.Capture = true;
            mouseDown    = e.Location;
            mouseMove    = e.Location;

            // reset rubberbanding flag
            rubberBanding = !rubberBanding;

            // if any of the shapes is chosen to be drawn, create new shape object with
            // start and end points as well as angle for rotation and scaling factor
            switch (createShape)
            {
            case CreateShape.SQUARE:

                square = new Square(mouseDown, mouseMove, angle, scale);
                break;

            case CreateShape.TRIANGLE:

                triangle = new Triangle(mouseDown, mouseMove, angle, scale);
                break;

            case CreateShape.CIRCLE:
                circle = new Circle(mouseDown, mouseMove, angle, scale);
                break;

            default:
                break;
            }


            if (e.Button == MouseButtons.Left)
            {
                // if left mouse button has been pressed check if it clicked anywhere inside a shape
                // from the shape list, if yes assign it to selectedShape object
                foreach (var shape in shapes.ToArray())
                {
                    if (shape.contains(e.Location))
                    {
                        createShape   = CreateShape.NONE;
                        selectedShape = shape;
                        if (selectedShape != null)
                        {
                            // record where the select shape has start and end points
                            selectedShapeStartPt = new PointF(selectedShape.Start.X, selectedShape.Start.Y);
                            selectedShapeEndPt   = new PointF(selectedShape.End.X, selectedShape.End.Y);

                            // calculate starting angle for rotation
                            float dx = e.X - ((selectedShape.Start.X + selectedShape.End.X) / 2);
                            float dy = e.Y - ((selectedShape.Start.Y + selectedShape.End.Y) / 2);
                            startAngle = (float)Math.Atan2(dy, dx);
                        }
                    }
                }
            }
            if (e.Button == MouseButtons.Right)
            {
                // if right button has been pressed, show a context menu to perform any action the shape
                // or if it was clicked somewhere else and not on any of the shapes, show context menu for shape creation
                if (shapes.Count != 0)
                {
                    foreach (var shape in shapes.ToArray())
                    {
                        if (shape.contains(e.Location))
                        {
                            selectedShape = shape;
                            PopupMenu.Show(this, e.Location);
                        }
                        else if (selectedShape == null || selectedShape.contains(e.Location) == false)
                        {
                            CreatePopupMenu.Show(this, e.Location);
                        }
                    }
                }
                else
                {
                    CreatePopupMenu.Show(this, e.Location);
                }
            }
            Invalidate();
        }
Example #17
0
 private void rotateShape(object sender, EventArgs e)
 {
     SetFlags(false, false, true);
     createShape = CreateShape.NONE;
 }
Example #18
0
        public void HandleInitialSceneLoad(LitePeer peer,
                                           OperationRequest operationRequest,
                                           SendParameters sendParameters)
        {
            //// var req = InitialSceneLoadRequest.Read(operationRequest);
            /// req.topicId
            _log.Debug("scene load request");

            CleanupEmptyClusters();

            //1st phase, send creation events for simple shapes (+cluster)  in the scene
            var simpleShapes = _doc.GetShapes().Where(sh => sh.ShapeCode() != VdShapeType.ClusterLink).ToArray();

            foreach (var sh in simpleShapes)
            {
                _room.PublishEventToSingle(peer,
                                           CreateShape.Write(sh.InitialOwner(), sh.Id(),
                                                             sh.ShapeCode(), 400, 400, false, sh.Tag(),
                                                             _topicId),
                                           sendParameters,
                                           (byte)DiscussionEventCode.CreateShapeEvent);
            }

            //2nd phase, send state update packets
            foreach (var sh in simpleShapes)
            {
                var st = sh.GetState();
                if (st == null)
                {
                    continue;
                }
                _room.PublishEventToSingle(peer,
                                           st.ToDict(),
                                           sendParameters,
                                           (byte)DiscussionEventCode.StateSyncEvent);
            }

            //3rd phase, sequence of cluster-add operations (enumerate contents of all existing clusters)
            var clusterShapes = _doc.GetShapes().Where(sh => sh.ShapeCode() == VdShapeType.Cluster);

            foreach (var clShape in clusterShapes)
            {
                var cluster = _topology.GetCluster(clShape.Id());
                _log.Info("scene load, cluster updates, num badges =" + cluster.GetClusterables());
                foreach (var badge in cluster.GetClusterables())
                {
                    var clustMsg = ClusterBadgeMessage.Write(badge.GetId(),
                                                             _doc.TryGetShape(badge.GetId()).InitialOwner(),
                                                             badge == cluster.GetClusterables().Last(),
                                                             cluster.GetId(),
                                                             _topicId,
                                                             -1);
                    _room.PublishEventToSingle(peer,
                                               clustMsg,
                                               sendParameters,
                                               (byte)DiscussionEventCode.ClusterBadgeEvent);
                }
            }

            //4rd phase, create links
            var linkShapes = _doc.GetShapes().Where(sh => sh.ShapeCode() == VdShapeType.ClusterLink);

            foreach (var lnk in linkShapes)
            {
                var edge = _topology.GetForwardEdge(lnk.Id());

                var ev = LinkCreateMessage.Write(edge.curr.GetId(),
                                                 edge.next.GetId(),
                                                 lnk.InitialOwner(),
                                                 lnk.Id(),
                                                 _topicId,
                                                 false,
                                                 (LinkHeadType)lnk.Tag());
                _room.PublishEventToSingle(peer, ev, sendParameters, (byte)DiscussionEventCode.LinkCreateEvent);

                //send link state update
                var st = lnk.GetState();
                if (st != null)
                {
                    _room.PublishEventToSingle(peer,
                                               st.ToDict(),
                                               sendParameters,
                                               (byte)DiscussionEventCode.StateSyncEvent);
                }
            }

            //5th phase, send cursor events
            foreach (var sh in _doc.GetShapes())
            {
                if (sh.GetCursor() == null)
                {
                    continue; //cursors are unset by default for all shapes
                }
                _room.PublishEventToSingle(peer,
                                           CursorEvent.Write(true,
                                                             sh.GetCursor().OwnerId,
                                                             sh.Id(),
                                                             _topicId),
                                           sendParameters,
                                           (byte)DiscussionEventCode.CursorEvent);
            }

            //6th phase, send ink
            if (_doc.inkData != null)
            {
                _room.PublishEventToSingle(peer,
                                           InkMessage.Write(-1,
                                                            _topicId,
                                                            _doc.inkData),
                                           sendParameters,
                                           (byte)DiscussionEventCode.InkEvent);
            }

            //7th phase, send laser pointers
            foreach (var laserPointer in _doc.LaserPointers)
            {
                _room.PublishEventToSingle(peer,
                                           laserPointer.ToDict(),
                                           sendParameters,
                                           (byte)DiscussionEventCode.AttachLaserPointerEvent);
            }

            //notify client loading sequence complete
            _room.PublishEventToSingle(peer,
                                       null,
                                       sendParameters,
                                       (byte)DiscussionEventCode.SceneLoadingDone);
        }
Example #19
0
 private void createCircle(object sender, EventArgs e)
 {
     SetFlags(false, false, false);
     createShape = CreateShape.CIRCLE;
 }
Example #20
0
 private void createTriangle(object sender, EventArgs e)
 {
     SetFlags(false, false, false);
     createShape = CreateShape.TRIANGLE;
 }
Example #21
0
 private void createSquare(object sender, EventArgs e)
 {
     SetFlags(false, false, false);
     createShape = CreateShape.SQUARE;
 }
Example #22
0
 private void buttonRelocate_Click(object sender, EventArgs e)
 {
     moving             = true;
     fabric             = null;
     buttonEdit.Enabled = false;
 }
Example #23
0
        private void pictureBox_MouseUp(object sender, MouseEventArgs e)
        {
            drawArea.Clear(Color.White);
            drawArea.DrawImage(btmp_back, 0, 0);
            pictureBox.Refresh();
            if (moving)
            {
                shapeList.Remove(selectedShape);
                fabric = null;
                if (checkedListBox.SelectedItem != null)
                {
                    checkedListBox.SetItemChecked(checkedListBox.Items.IndexOf(checkedListBox.SelectedItem), false);
                    checkedListBox.ClearSelected();
                }
                if (checkedListBoxComplex.SelectedItem != null)
                {
                    checkedListBoxComplex.SetItemChecked(checkedListBoxComplex.Items.IndexOf(checkedListBoxComplex.SelectedItem), false);
                    checkedListBoxComplex.ClearSelected();
                }
                selectedShape.CurrentFigure.Relocate(new Point(e.X, e.Y));
                shapeList.Add(new Configs(selectedShape));
                RedrawShapes();
                moving                 = false;
                selectedShape          = null;
                buttonRelocate.Enabled = false;
                buttonEdit.Enabled     = false;
                return;
            }
            buttonRelocate.Enabled = false;
            buttonEdit.Enabled     = false;
            selectedShape          = null;
            if (e.Button == MouseButtons.Left)
            {
                if (fabric != null)
                {
                    configs.CurrentFigure.SecondPoint = new Point(e.X, e.Y);
                    configs.CurrentFigure.Draw(drawArea, pen, shiftPressed);
                    configs.Color = pen.Color;
                    configs.Width = pen.Width;
                    btmp_back     = (Bitmap)btmp_front.Clone();
                    shapeList.Add(new Configs(configs));
                    pictureBox.Refresh();
                }
            }
            if (e.Button == MouseButtons.Right)
            {
                var shapes = new List <Configs>(shapeList);
                for (int i = shapes.Count - 1; i >= 0; i--)
                {
                    Type realizedInterface = shapes[i].CurrentFigure.GetType().GetInterface("Interfaces.ISelectable");

                    if ((realizedInterface != null) && (shapes[i].CurrentFigure.isInArea(new Point(e.X, e.Y))))
                    {
                        if (IsBeganCreate)
                        {
                            selectedFigures.Add(shapes[i]);
                            if (selectedFigures.Count < 2)
                            {
                                buttonEndCreate.Enabled = false;
                            }
                            else
                            {
                                buttonEndCreate.Enabled = true;
                            }
                            foreach (var shape in selectedFigures)
                            {
                                shape.CurrentFigure.Select(drawArea);
                            }
                            pictureBox.Refresh();
                        }
                        else
                        {
                            realizedInterface = null;
                            shapes[i].CurrentFigure.Select(drawArea);
                            pictureBox.Refresh();
                            selectedShape     = shapes[i];
                            realizedInterface = shapes[i].CurrentFigure.GetType().GetInterface("Interfaces.IEditable");
                            if (realizedInterface != null)
                            {
                                buttonRelocate.Enabled = true;
                                buttonEdit.Enabled     = true;
                            }
                        }
                        return;
                    }
                }
            }
            IsBeganCreate             = false;
            buttonBeginCreate.Enabled = true;
            buttonEndCreate.Enabled   = false;
            selectedFigures           = new List <Configs>();
        }