public void LTTransfer_IsEqual()
        {
            string getXmlEventResult(uint _startNumber, RaceRun _rr, LiveTimingFIS.LiveTimingFIS _lt)
            {
                var _results = ViewUtilities.ViewToList <RunResultWithPosition>(_rr.GetResultView());
                var _res     = _results.FirstOrDefault(_r => _r.StartNumber == _startNumber);

                return(_lt.getXmlEventResult(_rr, _res));
            }

            string xml;

            LiveTimingFIS.LiveTimingFIS lt = new LiveTimingFIS.LiveTimingFIS();

            TestDataGenerator tg = new TestDataGenerator();
            var rp = tg.createRaceParticipant();

            rp.Participant.Code = "123";
            var r   = tg.Model.GetRace(0);
            var rr1 = r.GetRun(0);

            rr1.SetStartFinishTime(r.GetParticipant(1), new TimeSpan(0, 08, 0, 0, 0), new TimeSpan(0, 08, 0, 0, 100));
            xml = getXmlEventResult(1, rr1, lt);

            var t1 = new LiveTimingFIS.LTTransfer(xml);
            var t2 = new LiveTimingFIS.LTTransfer(xml);

            Assert.IsTrue(t1.IsEqual(t2));

            rr1.SetStartFinishTime(r.GetParticipant(1), new TimeSpan(0, 08, 0, 0, 0), new TimeSpan(0, 08, 0, 0, 110));
            xml = getXmlEventResult(1, rr1, lt);
            var t3 = new LiveTimingFIS.LTTransfer(xml);

            Assert.IsFalse(t1.IsEqual(t3));
        }
        //Calculates whether ShowExpanded for a given WorklfowViewElement should be true or false.
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            ModelItem           modelItem         = (ModelItem)values[0];
            bool                isRootDesigner    = (bool)values[1];
            bool                shouldExpandAll   = (bool)values[2];
            bool                shouldCollapseAll = (bool)values[3];
            bool                expandState       = (bool)values[4];
            bool                pinState          = (bool)values[5];
            WorkflowViewElement viewElement       = (WorkflowViewElement)values[6];

            //Pinstate should be false in following cases (Designer should be unpinned in following cases):
            //1. ExpandAll is not enabled.
            //2. ExpandAll is enabled and ExpandState is true.
            //Similarly for Collapse All.
            if ((!shouldExpandAll || expandState) &&
                (!shouldCollapseAll || !expandState))
            {
                viewElement.PinState = false;
            }
            if (viewElement.IsAncestorOfRootDesigner)
            {
                return(true);
            }
            return(ViewUtilities.ShouldShowExpanded(isRootDesigner, viewElement.DoesParentAlwaysExpandChild(),
                                                    viewElement.DoesParentAlwaysCollapseChildren(), expandState, shouldExpandAll, shouldCollapseAll, viewElement.PinState));
        }
        public void BooleanIcon_False_ShouldReturnFalseIcon()
        {
            var htmlContent = ViewUtilities.BooleanIcon(false);
            var rawHtml     = ConvertHtmlContentToString(htmlContent);

            Assert.IsTrue(rawHtml.Contains("mdi-cancel"));
            Assert.IsTrue(rawHtml.Contains("text-danger"));
        }
        public void GetEnumDescription_DisplayAttribute_ShouldReturnDescription()
        {
            string expected = "Description from DisplayAttribute";
            var    value    = TestEnum.WithDisplayDescription;
            var    actual   = ConvertHtmlContentToString(ViewUtilities.GetEnumDescription(value));

            Assert.AreEqual(expected, actual);
        }
        public void GetEnumDescription_BothAttributes_ShouldReturnDescriptionAttributeValue()
        {
            string expected = "Description from DescriptionAttribute with both";
            var    value    = TestEnum.WithBoth;
            var    actual   = ConvertHtmlContentToString(ViewUtilities.GetEnumDescription(value));

            Assert.AreEqual(expected, actual);
        }
        public void GetEnumDescription_NoAttributes_ShouldReturnNothing()
        {
            string expected = "";
            var    value    = TestEnum.None;
            var    actual   = ConvertHtmlContentToString(ViewUtilities.GetEnumDescription(value));

            Assert.AreEqual(expected, actual);
        }
        public void BooleanIcon_True_ShouldReturnTrueIcon()
        {
            var htmlContent = ViewUtilities.BooleanIcon(true);
            var rawHtml     = ConvertHtmlContentToString(htmlContent);

            Assert.IsTrue(rawHtml.Contains("mdi-check"));
            Assert.IsTrue(rawHtml.Contains("text-success"));
        }
