Example #1
0
        private void butAddNote_Click(object sender, System.EventArgs e)
        {
            if (listCat.SelectedIndex == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select a category first."));
                return;
            }
            QuickPasteNote quickNote = new QuickPasteNote();

            quickNote.QuickPasteCatNum = _listCats[listCat.SelectedIndex].QuickPasteCatNum;
            FormQuickPasteNoteEdit FormQ = new FormQuickPasteNoteEdit(quickNote);

            FormQ.ShowDialog();
            if (FormQ.DialogResult != DialogResult.OK || FormQ.QuickNote == null)         //Deleted
            {
                return;
            }
            if (gridMain.GetSelectedIndex() == -1)
            {
                _listNotes.Add(FormQ.QuickNote);
            }
            else
            {
                int selectedIdx = _listNotes.IndexOf((QuickPasteNote)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag);
                _listNotes.Insert(selectedIdx, FormQ.QuickNote);               //Insert the new note at the selected index.
            }
            FillMain();
        }
Example #2
0
        private void butDownNote_Click(object sender, System.EventArgs e)
        {
            int selectedIdx = gridMain.GetSelectedIndex();

            if (selectedIdx == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select a note first."));
                return;
            }
            if (selectedIdx == gridMain.Rows.Count - 1)
            {
                return;                //can't go down any more
            }
            QuickPasteNote sourceNote = (QuickPasteNote)gridMain.Rows[selectedIdx].Tag;
            QuickPasteNote destNote   = (QuickPasteNote)gridMain.Rows[selectedIdx + 1].Tag;
            //The notes can be filtered out.  Find the source and destination in the list and swap them.
            int sourceIdx = _listNotes.IndexOf(sourceNote);
            int destIdx   = _listNotes.IndexOf(destNote);

            _listNotes[sourceIdx] = destNote;
            _listNotes[destIdx]   = sourceNote;
            gridMain.SetSelected(false);
            gridMain.SetSelected(selectedIdx + 1, true);
            FillMain();
        }
Example #3
0
        ///<summary></summary>
        public static void Delete(QuickPasteNote note)
        {
            string command = "DELETE from quickpastenote WHERE QuickPasteNoteNum = '"
                             + POut.PInt(note.QuickPasteNoteNum) + "'";

            General.NonQ(command);
        }
Example #4
0
        private void butEditNote_Click(object sender, System.EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select a note first."));
                return;
            }
            QuickPasteNote         quickNote = (QuickPasteNote)gridMain.Rows[gridMain.GetSelectedIndex()].Tag;
            FormQuickPasteNoteEdit FormQ     = new FormQuickPasteNoteEdit((QuickPasteNote)gridMain.Rows[gridMain.GetSelectedIndex()].Tag);

            FormQ.ShowDialog();
            if (FormQ.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (FormQ.QuickNote == null)           //deleted
            {
                _listNotes.Remove(quickNote);
            }
            else
            {
                _listNotes[_listNotes.IndexOf(quickNote)] = FormQ.QuickNote;
            }
            FillMain();
        }
Example #5
0
        ///<summary></summary>
        public static void Insert(QuickPasteNote note)
        {
            if (PrefB.RandomKeys)
            {
                note.QuickPasteNoteNum = MiscData.GetKey("quickpastenote", "QuickPasteNoteNum");
            }
            string command = "INSERT INTO quickpastenote (";

            if (PrefB.RandomKeys)
            {
                command += "QuickPasteNoteNum,";
            }
            command += "QuickPasteCatNum,ItemOrder,Note,Abbreviation) VALUES(";
            if (PrefB.RandomKeys)
            {
                command += "'" + POut.PInt(note.QuickPasteNoteNum) + "', ";
            }
            command +=
                "'" + POut.PInt(note.QuickPasteCatNum) + "', "
                + "'" + POut.PInt(note.ItemOrder) + "', "
                + "'" + POut.PString(note.Note) + "', "
                + "'" + POut.PString(note.Abbreviation) + "')";
            if (PrefB.RandomKeys)
            {
                General.NonQ(command);
            }
            else
            {
                note.QuickPasteNoteNum = General.NonQ(command, true);
            }
        }
 ///<summary></summary>
 public FormQuickPasteNoteEdit(QuickPasteNote quickNote)
 {
     //
     // Required for Windows Form Designer support
     //
     QuickNote = quickNote.Copy();
     InitializeComponent();
     Lan.F(this);
 }
 private void butDelete_Click(object sender, System.EventArgs e)
 {
     if (MessageBox.Show(Lan.g(this, "Delete note?"), "", MessageBoxButtons.OKCancel) != DialogResult.OK)
     {
         return;
     }
     QuickNote    = null;       //triggers an action in the calling form
     DialogResult = DialogResult.OK;
 }
Example #8
0
        private void butEditNote_Click(object sender, System.EventArgs e)
        {
            if (gridMain.GetSelectedIndex() == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select a note first."));
                return;
            }
            QuickPasteNote quickNote = (QuickPasteNote)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;

            ShowEditWindow(quickNote);
        }
Example #9
0
        ///<summary></summary>
        public static void Update(QuickPasteNote note)
        {
            string command = "UPDATE quickpastenote SET "
                             + "QuickPasteCatNum='" + POut.PInt(note.QuickPasteCatNum) + "'"
                             + ",ItemOrder = '" + POut.PInt(note.ItemOrder) + "'"
                             + ",Note = '" + POut.PString(note.Note) + "'"
                             + ",Abbreviation = '" + POut.PString(note.Abbreviation) + "'"
                             + " WHERE QuickPasteNoteNum = '" + POut.PInt(note.QuickPasteNoteNum) + "'";

            General.NonQ(command);
        }
