/// <summary> /// Create the secondary tile /// </summary> /// <param name="element">Element to pin</param> public async Task PinAsync(PinnableObject element) { SecondaryTile tile = new SecondaryTile { TileId = element.Id, ShortName = element.Title, DisplayName = element.Title, Arguments = element.Id, TileOptions = TileOptions.ShowNameOnLogo, Logo = new Uri("ms-appx:///Assets/Logo.png") }; if (await tile.RequestCreateAsync()) { // Tile template definition ITileSquarePeekImageAndText04 squareContent = TileContentFactory.CreateTileSquarePeekImageAndText04(); squareContent.TextBodyWrap.Text = element.Content; squareContent.Image.Src = element.ImageUrl; squareContent.Image.Alt = element.Content; // Tile creation TileNotification tileNotification = squareContent.CreateNotification(); // Send the notification TileUpdater tileUpdater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(element.Id); tileUpdater.Update(tileNotification); } }
public bool AcceptDroppedPinnable(PinnableObject pinnable) { if (pinnable.LookupType == LookupType.Material || pinnable.LookupType == LookupType.Taxon) { return true; } return false; }
public object Convert(object value, Type targetType, object parameter, string language) { string applicationName = ResourcesRsxAccessor.GetString("AppName"); PinnableObject pinnableObject = null; if (value is VisualGenericItem) { VisualGenericItem item = value as VisualGenericItem; pinnableObject = new PinnableObject { Id = string.Format("{0}-{1}-{2}", applicationName, item.Type, item.Id), Title = item.Title, ImageUrl = item.ImageUrl, Content = item.Title }; } else if (value is News) { News news = value as News; pinnableObject = new PinnableObject { Id = string.Format("{0}-News-{1}", applicationName, news.Id), Title = news.Title, ImageUrl = news.ImageUrl, Content = news.Title }; } else if (value is Conference) { Conference conference = value as Conference; pinnableObject = new PinnableObject { Id = string.Format("{0}-Conference-{1}", applicationName, conference.Id), Title = conference.Name, ImageUrl = conference.ImageUrl, Content = conference.Name }; } else if (value is Show) { Show salon = value as Show; pinnableObject = new PinnableObject { Id = string.Format("{0}-Show-{1}", applicationName, salon.Id), Title = salon.Name, ImageUrl = salon.ImageUrl, Content = salon.Name }; } return(pinnableObject); }
public override ViewModelBase CreatePinnableViewModel(PinnableObject pinnable) { SiteExplorerNodeType nodeType; if (Enum.TryParse(pinnable.LookupType.ToString(), out nodeType)) { return(ViewModelFromObjectID(nodeType, pinnable.ObjectID)); } return(null); }
private void PinSelected() { var selected = lvwResults.SelectedItem as ReferenceSearchResultViewModel; if (selected != null) { var pinnable = new PinnableObject(ToolsPlugin.TOOLS_PLUGIN_NAME, LookupType.Reference, selected.RefID, selected.DisplayLabel); PluginManager.Instance.PinObject(pinnable); } }
private void PinSelected() { var selected = GetSelected(); if (selected != null) { var pinnable = new PinnableObject(ToolsPlugin.TOOLS_PLUGIN_NAME, LookupType.Journal, selected.JournalID, selected.FullName); PluginManager.Instance.PinObject(pinnable); } }
public override ViewModelBase CreatePinnableViewModel(PinnableObject pinnable) { var placeName = pinnable.GetState <PlaceName>(); if (placeName != null) { return(new PlaceNameViewModel(placeName)); } return(null); }
public override T GetAdaptorForPinnable <T>(PinnableObject pinnable) { if (pinnable.LookupType == LookupType.Material) { if (typeof(T) == typeof(ILabelSetItemTarget)) { return((T)(object)(new AddToLabelSetAdapter(this, User))); } } return(base.GetAdaptorForPinnable <T>(pinnable)); }
private ViewModelBase GetViewModel(LookupType lookupType, int?objectId) { if (objectId.HasValue) { var plugin = PluginManager.Instance.GetLookupTypeOwner(lookupType); if (plugin != null) { var pin = new PinnableObject(plugin.Name, lookupType, objectId.Value); return(PluginManager.Instance.GetViewModel(pin)); } } return(null); }
public override T GetAdaptorForPinnable <T>(PinnableObject pinnable) { if (pinnable.LookupType == LookupType.Taxon) { if (typeof(T) == typeof(IMapPointSetGenerator)) { var taxon = Service.GetTaxon(pinnable.ObjectID); object generator = new DelegatingPointSetGenerator <Taxon>(_explorer.ContentControl.GenerateSpecimenPoints, taxon); return((T)generator); } } return(base.GetAdaptorForPinnable <T>(pinnable)); }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { PinnableObject pinnableObject = null; if (value is News) { News news = value as News; pinnableObject = new PinnableObjectWP { Id = string.Format("{0}-News-{1}", AppResources.APPLICATION_NAME, news.Id), NavigationPage = new Uri(string.Format("/NewsPage.xaml?Id={0}", news.Id), UriKind.Relative), Title = news.Title, BackTitle = news.DateTime.ToString("g", CultureInfo.CurrentUICulture), ImageUrl = news.ImageUrl, Content = news.ShortText }; } else if (value is Conference) { Conference conference = value as Conference; pinnableObject = new PinnableObjectWP { Id = string.Format("{0}-Conference-{1}", AppResources.APPLICATION_NAME, conference.Id), NavigationPage = new Uri(string.Format("/ConferencePage.xaml?Id={0}", conference.Id), UriKind.Relative), Title = conference.Name, BackTitle = string.Format(CultureInfo.CurrentUICulture, AppResources.FORMAT_CONFERENCE, conference.Start_DateTime, conference.End_DateTime, conference.Place), ImageUrl = conference.ImageUrl, Content = conference.Name }; } else if (value is Show) { Show salon = value as Show; pinnableObject = new PinnableObjectWP { Id = string.Format("{0}-Show-{1}", AppResources.APPLICATION_NAME, salon.Id), NavigationPage = new Uri(string.Format("/ShowPage.xaml?Id={0}", salon.Id), UriKind.Relative), Title = salon.Name, BackTitle = string.Format(CultureInfo.CurrentUICulture, AppResources.FORMAT_SALON, salon.Start_DateTime, salon.End_DateTime, salon.Place), ImageUrl = salon.ImageUrl, Content = salon.Name }; } return(pinnableObject); }
private DataObject CreateDragData(ViewModelBase dragged) { var selected = dragged as PlaceNameViewModel; if (selected != null) { var data = new DataObject("Pinnable", selected); var pinnable = new PinnableObject(GazetterPlugin.GAZETTEER_PLUGIN_NAME, LookupType.PlaceName, 0, selected.Model); data.SetData(PinnableObject.DRAG_FORMAT_NAME, pinnable); data.SetData(DataFormats.Text, selected.DisplayLabel); return(data); } return(null); }
private DataObject CreateDragData(ViewModelBase dragged) { var selected = dragged as JournalViewModel; if (selected != null) { var data = new DataObject("Pinnable", selected); var pinnable = new PinnableObject(ToolsPlugin.TOOLS_PLUGIN_NAME, LookupType.Journal, selected.JournalID); data.SetData(PinnableObject.DRAG_FORMAT_NAME, pinnable); data.SetData(DataFormats.Text, selected.DisplayLabel); return(data); } return(null); }
public override void PopulateFromPinnable(ViewModelBase viewModel, PinnableObject pinnable) { var item = viewModel as LoanMaterialViewModel; if (item != null && pinnable.LookupType == LookupType.Material) { var service = new MaterialService(User); var material = service.GetMaterial(pinnable.ObjectID); if (material != null) { var vm = PluginManager.Instance.GetViewModel(pinnable); txtMaterial.ObjectID = pinnable.ObjectID; txtMaterial.Text = vm.DisplayLabel; txtTaxon.Text = material.TaxaDesc; } } }
public void AddItemToLabelSet(PinnableObject item) { if (item.LookupType == LookupType.Material) { var frm = new AddToLabelSet(User, item.ObjectID); frm.WindowStartupLocation = WindowStartupLocation.CenterOwner; if (frm.ShowDialog().ValueOrFalse()) { // Do it! Plugin.AddItemToLabelSet(item, frm.LabelSetName); } } else { ErrorMessage.Show("Unhandled item type for this operation: " + item.LookupType.ToString()); return; } }
private void AddToLabelSet() { if (_viewModel != null) { if (_viewModel.IsChanged || _viewModel.MaterialID <= 0) { ErrorMessage.Show("This material has unsaved changes. Please apply the changes before trying again."); return; } // make a pinnable... var pinnable = new PinnableObject(MaterialPlugin.MATERIAL_PLUGIN_NAME, Data.LookupType.Material, _viewModel.MaterialID); var target = PluginManager.Instance.FindAdaptorForPinnable <ILabelSetItemTarget>(pinnable); if (target != null) { target.AddItemToLabelSet(pinnable); } } }
public override ViewModelBase CreatePinnableViewModel(PinnableObject pinnable) { var service = new SupportService(User); switch (pinnable.LookupType) { case LookupType.Reference: var refmodel = service.GetReference(pinnable.ObjectID); if (refmodel != null) { return(new ReferenceViewModel(refmodel)); } break; case LookupType.Journal: var jmodel = service.GetJournal(pinnable.ObjectID); if (jmodel != null) { return(new JournalViewModel(jmodel)); } break; case LookupType.Contact: var loanService = new LoanService(User); var cmodel = loanService.GetContact(pinnable.ObjectID); if (cmodel != null) { return(new ContactViewModel(cmodel)); } break; case LookupType.Loan: loanService = new LoanService(User); var lmodel = loanService.GetLoan(pinnable.ObjectID); if (lmodel != null) { return(new LoanViewModel(lmodel)); } break; } return(null); }
private void StartDrag(MouseEventArgs mouseEventArgs, System.Windows.Controls.TextBox txt) { var selected = txt.Tag as PlaceNameViewModel; if (selected != null) { var data = new DataObject("Pinnable", selected); var pinnable = new PinnableObject(GazetterPlugin.GAZETTEER_PLUGIN_NAME, LookupType.PlaceName, 0, selected.Model); data.SetData(PinnableObject.DRAG_FORMAT_NAME, pinnable); data.SetData(DataFormats.Text, selected.DisplayLabel); try { _IsDragging = true; DragDrop.DoDragDrop(txt, data, DragDropEffects.Copy | DragDropEffects.Move | DragDropEffects.Link); } finally { _IsDragging = false; } } InvalidateVisual(); }
internal void AddItemToLabelSet(PinnableObject item, string labelSetName) { var host = ShowLabelManager(); if (host != null) { var otm = host.Control as OneToManyControl; if (otm != null) { var existing = otm.FindItem((vm) => { var set = vm as LabelSetViewModel; return(set.Name.Equals(labelSetName, StringComparison.CurrentCultureIgnoreCase)); }); LabelManagerControl control = null; if (existing != null) { otm.SetSelectedItem(existing); control = otm.DetailControl as LabelManagerControl; } else { var set = otm.AddNew() as LabelSetViewModel; if (set != null) { set.Name = labelSetName; otm.SetSelectedItem(set); control = otm.DetailControl as LabelManagerControl; } } if (control != null) { control.AddItemFromPinnable(item); } } } }
public override ViewModelBase CreatePinnableViewModel(PinnableObject pinnable) { if (pinnable != null && pinnable.LookupType == LookupType.Taxon) { Taxon t = Service.GetTaxon(pinnable.ObjectID); if (t != null) { var m = new TaxonViewModel(null, t, tt => tt.TaxaFullName); return(m); } } if (pinnable != null && pinnable.LookupType == LookupType.DistributionRegion) { var service = new SupportService(User); var region = service.GetDistributionRegion(pinnable.ObjectID); if (region != null) { return(new DistributionRegionViewModel(region)); } } return(null); }
/// <summary> /// Informs the UI to pin a element /// </summary> /// <param name="element">Element to pin</param> private void Pin(PinnableObject element) { Messenger.Default.Send(element); }
private void AddToLabelSet() { if (_viewModel != null) { if (_viewModel.IsChanged || _viewModel.MaterialID <= 0) { ErrorMessage.Show("This material has unsaved changes. Please apply the changes before trying again."); return; } // make a pinnable... var pinnable = new PinnableObject(MaterialPlugin.MATERIAL_PLUGIN_NAME, Data.LookupType.Material, _viewModel.MaterialID); var target = PluginManager.Instance.FindAdaptorForPinnable<ILabelSetItemTarget>(pinnable); if (target != null) { target.AddItemToLabelSet(pinnable); } } }
public LinkedMultimediaItemsControl(MultimediaLinkViewModel viewModel) { InitializeComponent(); this.DataContext = viewModel; this.MultimediaID = viewModel.MultimediaID; var service = new SupportService(User); var mm = service.GetMultimedia(MultimediaID); var items = service.ListItemsLinkedToMultimedia(MultimediaID); var model = new ObservableCollection<ViewModelBase>(); foreach (MultimediaLinkedItem item in items) { if ( !string.IsNullOrWhiteSpace(item.CategoryName)) { LookupType t; if (Enum.TryParse<LookupType>(item.CategoryName, out t)) { var vm = PluginManager.Instance.GetViewModel(t, item.IntraCatID); if (vm!= null) { model.Add(vm); vm.Tag = t; } } } } lvw.MouseRightButtonUp += new MouseButtonEventHandler(lvw_MouseRightButtonUp); ListViewDragHelper.Bind(lvw, (dragged) => { if (dragged.Tag is LookupType) { var lookupType = (LookupType) dragged.Tag; var plugin = PluginManager.Instance.GetLookupTypeOwner(lookupType); if (plugin != null) { var data = new DataObject("Pinnable", dragged); var pinnable = new PinnableObject(plugin.Name, lookupType, dragged.ObjectID.Value); data.SetData(PinnableObject.DRAG_FORMAT_NAME, pinnable); data.SetData(DataFormats.Text, dragged.DisplayLabel); return data; } } return null; }); lvw.ItemsSource = model; CollectionView myView = (CollectionView)CollectionViewSource.GetDefaultView(lvw.ItemsSource); myView.SortDescriptions.Add(new SortDescription("Tag", ListSortDirection.Ascending)); myView.SortDescriptions.Add(new SortDescription("DisplayLabel", ListSortDirection.Ascending)); myView.GroupDescriptions.Add(new LinkedItemGroupDescription()); }
private DataObject CreateDragData(ViewModelBase dragged) { var selected = dragged as PlaceNameViewModel; if (selected != null) { var data = new DataObject("Pinnable", selected); var pinnable = new PinnableObject(GazetterPlugin.GAZETTEER_PLUGIN_NAME, LookupType.PlaceName, 0, selected.Model); data.SetData(PinnableObject.DRAG_FORMAT_NAME, pinnable); data.SetData(DataFormats.Text, selected.DisplayLabel); return data; } return null; }
/// <summary> /// Pin the conference /// </summary> /// <param name="conference">Conference transformed in adapted pinnable object</param> private void Pin(PinnableObject conference) { PinTaskHelper.CreateTile(conference as PinnableObjectWP); }
public override bool AcceptDroppedPinnable(PinnableObject pinnable) { return(pinnable.LookupType == LookupType.Material); }
/// <summary> /// Pin the news /// </summary> /// <param name="news">News transformed in adapted pinnable object</param> private void Pin(PinnableObject news) { PinTaskHelper.CreateTile(news as PinnableObjectWP); }
public void PopulateFromPinnable(ViewModelBase viewModel, PinnableObject pinnable) { var associate = viewModel as AssociateViewModel; if (associate != null) { var pinnableViewModel = PluginManager.Instance.GetViewModel(pinnable); if (pinnableViewModel != null) { associate.AssocName = pinnableViewModel.DisplayLabel; associate.RelativeCatID = TraitCategoryTypeHelper.GetCategoryIDFromLookupType(pinnable.LookupType); associate.RelativeIntraCatID = pinnable.ObjectID; } } }
/// <summary> /// Pin the show /// </summary> /// <param name="salon">Show transformed in adapted pinnable object</param> private void Pin(PinnableObject salon) { PinTaskHelper.CreateTile(salon as PinnableObjectWP); }
/// <summary> /// Pin the displayed conference on the Start Screen /// </summary> /// <param name="conference">The conference converted in a generic object</param> private async void Pin(PinnableObject conference) { CreateSecondaryTileHelper helper = new CreateSecondaryTileHelper(); await helper.PinAsync(conference); }
/// <summary> /// Pin the displayed show on the Start Screen /// </summary> /// <param name="show">The show converted in a generic object</param> private async void Pin(PinnableObject show) { CreateSecondaryTileHelper helper = new CreateSecondaryTileHelper(); await helper.PinAsync(show); }
public void AddMaterialToSet(PinnableObject item) { }
private DataObject CreateDragData(ViewModelBase dragged) { var selected = dragged as JournalViewModel; if (selected != null) { var data = new DataObject("Pinnable", selected); var pinnable = new PinnableObject(ToolsPlugin.TOOLS_PLUGIN_NAME, LookupType.Journal, selected.JournalID); data.SetData(PinnableObject.DRAG_FORMAT_NAME, pinnable); data.SetData(DataFormats.Text, selected.DisplayLabel); return data; } return null; }
public void AddItemFromPinnable(PinnableObject pinnable) { int maxOrder = 0; if (_itemModel.Count > 0) { maxOrder = _itemModel.Max((item) => { return(item.PrintOrder); }); } var newItem = new LabelSetItem { ItemID = pinnable.ObjectID, ItemType = pinnable.LookupType.ToString(), SetID = CurrentItemSetID, PrintOrder = maxOrder + 1, NumCopies = 1 }; var service = new MaterialService(User); Site site = null; SiteVisit visit = null; Material material = null; switch (pinnable.LookupType) { case LookupType.Material: material = service.GetMaterial(pinnable.ObjectID); visit = service.GetSiteVisit(material.SiteVisitID); site = service.GetSite(material.SiteID); break; case LookupType.SiteVisit: visit = service.GetSiteVisit(pinnable.ObjectID); site = service.GetSite(visit.SiteID); break; case LookupType.Site: site = service.GetSite(pinnable.ObjectID); break; } if (material != null) { newItem.MaterialID = material.MaterialID; newItem.TaxaFullName = material.TaxaDesc; newItem.AccessionNo = material.AccessionNumber; } if (visit != null) { newItem.VisitID = visit.SiteVisitID; newItem.Collectors = visit.Collector; newItem.DateType = visit.DateType; newItem.CasualDate = visit.CasualTime; newItem.StartDate = visit.DateStart; newItem.EndDate = visit.DateEnd; } if (site != null) { if (site.PoliticalRegionID <= 0) { ErrorMessage.Show("You cannot add this item as it does not belong to a political region (unplaced)"); return; } newItem.SiteID = site.SiteID; newItem.Region = site.PoliticalRegion; newItem.Local = site.Locality; newItem.LocalType = site.LocalityType; newItem.Lat = site.PosY1; newItem.Long = site.PosX1; newItem.Lat2 = site.PosY2; newItem.Long2 = site.PosX2; } var vm = new LabelSetItemViewModel(newItem); vm.DataChanged += new DataChangedHandler((viewModel) => { Host.RegisterUniquePendingChange(new UpdateLabelSetItemCommand(newItem)); }); Host.RegisterUniquePendingChange(new InsertLabelSetItemCommand(newItem, CurrentLabelSet.Model)); _itemModel.Add(vm); }
/// <summary> /// Pin the selected item /// </summary> /// <param name="element">Element converted in a generic item</param> private async void Pin(PinnableObject element) { CreateSecondaryTileHelper helper = new CreateSecondaryTileHelper(); await helper.PinAsync(element); }
/// <summary> /// Inform the UI to pin the element /// </summary> /// <param name="element">Element to pin</param> private void Pin(PinnableObject element) { MessengerInstance.Send(element); }
public virtual bool AcceptDroppedPinnable(PinnableObject pinnable) { return false; }
public virtual void PopulateFromPinnable(ViewModelBase viewModel, PinnableObject pinnable) { throw new NotImplementedException(); }