Beispiel #1
0
            public Breadcrumb GetFirst()
            {
                var result = ListHead;

                ListHead = ListHead.NextListElem;
                return(result);
            }
Beispiel #2
0
 public Breadcrumb(Vector3I position, int cost, int pathCost, Breadcrumb next)
 {
     Position = position;
     Cost     = cost;
     PathCost = pathCost;
     Next     = next;
 }
Beispiel #3
0
        /// <summary>
        /// <para>Credit for the original code to Roy T. - http://roy-t.nl/2011/09/24/another-faster-version-of-a-2d3d-in-c.html</para>
        /// <para>This was modified and adapted to suit the needs of this mod, which changes the specific end vector to an "outside of grid" target.</para>
        /// <para>Also made into a separate thread.</para>
        /// </summary>
        private void ThreadRun()
        {
            // generate crumbs and path cost
            crumb = PathfindGenerateCrumbs(selectedGrid, ref startPosition);

            // cleanup after PathfindGenerateCrumbs(), not critical but helps memory a tiny bit
            scanned.Clear();
            openList.Clear();

            if (crumb != null)
            {
                while (crumb.Next != null)
                {
                    if (ShouldCancelTask)
                    {
                        return;
                    }

                    lines.Add(new Line()
                    {
                        Start = crumb.Next.Position,
                        End   = crumb.Position,
                    });

                    crumb = crumb.Next;
                }
            }
        }
Beispiel #4
0
    void LayPath()
    {
        foreach (var milestone in milestones)
        {
            Circle  opportunity = Circle.New(milestone, 15f);
            Vector3 position    = opportunity.RandomContainedPoint();

            Breadcrumb breadcrumb = new Breadcrumb();
            breadcrumb.position           = position;
            breadcrumb.remaining_distance = Vector3.Distance(transform.position, position);
            path.Add(breadcrumb);

            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.name = "Crumb";
            cube.transform.position = breadcrumb.position;
        }

        Circle  main_target    = Circle.New(target.transform.position, 15f);
        Vector3 final_position = main_target.RandomContainedPoint();

        Breadcrumb last_crumb = new Breadcrumb();

        last_crumb.position           = final_position;
        last_crumb.remaining_distance = Vector3.Distance(transform.position, final_position);
        path.Add(last_crumb);
    }
Beispiel #5
0
        public JObject ToJObjectWithBreadcrumb(Exception exception)
        {
            var jobject = JObject.FromObject(exception, Serializer);

            if (GetConfig().Enabled == false)
            {
                return(jobject);
            }

            var breadcrumbTarget = jobject.Property("RemoteStackTraceString");

            breadcrumbTarget = breadcrumbTarget?.Value.Type == JTokenType.String ? breadcrumbTarget : jobject.Property("StackTraceString");

            if (breadcrumbTarget == null)
            {
                jobject.Add("StackTraceString", null);
                breadcrumbTarget = jobject.Property("StackTraceString");
            }

            var breadcrumb = new Breadcrumb
            {
                ServiceName    = CurrentApplicationInfo.Name,
                ServiceVersion = CurrentApplicationInfo.Version.ToString(),
                HostName       = CurrentApplicationInfo.HostName
            };

            if (exception is SerializableException serEx)
            {
                serEx.AddBreadcrumb(breadcrumb);
            }

            breadcrumbTarget.Value = $"\r\n--- End of stack trace from {breadcrumb} ---\r\n{breadcrumbTarget.Value}";

            return(jobject);
        }
        public Breadcrumb ResolveProductPage(Breadcrumb breadcrumb)
        {
            if (this.siteContext.IsProduct)
            {
                var productSegmentIndex  = breadcrumb.PageLinks.FindIndex(pageLink => pageLink.Title == "*");
                var categorySegmentIndex = breadcrumb.PageLinks.FindIndex(
                    pageLink => pageLink.Title.Equals("product", StringComparison.InvariantCultureIgnoreCase));

                var currentProduct = this.siteContext.CurrentProductItem;
                var productName    = currentProduct?.DisplayName;
                var categoryName   = this.GetProductCategory(currentProduct)?.DisplayName;

                if (productSegmentIndex != -1 && !string.IsNullOrEmpty(productName))
                {
                    breadcrumb.PageLinks[productSegmentIndex] = new PageLink
                    {
                        Title = productName,
                        Link  = ""
                    };
                }

                if (categorySegmentIndex != -1 && !string.IsNullOrEmpty(categoryName))
                {
                    var shopPageUrl     = LinkManager.GetItemUrl(this.GetShopPage());
                    var categoryPageUrl = $"{shopPageUrl}/{categoryName}";
                    breadcrumb.PageLinks[categorySegmentIndex] = new PageLink
                    {
                        Title = categoryName,
                        Link  = categoryPageUrl
                    };
                }
            }

            return(breadcrumb);
        }
