private void addNewImg_MouseUp(object sender, MouseButtonEventArgs e) { MList l = data[shownList]; if (l.CanObserve()) { bool wasModification = new AddItemDialog().ShowDialogForItem(this, l); if (wasModification) { Refresh(); } } }
private void DisplayItem(int i) { itemContentPanel.ClearGrid(); MList ml = data[shownList]; if (ml.Count == 0 || i == -1) { itemContentPanel.Visibility = Visibility.Collapsed; noItemsLabel.Visibility = Visibility.Visible; noItemsLabel.Content = i == -1 ? "No Item Selected" : "No Items!"; } else { itemContentPanel.Visibility = Visibility.Visible; noItemsLabel.Visibility = Visibility.Collapsed; MItem item = ml[i]; Utils.SetupContentGrid(itemContentPanel, ml.Template.Values.Select(fti => fti.Space)); //TODO foreach (string fieldName in ml.Template.Keys) { MField lif = item[fieldName]; FrameworkElement fe = null; FieldTemplateItem fti = ml.Template[fieldName]; if (lif.FieldType.Equals(FieldType.IMAGE)) { fe = new CImage(); (fe as CImage).Source = (lif as ImageField).ToVisibleValue(fti.Metadata) as System.Windows.Media.Imaging.BitmapImage; } //else if (lif is EnumField) { // fe = new Label(); // (fe as Label).Content = (lif as EnumField).GetSelectedValue(fti.Metadata as EnumMetadata); //} else { fe = new Label(); (fe as Label).Content = lif.Value == null ? "" : lif.ToVisibleValue(fti.Metadata).ToString(); } Grid.SetColumn(fe, fti.X); Grid.SetRow(fe, fti.Y); Grid.SetColumnSpan(fe, fti.Width); Grid.SetRowSpan(fe, fti.Height); itemContentPanel.Children.Add(fe); } } }
private void ReloadActionBar(MList list) { listActionBar.Children.Clear(); if (list != null && list.CanObserve()) { Label title = new Label(); title.Content = list.Name; DockPanel.SetDock(title, Dock.Left); listActionBar.Children.Add(title); listActionBar.Children.Add(CreateActionImage(Properties.Resources.optionIcon.ConvertToBitmapImage(), listOptionImg_MouseUp)); listActionBar.Children.Add(CreateActionImage(Properties.Resources.addIcon.ConvertToBitmapImage(), addNewImg_MouseUp)); if (list is SyncList) { listActionBar.Children.Add(CreateActionImage(Properties.Resources.reloadIcon.ConvertToBitmapImage(), SyncActionButton_OnClick)); } } }
/// <summary> /// Displays the list with the specified ID into the listItemGrid /// If the list is not obvervable, a screen specifying so is displayed /// </summary> private void DisplayList(int id) { if (data.Count > 0 && data[id].CanObserve()) { listItemGrid.Visibility = Visibility.Visible; noListsLabel.Visibility = Visibility.Collapsed; MList list = data[id]; //change the action bar's actions to match the current list // (and remove it if the list is not observable) ReloadActionBar(list); //load the items from this list listItemGrid.ItemsSource = list.Items; //setup columns listItemGrid.Columns.Clear(); foreach (string fieldName in list.Template.Keys) { listItemGrid.Columns.Add(DefineColumn(fieldName, list.Template[fieldName])); } } else { listItemGrid.Visibility = Visibility.Collapsed; noListsLabel.Visibility = Visibility.Visible; ReloadActionBar(null); //clear the items there listItemGrid.ItemsSource = null; //display the list is currently inaccessable noListsLabel.Content = data.Count > 0 ? "Currently Syncing" : "No lists!"; } if (data.Count > 0) { //update shown list shownList = id; //try to display the first item DisplayItem(0); } }
//methods public SyncTemplateItem ToTemplateItem(MList ml) { return(new SyncTemplateItem(Type, Metadata, ml.FindOpenSpace(1, 1), DefaultName, Id, ParamList)); }