private void Save_Click(object sender, RoutedEventArgs e)
        {
            // Validate favorite name.
            if (Favorite.IsTitleInvalid(MyTitle.Text))
            {
                var errorWindow = DialogWindow.ErrorWindow($"Please enter a valid name for this favorite set.");
                errorWindow.Owner = this;
                errorWindow.ShowDialog();
                MyTitle.Focus();
                MyTitle.SelectAll();
                return;
            }

            // Check if favorite title already exists.
            if (Favorite.TitleExists(MyTitle.Text))
            {
                var warningWindow = DialogWindow.WarningWindow(
                    message: $"{MyTitle.Text} already exists.  Would you like to overwrite?",
                    confirmButtonText: "Overwrite");
                warningWindow.Owner = this;
                if (warningWindow.ShowDialog() == true)
                {
                    // User opted to overwrite existing favorite entry.
                    SaveFavorite();
                }
            }
            else
            {
                // Checks passed.  Saving.
                SaveFavorite();
            }
        }
Exemplo n.º 2
0
        static List <MyTitle> getTitles(OleDbConnection cnn)
        {
            var titleLst = new List <MyTitle>();
            //get title
            var qry    = "select * from titles INNER JOIN paths ON titles.pathId = paths.ID order by ord ASC";
            var cmd    = new OleDbCommand(qry, cnn);
            var reader = cmd.ExecuteReader();
            int ord    = 0;

            while (reader.Read())
            {
                var title = new MyTitle();
                title.ID     = Convert.ToUInt64(reader["titles.ID"]);
                title.zTitle = Convert.ToString(reader["title"]);
                title.pathId = Convert.ToUInt64(reader["pathId"]);
                title.zPath  = Convert.ToString(reader["path"]);
                title.zPath += "/" + title.zTitle;
                title.ord    = Convert.ToInt32(reader["ord"]);
                titleLst.Add(title);
                Debug.Assert(title.ord > ord);
                ord = title.ord;
            }
            reader.Close();
            return(titleLst);
        }
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            // Validate favorite name.
            if (Favorite.IsTitleInvalid(MyTitle.Text))
            {
                var errorWindow = DialogWindow.ErrorWindow(Strings.NewFavorite_Error_InvalidName);
                errorWindow.Owner = this;
                errorWindow.ShowDialog();
                MyTitle.Focus();
                MyTitle.SelectAll();
                return;
            }

            // Check if favorite title already exists.
            if (Favorite.TitleExists(MyTitle.Text))
            {
                var warningWindow = DialogWindow.WarningWindow(
                    message: $"{MyTitle.Text} {Strings.NewFavorite_Warn_AlreadyExists}",
                    confirmButtonText: Strings.DialogButton_Overwrite);
                warningWindow.Owner = this;
                if (warningWindow.ShowDialog() == true)
                {
                    // User opted to overwrite existing favorite entry.
                    SaveFavorite();
                }
            }
            else
            {
                // Checks passed.  Saving.
                SaveFavorite();
            }
        }
Exemplo n.º 4
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            // Validate column count.
            if (int.TryParse(MyColumnCount.Text, out ColumnCount) == false || ColumnCount < 1 || ColumnCount > 10)
            {
                var errorWindow = DialogWindow.ErrorWindow("Please enter a valid number of columns (between 1 and 10).");
                errorWindow.Owner = this;
                errorWindow.ShowDialog();
                MyColumnCount.Focus();
                MyColumnCount.SelectAll();
                return;
            }

            // Validate favorite name.
            if (Favorite.IsTitleInvalid(MyTitle.Text))
            {
                var errorWindow = DialogWindow.ErrorWindow(Strings.NewFavorite_Error_InvalidName);
                errorWindow.Owner = this;
                errorWindow.ShowDialog();
                MyTitle.Focus();
                MyTitle.SelectAll();
                return;
            }

            // Split MyHosts string to array, trim each item, then convert to list. Ensure at least one host was entered.
            HostList = MyHosts.Text.Trim().Split(new char[] { ',', '\n' }).Select(host => host.Trim()).ToList();
            if (HostList.All(x => string.IsNullOrWhiteSpace(x)))
            {
                var errorWindow = DialogWindow.ErrorWindow("You have not entered any hosts. Provide at least one host for this favorite set.");
                errorWindow.Owner = this;
                errorWindow.ShowDialog();
                MyHosts.Focus();
                MyHosts.SelectAll();
                return;
            }

            // If creating a new favorite: Check and display warning if title already exists.
            // If editing a favorite and title has changed: Check and display warning if title already exists.
            // If editing a favorite and title has not changed: Proceed with save. No warning displayed.
            if ((!IsExisting && Favorite.TitleExists(MyTitle.Text)) ||
                (IsExisting && !string.Equals(OriginalTitle, MyTitle.Text) && Favorite.TitleExists(MyTitle.Text)))
            {
                var warningWindow = DialogWindow.WarningWindow(
                    message: $"{MyTitle.Text} {Strings.NewFavorite_Warn_AlreadyExists}",
                    confirmButtonText: Strings.DialogButton_Overwrite);
                warningWindow.Owner = this;
                if (warningWindow.ShowDialog() == true)
                {
                    // User opted to overwrite existing favorite entry.
                    SaveFavorite();
                }
            }
            else
            {
                // Checks passed.  Saving.
                SaveFavorite();
            }
        }
Exemplo n.º 5
0
 public void Show()
 {
     Console.ForegroundColor = ConsoleColor.Cyan;
     MyAuthor.Show();
     Console.ForegroundColor = ConsoleColor.DarkMagenta;
     MyCont.Show();
     Console.ForegroundColor = ConsoleColor.Green;
     MyTitle.Show();
 }
Exemplo n.º 6
0
        void DisplayTitle2(MyTitle title)
        {
            //if (m_curTitle == title.path) return;

            //DisplayTitle(title);
            //if (isEditing)
            //{
            //    BeginEditTitle(title);
            //}

            //m_curTitle = title.path;
        }
Exemplo n.º 7
0
 public int Add(MyTitle title)
 {
     if (!m_nodeDict.ContainsKey(title.path))
     {
         var tNode = addRow('T', 1, title.path, title.title);
         tNode.title = title;
         RenderNode(tNode);
         return(1);
     }
     else
     {
         //update
         var tNode = m_nodeDict[title.path];
         tNode.title.content = title.content;
     }
     return(0);
 }
Exemplo n.º 8
0
        private void Save_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(MyTitle.Text))
            {
                var dialogWindow = new DialogWindow(
                    DialogWindow.DialogIcon.Warning,
                    "Error",
                    $"Please enter a valid name for this favorite set.",
                    "OK",
                    false);
                dialogWindow.Owner = this;
                dialogWindow.ShowDialog();
                MyTitle.Focus();
                MyTitle.SelectAll();
                return;
            }

            if (Favorite.DoesTitleExist(MyTitle.Text))
            {
                var dialogWindow = new DialogWindow(
                    DialogWindow.DialogIcon.Warning,
                    "Warning",
                    $"{MyTitle.Text} already exists.  Would you like to overwrite?",
                    "Overwrite",
                    true);
                dialogWindow.Owner = this;
                if (dialogWindow.ShowDialog() == true)
                {
                    Favorite.SaveFavoriteSet(MyTitle.Text, HostList, ColumnCount);
                    DialogResult = true;
                }
            }
            else
            {
                Favorite.SaveFavoriteSet(MyTitle.Text, HostList, ColumnCount);
                DialogResult = true;
            }
        }
Exemplo n.º 9
0
 public int Remove(MyTitle title)
 {
     return(Remove(title.path));
 }