Beispiel #7
0
        public void VerifyDefaultBreadcrumb()
        {
            Breadcrumb breadcrumb = null;

            RunOnUIThread.Execute(() =>
            {
                breadcrumb     = new Breadcrumb();
                var stackPanel = new StackPanel();
                stackPanel.Children.Add(breadcrumb);

                Content = stackPanel;
                Content.UpdateLayout();
            });

            IdleSynchronizer.Wait();

            RunOnUIThread.Execute(() =>
            {
                ItemsRepeater breadcrumbItemsRepeater = (ItemsRepeater)breadcrumb.FindVisualChildByName("PART_BreadcrumbItemsRepeater");
                Verify.IsNotNull(breadcrumbItemsRepeater, "The underlying items repeater could not be retrieved");

                var breadcrumbNode1 = breadcrumbItemsRepeater.TryGetElement(1);
                Verify.IsNull(breadcrumbNode1, "There should be no items.");
            });
        }
Beispiel #8
0
        /// <summary>
        /// Converts the TreeNode into a breadcrumb.
        /// </summary>
        /// <param name="Page">The Page</param>
        /// <param name="IsCurrentPage">If the page is the current page</param>
        /// <returns></returns>
        public async Task <Breadcrumb> PageToBreadcrumbAsync(TreeNode Page, bool IsCurrentPage)
        {
            Breadcrumb breadcrumb = _Mapper.Map <Breadcrumb>(Page);

            breadcrumb.IsCurrentPage = IsCurrentPage;
            return(breadcrumb);
        }
        async Task postRequest(HttpResponseMessage response)
        {
            var crumb = new Breadcrumb("ApiService");

            crumb.Level   = BreadcrumbLevel.Info;
            crumb.Message = $"Received {response.RequestMessage.Method} {apiAddress}{response.RequestMessage.RequestUri.ToString()}";
            crumb.Data    = response.Headers.ToDictionary(x => x.Key, v => String.Join(" ", v.Value));

            //Add body if any
            if (response.Content != null)
            {
                crumb.Data.Add("Body", await response.Content.ReadAsStringAsync());
            }

            if (response.Headers.Contains("X-USER-TOKEN"))
            {
                var token = response.Headers.GetValues("X-USER-TOKEN").ElementAt(0);

                context.Response.Cookies.Append("access_token", token,
                                                new CookieOptions()
                {
                    Path     = "/",
                    Domain   = context.Request.Host.Host,
                    HttpOnly = false,
                    Secure   = false,
                    Expires  = DateTimeOffset.Now.AddDays(14)
                });
            }
        }
Beispiel #10
0
        public IActionResult Details(int id)
        {
            if (checkUserPermissionToApp.Invoke(LoggedUser.UserModel.Id, id))
            {
                Breadcrumb.Add("Application details", "Details", "Application");

                var app = getApp.Invoke(id);

                if (app == null)
                {
                    return(View("Error"));
                }

                var appModel = new AppViewModel {
                    Id = app.Id, Name = app.Name
                };

                var listUsers     = ListUsers(id);
                var combinedModel = new CombinedAppUserDetailsViewModel(appModel)
                {
                    Users = listUsers
                };

                return(View(combinedModel));
            }

            Alert.Danger("You don't have permission!");
            return(RedirectToAction("Index"));
        }