Beispiel #8
0
        public void UpdateInFinish(RaceRun raceRun, RaceParticipant rp)
        {
            SetActiveRaceRun(raceRun);

            var results         = ViewUtilities.ViewToList <RaceResultItem>(raceRun.GetRace().GetTotalResultView());
            var rri4Participant = results.FirstOrDefault(rri => rri.Participant == rp);

            scheduleTransfer(new LTTransfer(getXmlEventResult(raceRun, rri4Participant)));
        }
        public void GetWebsiteVersion_ShouldReturnAnything()
        {
            IHtmlContent htmlContent = ViewUtilities.GetWebsiteVersion();
            string       result      = ConvertHtmlContentToString(htmlContent);

            Assert.IsNotNull(result);
            Assert.IsFalse(string.IsNullOrWhiteSpace(result));
            Assert.IsTrue(result.Contains("."));
        }
Beispiel #10
0
        internal static bool IsRightToLeft(Visual visual)
        {
            Fx.Assert(visual != null, "visual != null");
            Transform trf    = ViewUtilities.GetTransformToRoot(visual) as Transform;
            Matrix    matrix = trf != null ? trf.Value : Matrix.Identity;
            Vector    dir    = new Vector(1, 0); // Point to right.

            dir = matrix.Transform(dir);
            return(dir.X < dir.Y);
        }
        protected void FileGrid_RowEditing(object sender, GridViewEditEventArgs e)
        {
            var primaryKey = (string)FileGrid.DataKeys[e.NewEditIndex].Value;
            var file       = HccApp.CatalogServices.ProductFiles.Find(primaryKey);

            if (!ViewUtilities.DownloadFile(file, HccApp))
            {
                MessageBox1.ShowWarning("The file to download could not be found.");
            }
        }
        public void XmlSerializer_EventResult()
        {
            string getXmlEventResult(uint _startNumber, RaceRun _rr, LiveTimingFIS.LiveTimingFIS _lt)
            {
                var _results = ViewUtilities.ViewToList <RunResultWithPosition>(_rr.GetResultView());
                var _res     = _results.FirstOrDefault(_r => _r.StartNumber == _startNumber);

                return(_lt.getXmlEventResult(_rr, _res));
            }

            string xml;

            LiveTimingFIS.LiveTimingFIS lt = new LiveTimingFIS.LiveTimingFIS();

            TestDataGenerator tg = new TestDataGenerator();
            var rp = tg.createRaceParticipant();

            rp.Participant.Code = "123";

            var r   = tg.Model.GetRace(0);
            var rr1 = r.GetRun(0);

            xml = getXmlEventResult(1, rr1, lt);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/@bib", xml, "1");
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/@correction", xml, "y");
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/time", xml, "0.00");

            rr1.SetStartFinishTime(r.GetParticipant(1), new TimeSpan(0, 08, 0, 0, 0), new TimeSpan(0, 08, 0, 0, 100));
            xml = getXmlEventResult(1, rr1, lt);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/time", xml, "0.10");

            rr1.SetStartFinishTime(r.GetParticipant(1), new TimeSpan(0, 08, 0, 0, 0), new TimeSpan(0, 08, 0, 30, 100));
            xml = getXmlEventResult(1, rr1, lt);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/time", xml, "30.10");

            rr1.SetStartFinishTime(r.GetParticipant(1), new TimeSpan(0, 08, 0, 0, 0), new TimeSpan(0, 08, 1, 30, 100));
            xml = getXmlEventResult(1, rr1, lt);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/finish/time", xml, "1:30.10");

            rr1.SetResultCode(r.GetParticipant(1), RunResult.EResultCode.DIS);
            xml = getXmlEventResult(1, rr1, lt);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/dq/@bib", xml, "1");

            rr1.SetResultCode(r.GetParticipant(1), RunResult.EResultCode.NaS);
            xml = getXmlEventResult(1, rr1, lt);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/dns/@bib", xml, "1");

            rr1.SetResultCode(r.GetParticipant(1), RunResult.EResultCode.NQ);
            xml = getXmlEventResult(1, rr1, lt);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/dns/@bib", xml, "1");

            rr1.SetResultCode(r.GetParticipant(1), RunResult.EResultCode.NiZ);
            xml = getXmlEventResult(1, rr1, lt);
            XmlAssertion.AssertXPathEvaluatesTo("/livetiming/raceevent/dnf/@bib", xml, "1");
        }
