Exemplo n.º 1
0
        public void LoadGraph(string data, string CWD, bool readOnly = false)
        {
            Release();

            Graph = new ImageGraph("Untitled");

            if (string.IsNullOrEmpty(data))
            {
                return;
            }

            Original = Graph;

            Graph.CWD = CWD;
            Graph.FromJson(data);

            Graph.OnGraphUpdated += Graph_OnGraphUpdated;

            Scale  = Graph.Zoom;
            XShift = Graph.ShiftX;
            YShift = Graph.ShiftY;

            ZoomLevel.Text = String.Format("{0:0}", Scale * 100);

            LoadGraphUI();
            ReadOnly = readOnly;

            Crumbs.Clear();

            BreadCrumb cb = new BreadCrumb(Crumbs, "Root", this, null);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加点击到导航中
        /// </summary>
        /// <param name="context">上下文</param>
        /// <param name="label">当前画面名称</param>
        public void Push(ActionExecutingContext context, string label)
        {
            string controller = context.RouteData.Values["controller"].ToString();
            string action     = context.RouteData.Values["action"].ToString();
            var    key        = ("/" + controller + "/" + action)
                                .ToLower()
                                .GetHashCode();

            if (Crumbs.Any(x => x.Key == key))
            {
                var newCrumbs = new List <StateEntry>();
                var remove    = false;
                // We've seen this route before, maybe user clicked on a breadcrumb
                foreach (var crumb in Crumbs)
                {
                    if (crumb.Key == key)
                    {
                        remove = true;
                    }
                    if (!remove)
                    {
                        newCrumbs.Add(crumb);
                    }
                }
                Crumbs = newCrumbs;
            }

            Current = new StateEntry().WithKey(key)
                      .SetContext(context)
                      .WithUrl(context.HttpContext.Request.Url.ToString())
                      .WithLabel(label);

            Crumbs.Add(Current);
        }
Exemplo n.º 3
0
        public UIGraph()
        {
            InitializeComponent();

            Id = Guid.NewGuid().ToString();

            GraphStack    = new Stack <GraphStackItem>();
            SelectedNodes = new List <UINode>();

            selectionRect        = new Rectangle();
            selectionRect.Stroke = new SolidColorBrush(Colors.DarkRed);
            selectionRect.StrokeDashArray.Add(2);
            selectionRect.StrokeDashArray.Add(2);
            selectionRect.StrokeDashCap       = PenLineCap.Round;
            selectionRect.StrokeEndLineCap    = PenLineCap.Round;
            selectionRect.StrokeThickness     = 1;
            selectionRect.HorizontalAlignment = HorizontalAlignment.Left;
            selectionRect.VerticalAlignment   = VerticalAlignment.Top;

            selectionRect.Fill = null;
            selectionRect.RenderTransformOrigin = new Point(0, 0);

            lookup    = new Dictionary <string, UINode>();
            Scale     = 1;
            PrevScale = 1;

            moving     = false;
            GraphNodes = new List <UINode>();
            Original   = Graph = new ImageGraph("Untitled");

            UpdateGrid();

            Crumbs.Clear();

            ConnectionPointPreview.RadiusX = 8;
            ConnectionPointPreview.RadiusY = 8;

            ConnectionPointPreview.Width  = 16;
            ConnectionPointPreview.Height = 16;

            ConnectionPointPreview.Fill = new SolidColorBrush(Colors.DarkRed);

            ConnectionPointPreview.HorizontalAlignment = HorizontalAlignment.Left;
            ConnectionPointPreview.VerticalAlignment   = VerticalAlignment.Top;

            ConnectionPathPreview.HorizontalAlignment = HorizontalAlignment.Left;
            ConnectionPathPreview.VerticalAlignment   = VerticalAlignment.Top;

            ConnectionPathPreview.Stroke = new SolidColorBrush(Colors.DarkRed);

            ConnectionPointPreview.IsHitTestVisible = false;
            ConnectionPathPreview.IsHitTestVisible  = false;

            BreadCrumb cb = new BreadCrumb(Crumbs, "Root", this, null);
        }
        public int AddCrumb(ICrumb crumb)
        {
            if (crumb == null)
            {
                throw new ArgumentNullException("Crumb");
            }

            Crumbs.Add(crumb);
            AddViewToRegion(crumb.Content);
            return(Crumbs.Count);
        }
        public int SetCrumbDescription(string description)
        {
            if (Crumbs.Count < 1)
            {
                return(-1);
            }

            ICrumb crumb = Crumbs.ElementAt <ICrumb>(Crumbs.Count - 1);

            crumb.Description = description;
            return(Crumbs.Count);
        }
Exemplo n.º 6
0
        /// <summary>
        /// provides a way to remove a crumb from the crumbs list
        /// </summary>
        /// <param name="context"></param>
        public void OnErrorRemoveCrumb(ResultExecutedContext context)
        {
            var key =
                context.HttpContext.Request.Url.LocalPath
                .ToLower()
                .GetHashCode();

            if (Crumbs.Any(x => x.Key == key))
            {
                var crumb = Crumbs.Single(x => x.Key == key);
                Crumbs.Remove(crumb);
            }
        }
Exemplo n.º 7
0
        public void Push(Node n, Graph graph, GraphStackType type, string param = null)
        {
            if (graph != null)
            {
                GraphStackItem item = new GraphStackItem();
                item.id        = n.Id;
                item.node      = n;
                item.graph     = graph;
                item.type      = type;
                item.parameter = param;


                if (!GraphStack.Contains(item))
                {
                    GraphStack.Push(item);
                    if (!Crumbs.Contains(n.Id))
                    {
                        BreadCrumb c = new BreadCrumb(Crumbs, graph.Name, this, n.Id);
                    }
                }
            }

            //no need to reload if it is the same graph already
            if (graph == Graph)
            {
                return;
            }
            if (graph == null)
            {
                return;
            }

            Graph.OnGraphUpdated -= Graph_OnGraphUpdated;

            ClearView();

            Graph = graph;

            Scale  = Graph.Zoom;
            XShift = Graph.ShiftX;
            YShift = Graph.ShiftY;

            ZoomLevel.Text = String.Format("{0:0}", Scale * 100);

            Graph.OnGraphUpdated += Graph_OnGraphUpdated;

            ReadOnly       = Graph.ReadOnly;
            Graph.ReadOnly = false;
            LoadGraphUI();
        }
Exemplo n.º 8
0
        public static MvcHtmlString BreadCrumbs(this HtmlHelper html, Crumbs crumbs, string header)
        {
            TagBuilder divMain = new TagBuilder("div");

            divMain.MergeAttributes(HtmlHelper.AnonymousObjectToHtmlAttributes(new { @class = "content-header row" }));

            TagBuilder headerPart = HeaderBuilder(header);

            TagBuilder contentPart = ContentBuilder(crumbs);

            divMain.InnerHtml = headerPart.ToString() + contentPart.ToString();

            return(new MvcHtmlString(divMain.ToString()));
        }
        private void AddCrumb()
        {
            lock (globalLock)
            {
                int desiredX = random.Next() % conf.MapWidth;
                int desiredY = random.Next() % conf.MapHeight;

                if (IsCellEmpty(desiredX, desiredY))
                {
                    Crumbs crumb = new Crumbs(desiredX, desiredY, conf.CrumbEnergy);
                    crumbs.Add(crumb);
                }
            }
        }
Exemplo n.º 10
0
        public int RemoveCrumb()
        {
            if (Crumbs.Count < 1)
            {
                return(-1);
            }

            Crumbs.RemoveAt(Crumbs.Count - 1);

            ICrumb crumb = Crumbs.ElementAt <ICrumb>(Crumbs.Count - 1);

            AddViewToRegion(crumb.Content);

            return(Crumbs.Count);
        }
Exemplo n.º 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.CurrentPath = Page.AppRelativeVirtualPath.Substring(1).Split('?')[0];

            Crumb CurrentCrumb = Crumbs.Find(c => c.Page.Equals(CurrentPath));

            this.CurrentCrumbs.Add(CurrentCrumb);
            while (CurrentCrumb.Previous != null)
            {
                CurrentCrumb = CurrentCrumb.Previous;
                this.CurrentCrumbs.Add(CurrentCrumb);
            }

            this.CurrentCrumbs.Reverse();
        }
