private void ProcessQuery(QueryEvent e)
        {
            var ret = 0;

            switch (e.Type)
            {
            case QueryType.ReqQryInstrument:
                ret = _client.Api.ReqQryInstrument(new CtpQryInstrument(), _client.GetNextRequestId());
                break;

            case QueryType.ReqQryInvestorPosition:
                ret = QryInvestorPosition();
                break;

            case QueryType.ReqQryTradingAccount:
                ret = QryTradingAccount();
                break;
            }
            if (ret == 0)
            {
                _sleeps = 1;
            }
            else
            {
                _sleeps *= 4;
                _sleeps %= 1023;
                _action.Post(e);
            }
            Thread.Sleep(_sleeps);
        }
Exemplo n.º 2
0
        public void DisplayAllCourseViews()
        {
            UndoMgr  undomgr  = new UndoMgr(5);
            EventDB  eventDB  = new EventDB(undomgr);
            SymbolDB symbolDB = new SymbolDB(Util.GetFileInAppDirectory("symbols.xml"));

            eventDB.Load(TestUtil.GetTestFile("courseview\\sampleevent1.coursescribe"));
            eventDB.Validate();

            foreach (Id <Course> courseId in QueryEvent.SortedCourseIds(eventDB))
            {
                CourseDesignator designator;
                if (QueryEvent.HasVariations(eventDB, courseId))
                {
                    var variationInfo = QueryEvent.GetAllVariations(eventDB, courseId).First();
                    designator = new CourseDesignator(courseId, variationInfo);
                }
                else
                {
                    designator = new CourseDesignator(courseId);
                }

                CourseView courseView = CourseView.CreateViewingCourseView(eventDB, designator);
                DumpCourseView(courseView, Console.Out);
                Console.WriteLine();
            }
        }