Beispiel #13
0
        public override void ExecuteResult(ControllerContext context)
        {
            var encoding = Encoding.UTF8;

            ViewUtilities.SetupHttpHeadersForDownload(context.HttpContext.Response, FileDescriptor, encoding);
            //var preamble = encoding.GetPreamble();
            var csvBytes = encoding.GetBytes(CsvContents);

            //context.HttpContext.Response.BinaryWrite(preamble);
            context.HttpContext.Response.BinaryWrite(csvBytes);
        }
Beispiel #14
0
        private async Task ProcessNavigationForAbsoulteUri(Queue <string> segments, IParameters parameters)
        {
            if (segments.Count == 0)
            {
                return;
            }

            (var view, var segmentParameters) = await ProcessSegmentAsync(null, segments, parameters).ConfigureAwait(false);

            _rootNavigationController.View = view;

            ViewUtilities.OnNavigatedTo(view, segmentParameters);
            await ProcessNavigation(view, segments, parameters);
        }
Beispiel #15
0
        private async Task ProcessNavigation(View currentView, Queue <string> segments, IParameters parameters)
        {
            if (segments.Count == 0)
            {
                return;
            }

            (var view, var segmentParameters) = await ProcessSegmentAsync(currentView, segments, parameters).ConfigureAwait(false);

            NavigationView.Navigate(currentView, view);
            ViewUtilities.OnNavigatedFrom(currentView, segmentParameters);
            ViewUtilities.OnNavigatedTo(view, segmentParameters);

            await ProcessNavigation(view, segments, parameters).ConfigureAwait(false);
        }