Beispiel #11
0
        public void NetworkBreadcrumbJsonTest()
        {
            // Network,         // 2 - network breadcrumb    ; [verb,url,...,statusCode,errorCode]
            DateTime now = DateTime.UtcNow;
            // Yes, TimeUtils.ISO8601DateString for Endpoint and TimeUtils.GMTDateString for Breadcrumb is odd.
            Endpoint endpoint1 = new Endpoint(
                "POST",
                "http://www.mrscritter.com",
                TimeUtils.ISO8601DateString(now),
                433,
                3213,
                2478,
                HttpStatusCode.OK,
                WebExceptionStatus.Success);
            Breadcrumb breadcrumb1 = new Breadcrumb(TimeUtils.GMTDateString(now), BreadcrumbType.Network, endpoint1);
            // Testing BreadcrumbConverter WriteJson
            string json1 = JsonConvert.SerializeObject(breadcrumb1);

            // NOTE: VS editor syntax colors embedded URL, but the C# syntax is correct.
            Assert.IsTrue(json1.IndexOf(",2,[\"POST\",\"http://www.mrscritter.com") >= 0);
            Assert.IsTrue(json1.IndexOf(",433,2,3213,2478,200,5,0]]") >= 0);
            string json2 = JsonConvert.SerializeObject(breadcrumb1, Formatting.None, new BreadcrumbConverter());

            Debug.WriteLine("json1 == " + json1);
            Debug.WriteLine("json2 == " + json2);
            Assert.AreEqual(json1, json2);
            // Testing BreadcrumbConverter ReadJson
            Breadcrumb breadcrumb2 = JsonConvert.DeserializeObject(json1, typeof(Breadcrumb)) as Breadcrumb;

            Assert.IsNotNull(breadcrumb2);
            string json3 = JsonConvert.SerializeObject(breadcrumb2);

            Debug.WriteLine("json3 == " + json3);
            Assert.AreEqual(json1, json3);
        }
Beispiel #12
0
        public static MvcHtmlString MakeBreadcrumb(this HtmlHelper helper)
        {
            UrlHelper  url = new UrlHelper(helper.ViewContext.RequestContext);
            Breadcrumb bc  = new Breadcrumb(url, helper.ViewContext.RouteData.DataTokens, helper.ViewContext.RouteData.Values);

            return(MvcHtmlString.Create(bc.HtmlCode.ToString()));
        }
Beispiel #13
0
    // Unity

    private void Awake()
    {
        if (haunt != null)
        {
            has_objective          = true;
            candle_light.color     = candle_color;
            candle_light.intensity = candle_intensity;
            candle_light.range     = candle_range;

            // Create a circle around our haunt

            Circle haunting_circle = Circle.New(haunt.position, haunt_radius);

            for (int i = haunting_circle.VertexCount - 1; i <= 0; i--)
            {
                path.Add(CreateBreadcrumb(haunting_circle.Vertices[i]));
            }

            foreach (var point in haunting_circle.Vertices)
            {
                path.Add(CreateBreadcrumb(point));
            }
            looping_path       = true;
            transform.position = path[0].position;
            current_objective  = path[0];
        }
    }
Beispiel #14
0
        internal void AddBreadcrumb(HttpApplication httpApplication)
        {
            if (httpApplication == null)
            {
                return;
            }

            HttpRequest request = httpApplication.Context.Request;

            if (request == null)
            {
                return;
            }

            HttpResponse response = httpApplication.Context.Response;

            if (response == null)
            {
                return;
            }

            Breadcrumb breadcrumb = new Breadcrumb();

            breadcrumb.Event      = BreadcrumbEvent.Request;
            breadcrumb.CustomData = new Dictionary <string, string>()
            {
                { "method", request.HttpMethod },
                { "url", request.Url.ToString() },
                { "status", response.StatusDescription },
                { "session", TryGetSessionId(request, response) }
            };

            base.AddBreadcrumb(breadcrumb);
        }
Beispiel #15
0
    /// <summary>
    /// Checks if there is a valid node in Direction d of the passed Vector3 v
    /// </summary>
    /// <param name="v">The main vector we are checking</param>
    /// <param name="d">The direction from the root vector v we are checking</param>
    /// <returns>If a valid vector is found, returns that. Otherwise, returns an invalid vector Vector3.down (we don't care about vectors in the Y direction for 2D searching)</returns>
    Breadcrumb CheckNode(Breadcrumb crumb, Direction d)
    {
        Breadcrumb result = null;
        int        X      = (int)crumb.coordinates.x;
        int        Y      = (int)crumb.coordinates.y;

        switch (d)
        {
        case Direction.North:       result = Map.GetCrumb(X, Y + 1);        break;

        case Direction.South:       result = Map.GetCrumb(X, Y - 1);        break;

        case Direction.East:        result = Map.GetCrumb(X + 1, Y);        break;

        case Direction.West:        result = Map.GetCrumb(X - 1, Y);        break;

        case Direction.NorthEast:   result = Map.GetCrumb(X + 1, Y + 1);    break;

        case Direction.NorthWest:   result = Map.GetCrumb(X - 1, Y + 1);    break;

        case Direction.SouthEast:   result = Map.GetCrumb(X + 1, Y - 1);    break;

        case Direction.SouthWest:   result = Map.GetCrumb(X - 1, Y - 1);    break;
        }
        return(result);
    }