Exemplo n.º 12
0
        private void OnCrumbAccessed(ICrumb crumb)
        {
            IRegion region = this._regionManager.Regions[RegionNames.MainRegion];

            var indexInicial = Crumbs.IndexOf(crumb);

            // Remove na ordem inversa
            for (int i = (Crumbs.Count - 1); i > indexInicial; i--)
            {
                ICrumb c = Crumbs.ElementAt <ICrumb>(i);
                region.Deactivate(c.Content.View);
                region.Remove(c.Content.View);
                Crumbs.RemoveAt(i);
            }

            region.Activate(crumb.Content.View);
        }
        private Shape ConvertCrumb(IGameObject gameObject)
        {
            Crumbs crumb = gameObject as Crumbs;

            if (crumb == null)
            {
                return(null);
            }

            Shape shape = new Rectangle();

            shape.SetValue(Canvas.LeftProperty, crumb.PosX * StepWidth);
            shape.SetValue(Canvas.TopProperty, crumb.PosY * StepHeight);

            shape.Width  = StepWidth;
            shape.Height = StepHeight;

            shape.Fill = crumbsBrush;

            return(shape);
        }
Exemplo n.º 14
0
        private static TagBuilder ContentBuilder(Crumbs crumbs)
        {
            TagBuilder contentMain = new TagBuilder("div");

            contentMain.AddCssClass("content-header-right breadcrumbs-right breadcrumbs-top col-md-6 col-12");

            TagBuilder contentWrap = new TagBuilder("div");

            contentWrap.AddCssClass("breadcrumb-wrapper col-12");

            TagBuilder olList = new TagBuilder("ol");

            olList.AddCssClass("breadcrumb");

            foreach (Crumb item in crumbs)
            {
                TagBuilder li = new TagBuilder("li");
                li.AddCssClass("breadcrumb-item");

                TagBuilder a = new TagBuilder("a");
                a.InnerHtml = item.Name;

                if (!String.IsNullOrEmpty(item.Link))
                {
                    a.MergeAttributes(HtmlHelper.AnonymousObjectToHtmlAttributes(new { href = item.Link }));
                }

                li.InnerHtml = a.ToString();

                olList.InnerHtml += li.ToString();
            }

            contentWrap.InnerHtml = olList.ToString();
            contentMain.InnerHtml = contentWrap.ToString();

            return(contentMain);
        }
