private void FillList(TreeViewItem parent, Element element)
        {
            var list = Element.GetList( element.ID );
            if (list.Count() > 0)
            {
                foreach (var l in list)
                {
                    TreeViewItem newSubChild = new TreeViewItem();
                    newSubChild.Header = l.Name;
                    newSubChild.Tag = l;
                    newSubChild.IsExpanded = true;
                    parent.Items.Add(newSubChild);

                    FillList(newSubChild, l);
                }
            }

            foreach (var aw in element.Actionwords)
            {
                TreeViewItem newSubChild = new TreeViewItem();
                newSubChild.Header = aw.Name;
                newSubChild.FontWeight = FontWeights.Bold;
                newSubChild.Tag = aw;
                newSubChild.IsExpanded = true;
                newSubChild.MouseDoubleClick += new MouseButtonEventHandler(newSubChild_MouseDoubleClick);
                parent.Items.Add(newSubChild);

            }
        }
 private void FillElementTree(TreeViewItem parent, Element element)
 {
     foreach (var l in element.Elements)
     {
         var newSubChild = AddElementToTree(parent, l);
         FillElementTree(newSubChild, l);
     }
 }
        private TreeViewItem AddElementToTree(TreeViewItem parent, Element element)
        {
            TreeViewItem newChild = new TreeViewItem();
            newChild.Header = element.Name;
            newChild.Tag = element;
            newChild.IsExpanded = true;
            if (parent == null)
                tvCategories.Items.Add(newChild);
            else
                parent.Items.Add(newChild);

            tvCategories.RegisterName(element.Name.Replace(" ", "_"), newChild);

            return newChild;
        }
Пример #4
0
        public static List<Screen> GetList(Element element = null)
        {
            var list = new List<Screen>();
            var conn = TFDatabase.Active.Connection;
            OleDbCommand cmd;

            if (element == null)
            {
                cmd = new OleDbCommand("SELECT * FROM [screen]", conn);
            }
            else
            {
                cmd = new OleDbCommand("SELECT * FROM [screen] WHERE [element]=@ID", conn);
                cmd.Parameters.AddWithValue("@ID", element.ID);
            }

            var reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                list.Add(new Screen()
                {
                    ID = Convert.ToInt32(reader["screen_id"].ToString())
                    ,
                    Name = reader["screenname"].ToString()
                    ,
                    Fullname = reader["screenname full"].ToString()
                    ,
                    ElementID = Convert.ToInt32(reader["element"].ToString())
                    ,
                    Element = element
                });
            }

            cmd.Dispose();
            return list;
        }
Пример #5
0
        public static List<Element> GetList(int parent = 0)
        {
            var list = new List<Element>();

            var conn = TFDatabase.Active.Connection;

            var cmd = new OleDbCommand("SELECT [element_id], [element_name], [element_fullname] FROM [element] WHERE [parent]=@ID", conn);
            cmd.Parameters.AddWithValue("@ID", parent);

            var reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                var el = new Element()
                {
                      ID = Convert.ToInt32(reader["element_id"].ToString())
                    , Name = reader["element_name"].ToString()
                    , Fullname = reader["element_fullname"].ToString()
                    , Parent = parent
                };
                el.Dirty = false;
                list.Add(el);
            }

            cmd.Dispose();

            return list;
        }
Пример #6
0
        public static Element New(Element parent = null, string name = "<new element>")
        {
            var element = new Element();

            element.ID = 0;
            element.Name = name;
            if (parent!=null)
                element.Parent = parent.ID;
            else
                element.Parent = 0;
            element._isnew = true;

            return element;
        }
        private void tvCategories_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            var sel = (TreeViewItem)tvCategories.SelectedItem;

            if (sel == null) return; // nothing selected

            var t = sel.Tag;

            if (t == null) return;

            if (t.GetType().Equals(typeof(Element)))
            {
                current_element = (Element)t;
            }
        }
Пример #8
0
 public static Actionword New(Element element, string name)
 {
     var actionword = new Actionword() {  Element = element, Name = name };
     actionword._isnew = true;
     return actionword;
 }
Пример #9
0
        public static List<Actionword> GetList(Element element = null)
        {
            var list = new List<Actionword>();
            var conn = TFDatabase.Active.Connection;
            OleDbCommand cmd;

            if (element == null)
            {
                cmd = new OleDbCommand("SELECT * FROM [actionword]", conn);
            }
            else
            {
                cmd = new OleDbCommand("SELECT * FROM [actionword] WHERE [element]=@ID", conn);
                cmd.Parameters.AddWithValue("@ID", element.ID);
            }

            var reader = cmd.ExecuteReader();
            while (reader.Read())
            {
                var aw = new Actionword() {
                    ID = Convert.ToInt32(reader["actionword_ID"].ToString())
                    , Name = reader["actionword"].ToString()
                    , Description = reader["description"].ToString()
                    , Actions = reader["actions"].ToString()
                    , PreCondition = reader["precondition"].ToString()
                    , PostCondition = reader["postcondition"].ToString()
                    , Element = element
                };
                aw.Dirty = false;
                if ( reader["start_screen"]==null )
                    aw.StartScreen = int.Parse(reader["start_screen"].ToString());

                if (reader["end_screen"] == null)
                    aw.EndScreen = int.Parse(reader["end_screen"].ToString());

                list.Add(aw);
            }

            cmd.Dispose();
            return list;
        }