Ejemplo n.º 1
0
        public void UpdateRootPath(string newRootPath)
        {
            root.Path = newRootPath;
            root.Elements.Clear();

            ni_root.Path = newRootPath;
            ni_root.Items.Clear();
            ni_root.Items.Clear();
            selectedElements.Clear();
            updateStatusList.Clear();
            tobeDeletedElements.Clear();

            GC.Collect();

            dbControl = new DatabaseControl(newRootPath);
            dbControl.newXooMLCreate += new NewXooMLCreateDelegate(dbControl_newXooMLCreate);
            dbControl.OpenConnection();
            dbControl.newDBControlHighP += new NewDatabaseControlHandler(dbControl_newDBControlHighP);
            dbControl.newDBControlLowP += new NewDatabaseControlHandler(dbControl_newDBControlLowP);
            dbControl.elementUpdate += new ElementUpdateDelegate(dbControl_elementUpdate);
            dbControl.elementStatusChangedDelegate += new ElementStatusChangedDelegate(dbControl_elementStatusChanged);
            dbControl.elementDelete += new ElementDeleteDelegate(dbControl_elementDelete);

            foreach (Element element in dbControl.GetAllElementFromXML())
            {
                AddElement(element, root);

                if (element.IsHeading)
                {
                    NavigationItem ni = new NavigationItem
                    {
                        Name = element.NoteText,
                        Path = element.Path,
                        Parent = ni_root,
                    };
                    ni.Items.Add(new NavigationItem());
                    ni_root.Items.Add(ni);
                }
            }

            currentElement = root;

            RunXMLBackgroundWorker();
        }
Ejemplo n.º 2
0
        public Element GetHeadingElement(NavigationItem ni)
        {
            Element targetElement = null;

            Stack<string> stack = new Stack<string>();
            NavigationItem ni_iter = ni;
            while (ni_iter != null)
            {
                stack.Push(ni_iter.Name);
                ni_iter = ni_iter.Parent;
            }

            stack.Pop();
            targetElement = root;
            while (stack.Count != 0)
            {
                string name = stack.Pop();
                if (targetElement.IsExpanded == false)
                {
                    isNavigationExpansion = true;
                    targetElement.IsExpanded = true;
                    targetElement.LevelOfSynchronization = 1;
                    UpdateElement(targetElement);
                    SyncHeadingElement(targetElement);
                    return null;
                }
                foreach (Element ele in targetElement.Elements)
                {
                    if (ele.NoteText == name)
                    {
                        targetElement = ele;
                        break;
                    }
                }
            }

            return targetElement;
        }
Ejemplo n.º 3
0
        public void SyncNavigationItem(NavigationItem ni_root)
        {
            List<NavigationItem> ni_list;

            if (ni_root.Path != root.Path)
            {
                DatabaseControl temp_dbControl = new DatabaseControl(ni_root.Path);
                temp_dbControl.OpenConnection();
                ni_list = temp_dbControl.GetAllHeadingElementFromXML();
                temp_dbControl.CloseConnection();
            }
            else
            {
                ni_list = dbControl.GetAllHeadingElementFromXML();
            }

            ni_root.Items.Clear();
            foreach (NavigationItem ni in ni_list)
            {
                ni.Parent = ni_root;
                ni.Items.Add(new NavigationItem());
                ni_root.Items.Add(ni);
            }
        }
Ejemplo n.º 4
0
        // Note: param "rootElementPath" should be ending with System.IO.Path.DirectorySeparatorChar
        public ElementControl(string rootElementPath)
        {
            root = new Element
            {
                ParentElement = null,
                HeadImageSource = String.Empty,
                TailImageSource = String.Empty,
                NoteText = String.Empty,
                IsExpanded = true,
                Path = rootElementPath,
                Type = ElementType.Heading,
            };

            ni_root = new NavigationItem
            {
                Name = String.Empty,
                Path = rootElementPath,
                Parent = null,
            };

            dbControl = new DatabaseControl(rootElementPath);
            dbControl.newXooMLCreate += new NewXooMLCreateDelegate(dbControl_newXooMLCreate);
            dbControl.OpenConnection();
            dbControl.newDBControlHighP += new NewDatabaseControlHandler(dbControl_newDBControlHighP);
            dbControl.newDBControlLowP += new NewDatabaseControlHandler(dbControl_newDBControlLowP);
            dbControl.elementUpdate += new ElementUpdateDelegate(dbControl_elementUpdate);
            dbControl.elementStatusChangedDelegate += new ElementStatusChangedDelegate(dbControl_elementStatusChanged);
            dbControl.elementDelete += new ElementDeleteDelegate(dbControl_elementDelete);

            root.ShowAssociationMarkedDone = dbControl.GetFragmentElementFromXML().ShowAssociationMarkedDone;
            root.ShowAssociationMarkedDefer = dbControl.GetFragmentElementFromXML().ShowAssociationMarkedDefer;

            foreach (Element element in dbControl.GetAllElementFromXML())
            {
                if (element.IsVisible == Visibility.Collapsed)
                {
                    continue;
                }

                AddElement(element, root);

                if (element.IsHeading)
                {
                    NavigationItem ni = new NavigationItem
                    {
                        Name = element.NoteText,
                        Path = element.Path,
                        Parent = ni_root,
                    };
                    ni.Items.Add(new NavigationItem());
                    ni_root.Items.Add(ni);
                }
            }

            currentElement = root;

            RunXMLBackgroundWorker();
        }