Example #1
0
        private void newItemButton_Click(object sender, EventArgs e)
        {
            ItemDataWrapper newitem = new ItemDataWrapper();

            Storage.OpenItems.Add(newitem);
            entriesListBox.SelectedIndex = Storage.OpenItems.Count - 1;

            //Fill in default values
            foreach (Control c in Controls)
            {
                if (c.Visible && c.Tag is DataFormTag)
                {
                    foreach (Control d in c.Controls[0].Controls)
                    {
                        if (d.Tag is JsonFormTag &&
                            !string.IsNullOrEmpty(((JsonFormTag)d.Tag).key) &&
                            ((JsonFormTag)d.Tag).mandatory &&
                            !newitem.data.ContainsKey(((JsonFormTag)d.Tag).key))
                        {
                            newitem.data[((JsonFormTag)d.Tag).key] = ((JsonFormTag)d.Tag).def;
                        }
                    }
                }
            }

            Storage.FileChanged();
        }
Example #2
0
 private void ControlSetDefaults(Control c, ItemDataWrapper newitem)
 {
     foreach (Control d in c.Controls)
     {
         if (d.Tag is JsonFormTag &&
             !string.IsNullOrEmpty(((JsonFormTag)d.Tag).key) &&
             ((JsonFormTag)d.Tag).mandatory &&
             !newitem.data.ContainsKey(((JsonFormTag)d.Tag).key))
         {
             newitem.data[((JsonFormTag)d.Tag).key] = ((JsonFormTag)d.Tag).def;
         }
         if (d.Controls.Count > 0)
         {
             ControlSetDefaults(d, newitem);
         }
     }
 }
Example #3
0
        private void newItemButton_Click(object sender, EventArgs e)
        {
            ItemDataWrapper newitem = new ItemDataWrapper(Storage.CurrentFileIndex);

            Storage.OpenItems.Add(newitem);
            entriesListBox.SelectedIndex = Storage.OpenItems.Count - 1;

            //Fill in default values
            foreach (Control c in Controls)
            {
                if (c.Visible && c.Tag is DataFormTag)
                {
                    ControlSetDefaults(c, newitem);
                }
            }

            Storage.FileChanged();
        }
Example #4
0
        public ItemDataWrapper(ItemDataWrapper copy)
        {
            data = new Dictionary<string, object>(copy.data);
            int lastitem = 0;
            foreach (ItemDataWrapper i in Storage.OpenItems)
                if (i.Display.StartsWith(copy.Display))
                {
                    try
                    {
                        lastitem = Math.Max(lastitem, Int32.Parse(i.Display.Substring(copy.Display.Length)));
                    }
                    catch (FormatException)
                    {

                    }
                }

            //TODO: might need a different display member
            data["id"] = copy.Display + (lastitem + 1);
        }
Example #5
0
        public ItemDataWrapper(ItemDataWrapper copy)
        {
            data = new Dictionary <string, object>(copy.data);
            int lastitem = 0;

            foreach (ItemDataWrapper i in Storage.OpenItems)
            {
                if (i.Display.StartsWith(copy.Display))
                {
                    try
                    {
                        lastitem = Math.Max(lastitem, Int32.Parse(i.Display.Substring(copy.Display.Length)));
                    }
                    catch (FormatException)
                    {
                    }
                }
            }

            //TODO: might need a different display member
            data["id"] = copy.Display + (lastitem + 1);
        }
Example #6
0
        /// <summary>
        /// Create a new item with data copied from the specified item.
        /// </summary>
        /// <param name="copy"></param>
        public ItemDataWrapper(ItemDataWrapper copy)
        {
            this.memberOf = copy.memberOf;

            data = new Dictionary<string, object>(copy.data);
            int lastitem = 0;
            foreach (ItemDataWrapper i in Storage.OpenItems)
                if (i.Display.StartsWith(copy.Display))
                {
                    try
                    {
                        lastitem = Math.Max(lastitem, Int32.Parse(i.Display.Substring(copy.Display.Length)));
                    }
                    catch (FormatException)
                    {

                    }
                }

            //TODO: support raw arrays (skills)
            data[MemberOf.displayMember] = copy.Display + (lastitem + 1);
        }
Example #7
0
        /// <summary>
        /// Create a new item with data copied from the specified item.
        /// </summary>
        /// <param name="copy"></param>
        public ItemDataWrapper(ItemDataWrapper copy)
        {
            this.memberOf = copy.memberOf;

            data = new Dictionary <string, object>(copy.data);
            int lastitem = 0;

            foreach (ItemDataWrapper i in Storage.OpenItems)
            {
                if (i.Display.StartsWith(copy.Display))
                {
                    try
                    {
                        lastitem = Math.Max(lastitem, Int32.Parse(i.Display.Substring(copy.Display.Length)));
                    }
                    catch (FormatException)
                    {
                    }
                }
            }

            //TODO: support raw arrays (skills)
            data[MemberOf.displayMember] = copy.Display + (lastitem + 1);
        }
Example #8
0
        private void newItemButton_Click(object sender, EventArgs e)
        {
            ItemDataWrapper newitem = new ItemDataWrapper(Storage.CurrentFileIndex);
            Storage.OpenItems.Add(newitem);
            entriesListBox.SelectedIndex = Storage.OpenItems.Count - 1;

            //Fill in default values
            foreach (Control c in Controls)
            {
                if (c.Visible && c.Tag is DataFormTag)
                {
                    ControlSetDefaults(c, newitem);
                }
            }

            Storage.FileChanged();
        }
Example #9
0
 private void ControlSetDefaults(Control c, ItemDataWrapper newitem)
 {
     foreach (Control d in c.Controls)
     {
         if (d.Tag is JsonFormTag
             && !string.IsNullOrEmpty(((JsonFormTag)d.Tag).key)
             && ((JsonFormTag)d.Tag).mandatory
             && !newitem.data.ContainsKey(((JsonFormTag)d.Tag).key))
         {
             newitem.data[((JsonFormTag)d.Tag).key] = ((JsonFormTag)d.Tag).def;
         }
         if (d.Controls.Count > 0)
         {
             ControlSetDefaults(d, newitem);
         }
     }
 }
Example #10
0
        private void newItemButton_Click(object sender, EventArgs e)
        {
            ItemDataWrapper newitem = new ItemDataWrapper();
            Storage.OpenItems.Add(newitem);
            entriesListBox.SelectedIndex = Storage.OpenItems.Count - 1;

            //Fill in default values
            foreach (Control c in Controls)
            {
                if (c.Visible && c.Tag is DataFormTag)
                {
                    foreach (Control d in c.Controls[0].Controls)
                    {
                        if (d.Tag is JsonFormTag
                            && !string.IsNullOrEmpty(((JsonFormTag)d.Tag).key)
                            && ((JsonFormTag)d.Tag).mandatory
                            && !newitem.data.ContainsKey(((JsonFormTag)d.Tag).key))
                        {
                            newitem.data[((JsonFormTag)d.Tag).key] = ((JsonFormTag)d.Tag).def;
                        }
                    }
                }
            }

            Storage.FileChanged();
        }