Beispiel #1
0
 internal void SetMetadata(string fieldName, IMetadata metadata)
 {
     template[fieldName].Metadata = metadata;
     foreach (MItem mi in items)
     {
         MField mf = mi[fieldName];
         if (!metadata.Verify(mf.Value))
         {
             mf.Value = mf.StartingValue();
         }
     }
 }
Beispiel #2
0
 /// <summary>
 /// Recovers an MItem from a decoded dictionary set
 /// </summary>
 internal MItem(Dictionary <string, string> decoded)
 {
     fields = new Dictionary <string, MField>();
     foreach (string fieldName in decoded.Keys)
     {
         if (!fieldName.Equals(C.TYPE_ID_KEY))
         {
             //decode the MField's data and add the field
             MField mf = CreateField(Utils.DecodeMultiple(decoded[fieldName]));
             fields.Add(fieldName, mf);
         }
     }
 }
Beispiel #3
0
        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);
                }
            }
        }
 /// <summary>
 /// Fills a ui element with the data from a field
 /// </summary>
 /// <param name="uiField">the ui element to fill</param>
 /// <param name="field">the field to get data from</param>
 private void FillValueIn(FrameworkElement uiField, MField field)
 {
     if (uiField is TextBox)
     {
         //includes TextBox, NumberTextBox, DecimalTextBox
         (uiField as TextBox).Text = field.Value.ToString();
     }
     else if (uiField is DatePicker)
     {
         (uiField as DatePicker).SelectedDate = (DateTime)field.Value;
     }
     else if (uiField is ComboBox)
     {
         (uiField as ComboBox).SelectedIndex = (int)field.Value;
     }
     else if (uiField is BackupImage)
     {
         //set the source to a BitmapImage, and store the XImage for later
         (uiField as BackupImage).SetSourceAndBackup((field as ImageField).Value as XImage);
     }
 }
Beispiel #5
0
 private void SaveReadable()
 {
     //TODO
     using (TextWriter tw = new StreamWriter(C.READABLE_BACKUP_FILE)) {
         foreach (MList ml in lists)
         {
             tw.WriteLine(ml.Name);
             tw.WriteLine("=================");
             foreach (MItem mi in ml)
             {
                 tw.WriteLine("Item:");
                 foreach (string fieldName in ml.Template.Keys)
                 {
                     MField            lif = mi[fieldName];
                     FieldTemplateItem fti = ml.Template[fieldName];
                     tw.Write("\t" + fieldName + ": ");
                     tw.Write(lif.ToReadable(fti.Metadata));
                 }
             }
         }
     }
 }