Example #10
0
 private void gridMain_CellDoubleClick(object sender, UI.ODGridClickEventArgs e)
 {
     if (_isSetupMode)
     {
         QuickPasteNote quickNote = (QuickPasteNote)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag;
         ShowEditWindow(quickNote);
     }
     else
     {
         InsertValue(((QuickPasteNote)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag).Note);
         DialogResult = DialogResult.OK;
     }
 }
Example #11
0
        ///<summary>When saving an abbrev, this makes sure that the abbreviation is not already in use.</summary>
        public static bool AbbrAlreadyInUse(QuickPasteNote note)
        {
            string command = "SELECT * FROM quickpastenote WHERE "
                             + "Abbreviation='" + POut.PString(note.Abbreviation) + "' "
                             + "AND QuickPasteNoteNum != '" + POut.PInt(note.QuickPasteNoteNum) + "'";
            DataTable table = General.GetTable(command);

            if (table.Rows.Count == 0)
            {
                return(false);
            }
            return(true);
        }
Example #12
0
        ///<summary></summary>
        public static void Refresh()
        {
            string command =
                "SELECT * from quickpastenote "
                + "ORDER BY ItemOrder";
            DataTable table = General.GetTable(command);

            List = new QuickPasteNote[table.Rows.Count];
            for (int i = 0; i < List.Length; i++)
            {
                List[i] = new QuickPasteNote();
                List[i].QuickPasteNoteNum = PIn.PInt(table.Rows[i][0].ToString());
                List[i].QuickPasteCatNum  = PIn.PInt(table.Rows[i][1].ToString());
                List[i].ItemOrder         = PIn.PInt(table.Rows[i][2].ToString());
                List[i].Note         = PIn.PString(table.Rows[i][3].ToString());
                List[i].Abbreviation = PIn.PString(table.Rows[i][4].ToString());
            }
        }
Example #13
0
        ///<summary>Only used from FormQuickPaste to get all notes for the selected cat.</summary>
        public static QuickPasteNote[] GetForCat(int cat)
        {
            ArrayList ALnotes = new ArrayList();

            for (int i = 0; i < List.Length; i++)
            {
                if (List[i].QuickPasteCatNum == cat)
                {
                    ALnotes.Add(List[i]);
                }
            }
            QuickPasteNote[] retArray = new QuickPasteNote[ALnotes.Count];
            for (int i = 0; i < ALnotes.Count; i++)
            {
                retArray[i] = (QuickPasteNote)ALnotes[i];
            }
            return(retArray);
        }
Example #14
0
        private void ShowEditWindow(QuickPasteNote quickNote)
        {
            FormQuickPasteNoteEdit FormQ = new FormQuickPasteNoteEdit((QuickPasteNote)gridMain.ListGridRows[gridMain.GetSelectedIndex()].Tag);

            FormQ.ShowDialog();
            if (FormQ.DialogResult != DialogResult.OK)
            {
                return;
            }
            if (FormQ.QuickNote == null)           //deleted
            {
                _listNotes.Remove(quickNote);
            }
            else
            {
                _listNotes[_listNotes.IndexOf(quickNote)] = FormQ.QuickNote;
            }
            FillMain();
        }
Example #15
0
        private void butAddNote_Click(object sender, System.EventArgs e)
        {
            if (listCat.SelectedIndex == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select a category first."));
                return;
            }
            QuickPasteNote quickNote = new QuickPasteNote();

            quickNote.QuickPasteCatNum = QuickPasteCats.List[listCat.SelectedIndex].QuickPasteCatNum;
            if (listNote.SelectedIndex == -1)
            {
                quickNote.ItemOrder = notesForCat.Length;              //one more than list will hold.
            }
            else
            {
                quickNote.ItemOrder = listNote.SelectedIndex;
            }
            FormQuickPasteNoteEdit FormQ = new FormQuickPasteNoteEdit(quickNote);

            FormQ.IsNew = true;
            FormQ.ShowDialog();
            if (FormQ.DialogResult == DialogResult.OK)
            {
                if (listNote.SelectedIndex != -1)
                {
                    //move other items down in list to make room for new one.
                    for (int i = quickNote.ItemOrder; i < notesForCat.Length; i++)
                    {
                        notesForCat[i].ItemOrder++;
                        QuickPasteNotes.Update(notesForCat[i]);
                    }
                }
                localChanged = true;
            }
            QuickPasteNotes.Refresh();
            FillNotes();
        }
Example #16
0
        /// <summary>Moves the selected note either down or up in the grid and sets the itemOrder for each.</summary>
        private void MoveNote(bool isDown)
        {
            int selectedIdx    = gridMain.GetSelectedIndex();
            int destinationIdx = (selectedIdx + (isDown?1:-1));

            if (selectedIdx == -1)
            {
                MessageBox.Show(Lan.g(this, "Please select a note first."));
                return;
            }
            if (!destinationIdx.Between(0, gridMain.ListGridRows.Count - 1))
            {
                return;                //can't go up or down any more
            }
            QuickPasteNote sourceNote = (QuickPasteNote)gridMain.ListGridRows[selectedIdx].Tag;
            QuickPasteNote destNote   = (QuickPasteNote)gridMain.ListGridRows[destinationIdx].Tag;

            sourceNote.ItemOrder = _listNotes.IndexOf(destNote);
            destNote.ItemOrder   = _listNotes.IndexOf(sourceNote);
            gridMain.SetSelected(false);
            FillMain();
            gridMain.SetSelected(destinationIdx, true);
        }