Exemplo n.º 3
0
 public DescriptionPrinting(EventDB eventDB, SymbolDB symbolDB, Controller controller, DescriptionPrintSettings descPrintSettings)
     : base(QueryEvent.GetEventTitle(eventDB, " "), controller, descPrintSettings.PageSettings, descPrintSettings.BoxSize, descPrintSettings.CountKind, descPrintSettings.Count)
 {
     this.eventDB           = eventDB;
     this.symbolDB          = symbolDB;
     this.descPrintSettings = descPrintSettings;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Enrich the registration event
        /// </summary>
        internal void EnrichRegistrationEvent(IDbConnection conn, IDbTransaction tx, RegistrationEvent hsrEvent)
        {
            decimal tryDec;
            ISystemConfigurationService configService = ApplicationContext.ConfigurationService;

            // Create a query based on the person
            Person subject = hsrEvent.FindComponent(HealthServiceRecordSiteRoleType.SubjectOf) as Person;

            if (subject.AlternateIdentifiers.Exists(o => o.Domain == configService.OidRegistrar.GetOid(ClientRegistryOids.CLIENT_CRID).Oid))
            {
                subject = new Person()
                {
                    AlternateIdentifiers = new List <DomainIdentifier>(subject.AlternateIdentifiers.FindAll(o => o.Domain == configService.OidRegistrar.GetOid(ClientRegistryOids.CLIENT_CRID).Oid)),
                    Status = StatusType.Normal
                }
            }
            ;
            else if (subject.AlternateIdentifiers.Exists(o => o is AuthorityAssignedDomainIdentifier))
            {
                subject = new Person()
                {
                    AlternateIdentifiers = new List <DomainIdentifier>(subject.AlternateIdentifiers.FindAll(o => o is AuthorityAssignedDomainIdentifier)),
                    Status = StatusType.Normal
                }
            }
            ;
            else
            {
                subject = new Person()
                {
                    AlternateIdentifiers = new List <DomainIdentifier>(subject.AlternateIdentifiers),
                    Status = StatusType.Normal
                }
            };

            QueryEvent        query = new QueryEvent();
            RegistrationEvent evt   = new RegistrationEvent();

            query.Add(evt, "SUBJ", HealthServiceRecordSiteRoleType.SubjectOf, null);
            evt.Status = StatusType.Active | StatusType.Obsolete;
            evt.Add(subject, "SUBJ", HealthServiceRecordSiteRoleType.SubjectOf, null);
            query.Add(new QueryParameters()
            {
                MatchingAlgorithm = MatchAlgorithm.Exact,
                MatchStrength     = MatchStrength.Exact
            }, "FLTR", HealthServiceRecordSiteRoleType.FilterOf, null);
            var tRecordIds = QueryRecord(query);

            if (tRecordIds.Length != 1)
            {
                throw new MissingPrimaryKeyException(ApplicationContext.LocaleService.GetString("DBCF004"));
            }
            else if (tRecordIds[0].Domain != configService.OidRegistrar.GetOid(ClientRegistryOids.REGISTRATION_EVENT).Oid)
            {
                throw new MissingPrimaryKeyException(ApplicationContext.LocaleService.GetString("DBCF005"));
            }

            tryDec = Decimal.Parse(tRecordIds[0].Identifier);
            hsrEvent.AlternateIdentifier = tRecordIds[0];
        }
Exemplo n.º 5
0
        public void Files_Relay_SingleFile()
        {
            EventDB  eventDB  = controller.GetEventDB();
            SymbolDB symbolDB = ui.symbolDB;

            CoursePdfSettings settings = new CoursePdfSettings();

            settings.mapDirectory              = settings.fileDirectory = false;
            settings.outputDirectory           = TestUtil.GetTestFile("controller\\pdf_create1");
            settings.CourseIds                 = new Id <Course>[] { CourseId(2), Id <Course> .None };
            settings.ColorModel                = ColorModel.CMYK;
            settings.CropLargePrintArea        = true;
            settings.FileCreation              = CoursePdfSettings.PdfFileCreation.SingleFile;
            settings.PrintMapExchangesOnOneMap = false;

            bool success = controller.LoadInitialFile(TestUtil.GetTestFile("controller\\variations.ppen"), true);

            Assert.IsTrue(success);

            var coursePdf     = new CoursePdf(eventDB, symbolDB, controller, controller.MapDisplay, settings, new CourseAppearance());
            var filesToCreate = coursePdf.GetFilesToCreate();

            VariationInfo[] relayVariations = QueryEvent.GetAllVariations(eventDB, CourseId(2)).ToArray();

            Assert.AreEqual(1, filesToCreate.Count);

            Assert.AreEqual(TestUtil.GetTestFile("controller\\pdf_create1\\variations.pdf"), filesToCreate[0].First);
            CollectionAssert.AreEqual(new CourseDesignator[] {
                new CourseDesignator(CourseId(2), relayVariations[0]),
                new CourseDesignator(CourseId(2), relayVariations[1]),
                new CourseDesignator(CourseId(2), relayVariations[2]),
                new CourseDesignator(CourseId(2), relayVariations[3]),
                CourseDesignator.AllControls
            }, filesToCreate[0].Second.ToList());
        }
Exemplo n.º 6
0
        // Format the given CourseView into a bunch of course objects, and add it to the given course Layout
        public RectangleF FormatCourseToLayout(SymbolDB symbolDB, CourseView courseViewAllVariations, CourseView specificVariation, CourseLayout courseLayout,
                                               Id <CourseControl> ccSelection1, Id <CourseControl> ccSelection2, CourseLayer layerAllVariations, CourseLayer layerSpecificVariation)
        {
            this.eventDB      = courseViewAllVariations.EventDB;
            this.symbolDB     = symbolDB;
            this.courseLayout = courseLayout;
            this.courseLayerAllVariationsAndParts  = layerAllVariations;
            this.courseLayerSpecificVariation      = layerSpecificVariation;
            this.controlViewsAllVariationsAndParts = courseViewAllVariations.ControlViews;
            this.controlViewsSpecificVariation     = specificVariation.ControlViews;
            this.controlPositions = new ControlPosition[controlViewsAllVariationsAndParts.Count];
            this.courseControlIdsSpecificVariation = QueryEvent.EnumCourseControlIds(eventDB, specificVariation.CourseDesignator).ToArray();
            this.courseControlIdSelection1         = ccSelection1;
            this.courseControlIdSelection2         = ccSelection2;
            this.variationMap = QueryEvent.GetVariantCodeMapping(eventDB, courseViewAllVariations.CourseDesignator);

            SizeF totalAbstractSize = AssignControlPositions(0, controlViewsAllVariationsAndParts.Count, 0, 0);

            // Now create objects now that the positions have been created.
            courseObjRatio = 1.0F;
            appearance     = new CourseAppearance();

            for (int index = 0; index < controlViewsAllVariationsAndParts.Count; ++index)
            {
                CreateObjectsForControlView(controlViewsAllVariationsAndParts[index], controlPositions[index]);
            }

            PointF     bottomCenter = LocationFromAbstractPosition(0, 0);
            SizeF      size         = SizeFromAbstractSize(totalAbstractSize);
            RectangleF rect         = new RectangleF(bottomCenter.X - size.Width / 2, bottomCenter.Y - size.Height, size.Width, size.Height);

            rect.Inflate(widthUnit, heightUnit);
            return(rect);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Receive message from AsyncTcpManager
        /// </summary>
        /// <param name="message"></param>
        public void ReceiveMessage(object message)
        {
            if (QueryEvent != null)
            {
                //Asyncronized query
                if (message is QueryResult)
                {
                    _QueryResult = message as QueryResult;
                }
                else if (message is InnerServerException)
                {
                    _AsyncException = new ServerException(message as InnerServerException);
                }
                else if (message is TcpRemoteCloseException)
                {
                    _AsyncException = message as TcpRemoteCloseException;
                }
                else if (message is Exception)
                {
                    _AsyncException = message as Exception;
                }

                this.EndAsyncQuery();
                QueryEvent.Set();
                return;
            }

            //Syncronized query
            if (OnReceiveAsyncMessage != null)
            {
                OnReceiveAsyncMessage(message);
            }
        }
Exemplo n.º 8
0
        public void QueryEventModelJsonTest()
        {
            var r  = CreateRequest();
            var qe = new QueryEvent(r);

            string json = RegisterQuery.ToJSON <QueryEvent>  (qe);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Begins profile.
        /// </summary>
        /// <param name="profileColor">The profile event color.</param>
        /// <param name="profilingKey">The <see cref="ProfilingKey"/></param>
        public Scope BeginProfile(Color4 profileColor, ProfilingKey profilingKey)
        {
            if (!Profiler.IsEnabled(profilingKey))
            {
                return(new Scope(this, profilingKey));
            }

            EnsureQueryPoolSize();

            // Push the current query range onto the stack
            var query = new QueryEvent
            {
                ProfilingKey = profilingKey,
                Pool         = currentQueryPool,
                Index        = currentQueryIndex++,
            };

            queries.Push(query);

            // Query the timestamp at the beginning of the range
            commandList.WriteTimestamp(currentQueryPool, query.Index);

            // Add the queries to the list of queries to proceess
            queryEvents.Enqueue(query);

            // Sets a debug marker if debug mode is enabled
            if (commandList.GraphicsDevice.IsDebugMode)
            {
                commandList.BeginProfile(profileColor, profilingKey.Name);
            }

            return(new Scope(this, profilingKey));
        }
Exemplo n.º 10
0
        bool WriteCourse(Id <Course> courseId, int courseNumber)
        {
            // A course must have a start and a finish to be output.
            if (!QueryEvent.HasStartControl(eventDB, courseId))
            {
                return(false);
            }
            if (!QueryEvent.HasFinishControl(eventDB, courseId))
            {
                return(false);
            }

            Course course  = eventDB.GetCourse(courseId);
            bool   isScore = (course.kind == CourseKind.Score);

            string[]   classNames = GetClassNames(eventDB, courseId);
            CourseView courseView = CourseView.CreateViewingCourseView(eventDB, new CourseDesignator(courseId));

            WriteCourseGroupStart(course.name, courseNumber, classNames, isScore);

            WriteCourseVariations(courseId, course.name, courseNumber, classNames, isScore);

            WriteCourseGroupEnd();

            return(true);
        }
Exemplo n.º 11
0
 private void TaskRun(CancellationToken ct)
 {
     try {
         while (!ct.IsCancellationRequested)
         {
             if (_lastQuery == null)
             {
                 if (_requests.TryTake(out var e, 10, ct))
                 {
                     ++_qryCount;
                     _lastQuery = e;
                     ProcessQuery(e);
                 }
             }
             else if (_responses.TryTake(out var e, 10, ct))
             {
                 if (ProcessResponse(e))
                 {
                     ResetQuery();
                 }
             }
         }
     }
     catch (OperationCanceledException) {
     }
 }
Exemplo n.º 12
0
        // Determine the type of flagging
        private static string FlaggingType(EventDB eventDB, Id <ControlPoint> controlId1, Id <ControlPoint> controlId2, Id <Leg> legId)
        {
            string       flaggingType = SelectionDescriptionText.None;
            FlaggingKind kind         = QueryEvent.GetLegFlagging(eventDB, controlId1, controlId2, legId);

            switch (kind)
            {
            case FlaggingKind.All: flaggingType = SelectionDescriptionText.EntireLeg; break;

            case FlaggingKind.Begin: flaggingType = SelectionDescriptionText.AwayFromControl; break;

            case FlaggingKind.End: flaggingType = SelectionDescriptionText.IntoControl; break;
            }

            // We use slightly different wording based on the finish control.
            ControlPoint ending = eventDB.GetControl(controlId2);

            if (ending.kind == ControlPointKind.Finish)
            {
                // finish control can influence flagging!
                if (ending.symbolIds[0] == "14.2" && kind == FlaggingKind.None)
                {
                    flaggingType = SelectionDescriptionText.FinishFunnel;
                }
                else if (ending.symbolIds[0] == "14.2" && kind == FlaggingKind.End)
                {
                    flaggingType = SelectionDescriptionText.IntoFinishFunnel;
                }
            }

            return(flaggingType);
        }
Exemplo n.º 13
0
        // Get the controls the define where to insert the new control point.
        private void GetControlInsertionPoint(PointF pt, out CourseDesignator courseDesignator,
                                              out Id <CourseControl> courseControlId1, out Id <CourseControl> courseControlId2,
                                              out LegInsertionLoc legInsertionLoc)
        {
            SelectionMgr.SelectionInfo selection = selectionMgr.Selection;
            courseDesignator = selection.ActiveCourseDesignator;
            courseControlId1 = Id <CourseControl> .None;
            courseControlId2 = Id <CourseControl> .None;
            legInsertionLoc  = LegInsertionLoc.Normal;

            if (selection.SelectionKind == SelectionMgr.SelectionKind.Control &&
                (courseDesignator.IsAllControls || QueryEvent.IsCourseControlInPart(eventDB, courseDesignator, selection.SelectedCourseControl)))
            {
                courseControlId1 = selection.SelectedCourseControl;
            }
            else if (selection.SelectionKind == SelectionMgr.SelectionKind.Leg)
            {
                courseControlId1 = selection.SelectedCourseControl;
                courseControlId2 = selection.SelectedCourseControl2;
                legInsertionLoc  = selection.LegInsertionLoc;
            }
            else if (courseDesignator.IsNotAllControls)
            {
                // Not all control, and neight control or leg is selected. Use the closest leg.
                QueryEvent.LegInfo leg = QueryEvent.FindClosestLeg(eventDB, courseDesignator, pt);
                courseControlId1 = leg.courseControlId1;
                courseControlId2 = leg.courseControlId2;
            }

            if (courseDesignator.IsNotAllControls)
            {
                QueryEvent.FindControlInsertionPoint(eventDB, courseDesignator, ref courseControlId1, ref courseControlId2, ref legInsertionLoc);
            }
        }
Exemplo n.º 14
0
 public static void Init()
 {
     if (null == OnQueryDone)
     {
         OnQueryDone = new QueryEvent();
     }
 }
Exemplo n.º 15
0
        private void ProcessQuery(QueryEvent <T> e)
        {
            int ret;

            if (e.Type == null)
            {
                return;
            }

            switch (e.Type)
            {
            case QueryType.ReqQryInstrument:
                ret = QueryInstrument(e.Field);
                break;

            case QueryType.ReqQryInvestorPosition:
                ret = QryInvestorPosition(e.Field);
                break;

            case QueryType.ReqQryTradingAccount:
                ret = QryTradingAccount(e.Field);
                break;

            case QueryType.ReqQryOrder:
                ret = QryOrder(e.Field);
                break;

            case QueryType.ReqQryTrade:
                ret = QryTrade(e.Field);
                break;

            case QueryType.ReqQryInstrumentCommissionRate:
                ret = QryInstrumentCommissionRate(e.Field);
                break;

            case QueryType.ReqQryInstrumentMarginRate:
                ret = QryInstrumentMarginRate(e.Field);
                break;

            case QueryType.ReqQrySettlementInfo:
                ret = QrySettlementInfo(e.Field);
                break;

            case QueryType.ReqQryInvestor:
                ret = QryInvestor(e.Field);
                break;

            case QueryType.ReqQryQuote:
                ret = QryQuote(e.Field);
                break;

            default:
                return;
            }
            if (ret != 0)
            {
                DelayQuery(1000);
            }
        }
Exemplo n.º 16
0
        public void TestEventPublish()
        {
            var data = new QueryEvent(CreateRequest());

            RegisterQuery.PublishTopic(data);

            Assert.IsTrue(true);
        }
Exemplo n.º 17
0
 // Create a description formatter to format the given courseView.
 // Currently, the language for the text descriptions is taken from the language set for the event. It would be easy to make this
 // a parameter to the constructor (e.g., to allow printing in a different language), but this currently isn't required.
 public DescriptionFormatter(CourseView courseView, SymbolDB symbolDB, Purpose purpose)
 {
     this.courseView = courseView;
     this.eventDB    = courseView.EventDB;
     this.symbolDB   = symbolDB;
     this.language   = QueryEvent.GetDescriptionLanguage(eventDB);
     this.purpose    = purpose;
 }
 public void QueryDoubleClick(QueryEvent query)
 {
     if (query == null)
     {
         return;                // it the user clicked on an empty query exit here
     }
     _eventAggregator.PublishOnUIThread(new SendTextToEditor(query.Query + "\n", query.DatabaseName));
 }
Exemplo n.º 19
0
        public void AddLegBend()
        {
            Setup("modes\\speciallegs.ppen");

            // Select course 1.
            controller.SelectTab(1);       // Course 1.
            CheckHighlightedLines(controller, -1, -1);

            // Click on leg to select it.
            MapViewer.DragAction dragAction = controller.LeftButtonDown(Pane.Map, new PointF(18.4F, 30.1F), 0.3F);
            Assert.AreEqual(MapViewer.DragAction.DelayedDrag, dragAction);
            controller.LeftButtonClick(Pane.Map, new PointF(18.4F, 30.1F), 0.3F);

            // Begin the add bend mode.
            controller.BeginAddLegBend();

            // Should have crosshair cursor
            ui.MouseMoved(12.2F, 14.4F, 0.3F);
            Cursor cursor = controller.GetMouseCursor(Pane.Map, new PointF(12.2F, 14.4F), 0.3F);

            Assert.AreSame(Cursors.Cross, cursor);

            // And the adding bend text.
            Assert.AreEqual(StatusBarText.AddingBend, controller.StatusText);


            // Check the highlights
            CourseObj[] highlights = (CourseObj[])controller.GetHighlights(Pane.Map);
            Assert.AreEqual(1, highlights.Length);
            Assert.AreEqual(@"Leg:            control:3  course-control:3  scale:1  course-control2:4  path:N(9.1,10.27)--N(12,20)--N(23.65,38.6)",
                            highlights[0].ToString());

            // Click to add a bend.
            dragAction = controller.LeftButtonDown(Pane.Map, new PointF(12.2F, 14.4F), 0.3F);
            Assert.AreEqual(MapViewer.DragAction.None, dragAction);


            // Check the status text
            Assert.AreEqual(StatusBarText.DragCorner, controller.StatusText);
            // Check the cursor
            cursor = controller.GetMouseCursor(Pane.Map, new PointF(12.2F, 14.4F), 0.3F);
            Assert.AreSame(Util.MoveHandleCursor, cursor);

            // Check the highlights
            highlights = (CourseObj[])controller.GetHighlights(Pane.Map);
            Assert.AreEqual(1, highlights.Length);
            Assert.AreEqual("Leg:            control:3  course-control:3  scale:1  course-control2:4  path:N(9.7,10.02)--N(12.2,14.4)--N(12,20)--N(23.65,38.6)",
                            highlights[0].ToString());

            // Make sure the leg has a new bend.
            Leg leg = eventDB.GetLeg(QueryEvent.FindLeg(eventDB, ControlId(3), ControlId(4)));

            Assert.AreEqual(2, leg.bends.Length);
            Assert.AreEqual(new PointF(12.2F, 14.4F), leg.bends[0]);
            Assert.AreEqual(new PointF(12, 20), leg.bends[1]);
            Assert.AreEqual(new PointF(12, 20), leg.flagStartStop);
        }
Exemplo n.º 20
0
        public void QueryEventModelCCTest()
        {
            var r  = CreateRequest();
            var qe = new QueryEvent(r);

            Guid g = new Guid();

            Assert.IsTrue(Guid.TryParse(qe.QueryID, out g), "QueryID not a Guid");
        }
Exemplo n.º 21
0
        public void AddLegGap2()
        {
            Setup("modes\\gappedlegs.coursescribe");

            // Select course 1.
            controller.SelectTab(1);       // Course 1.
            CheckHighlightedLines(controller, -1, -1);

            // Click on leg to select it.
            MapViewer.DragAction dragAction = controller.LeftButtonDown(Pane.Map, new PointF(71, 0), 0.3F);
            Assert.AreEqual(MapViewer.DragAction.DelayedDrag, dragAction);
            controller.LeftButtonClick(Pane.Map, new PointF(71, 0), 0.3F);

            // Begin the add gap mode.
            controller.BeginAddGap();

            // Should have crosshair cursor
            ui.MouseMoved(72, 10, 0.3F);
            Cursor cursor = controller.GetMouseCursor(Pane.Map, new PointF(72, 10), 0.3F);

            Assert.AreSame(Cursors.Cross, cursor);

            // And the adding leg gap text.
            Assert.AreEqual(StatusBarText.AddingLegGap, controller.StatusText);

            // Check the highlights
            CourseObj[] highlights = (CourseObj[])controller.GetHighlights(Pane.Map);
            Assert.AreEqual(1, highlights.Length);
            Assert.AreEqual(@"Leg:            control:1  course-control:1  scale:1  course-control2:2  path:N(73.43,10.02)--N(68,-22)--N(40.52,-22.36)  gaps: (s:2.96,l:3.5) (s:20.96,l:9)",
                            highlights[0].ToString());

            // Click and drag add a gap.
            dragAction = controller.LeftButtonDown(Pane.Map, new PointF(72, 10), 0.3F);
            Assert.AreEqual(MapViewer.DragAction.DelayedDrag, dragAction);
            controller.LeftButtonEndDrag(Pane.Map, new PointF(50, -25), new PointF(72, 10), 0.3F);

            // Check the status text
            ui.MouseMoved(12, -1, 0.1F);
            Assert.AreEqual(StatusBarText.DefaultStatus, controller.StatusText);
            // Check the cursor
            cursor = controller.GetMouseCursor(Pane.Map, new PointF(12, -1), 0.3F);
            Assert.AreSame(Cursors.Default, cursor);

            // Check the highlights
            highlights = (CourseObj[])controller.GetHighlights(Pane.Map);
            Assert.AreEqual(1, highlights.Length);
            Assert.AreEqual(@"Leg:            control:1  course-control:1  scale:1  course-control2:2  path:N(73.43,10.02)--N(68,-22)--N(40.52,-22.36)  gaps: (s:0.25,l:50.26)",
                            highlights[0].ToString());

            // Make sure the leg gap is added.
            Leg leg = eventDB.GetLeg(QueryEvent.FindLeg(eventDB, ControlId(1), ControlId(2)));

            Assert.AreEqual(1, leg.gaps.Length);
            Assert.AreEqual(4.29F, leg.gaps[0].distanceFromStart, 0.01F);
            Assert.AreEqual(50.26F, leg.gaps[0].length, 0.01F);
        }
Exemplo n.º 22
0
        public void AddLegGap3()
        {
            Setup("modes\\gappedlegs.coursescribe");

            // Select course 1.
            controller.SelectTab(1);       // Course 1.
            CheckHighlightedLines(controller, -1, -1);

            // Click on leg to select it.
            MapViewer.DragAction dragAction = controller.LeftButtonDown(Pane.Map, new PointF(20, -5), 0.3F);
            Assert.AreEqual(MapViewer.DragAction.DelayedDrag, dragAction);
            controller.LeftButtonClick(Pane.Map, new PointF(20, -5), 0.3F);

            // Begin the add gap mode.
            controller.BeginAddGap();

            // Should have crosshair cursor
            ui.MouseMoved(32, -5, 0.3F);
            Cursor cursor = controller.GetMouseCursor(Pane.Map, new PointF(32, -5), 0.3F);

            Assert.AreSame(Cursors.Cross, cursor);

            // And the adding leg gap text.
            Assert.AreEqual(StatusBarText.AddingLegGap, controller.StatusText);

            // Check the highlights
            CourseObj[] highlights = (CourseObj[])controller.GetHighlights(Pane.Map);
            Assert.AreEqual(1, highlights.Length);
            Assert.AreEqual(@"Leg:            control:2  course-control:2  scale:1  course-control2:3  path:N(35.72,-20.39)--N(10.18,5.49)",
                            highlights[0].ToString());

            // Click to add a gap.
            dragAction = controller.LeftButtonDown(Pane.Map, new PointF(30, -11), 0.3F);
            Assert.AreEqual(MapViewer.DragAction.DelayedDrag, dragAction);
            controller.LeftButtonClick(Pane.Map, new PointF(30, -11), 0.3F);

            // Check the status text
            ui.MouseMoved(12, -1, 0.1F);
            Assert.AreEqual(StatusBarText.DefaultStatus, controller.StatusText);
            // Check the cursor
            cursor = controller.GetMouseCursor(Pane.Map, new PointF(12, -1), 0.3F);
            Assert.AreSame(Cursors.Default, cursor);

            // Check the highlights
            highlights = (CourseObj[])controller.GetHighlights(Pane.Map);
            Assert.AreEqual(1, highlights.Length);
            Assert.AreEqual(@"Leg:            control:2  course-control:2  scale:1  course-control2:3  path:N(35.72,-20.39)--N(10.18,5.49)  gaps: (s:9.7,l:2)",
                            highlights[0].ToString());

            // Make sure the leg gap is added.
            Leg leg = eventDB.GetLeg(QueryEvent.FindLeg(eventDB, ControlId(2), ControlId(3)));

            Assert.AreEqual(1, leg.gaps.Length);
            Assert.AreEqual(12.52F, leg.gaps[0].distanceFromStart, 0.01F);
            Assert.AreEqual(2.0F, leg.gaps[0].length, 0.01F);
        }
Exemplo n.º 23
0
        void FindForks()
        {
            variationMapping = QueryEvent.GetVariantCodeMapping(eventDB, new CourseDesignator(courseId));

            // Find all forks.
            allForks = new List <Fork>();
            Id <CourseControl> firstCourseControlId = eventDB.GetCourse(courseId).firstCourseControl;

            firstForkInCourse = FindForksToJoin(firstCourseControlId, Id <CourseControl> .None);
        }
Exemplo n.º 24
0
 // Get the description kind to use.
 private DescriptionKind GetDescriptionKind(CourseView courseView)
 {
     if (descPrintSettings.UseCourseDefault)
     {
         return(QueryEvent.GetDefaultDescKind(eventDB, courseView.BaseCourseId));
     }
     else
     {
         return(descPrintSettings.DescKind);
     }
 }
        /// <summary>
        /// 获取对象列表
        /// </summary>
        /// <param name="query">查询对象</param>
        /// <returns>对象列表</returns>
        public sealed override List <DT> GetList(IQuery query)
        {
            IEnumerable <DT> datas = GetDataList(query);

            if (QueryEvent == null)
            {
                return(datas.ToList());
            }
            QueryEvent?.Invoke(ref datas);
            return(datas.ToList());
        }
Exemplo n.º 26
0
        // Describe a special.
        private static TextPart[] DescribeSpecial(EventDB eventDB, Id <Special> specialId, float scaleRatio, DescKind descKind)
        {
            Debug.Assert(descKind == DescKind.Tooltip || descKind == DescKind.DescPane);

            List <TextPart> list    = new List <TextPart>();
            Special         special = eventDB.GetSpecial(specialId);

            // Name of the special.
            list.Add(new TextPart(TextFormat.Title, SpecialName(eventDB, specialId)));

            if (descKind == DescKind.DescPane)
            {
                // Special location.
                if (special.kind == SpecialKind.FirstAid || special.kind == SpecialKind.Water || special.kind == SpecialKind.Forbidden ||
                    special.kind == SpecialKind.OptCrossing || special.kind == SpecialKind.RegMark || special.kind == SpecialKind.Descriptions)
                {
                    list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Location + "  "));
                    list.Add(new TextPart(TextFormat.SameLine, string.Format("({0:##0.0}, {1:##0.0})", special.locations[0].X, special.locations[0].Y)));
                }
            }

            if (special.kind == SpecialKind.Image)
            {
                list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.FileName + "  "));
                list.Add(new TextPart(TextFormat.SameLine, string.Format("{0}", special.text)));
            }

            if (special.kind == SpecialKind.Boundary || special.kind == SpecialKind.Line)
            {
                list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.Length));
                list.Add(new TextPart(TextFormat.SameLine,
                                      string.Format("{0:#,###} m", QueryEvent.ComputeSpecialLength(eventDB, specialId))));
            }

            // Line height for descriptions.
            if (special.kind == SpecialKind.Descriptions)
            {
                list.Add(new TextPart(TextFormat.Header, SelectionDescriptionText.LineHeight + "  "));
                list.Add(new TextPart(TextFormat.SameLine, string.Format("{0:#0.0} mm", Geometry.Distance(special.locations[0], special.locations[1]) / scaleRatio)));
            }

            // Which courses is it used in?
            list.Add(new TextPart(TextFormat.Header, (descKind == DescKind.Tooltip ? SelectionDescriptionText.UsedIn : SelectionDescriptionText.UsedInCourses)));
            if (special.allCourses)
            {
                list.Add(new TextPart(descKind == DescKind.Tooltip ? TextFormat.SameLine : TextFormat.NewLine, SelectionDescriptionText.CourseList_AllCourses));
            }
            else
            {
                list.Add(new TextPart(descKind == DescKind.Tooltip ? TextFormat.SameLine : TextFormat.NewLine, CourseListText(eventDB, special.courses)));
            }

            return(list.ToArray());
        }