Beispiel #16
0
    /// <summary>
    /// Add breadcrumb by providing Breadcrumb object
    /// </summary>
    /// <param name="breadcrumb">Breadcrumb</param>
    public void AddBreadcrumb(Breadcrumb breadcrumb)
    {
        string json           = breadcrumb.ToJson();
        long   breadcrumbSize = Encoding.UTF8.GetBytes(json).Length;

        // might have to async this entire piece - since order is not important and this might block a render thread
        // it might not even be worth it to lock on this - although linkedlist is not threadsafe it might be better to use a ConcurrentQueue: https://docs.microsoft.com/en-us/dotnet/api/system.collections.concurrent.concurrentqueue-1?view=net-5.0
        // note that this cannot be answered without doing meaningful tests.
        lock (syncLock)
        {
            breadcrumbsByteSize += breadcrumbSize;

            // pop breadcrumbs until there's enough space
            while (breadcrumbsByteSize > maxFileSize)
            {
                string toBePurged = breadcrumbs.First.Value;
                breadcrumbs.RemoveFirst();
                breadcrumbsByteSize -= Encoding.UTF8.GetBytes(toBePurged).Length;
            }

            breadcrumbs.AddLast(json);

            // if a write has been sheduled, the previous record will be written when it triggers, so don't schedule another
            if (autoWrite && !writeScheduled)
            {
                writeScheduled = true;
                Task.Delay(waitBeforeWrite).ContinueWith(t =>
                {
                    this.Write();
                });
            }
        }
    }
Beispiel #17
0
 public BreadcrumbCollector(Breadcrumb item, int totalBreadcrumbsize, int maxTotalBreadcrumbsize, string nodeName)
 {
     this.item = item;
     this.totalBreadcrumbsize    = totalBreadcrumbsize;
     this.maxTotalBreadcrumbsize = maxTotalBreadcrumbsize;
     this.nodeName = nodeName;
 }
        /// <summary>
        /// Converts the TreeNode into a breadcrumb.
        /// </summary>
        /// <param name="Page">The Page</param>
        /// <param name="IsCurrentPage">If the page is the current page</param>
        /// <returns></returns>
        public Breadcrumb PageToBreadcrumb(TreeNode Page, bool IsCurrentPage)
        {
            Breadcrumb breadcrumb = _Mapper.Map <Breadcrumb>(Page);

            breadcrumb.IsCurrentPage = IsCurrentPage;
            return(breadcrumb);
        }
        public void ResolveCategoryPage_ShouldReturnBreadcrumbWithCorrectPageLinkTitles(
            string[] initialTitles,
            string[] expectedTitles)
        {
            // arrange
            var categoryItem = this.SitecoreTree.GetItem(CategoryId);

            this.SiteContext.IsCategory.Returns(x => true);
            this.SiteContext.CurrentCategoryItem.Returns(x => categoryItem);

            var initialPageLinks = initialTitles.Select(title => new PageLink {
                Title = title, Link = ""
            }).ToList();
            var breadcrumb = new Breadcrumb
            {
                PageLinks = initialPageLinks
            };

            // act
            var result       = this.BreadcrumbService.ResolveCategoryPage(breadcrumb);
            var resultTitles = result.PageLinks.Select(p => p.Title).ToArray();

            // assert
            Assert.Equal(expectedTitles, resultTitles);
        }
