Exemple #1
0
        private void Edit_Click(object sender, RoutedEventArgs e)
        {
            MenuItem i = sender as MenuItem;
            Button   b = (i.Parent as ContextMenu).PlacementTarget as Button;

            var n = new newSnippet();

            var d_full  = snips[b.Content.ToString()];
            var d_short = b.Content.ToString();

            n.tbFullText.Text  = d_full;
            n.tbShortName.Text = d_short;


            var res = n.ShowDialog();

            if (res != null && res == true)
            {
                var name = n.tbShortName.Text;
                var full = n.tbFullText.Text;
                if (n.tbShortName.Text != d_short)
                {
                    snips.Remove(d_short);
                    snips.Add(n.tbShortName.Text, n.tbFullText.Text);
                    b.Content = n.tbShortName.Text;
                    b.ToolTip = n.tbFullText.Text;
                }
                else if (n.tbShortName.Text == d_short)
                {
                    snips[d_short] = n.tbFullText.Text;
                    b.ToolTip      = n.tbFullText.Text;
                }
            }
        }
Exemple #2
0
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            var n   = new newSnippet();
            var res = n.ShowDialog();

            if (res != null && res == true)
            {
                var ind    = 1;
                var name   = n.tbShortName.Text;
                var d_name = name;
                var full   = n.tbFullText.Text;

                while (snips.ContainsKey(name))
                {
                    name  = d_name;
                    name += ind;
                    ind++;
                }

                snips.Add(name, full);
                StackMain.Children.Add(CreateButton(name, full));
            }
        }