Exemplo n.º 27
0
        /// <summary>
        /// Get Object List
        /// </summary>
        /// <param name="query">query model</param>
        /// <returns>object list</returns>
        public sealed override async Task <List <DT> > GetListAsync(IQuery query)
        {
            IEnumerable <DT> datas = await GetDataListAsync(query).ConfigureAwait(false);

            if (QueryEvent == null)
            {
                return(datas.ToList());
            }
            QueryEvent?.Invoke(ref datas);
            return(datas.ToList());
        }
Exemplo n.º 28
0
 public bool Remove(QueryEvent <Boolean> test)
 {
     for (int i = length - 1; i > -1; i--)
     {
         Boolean t = Boolean.ValueOf(Get(i));
         if (test.Hit(t))
         {
             return(RemoveValue(t.BooleanValue()));
         }
     }
     return(false);
 }
Exemplo n.º 29
0
 public bool Find(QueryEvent <Boolean> test)
 {
     for (int i = 0; i < length; i++)
     {
         Boolean t = Boolean.ValueOf(Get(i));
         if (test.Hit(t))
         {
             return(t.BooleanValue());
         }
     }
     return(false);
 }
Exemplo n.º 30
0
 public bool Remove(QueryEvent <Float> test)
 {
     for (int i = length - 1; i > -1; i--)
     {
         Float t = Float.ValueOf(Get(i));
         if (test.Hit(t))
         {
             return(RemoveValue(t.FloatValue()));
         }
     }
     return(false);
 }