Beispiel #20
0
        public void UserBreadcrumbJsonTest()
        {
            // Text,            // 1 - user breadcrumb       ; {text:,level:}
            DateTime now = DateTime.UtcNow;
            // Yes, TimeUtils.ISO8601DateString for Endpoint and TimeUtils.GMTDateString for Breadcrumb is odd.
            Dictionary <string, Object> data1 = new Dictionary <string, Object>();

            data1["text"]  = "Critter Bowl is Empty!";
            data1["level"] = (int)BreadcrumbTextType.Urgent;
            Breadcrumb breadcrumb1 = new Breadcrumb(TimeUtils.GMTDateString(now), BreadcrumbType.Text, data1);
            // Testing BreadcrumbConverter WriteJson
            string json1 = JsonConvert.SerializeObject(breadcrumb1);

            // We don't assume Dictionary key-value pairs appear in any particular order.
            Assert.IsTrue(json1.IndexOf("\"text\":\"Critter Bowl is Empty!\"") >= 0);
            Assert.IsTrue(json1.IndexOf("\"level\":1") >= 0);
            Assert.IsTrue(json1.IndexOf(",1,{") >= 0);
            Assert.IsTrue(json1.IndexOf("}]") >= 0);
            string json2 = JsonConvert.SerializeObject(breadcrumb1, Formatting.None, new BreadcrumbConverter());

            Debug.WriteLine("json1 == " + json1);
            Debug.WriteLine("json2 == " + json2);
            Assert.AreEqual(json1, json2);
            // Testing BreadcrumbConverter ReadJson
            Breadcrumb breadcrumb2 = JsonConvert.DeserializeObject(json1, typeof(Breadcrumb)) as Breadcrumb;

            Assert.IsNotNull(breadcrumb2);
            string json3 = JsonConvert.SerializeObject(breadcrumb2);

            Debug.WriteLine("json3 == " + json3);
            Assert.AreEqual(json1, json3);
        }
Beispiel #21
0
        internal void UpdateBreadcrumb(HttpApplication httpApplication)
        {
            if (httpApplication == null)
            {
                return;
            }

            HttpRequest request = httpApplication.Context.Request;

            if (request == null)
            {
                return;
            }

            HttpResponse response = httpApplication.Context.Response;

            if (response == null)
            {
                return;
            }

            Breadcrumb breadcrumb = LogifyAlert.Instance.Breadcrumbs.Where(b =>
                                                                           b.GetIsAuto() &&
                                                                           b.Event == BreadcrumbEvent.Request &&
                                                                           b.CustomData != null &&
                                                                           b.CustomData["method"] == request.HttpMethod &&
                                                                           b.CustomData["url"] == request.Url.ToString() &&
                                                                           b.CustomData["session"] == TryGetSessionId(request, response)
                                                                           ).First();

            if (breadcrumb != null)
            {
                breadcrumb.CustomData["status"] = "Failed";
            }
        }
Beispiel #22
0
        /// <summary>
        /// Handler for drop events on breadcrumbs. Moves the dropped node into the target group,
        /// if appropriate.
        /// </summary>
        /// <param name="sender">The element receiving the drop event.</param>
        /// <param name="e">DragEventArgs for the drop.</param>
        private async void Breadcrumb_Drop(object sender, DragEventArgs e)
        {
            // First get the group we are dropping onto...
            FrameworkElement senderElement = sender as FrameworkElement;

            DebugHelper.Assert(senderElement != null);

            Breadcrumb thisBreadcrumb = senderElement.DataContext as Breadcrumb;

            DebugHelper.Assert(thisBreadcrumb != null);

            IKeePassGroup thisGroup = thisBreadcrumb.Group;

            DebugHelper.Assert(thisGroup != null);

            DragOperationDeferral deferral = e.GetDeferral();

            // Get the UUID of the dropped node - if possible, move it into this group.
            string encodedUuid = await e.DataView.GetTextAsync();

            if (thisGroup.TryAdopt(encodedUuid))
            {
                DebugHelper.Trace($"Successfully moved node {encodedUuid} to new parent {thisGroup.Uuid.EncodedValue}");
                e.AcceptedOperation = DataPackageOperation.Move;
            }
            else
            {
                DebugHelper.Trace($"WARNING: Unable to locate dropped node {encodedUuid}");
                e.AcceptedOperation = DataPackageOperation.None;
            }

            e.Handled = true;
            deferral.Complete();
        }
