public NetworkView(NetworkViewModel viewModel) { height = jQuery.Window.GetHeight(); width = jQuery.Window.GetWidth(); vm = viewModel; force = D3.Layout.Force() .Size(new int[] { width, height }) .LinkDistance(150) .Friction(0.7) .Charge(-700) .On("tick", Tick); zoom = D3.Behavior .Zoom() .ScaleExtent(new Number[] { minZoom, maxZoom }) .Center2(new Number[] { width / 2, height / 2 }) .On("zoom", zoomed); svg = D3.Select("#networksvg") .Attr("width", width) .Attr("height", height) .Call(zoom) .Append("g"); dragBehavior = force.OnDrag() .On("dragstart", dragstart); // Add InfoBox SVGexactTip = D3.Select("#infoBox").Style("opacity", 0); nodeData = (Stack<EntityNode>)(object)force.Nodes(); linkData = (Stack<EntityLink>)(object)force.Links(); link = svg.SelectAll(".link"); node = svg.SelectAll(".node"); Update(); ViewBase.RegisterViewModel(vm); // Create event listeners for MVVM vm.OnNewNodes += OnNodesChange; vm.OnSelectedNodesAdded += vm_OnSelectedNodesAdded; vm.OnSelectedNodesCleared += vm_OnSelectedNodesCleared; vm.OnSelectedLinksAdded+=vm_OnSelectedLinksAdded; vm.OnInfoBoxClose += vm_OnInfoBoxClose; vm.OnZoom += vm_OnZoom; jQuery.Window.Resize(OnResize); jQuery.OnDocumentReady(delegate() { Window.SetTimeout(delegate() { vm.ProcessQueue(); }, 10); }); }
public List<FormCell> GetQuickViewForm(NetworkViewModel vm) { Entity record = (Entity)SourceData; if (record == null) return null; List<FormCell> form = new List<FormCell>(); // Get the Quick Form defintion if (vm.Config.QuickViewForms.ContainsKey(record.LogicalName)) { foreach (string field in vm.Config.QuickViewForms[record.LogicalName].Keys) { string label = vm.Config.QuickViewForms[record.LogicalName][field]; string value = GetStringValue(field, record); form.Add(new FormCell(label, value)); } } return form; }
public void UserClickCommand(NetworkViewModel that, UserOrTeam user) { DemoMode.SetValue(false); UnselectAll(); bool selected = false; // If already selected then toggle if (user == null || that.SelectedUserId.GetValue() == user.Id.ToString()) { that.SelectedUserId.SetValue(null); } else { that.SelectedUserId.SetValue(user.Id.ToString()); selected = true; } if (selected) { foreach (string partyid in user.Parties.Keys) { EntityReference party = user.Parties[partyid]; // If overflow - add that instead string key = GetIdIndexKeyEntityRef(party); if (idIndex.ContainsKey(key) && idIndex[key].ReplacedByOverflow != null) { Entity overflow = (Entity)idIndex[GetIdIndexKeyEntityRef(party)].ReplacedByOverflow.SourceData; HighlightedEntities.Push(new EntityReference(new Guid(overflow.Id), overflow.LogicalName, null)); } else { HighlightedEntities.Push(party); } } } if (OnSelectedNodesAdded != null) OnSelectedNodesAdded(this, null); if (OnSelectedLinksAdded != null) OnSelectedLinksAdded(this, null); }
public static void Init() { LocalisedContentLoader.FallBackLCID = 0; LocalisedContentLoader.SupportedLCIDs.Add(1033); LocalisedContentLoader.LoadContent("dev1_/js/NetworkViewConfig.js", 1033, delegate() { // Check the webresource parameters Dictionary<string, string> data = GetQueryStringData(); // Webresource accepts the root id and entity type name (etn) if (!data.ContainsKey("etn")) data["etn"] = "account"; NetworkViewModel vm = new NetworkViewModel(new Guid(data["id"]), data["etn"], GlobalSettings.GraphOptions); view = new NetworkView(vm); }); }
public void ConnectionRoleClickCommand(NetworkViewModel that, string role) { DemoMode.SetValue(false); // Clear the currently selected users/teams SelectedUserId.SetValue(null); UnselectAll(); // Find the connecitons and highlght them if (!ConnectionRoleIndex.ContainsKey(role)) return; if (SelectedConnectionRoles.GetItems().Contains(role)) { SelectedConnectionRoles.Remove(role); foreach (string key in ConnectionRoleIndex[role].Keys) { SelectLink(key, false); } } else { SelectedConnectionRoles.Push(role); foreach (string key in ConnectionRoleIndex[role].Keys) { SelectLink(key, true); } } if (OnSelectedLinksAdded != null) OnSelectedLinksAdded(this, null); if (OnSelectedNodesAdded != null) OnSelectedNodesAdded(this, null); }