Example #1
0
        // Includes XML IO
        public void UpdateElement(Element element)
        {
            if (element == root)
            {
                dbControl.UpdateFragmentElementIntoXML(element);
                return;
            }

            if (element.IsCommandNote)
            {
                return;
            }

            if (element.ParentElement == null)
            {
                return;
            }

            if (element.IsLocalHeading)
            {
                string previousName = System.IO.Directory.GetParent(element.Path).Name;
                string currentName = HeadingNameConverter.ConvertFromHeadingNameToFolderName(element);
                if (previousName != currentName)
                {
                    if (CheckOpenFiles(element) == true)
                    {
                        return;
                    }
                }
            }

            if (element.ParentElement.Path != root.Path)
            {
                DatabaseControl temp_dbControl = new DatabaseControl(element.ParentElement.Path);
                temp_dbControl.newXooMLCreate += new NewXooMLCreateDelegate(dbControl_newXooMLCreate);
                temp_dbControl.OpenConnection();
                temp_dbControl.elementStatusChangedDelegate += new ElementStatusChangedDelegate(dbControl_elementStatusChanged);
                temp_dbControl.UpdateElementIntoXML(element);
                temp_dbControl.CloseConnection();
            }
            else
            {
                dbControl.UpdateElementIntoXML(element);
            }

            switch (element.Type)
            {
                case ElementType.Heading:
                    if (element.IsLocalHeading)
                    {
                        string previousPath = element.Path;
                        element.Path = element.ParentElement.Path + HeadingNameConverter.ConvertFromHeadingNameToFolderName(element) + System.IO.Path.DirectorySeparatorChar;
                        try
                        {
                            RenameFolder(element, previousPath);
                        }
                        catch (Exception)
                        {
                            element.Path = previousPath;
                            element.NoteText = System.IO.Directory.GetParent(element.Path).Name;
                            MessageBox.Show("The heading name is too long, please shorten the name and try again.");
                            return;
                        }
                    }
                    DatabaseControl temp_dbControl = new DatabaseControl(element.Path);
                    temp_dbControl.newXooMLCreate +=new NewXooMLCreateDelegate(dbControl_newXooMLCreate);
                    temp_dbControl.OpenConnection();
                    temp_dbControl.UpdateFragmentElementIntoXML(element);
                    temp_dbControl.CloseConnection();
                    break;
                case ElementType.Note:
                    break;
            };
        }
Example #2
0
        public void HideElement(Element element)
        {
            if (element.IsCommandNote)
            {
                return;
            }

            if (element.ElementAboveUnderSameParent != null &&
                element.ElementAboveUnderSameParent.IsCommandNote &&
                element.ElementAboveUnderSameParent.Command == ElementCommand.DisplayMoreAssociations)
            {
                int hiddenAssociationCount = Int32.Parse(element.ElementAboveUnderSameParent.NoteText.Split(' ')[10]);
                element.ElementAboveUnderSameParent.NoteText = String.Format("Click the icon on the right to show the next {0} association(s)", ++hiddenAssociationCount);
            }
            else if (element.ElementBelowUnderSameParent != null &&
                element.ElementBelowUnderSameParent.IsCommandNote &&
                element.ElementBelowUnderSameParent.Command == ElementCommand.DisplayMoreAssociations)
            {
                int hiddenAssociationCount = Int32.Parse(element.ElementBelowUnderSameParent.NoteText.Split(' ')[10]);
                element.ElementBelowUnderSameParent.NoteText = String.Format("Click the icon on the right to show the next {0} association(s)", ++hiddenAssociationCount);
            }
            else
            {
                int hiddenAssociationCount = 0;
                Element commandNote = new Element();
                commandNote.Type = ElementType.Note;
                commandNote.Command = ElementCommand.DisplayMoreAssociations;
                commandNote.Status = ElementStatus.Special;
                commandNote.TailImageSource = String.Format("pack://application:,,,/{0};component/{1}", "Planz", "Images/command.png");
                commandNote.HasAssociation = true;
                commandNote.CanOpen = false;
                commandNote.CanExplore = false;
                commandNote.CanRename = false;
                commandNote.CanDelete = false;
                commandNote.NoteText = String.Format("Click the icon on the right to show the next {0} association(s)", ++hiddenAssociationCount);

                InsertElement(commandNote, element.ParentElement, element.Position);
            }

            element.IsVisible = Visibility.Collapsed;

            DatabaseControl temp_dbControl = new DatabaseControl(element.ParentElement.Path);
            temp_dbControl.OpenConnection();
            temp_dbControl.UpdateElementIntoXML(element);
            temp_dbControl.CloseConnection();
        }