Exemplo n.º 15
0
        private void Add(string url, string label, Type resourceType = null, ActionExecutingContext actionContext = null)
        {
            var key = url.ToLowerInvariant().GetHashCode();

            // when pushing entries into the list determine their level in hierarchy so that
            // deeper links are added to the end of the list
            int levels = BreadCrumb.HierarchyProvider.GetLevel(url);

            if (Crumbs.Any(x => x.Key == key))
            {
                var newCrumbs = new SortedSet <StateEntry>(new StateEntryComparer());
                var remove    = false;
                // We've seen this route before, maybe user clicked on a breadcrumb
                foreach (var crumb in Crumbs)
                {
                    if (crumb.Key == key)
                    {
                        remove = true;
                    }
                    if (!remove)
                    {
                        newCrumbs.Add(crumb);
                    }
                }
                Crumbs = newCrumbs;
            }

            Current = new StateEntry()
                      .WithKey(key)
                      .SetContext(actionContext)
                      .WithUrl(url)
                      .WithLevel(levels)
                      .WithLabel(ResourceHelper.GetResourceLookup(resourceType, label));

            Crumbs.Add(Current);
        }
Exemplo n.º 16
0
        protected void RestoreStack()
        {
            if (StoredGraphStack != null)
            {
                var  graph = Original;
                Node n;
                for (int i = 0; i < StoredGraphStack.Length; i++)
                {
                    GraphStackItem item = GraphStackItem.FromJson(StoredGraphStack[i]);
                    if (graph.NodeLookup.TryGetValue(item.id, out n))
                    {
                        item.node = n;

                        if (item.type == GraphStackType.Pixel)
                        {
                            if (n is PixelProcessorNode)
                            {
                                graph      = (n as PixelProcessorNode).Function;
                                item.graph = graph;

                                if (!GraphStack.Contains(item))
                                {
                                    GraphStack.Push(item);

                                    if (!Crumbs.Contains(n.Id))
                                    {
                                        BreadCrumb c = new BreadCrumb(Crumbs, graph.Name, this, n.Id);
                                    }
                                }
                            }
                            else
                            {
                                //we return as the stack does not match
                                StoredGraphStack = null;
                                return;
                            }
                        }
                        else if (item.type == GraphStackType.Parameter && !string.IsNullOrEmpty(item.parameter))
                        {
                            if (graph.HasParameterValue(item.id, item.parameter))
                            {
                                if (graph.IsParameterValueFunction(item.id, item.parameter))
                                {
                                    var v = graph.GetParameterRaw(item.id, item.parameter);
                                    item.graph = v.Value as Graph;

                                    if (!GraphStack.Contains(item))
                                    {
                                        GraphStack.Push(item);

                                        if (!Crumbs.Contains(n.Id))
                                        {
                                            BreadCrumb c = new BreadCrumb(Crumbs, graph.Name, this, n.Id);
                                        }
                                    }
                                }
                                else
                                {
                                    StoredGraphStack = null;
                                    return;
                                }
                            }
                            else
                            {
                                StoredGraphStack = null;
                                return;
                            }
                        }
                        else if (item.type == GraphStackType.FX)
                        {
                            //do same as pixel basically
                        }
                        else if (item.type == GraphStackType.CustomFunction)
                        {
                            FunctionGraph fn = graph.CustomFunctions.Find(m => m.Name.Equals(item.id));

                            if (fn != null)
                            {
                                graph = item.graph = fn;

                                if (!GraphStack.Contains(item))
                                {
                                    GraphStack.Push(item);

                                    if (!Crumbs.Contains(item.id))
                                    {
                                        BreadCrumb c = new BreadCrumb(Crumbs, fn.Name, this, item.id);
                                    }
                                }
                            }
                            else
                            {
                                StoredGraphStack = null;
                                return;
                            }
                        }
                        else
                        {
                            StoredGraphStack = null;
                            return;
                        }
                    }
                    else
                    {
                        StoredGraphStack = null;
                        return;
                    }
                }

                if (graph != null)
                {
                    LoadGraph(graph);
                }

                StoredGraphStack = null;
            }
        }