Example #1
0
        private void DisplayObject(object sender, EventArgs e)
        {
            DataGridViewRow row = (dataGridView1.SelectedRows.Count > 0 ? dataGridView1.SelectedRows[0] : dataGridView1.Rows[dataGridView1.SelectedCells[0].RowIndex]);
            OMKey           key = new OMKey((string)row.Cells[0].Value, (string)row.Cells[1].Value, (int)row.Cells[2].Value);

            ObjectDisplayForm odf = new ObjectDisplayForm(key.ToString());

            odf.Show();
        }
Example #2
0
        public static bool Remove(string name)
        {
            object o = Get(name);

            if (o != null)
            {
                OMKey key = OM.Where(x => x.Value == o).Select(x => x.Key).SingleOrDefault();
                OM.Remove(key);

                return(true);
            }

            return(false);
        }
Example #3
0
        private static string Add(string name, object o, int c)
        {
            OMKey key = new OMKey(name, o.GetType().Name, c);

            if (OM.ContainsKey(key))
            {
                return(Add(name, o, ++c));
            }
            else
            {
                OM.Add(key, o);

                return(key.ToString());
            }
        }
Example #4
0
        // Unsanitised names will cause problems with this function.
        public static bool Contains(string name, bool strict)
        {
            string[] tokens = name.Split(new string[] { "::", "@@" }, StringSplitOptions.RemoveEmptyEntries);

            if (strict)
            {
                if (tokens.Length == 1 || tokens.Length > 3)
                {
                    return(false);
                }

                OMKey key = new OMKey(tokens[0], tokens[1], (tokens.Length == 2 ? -1 : int.Parse(tokens[2])));
                return(OM.ContainsKey(key));
            }
            else
            {
                return(OM.Keys.Where(x => x.Name == tokens[0]).Count() > 0);
            }
        }
Example #5
0
        // To make value comparisons work.
        public override bool Equals(object obj)
        {
            OMKey other = obj as OMKey;

            return(other != null && other.ToString() == this.ToString());
        }
Example #6
0
        private void DeleteObject(object sender, DataGridViewRowCancelEventArgs e)
        {
            OMKey key = new OMKey((string)e.Row.Cells[0].Value, (string)e.Row.Cells[1].Value, (int)e.Row.Cells[2].Value);

            XLOM.Remove(key.ToString());
        }