Beispiel #16
0
        private async Task <(View view, IParameters segmentParameters)> ProcessSegmentAsync(View currentView, Queue <string> segments, IParameters parameters)
        {
            var nextSegment = segments.Dequeue();

            var segmentParameters = UriParsingHelper.GetSegmentParameters(nextSegment, parameters);

            if (currentView != null && !await ViewUtilities.CanNavigateAsync(currentView, parameters))
            {
                throw new NavigationException(NavigationException.ViewCannotNavigate);
            }

            var view = CreateViewFor(UriParsingHelper.GetSegmentName(nextSegment));

            ViewUtilities.Initialize(view, segmentParameters);

            return(view, segmentParameters);
        }
        public DialogServiceControl()
        {
            InitializeComponent();

            var vm = ViewUtilities.SetDataContext <DialogServiceViewModel>(this);

            if (vm != null)
            {
                vm.ShowDialogRequested         += Vm_ShowDialogRequested;
                vm.ShowProgressDialogRequested += Vm_ShowProgressDialogRequested;
                vm.ShowFileDialogRequested     += Vm_ShowFileDialogRequested;
                vm.ShowMessageDialogRequested  += Vm_ShowMessageDialogRequested;
                vm.DispatchToUIThreadRequested += Vm_DispatchToUIThreadRequested;
            }

            if (!DesignerProperties.GetIsInDesignMode(this))
            {
                if (DependencyContainer.IsTypeRegistered <IDialogCreator>())
                {
                    this.dialogCreator = DependencyContainer.Get <IDialogCreator>();
                }
            }
        }
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values[0] != DependencyProperty.UnsetValue && values[1] != DependencyProperty.UnsetValue)
            {
                bool isExpanded               = (bool)values[0];
                bool isPinned                 = (bool)values[1];
                bool shouldExpandAll          = (bool)values[2];
                bool shouldCollapseAll        = (bool)values[3];
                ExpandableItemWrapper wrapper = (ExpandableItemWrapper)values[4];

                if ((!shouldExpandAll || isExpanded) &&
                    (!shouldCollapseAll || !isExpanded))
                {
                    wrapper.SetPinState(false);
                }

                return(ViewUtilities.ShouldShowExpanded(isExpanded, shouldExpandAll, shouldCollapseAll, wrapper.IsPinned));
            }
            else
            {
                return(false);
            }
        }
Beispiel #19
0
        public void UpdateResults(RaceRun raceRun)
        {
            if (!raceRun.HasResults())
            {
                return;
            }

            SetActiveRaceRun(raceRun);

            var results = ViewUtilities.ViewToList <RunResultWithPosition>(raceRun.GetResultView());

            RunResultWithPosition lastRR = null;

            foreach (var rr in results)
            {
                if (rr.ResultCode == RunResult.EResultCode.NotSet)
                {
                    continue;
                }

                scheduleTransfer(new LTTransfer(getXmlEventResult(raceRun, rr)));

                if (lastRR == null ||
                    (lastRR.StartTime != null && rr.StartTime != null && lastRR.StartTime < rr.StartTime)
                    )
                {
                    lastRR = rr;
                }
            }

            // Update livetiming with last known time
            if (lastRR != null)
            {
                scheduleTransfer(new LTTransfer(getXmlEventResult(raceRun, lastRR)));
            }
        }
 internal bool DoesParentAlwaysCollapseChildren()
 {
     return(ViewUtilities.DoesParentAlwaysCollapseChildren(this.ModelItem, this.Context));
 }
 internal bool DoesParentAlwaysExpandChild()
 {
     return(ViewUtilities.DoesParentAlwaysExpandChildren(this.ModelItem, this.Context));
 }
Beispiel #22
0
        static int QueryTypeCode(string logicalName, IOrganizationService service)
        {
            var typecode = ViewUtilities.Metadata(logicalName, service)?.ObjectTypeCode;

            return(typecode == null ? throw new Exception($"TypeCode for entity '{logicalName}' not found in metadata.") : (int)typecode);
        }
Beispiel #23
0
        public TesMenuControl()
        {
            InitializeComponent();

            ViewUtilities.SetDataContext <TestMenuControlViewModel>(this);
        }
Beispiel #24
0
        public DataGridTestControl()
        {
            InitializeComponent();

            ViewUtilities.SetDataContext <DataGridTestControlViewModel>(this);
        }
Beispiel #25
0
 public SetupViewModel(DatabaseModel databaseModel, SettingsModel settingsModel, ViewUtilities viewUtilities)
 {
     this.DatabaseModel = databaseModel;
     this.SettingsModel = settingsModel;
     this.ViewUtilities = viewUtilities;
 }
Beispiel #26
0
    public static SetupView CreateView(DatabaseModel databaseModel, SettingsModel settingsModel, ViewUtilities viewUtilities)
    {
        var setupViewModel = new SetupViewModel(databaseModel, settingsModel, viewUtilities);
        var setupView      = new SetupView();

        setupView.DataContext = setupViewModel;
        return(setupView);
    }