Beispiel #23
0
        public async Task Invoke(HttpContext context)
        {
            logger.LogInformation($"{context.Request.Path}\tRECEIVED");
            var sw = new Stopwatch();

            sw.Start();

            var crumb = new Breadcrumb("LoggerMiddleware");

            crumb.Message = $"{context.Request.Method} {context.Request.Path}{context.Request.QueryString.ToUriComponent()}";
            crumb.Data    = new Dictionary <string, string>()
            {
                { "IsAuthenticated", context.User.Identity.IsAuthenticated.ToString() },
                { "Authentication", context.User.Identity.IsAuthenticated ? context.User.Identity.Name : "Unknown" }
            };
            raven.AddTrail(crumb);

            try
            {
                await _next.Invoke(context);
            }
            catch (Exception e)
            {
                //Log exception with RavenClient
                await raven.CaptureNetCoreEventAsync(e);
            }

            sw.Stop();
            logger.LogInformation($"{context.Request.Path}\t{sw.Elapsed.TotalMilliseconds}(ms)");
        }
        public override void AddBreadcrumbImpl(Breadcrumb breadcrumb)
        {
            var level     = GetBreadcrumbLevel(breadcrumb.Level);
            var timestamp = GetTimestamp(breadcrumb.Timestamp);

            SentryCocoaBridgeProxy.SentryNativeBridgeAddBreadcrumb(timestamp, breadcrumb.Message, breadcrumb.Type, breadcrumb.Category, level);
        }
Beispiel #25
0
 public void AddBreadcrumb(Breadcrumb breadcrumb)
 {
     _options.DiagnosticLogger?.Log(SentryLevel.Debug,
                                    "{0} Scope Sync - Adding breadcrumb m:\"{1}\" l:\"{2}\"", null, _name,
                                    breadcrumb.Message, breadcrumb.Level);
     AddBreadcrumbImpl(breadcrumb);
 }
        public async Task AddInternalBreadcrumb_DuplicatedIs2SecondsAhead_BreadcrumbAdded()
        {
            //Assert
            const string message = "message";
            const string type    = "type";
            var          data    = new Dictionary <string, string> {
                { "key", "value" }
            };
            var logger  = Substitute.For <IDiagnosticLogger>();
            var hub     = Sut;
            var options = new SentryXamarinOptions();

            options.Debug            = true;
            options.DiagnosticLogger = logger;

            var breadcrumb = new Breadcrumb(message, type, data);
            await Task.Delay(3000);

            options.LastInternalBreadcrumb = breadcrumb;

            //Act
            hub.AddInternalBreadcrumb(options, message, null, type, data);

            //Assert
            logger.DidNotReceive().Log(Arg.Any <SentryLevel>(), Arg.Is <string>(IHubExtensions.DuplicatedBreadcrumbDropped), Arg.Any <Exception>(), Arg.Any <object[]>());
            Assert.NotEqual(breadcrumb, options.LastInternalBreadcrumb);
        }
Beispiel #27
0
        void LogMouse(IDictionary <string, string> properties, FrameworkElement source, MouseButtonEventArgs e, bool isUp)
        {
            properties["ButtonState"] = e.ButtonState.ToString();
            properties["mouseButton"] = e.ChangedButton.ToString();
            properties["ClickCount"]  = e.ClickCount.ToString();
            Breadcrumb item = new Breadcrumb();

            if (e.ClickCount == 2)
            {
                properties["action"] = "doubleClick";
                item.Event           = BreadcrumbEvent.MouseDoubleClick;
            }
            else if (isUp)
            {
                properties["action"] = "up";
                item.Event           = BreadcrumbEvent.MouseUp;
            }
            else
            {
                properties["action"] = "down";
                item.Event           = BreadcrumbEvent.MouseDown;
            }
            CollectMousePosition(properties, source, e);
            item.CustomData = properties;

            AddBreadcrumb(item);
        }
Beispiel #28
0
        public IActionResult AddUser(int appId)
        {
            Breadcrumb.Add("Add user", "AddUser", "Application");
            ViewData["appId"] = appId;

            return(View("AddUser"));
        }
