示例#1
0
        /// <summary>
        /// Display the theme dialog. With an ID property of 0, the dialog goes into "new theme" mode. Setting the ID > 0 the dialog goes into "theme edit" mode.
        /// </summary>
        public void AddTheme()
        {
            statusLabel.Text = "Creating new theme...";
            ThemeDialog  myThemeDialog = new ThemeDialog();
            DialogResult result        = myThemeDialog.ShowDialog();

            // Dialog, go into "new theme" mode.
            myThemeDialog.FolderID = 0;

            if (result == DialogResult.OK)
            {
                try
                {
                    rssDataSet.FolderRow theme = rssDataSet.Folder.NewFolderRow();
                    theme.FolderName = myThemeDialog.FolderName;
                    int rowsAffected = folderTableAdapter.Update(theme);
                    rssDataSet.Folder.AddFolderRow(theme);
                    SqlConnection     cn = new SqlConnection();
                    SqlDataAdapter    da;
                    SqlCommandBuilder cmdBuilder;
                    cn.ConnectionString = System.Configuration.ConfigurationManager.ConnectionStrings["RSSReader.Properties.Settings.rssConnectionString"].ConnectionString;
                    cn.Open();
                    da         = new SqlDataAdapter("select * from Folder order by FolderId", cn);
                    cmdBuilder = new SqlCommandBuilder(da);
                    var submit = cmdBuilder.GetUpdateCommand().CommandText;
                    da.Update(rssDataSet, "Folder");
                    statusLabel.Text = "New theme created - '" + myThemeDialog.FolderName + "'";
                    Logging.WriteLog("New theme created - '" + myThemeDialog.FolderName + "'", Logging.LogType.Information, Logging.LogCaller.MainForm);
                }
                catch (Exception ex)
                {
                    statusLabel.Text = "Problem creating new theme. Could not save into database.";
                    MessageBox.Show("Problem creating new theme: " + ex.Message);
                    Logging.WriteLog(ex.Message, Logging.LogType.Error, Logging.LogCaller.MainForm);
                }
            }
            else
            {
                statusLabel.Text = "New folder operation cancelled.";
            }

            myThemeDialog = null;
        }
示例#2
0
        /// <summary>
        /// Edit the chosen theme.
        /// </summary>
        public void EditTheme()
        {
            statusLabel.Text = "Editing theme...";
            int          themeID       = (int)folderComboBox.SelectedValue;
            ThemeDialog  myThemeDialog = new ThemeDialog();
            DialogResult result        = myThemeDialog.ShowDialog();

            rssDataSet.FolderRow folder = rssDataSet.Folder.FindByFolderID(themeID);
            myThemeDialog.FolderID   = themeID;
            myThemeDialog.FolderName = folder.FolderName;

            if (result == DialogResult.OK)
            {
                int rowsAffected = folderTableAdapter.Update(folder);

                try
                {
                    folder.BeginEdit();
                    folder.FolderName = myThemeDialog.FolderName;
                    folder.EndEdit();

                    if (rowsAffected > 0)
                    {
                        statusLabel.Text = "Folder edited successfully: '" + folder.FolderName + "'";
                    }
                    else
                    {
                        statusLabel.Text = "Problem updating folder.  Could not save into the database.";
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Problem editing folder: " + ex.Message);
                }
            }
            else
            {
                statusLabel.Text = "Edit folder operation cancelled.";
            }
            myThemeDialog = null;
        }
示例#3
0
        private void themeClicked(object sender, RoutedEventArgs e)
        {
            ThemeDialog themeDialog = new ThemeDialog();

            themeDialog.ShowDialog();
        }