private static void OnNewContactSaved(IResource res, object tag) { Trace.WriteLine("OnNewContactSaved is called for " + res.DisplayName); // NB: SetPropAsync does not work properly under Windows2000 // new ResourceProxy( res ).SetPropAsync( ContactHelper._propUserCreated, true ); new ResourceProxy(res).SetProp(ContactManager._propUserCreated, true); if (tag != null) { NewContactLocation location = (NewContactLocation)tag; if (location.AddressBook != null) { AddressBook ab = new AddressBook(location.AddressBook); ab.AddContact(res); } if (location.Category != null) { Core.CategoryManager.AddResourceCategory(res, location.Category); } } Core.WorkspaceManager.AddToActiveWorkspace(res); }
public void Execute(IActionContext context) { ContactView cv = new ContactView(); IResource contact = Core.ResourceStore.NewResourceTransient("Contact"); NewContactLocation location = new NewContactLocation(); IResource owner = Core.ResourceBrowser.OwnerResource; if (context.SelectedResources.Count == 1 && context.SelectedResources [0].Type == "AddressBook") { location.AddressBook = context.SelectedResources [0]; } else if (owner != null && owner.Type == "AddressBook") { location.AddressBook = owner; } if (owner != null && owner.Type == "Category") { location.Category = owner; } Core.UIManager.OpenResourceEditWindow(cv, contact, true, OnNewContactSaved, location); }