Beispiel #29
0
        /// <summary>
        /// Handler for DragEnter events on breadcrumbs. Updates the AcceptedOperation
        /// property of <paramref name="e"/> based on the drop target.
        /// </summary>
        /// <param name="sender">The element receiving the DragEnter event.</param>
        /// <param name="e">DragEventArgs for the drag.</param>
        private async void Breadcrumb_DragEnter(object sender, DragEventArgs e)
        {
            // Get the group we are currently over...
            FrameworkElement senderElement = sender as FrameworkElement;

            DebugHelper.Assert(senderElement != null);

            Breadcrumb thisBreadcrumb = senderElement.DataContext as Breadcrumb;

            DebugHelper.Assert(thisBreadcrumb != null);

            IKeePassGroup thisGroup = thisBreadcrumb.Group;

            DebugHelper.Assert(thisGroup != null);

            // Update the DataPackageOperation of the drag event based on whether
            // we are dragging a node over a group (generally, yes).
            DragOperationDeferral deferral = e.GetDeferral();

            string text = await e.DataView.GetTextAsync();

            if (!String.IsNullOrWhiteSpace(text) && thisGroup.CanAdopt(text))
            {
                e.AcceptedOperation = DataPackageOperation.Move;
                e.Handled           = true;
            }

            deferral.Complete();
        }
Beispiel #30
0
        public Breadcrumb Swap(Breadcrumb lineage)
        {
            Region = lineage.Authority;
            Authority = lineage.Locality;
            Locality = lineage.Organisation;

            return this;
        }
Beispiel #31
0
    // private


    Breadcrumb CreateBreadcrumb(Vector3 objective)
    {
        Breadcrumb breadcrumb = new Breadcrumb();

        breadcrumb.position           = objective;
        breadcrumb.remaining_distance = Vector3.Distance(transform.position, objective);
        return(breadcrumb);
    }
        public When_created_from_comparison_result_of_different_types()
        {
            var a = new A { Int32Value = 32, StringValue = "S1" };
            var b = new B { Int64Value = 64, StringValue = "S2" };

            var breadcrumbUpdate = new Breadcrumb(null, StringValuePropertyA, StringValuePropertyB, new DynamicObject(a), a, new DynamicObject(b), b, () => "ValueS");
            var breadcrumbInsert = new Breadcrumb(null, null, Int64ValueProperty, new DynamicObject(a), a, new DynamicObject(b), b, () => "Value64");
            var breadcrumbDelete = new Breadcrumb(null, Int32ValueProperty, null, new DynamicObject(a), a, new DynamicObject(b), b, () => "Value32");

            var deltas = new[]
            {
                new Delta(ChangeType.Update, breadcrumbUpdate, "S1", "S2", "vS1", "vS2"),
                new Delta(ChangeType.Delete, breadcrumbDelete, 32, null, "v32", "NULL"),
                new Delta(ChangeType.Insert, breadcrumbInsert, null, 64, "NULL", "v64"),
            };

            result = new ComparisonResult(a.GetType(), b.GetType(), deltas).AsSimpleResult();
        }
Beispiel #33
0
    /// <summary>
    /// Spawns the breadcrumb.
    /// </summary>
    protected void HandleBreadcrumbSpawn()
    {
        if (currentTime >= spawnInterval)
        {
            if (breadcrumbPrefab != null)
            {
                // Spawn breadcrumb
                GameObject breadcrumb = (GameObject) Instantiate(breadcrumbPrefab,
                    new Vector3(transform.position.x, transform.position.y + heightOffset, transform.position.z),
                    breadcrumbPrefab.transform.rotation);

                breadcrumbCount++;
                breadcrumb.name = "Breadcrumb" + breadcrumbCount;

                // Set the successor of the last breadcrumb.
                if (lastSpawnedBreadcrumb != null)
                    lastSpawnedBreadcrumb.Successor = breadcrumb;

                Breadcrumb b = breadcrumb.GetComponent<Breadcrumb>();
                if (b != null)
                {
                    // The successor of the just spawned breadcrumb is always the Player gameobject.
                    GameObject successor = this.gameObject;

                    lastSpawnedBreadcrumb = b;
                    lastSpawnedBreadcrumb.Successor = successor;
                }

                currentTime = 0f;
            }
            else
                Debug.LogError("BreadcrumbGenerator: No prefab Reference!");

        }

        currentTime += Time.deltaTime;
    }
