private void CreateTopic_CanExecute(Object sender, CanExecuteRoutedEventArgs e)
 {
     if (HelpFunctions.StringIsBlank(GivenTitleTextBox.Text))
     {
         e.CanExecute = false;
     }
     else
     {
         e.CanExecute = true;
     }
 }
示例#2
0
        //Updates all references to a project with the info of a new one
        public void EditTopic(String oldTitle, Topic newTopic)
        {
            //update memory
            if (!newTopic.title.Equals(oldTitle))
            {
                //add references to new title, remove references from old title
                AddTopicToMemory(newTopic);
                List <String> associatedTopics = new List <String>(topicConnections[oldTitle]);
                foreach (String tag in associatedTopics)
                {
                    CreateTopicTagPairing(newTopic.title, tag);
                    DeleteTopicTagPairing(oldTitle, tag);
                }
                RemoveTopicFromMemory(oldTitle);
            }
            else
            {
                topics[oldTitle] = newTopic;
            }

            //update database

            //convert complex fields to binary
            byte[] mainImageBytes = HelpFunctions.ImageToBytes(newTopic.main_image);

            //update UserTopics
            SQLiteCommand command = dbConnection.CreateCommand();

            command.CommandText =
                "update UserTopics set " +
                "title = (@title), " +
                "text_body = (@body), " +
                "main_image = (@image) " + //don't forget to add comma back in
                                           //"set image_gallery = (@gallery) " +
                "where parent_project = (@parent) " +
                "and title = (@oldTitle)";

            command.Parameters.AddWithValue("@title", newTopic.title);
            command.Parameters.AddWithValue("@body", newTopic.encoded_text);
            command.Parameters.AddWithValue("@image", mainImageBytes);
            //command.Parameters.AddWithValue("@gallery", );
            command.Parameters.AddWithValue("@parent", newTopic.parent_project);
            command.Parameters.AddWithValue("@oldTitle", oldTitle);
            dbConnection.Open();
            command.ExecuteNonQuery();
            dbConnection.Close();
        }
示例#3
0
        private void FillProjectSideBar(StackPanel OtherProjects)
        {
            List <String> appProjects = new List <string>();

            foreach (String projectName in theWindow.appProjects)
            {
                if (!projectName.Equals((parentControl as ProjectHomeUserControl).project.title)) //don't give a link to the topic that's already displayed
                {
                    WrapPanel cursorWrap  = new WrapPanel();
                    TextBlock projectLink = HelpFunctions.CreateSideBarLink(projectName);
                    projectLink.Cursor   = Cursors.Hand;
                    projectLink.MouseUp += LinkToTargetProject;
                    cursorWrap.Children.Add(projectLink);
                    OtherProjects.Children.Add(cursorWrap);
                }
            }
        }
 private void NewTag_Clicked(Object sender, RoutedEventArgs e)
 {
     if (!NewTagInputBox.Visibility.Equals(Visibility.Visible))
     {
         NewTagInputBox.Visibility = Visibility.Visible;
         Keyboard.Focus(NewTagInputBox);
     }
     else
     {
         if (!HelpFunctions.StringIsBlank(NewTagInputBox.Text))
         {
             this.project.AddTag(NewTagInputBox.Text);
             UpdateTagList();
             NewTagInputBox.Visibility = Visibility.Collapsed;
             NewTagInputBox.Text       = "";
         }
     }
 }
        //Adds a togglebutton representing a tag to the UI
        private void AddTagToUI(String tag)
        {
            ToggleButton tagUI = HelpFunctions.CreateTagToggle(tag);

            //right click context menu
            tagUI.ContextMenu = new ContextMenu();
            tagUI.ContextMenu.PlacementTarget = tagUI;
            tagUI.ContextMenu.Items.Add(new MenuItem());
            ((MenuItem)tagUI.ContextMenu.Items[0]).Header = "Add Topics";
            ((MenuItem)tagUI.ContextMenu.Items[0]).Click += AddTopicsToTag_Clicked;
            tagUI.ContextMenu.Items.Add(new MenuItem());
            ((MenuItem)tagUI.ContextMenu.Items[1]).Header = "Remove Topics";
            ((MenuItem)tagUI.ContextMenu.Items[1]).Click += RemoveTopicsFromTag_Clicked;
            tagUI.ContextMenu.Items.Add(new MenuItem());
            ((MenuItem)tagUI.ContextMenu.Items[2]).Header = "Delete Tag";
            ((MenuItem)tagUI.ContextMenu.Items[2]).Click += DeleteTag_Clicked;
            //event handlers for sorting
            tagUI.Checked   += Tag_SelectionChanged;
            tagUI.Unchecked += Tag_SelectionChanged;
            //add to UI
            this.tagsList.Add(tag, tagUI);
            TagsPanel.Children.Add(tagUI);
        }