public UIGraphNode AddGraphItem(int lever_v, UIGraphNode partent, Pathea.Replicator.Formula ms, string[] strSprites, string strAtlas) { UIGraphNode node = new UIGraphNode(lever_v, partent); GameObject o = CreateGraphItem(partent, lever_v); int tempIndex = mGraphItemList.Count; node.mObject = o; node.mIndex = tempIndex; node.mCtrl = o.GetComponent <UIGraphItemCtrl>(); node.mTreeGrid = o.GetComponent <UITreeGrid>(); node.mTipCtrl = node.mCtrl.mTipCtrl; node.ms = ms; if (partent == null) { rootNode = node; } if (node.mCtrl != null) { node.mCtrl.SetCotent(strSprites, strAtlas); node.mCtrl.SetIndex(tempIndex); } mGraphItemList.Add(node); return(node); }
private void graphCanvas_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { UIGraphNode underMouseUIGraphNode = graphCanvas.GetUnderMouseUIGraphNode(); UIGraphWay underMouseUIGraphWay = graphCanvas.GetUnderMouseUIGraphWay(); if (underMouseUIGraphWay == null) { if (underMouseUIGraphNode == null) { graphCanvas.AddUIGraphNode(new UIGraphNode(e.GetPosition(graphCanvas))); HistorySnapshop(); } else { graphCanvas.Draging = underMouseUIGraphNode; graphCanvas.DragingOffset = new Point(e.GetPosition(graphCanvas).X - underMouseUIGraphNode.GetCenter().X, e.GetPosition(graphCanvas).Y - underMouseUIGraphNode.GetCenter().Y); graphCanvas.Draging.CaptureMouse(); } } else { var wayEditor = new WayEditorWindow(underMouseUIGraphWay); wayEditor.Owner = this; wayEditor.ShowDialog(); if (wayEditor.Modified) { underMouseUIGraphWay.Update(); HistorySnapshop(); } } }
private GameObject CreateGraphItem(UIGraphNode parent, int lever_v) { if (mContent == null || mPrefabGraphItem == null) { return(null); } GameObject o = GameObject.Instantiate(mPrefabGraphItem) as GameObject; if (parent == null) { o.transform.parent = mContent.transform; o.transform.localPosition = new Vector3(0, 0, 0); } else { o.transform.parent = parent.mCtrl.child.transform; o.transform.localPosition = new Vector3(0, mGraphItemHeight, 0); } o.transform.localScale = new Vector3(1, 1, 1); if (parent != null) { UITreeGrid treegrid = parent.mObject.GetComponent <UITreeGrid>(); UITreeGrid thistreegrid = o.GetComponent <UITreeGrid>(); if (treegrid != null && thistreegrid != null) { treegrid.m_Children.Add(thistreegrid); } } return(o); }
private bool ReDrawGraph(int itemID, int scirptIndex = 0) { if (mGraphCtrl == null) { return(false); } this.AddScriptItemData(itemID); if (!this.m_Formulas.ContainsKey(itemID) || scirptIndex >= this.m_Formulas[itemID].Count || scirptIndex < 0) { return(true); } if (mRootType == ItemLabel.Root.ISO) { // Iso } else { Pathea.Replicator.KnownFormula knownFornula = this.m_Formulas[itemID][scirptIndex]; Pathea.Replicator.Formula ms = knownFornula.Get(); ItemProto item = this.m_ItemDataList.Find(a => a.id == itemID); if (ms == null || item == null) { return(false); } // 临时处理 bool enable = (ms.workSpace != 0) ? true : false; mLbGraphInfo.enabled = enable; mLbGraphInfo.text = enable ? PELocalization.GetString(8000151) : ""; mGraphCtrl.ClearGraph(); int level_v = 0; UIGraphNode root = mGraphCtrl.AddGraphItem(level_v, null, ms, item.icon, "Icon"); root.mTipCtrl.SetToolTipInfo(ListItemType.mItem, itemID); root.mCtrl.ItemClick += this.GraphItemOnClick; this.m_CurScriptMatIDs.Clear(); for (int j = 0; j < ms.materials.Count; j++) { if (ms.materials[j].itemId != 0) { this.m_CurScriptMatIDs.Add(ms.materials[j].itemId); ItemProto item2 = ItemProto.GetItemData(ms.materials[j].itemId); UIGraphNode node = mGraphCtrl.AddGraphItem(level_v, root, null, item2.icon, "Icon"); node.mTipCtrl.SetToolTipInfo(ListItemType.mItem, ms.materials[j].itemId); node.mCtrl.ItemClick += this.GraphItemOnClick; } } UpdateItemsTrackState(ms); } mGraphCtrl.DrawGraph(); return(true); }
public UIGraphNode(int lever_v, UIGraphNode partent) { mLever_v = lever_v; mPartent = partent; mIndexForPartent = -1; mObject = null; mCtrl = null; ms = null; needCount = 0; getCount = 0; bagCount = 0; }
void _setCompundInfo(int id) { UIGraphNode rootNode = FactoryReplicator.m_MiddleContent.graphCtrl.rootNode; if (rootNode.mCtrl.mContentSprites[0].gameObject.activeSelf) { int m_id = rootNode.GetItemID(); ItemProto item = ItemProto.GetItemData(m_id); m_RightGridItem.SetCotent(item.icon); m_RightGridItem.SetToolTipInfo(ListItemType.mItem, m_id); } else { m_RightGridItem.SetCotent(rootNode.mCtrl.mContentTexture.mainTexture); m_RightGridItem.SetToolTipInfo(ListItemType.mItem, rootNode.GetItemID()); } FactoryReplicator.m_RightContent.countInput.text = rootNode.ms.m_productItemCount.ToString(); }
private void SetBottomInfo() { UIGraphNode rootNode = mGraphCtrl.rootNode; if (rootNode.mCtrl.mContentSprites[0].gameObject.activeSelf) { int m_id = rootNode.GetItemID(); ItemProto item = ItemProto.GetItemData(m_id); mButtomGrid.SetCotent(item.icon); mButtomGrid.SetToolTipInfo(ListItemType.mItem, m_id); } else { mButtomGrid.SetCotent(rootNode.mCtrl.mContentTexture.mainTexture); mButtomGrid.SetToolTipInfo(ListItemType.mItem, rootNode.GetItemID()); } mBottomCountLb.text = rootNode.ms.m_productItemCount.ToString(); }
public void LoadFromGraph(Graph graph) { // предотвращаем ошибки из за загрузки из себя же if (this == graph) { return; } Clear(); var nodeDictionary = new Dictionary <GraphNode, UIGraphNode>(); foreach (GraphNode node in graph.Nodes) { var newNode = new UIGraphNode(node.Position, node.Name, node.Info); nodeDictionary[node] = newNode; AddNode(newNode); } for (int i = 0; i < graph.MarkedNodes.Count; i++) { nodeDictionary[graph.MarkedNodes[i]].Style = graph.MarkedNodes[i].Style; } foreach (GraphWay way in graph.Ways) { var newWay = new UIGraphWay(nodeDictionary[way.From], nodeDictionary[way.To], way.Oriented); if (!way.WeightIsLen) { newWay.WeightIsLen = false; newWay.Weight = way.Weight; } newWay.Style = way.Style; AddWay(newWay); } }
private void graphCanvas_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { UIGraphNode underMouseUIGraphNode = graphCanvas.GetUnderMouseUIGraphNode(); UIGraphWay underMouseUIGraphWay = graphCanvas.GetUnderMouseUIGraphWay(); if (underMouseUIGraphNode != null) { if (underMouseUIGraphNode.ToggleMark()) // если вернется true значит вершина помечается, иначе пометка снимается { if (AutomatAddWayMode.IsChecked && Commands.AppCommands.AddWay.CanExecute(null, this)) { Commands.AppCommands.AddWay.Execute(null, this); } } HistorySnapshop(); } else if (underMouseUIGraphWay != null) { graphCanvas.RemoveUIGraphWay(underMouseUIGraphWay); HistorySnapshop(); } }
public void RemoveUIGraphNode(UIGraphNode node) { Graph.RemoveNode(node); DrawGraph(true); }
public void AddUIGraphNode(UIGraphNode node) { Graph.AddNode(node); DrawGraph(); }
public UIGraphWay(UIGraphNode FromNode, UIGraphNode ToNode, bool oriented = true) : base(FromNode, ToNode, oriented) { makeVisual(); }
// --------------------------------- // Func // --------------------------------- private bool ReDrawGraph(int itemID, int scirptIndex = 0) { if (FactoryReplicator == null) { return(false); } this.AddScriptItemData(itemID); if (!this.m_Formulas.ContainsKey(itemID) || scirptIndex >= this.m_Formulas[itemID].Count || scirptIndex < 0) { return(true); } UIGraphControl graph_ctrl = FactoryReplicator.m_MiddleContent.graphCtrl; if (m_RootType == ItemLabel.Root.ISO) { // Iso } else { if (itemID != -1) { //Pathea.Replicator.Formula ms = Pathea.Replicator.Formula.Mgr.Instance.FindByProductId(m_id); Pathea.Replicator.KnownFormula knownFornula = this.m_Formulas[itemID][scirptIndex]; Pathea.Replicator.Formula ms = knownFornula.Get(); ItemProto item = this.m_ItemDataList.Find(a => a.id == itemID); if (ms == null || item == null) { return(false); } FactoryReplicator.ClearGraph(); int level_v = 0; UIGraphNode root = graph_ctrl.AddGraphItem(level_v, null, ms, item.icon, "Icon"); root.mTipCtrl.SetToolTipInfo(ListItemType.mItem, itemID); root.mCtrl.ItemClick += this.OnGraphItemClick; for (int j = 0; j < ms.materials.Count; j++) { if (ms.materials[j].itemId != 0) { ItemProto item2 = ItemProto.GetItemData(ms.materials[j].itemId); string[] strico2 = item2.icon; UIGraphNode node = graph_ctrl.AddGraphItem(level_v, root, null, strico2, "Icon"); node.mTipCtrl.SetToolTipInfo(ListItemType.mItem, ms.materials[j].itemId); node.mCtrl.ItemClick += this.OnGraphItemClick; } } UpdateItemsTrackState(ms); } } // graph_ctrl.DrawGraph(); FactoryReplicator.DrawGraph(); return(true); }