private void PopupRoots() { List <Wrappers.Node> roots = new List <Wrappers.Node>(d_roots); roots.Remove(d_active); Menu menu = new Menu(); menu.Show(); foreach (Wrappers.Node root in d_roots) { MenuItem item = new MenuItem(RootName(root)); item.Show(); Wrappers.Node grp = root; item.Activated += delegate { Update(grp); Activated(this, d_active); }; menu.Append(item); } menu.Popup(null, null, null, 1, 0); }
private void Populate() { if (d_wrapper == null) { return; } foreach (Cdn.Variable prop in d_wrapper.Variables) { d_treeview.NodeStore.Add(new Node(prop)); } Wrappers.Node grp = d_wrapper as Wrappers.Node; if (grp != null) { foreach (string name in grp.VariableInterface.Names) { d_treeview.NodeStore.Add(new InterfaceNode(grp.VariableInterface, name)); } } d_dummy = new Node(null); d_treeview.NodeStore.Add(d_dummy); Connect(); }
public InterfaceVariable(Wrappers.Node grp, string name, string childname, string propid) : base(grp.Parent, grp) { d_group = grp; d_name = name; d_childname = childname; d_variableid = propid; }
private void HandleGroupToggled(object sender, EventArgs e) { Widget w = (Widget)sender; ToggleButton toggle = (ToggleButton)w; Wrappers.Node selected = (Wrappers.Node)w.Data["WrappedGroup"]; if (selected == d_active) { if (!toggle.Active) { toggle.Active = true; return; } if (d_roots.Contains(selected) && d_roots.Count > 1) { PopupRoots(); } return; } SetActive(d_active, false); SetActive(selected, true); Activated(this, d_active); }
private void UpdateFrom() { if (d_input != null) { d_input.Moved -= OnFromMoved; } Wrappers.Node oldFrom = d_input; d_input = Wrappers.Wrapper.Wrap(WrappedObject.Input as Cdn.Node) as Wrappers.Node; RecalculateLinkOffsets(oldFrom, d_output); if (d_input != null) { d_input.Moved += OnFromMoved; RecalculateLinkOffsets(d_input, d_output); d_input.LinkFocus = LinkFocus; if (d_output != null) { Allocation.Assign(0, 0, 1, 1); } } }
private void UpdateTo() { if (d_output != null) { d_output.Moved -= OnToMoved; d_output.Unlink(this); } Wrappers.Node oldTo = d_output; d_output = Wrappers.Wrapper.Wrap(WrappedObject.Output as Cdn.Node) as Wrappers.Node; RecalculateLinkOffsets(d_input, oldTo); if (d_output != null) { d_output.Moved += OnToMoved; d_output.Link(this); RecalculateLinkOffsets(d_input, d_output); d_output.LinkFocus = LinkFocus; if (d_input != null) { Allocation.Assign(0, 0, 1, 1); } } }
public Import(Wrappers.Network network, Wrappers.Node parent, string id, string filename) { d_network = network; d_parent = parent; d_id = id; d_filename = filename; }
private void HandleChildRemoved(Wrappers.Node source, Wrappers.Wrapper child) { Wrappers.Node grp = child as Wrappers.Node; if (grp == null) { return; } if (d_pathWidgets.ContainsKey(grp)) { int start = d_pathGroups.IndexOf(grp); for (int i = start; i < d_pathGroups.Count; ++i) { d_pathGroups[i].ChildRemoved -= HandleChildRemoved; d_pathWidgets.Remove(d_pathGroups[i]); if (d_pathGroups[i] == d_active) { d_active = null; } } d_pathGroups.RemoveRange(start, d_pathGroups.Count - start); Widget[] children = Children; for (int i = start * 2 - 1; i < children.Length; ++i) { children[i].Destroy(); } } }
public Pathbar(params Wrappers.Node[] roots) : base(false, 0) { d_pathWidgets = new Dictionary <Wrappers.Node, ToggleButton>(); d_pathGroups = new List <Wrappers.Node>(); d_roots = new List <Wrappers.Node>(roots); d_active = null; }
public AttachEdge(Wrappers.Edge link, Wrappers.Node from, Wrappers.Node to) : base(link.Parent, link) { d_from = from; d_to = to; d_prevFrom = link.Input; d_prevTo = link.Output; d_link = link; }
private void HandleEdgeActionTargetEditingStarted(object o, EditingStartedArgs args) { Entry entry = args.Editable as Entry; if (entry == null) { return; } d_editingEntry = entry; d_editingPath = args.Path; if (d_treeview.NodeStore.FindPath(args.Path).EdgeAction == null) { entry.Text = ""; } d_editingEntry.KeyPressEvent += delegate(object source, KeyPressEventArgs a) { OnEntryKeyPressed(a, d_rendererTarget, TargetEdited); }; if (d_link.Output == null) { return; } EntryCompletion completion = new EntryCompletion(); ListStore props = new ListStore(typeof(string)); Dictionary <string, bool> found = new Dictionary <string, bool>(); Wrappers.Node grp = d_link.Output; if (grp != null) { foreach (string name in grp.VariableInterface.Names) { props.AppendValues(name); found[name] = true; } } foreach (Variable prop in d_link.Output.Variables) { if (!found.ContainsKey(prop.Name)) { props.AppendValues(prop.Name); } } completion.Model = props; completion.TextColumn = 0; completion.InlineSelection = true; completion.InlineCompletion = true; entry.Completion = completion; }
private void Build(Wrappers.Node grp) { foreach (Wrappers.Wrapper child in grp.Children) { ChildAdded(grp, child); } grp.ChildAdded += ChildAdded; grp.ChildRemoved += ChildRemoved; }
public WrapperNode(Widget widget, Wrappers.Wrapper wrapper, GLib.Object obj) { d_widget = widget; d_wrapper = wrapper; d_object = obj; d_icon = WrapperIcon(); d_inconsistent = new List <WrapperNode>(); if (d_wrapper != null) { Wrappers.Node grp = wrapper as Wrappers.Node; if (grp != null) { grp.ChildAdded += OnChildAdded; grp.ChildRemoved += OnChildRemoved; foreach (Wrappers.Wrapper wr in grp.Children) { OnChildAdded(grp, wr); } } Wrappers.Edge link = wrapper as Wrappers.Edge; if (link != null) { d_wrapper.WrappedObject.AddNotification("from", OnLinkChanged); d_wrapper.WrappedObject.AddNotification("to", OnLinkChanged); } d_wrapper.WrappedObject.AddNotification("id", OnIdChanged); d_wrapper.VariableAdded += OnVariableAdded; d_wrapper.VariableRemoved += OnVariableRemoved; foreach (Cdn.Variable prop in d_wrapper.WrappedObject.Variables) { OnVariableAdded(wrapper, prop); } } if (d_object != null) { if (d_object is Cdn.Variable) { d_object.AddNotification("name", OnIdChanged); } else if (d_object is Cdn.EdgeAction) { d_object.AddNotification("target", OnIdChanged); } } }
public Node(Wrappers.Wrapper obj) : base(obj) { d_node = obj as Wrappers.Node; d_colors = new double[5][]; d_colors[0] = new double[] { 26 / 125.0, 80 / 125.0, 130 / 125.0 }; d_colors[1] = new double[] { 80 / 125.0, 26 / 125.0, 130 / 125.0 }; d_colors[2] = new double[] { 26 / 125.0, 130 / 125.0, 80 / 125.0 }; d_colors[3] = new double[] { 130 / 125.0, 80 / 125.0, 26 / 125.0 }; d_colors[4] = new double[] { 80.0 / 125.0, 130.0 / 125.0, 26.0 / 125.0 }; }
private string RootName(Wrappers.Node root) { string ret = root.ToString(); if (ret.Length > 0 && char.IsLetter(ret[0])) { ret = ret.Substring(0, 1).ToUpper() + ret.Substring(1); } return(ret); }
private void OnChildRemoved(Wrappers.Node grp, Wrappers.Wrapper child) { foreach (WrapperNode node in AllChildren) { if (node.Wrapper == child) { Remove(node); break; } } }
private List <Wrappers.Node> Collect(Wrappers.Node grp) { List <Wrappers.Node> ret = new List <Wrappers.Node>(); do { ret.Add(grp); grp = grp.Parent; } while (grp != null); ret.Reverse(); return(ret); }
public Object(Wrappers.Node parent, Wrappers.Wrapper wrapped) { d_parent = parent; d_wrapped = wrapped; d_templates = new List <Wrappers.Wrapper>(); Wrappers.Edge link = wrapped as Wrappers.Edge; if (link != null) { d_from = link.Input; d_to = link.Output; } }
private void AllObjects(Wrappers.Node grp, List <Wrappers.Object> ret) { foreach (Wrappers.Object child in grp.Children) { ret.Add(child); Wrappers.Node cg = child as Wrappers.Node; if (cg != null) { AllObjects(cg, ret); } } ret.Add(grp); }
private bool PropertyExists(string name) { if (d_wrapper.Variable(name) != null) { return(true); } Wrappers.Node grp = d_wrapper as Wrappers.Node; if (grp == null) { return(false); } return(grp.VariableInterface.Implements(name)); }
private void Clear() { while (Children.Length != 0) { Remove(Children[0]); } foreach (Wrappers.Node grp in d_pathGroups) { grp.ChildRemoved -= HandleChildRemoved; } d_pathWidgets.Clear(); d_pathGroups.Clear(); d_active = null; }
private void HandleGroupInterfaceVariableAdded(object source, Cdn.AddedArgs args) { Wrappers.Node grp = (Wrappers.Node)d_wrapper; if (!d_blockInterfaceRemove) { d_treeview.NodeStore.Add(new InterfaceNode(grp.VariableInterface, args.Name)); } else { Node node = d_treeview.NodeStore.Find(args.Name); if (node != null) { node.EmitChanged(); } } }
private void MergeAnnotations(Wrappers.Wrapper original, Wrappers.Wrapper imported) { imported.Allocation = original.Allocation.Copy(); Wrappers.Node grp = original as Wrappers.Node; Wrappers.Node imp = imported as Wrappers.Node; if (grp != null) { foreach (Wrappers.Wrapper wrapper in grp.Children) { Wrappers.Wrapper other = imp.GetChild(wrapper.Id); if (other != null) { MergeAnnotations(wrapper, other); } } } }
private void SetActive(Wrappers.Node grp, bool active) { if (grp == null) { return; } ToggleButton but = d_pathWidgets[grp]; but.Toggled -= HandleGroupToggled; but.Active = active; but.Toggled += HandleGroupToggled; but.Sensitive = !active || d_roots.Contains(grp); but.Relief = active ? ReliefStyle.Half : ReliefStyle.None; if (active) { d_active = grp; } }
override public void Dispose() { base.Dispose(); if (d_wrapper != null) { d_wrapper.WrappedObject.RemoveNotification("from", OnLinkChanged); d_wrapper.WrappedObject.RemoveNotification("to", OnLinkChanged); d_wrapper.WrappedObject.RemoveNotification("id", OnIdChanged); Wrappers.Node grp = d_wrapper as Wrappers.Node; if (grp != null) { grp.ChildAdded -= OnChildAdded; grp.ChildRemoved -= OnChildRemoved; } d_wrapper.VariableAdded -= OnVariableAdded; d_wrapper.VariableRemoved -= OnVariableRemoved; } if (d_object != null) { if (d_object is Cdn.Variable) { d_object.RemoveNotification("name", OnIdChanged); } else if (d_object is Cdn.EdgeAction) { d_object.RemoveNotification("target", OnIdChanged); } d_object = null; } d_wrapper = null; }
public FindTemplate(Wrappers.Node grp, FilterFunc func, Gtk.Window parent) : base("Find Template", parent, DialogFlags.DestroyWithParent | DialogFlags.NoSeparator) { d_tree = new Widgets.WrappersTree(grp); d_tree.RendererToggle.Visible = false; d_tree.Show(); if (func != null) { d_tree.Filter += delegate(Widgets.WrappersTree.WrapperNode node, ref bool ret) { if (node.Wrapper == null) { ret = false; } else { ret &= func(node.Wrapper); } }; } d_tree.Activated += delegate(object source, Widgets.WrappersTree.WrapperNode[] wrappers) { Respond(ResponseType.Apply); }; d_tree.TreeView.Selection.SelectFunction = CantSelectImports; VBox.PackStart(d_tree, true, true, 0); TransientFor = parent; AddButton(Gtk.Stock.Close, ResponseType.Close); AddButton(Gtk.Stock.Apply, ResponseType.Apply); d_tree.Entry.GrabFocus(); SetDefaultSize(400, 300); }
public void Attach(Wrappers.Node from, Wrappers.Node to) { WrappedObject.Attach(from, to); }
public AddNode(Wrappers.Node node, IEnumerable <IAction> actions) : base(actions) { d_node = node; }
public RemoveObject(Wrappers.Node parent, Wrappers.Wrapper wrapped) : base(parent, wrapped) { }
public Ungroup(Wrappers.Node parent, IAction[] actions) : base(actions) { d_parent = parent; }