Beispiel #34
0
 /// <summary>
 /// Sets the actual breadcrumb if there is nothing set, 
 /// or if the breadcrumb is the succesor of the breadcrumb.
 /// </summary>
 /// <param name="breadcrumb">Breadcrumb</param>
 public void SetBreadcrumb(Breadcrumb breadcrumb)
 {
     if (this.Breadcrumb)
     {
         // If the the npc has no breadcrumb assigned, then assign it.
         if (currentBreadcrumb == null)
         {
             currentBreadcrumb = breadcrumb;
             LatestPosition = currentBreadcrumb.transform.position;
         }
         // If the incoming breadcrumb is the same as the successor of the current breadcrumb, assign it.
         else if (breadcrumb.gameObject.GetInstanceID() == currentBreadcrumb.Successor.gameObject.GetInstanceID())
         {
             currentBreadcrumb = breadcrumb;
             LatestPosition = currentBreadcrumb.transform.position;
         }
     }
 }
 public PathHelper(Breadcrumb root)
 {
     Root = root;
 }
 public SimpleBreadcrumb(Breadcrumb breadcrumb)
 {
     _breadcrumb = breadcrumb;
     _parent = new Lazy<SimpleBreadcrumb>(() => ReferenceEquals(null, _breadcrumb.Parent) ? null : new SimpleBreadcrumb(_breadcrumb.Parent));
 }
        private static void Assert_level2_breadcrumb_values(Breadcrumb breadcrumb)
        {
            var l2Property = typeof(L1).GetProperty("L2Property");

            breadcrumb.PathShouldBe("ROOT", "Level-1-Property");
            breadcrumb.DisplayString.ShouldBe("Level-2");
            breadcrumb.PropertiesShouldBe(l2Property);
            breadcrumb.ItemTypesShouldBe<L1>();

            Assert_level1_breadcrumb_values(breadcrumb.Parent);
        }
 private static void Assert_root_breadcrumb_values(Breadcrumb breadcrumb)
 {
     breadcrumb.ShouldNotBeNull();
     breadcrumb.DisplayString.ShouldBe("ROOT");
     breadcrumb.ItemTypesShouldBe<L0>();
     breadcrumb.Parent.ShouldBeNull();
     breadcrumb.Path.ShouldBeNull();
     breadcrumb.PropertiesShouldBeNull();
 }
        public void AddBreadcrumb(){

            if (radGridView1.SelectedItem != null)
            {
                //if its not shown show it
                if (bread1.Visibility == System.Windows.Visibility.Collapsed)
                {
                    bread1.Visibility = System.Windows.Visibility.Visible;
                    BreadGridRow.Height = new GridLength(28);
                    bread1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Render, EmptyDelegate);
                    ShowListView();
                } 

                DataRow r = ((DataRowView)radGridView1.SelectedItem).Row;
                if (r.Table.Columns.Contains(_sObjectDef.NameField))
                {

                    Breadcrumb b = new Breadcrumb();
                    b._objectname = _sObjectDef.Name;
                    b._r = r;

                    Telerik.Windows.Controls.Label l;
                    if (bread1.Children.Count > 0)
                    {
                        l = new Telerik.Windows.Controls.Label();
                        l.Content = ">";
                        bread1.Children.Add(l);
                    }

                    l = new Telerik.Windows.Controls.Label();
                    l.Content = _sObjectDef.Label + ":" + r[_sObjectDef.NameField];
                    l.MouseEnter += new MouseEventHandler(breadcrumb_l_MouseEnter);
                    l.MouseLeave += new MouseEventHandler(breadcrumb_l_MouseLeave);
                    l.MouseDown += new MouseButtonEventHandler(breadcrumb_l_MouseDown);
                    l.Tag = b;
                    bread1.Children.Add(l);
                }
            }
        }
 public bool Equals(Breadcrumb other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.Link, Link);
 }
Beispiel #41
0
    protected override void Start()
    {
        base.Start();

        // Find the game manager
        this.gameManager = GameObject.FindObjectOfType<GameManager>();
        this.currentBreadcrumb = null;
        this.latestPosition = Vector3.zero;

        // Instantiate goal pin and give it a position outside of the screen.
        instantiatedGoalPin = Instantiate(goalPin, new Vector3(0, -50, 0), goalPin.transform.rotation) as GameObject;
    }
Beispiel #42
0
    // Use this for initialization
    void Start()
    {
        pause = false;
        currentTime = 0f;
        lastSpawnedBreadcrumb = null;
        breadcrumbCount = 0;

        GameManager.GamePaused += InvertPause;
        NPCBreadcrumb.FoundPlayer += StopSpawn;
    }