Example #1
0
        private void Pf_SelectClick(object sender, RoutedEventArgs e)
        {
            int id = PostItFields.Where(x => x.IsFocused).Count();

            IsSelected = id > 0;

            PostItFields.ForEach(x => x.textField.IsEnabled = id == 0);
            ToDelete?.Invoke(this, e);
        }
Example #2
0
        private void Pf_LostFocus(object sender, RoutedEventArgs e)
        {
            PostItField pf = (PostItField)sender;

            if (pf.Id == -1 && string.IsNullOrWhiteSpace(pf.Text))
            {
                PostItFields.Remove(pf);
                group.Children.Remove(pf);

                TextChanged?.Invoke(this, e);
            }
        }
Example #3
0
        public void DelPostIt()
        {
            IsSelected = false;

            List <PostItField> toDelete = PostItFields.Where(x => x.IsFocused).Cast <PostItField>().ToList();

            foreach (PostItField pf in toDelete)
            {
                PostItFields.Remove(pf);
                group.Children.Remove(pf);

                PostIt postIt = new PostIt(pf.Id);
                postItRepository.Delete(postIt);
            }
            PostItFields.ForEach(x => x.textField.IsEnabled = true);
            SavePostIt();
        }
Example #4
0
        private void Pf_FixedClick(object sender, RoutedEventArgs e)
        {
            PostItField pf = (PostItField)sender;

            if (pf.IsFixed && PostItFields.IndexOf(pf) != 0)
            {
                PostItFields[0].IsFixed = false;

                PostItFields.Remove(pf);
                PostItFields.Insert(0, pf);

                group.Children.Remove(pf);
                group.Children.Insert(0, pf);
            }

            SavePostIt();
        }
Example #5
0
        private void Pf_DownClick(object sender, RoutedEventArgs e)
        {
            PostItField postIt = (PostItField)sender;
            int         index  = PostItFields.IndexOf(postIt);

            if (index == PostItFields.Count - 1 || PostItFields[index].IsFixed)
            {
                return;
            }

            PostItFields.RemoveAt(index);
            PostItFields.Insert(index + 1, postIt);

            group.Children.RemoveAt(index);
            group.Children.Insert(index + 1, postIt);

            SavePostIt();
        }
Example #6
0
        private void Pf_UpClick(object sender, RoutedEventArgs e)
        {
            PostItField postIt      = (PostItField)sender;
            int         index       = PostItFields.IndexOf(postIt);
            int         minPosition = PostItFields.Count > 0 && PostItFields[0].IsFixed ? 1 : 0;

            if (index == minPosition || index == 0)
            {
                return;
            }

            PostItFields.RemoveAt(index);
            PostItFields.Insert(index - 1, postIt);

            group.Children.RemoveAt(index);
            group.Children.Insert(index - 1, postIt);

            SavePostIt();
        }
Example #7
0
        private void NewPostItField(PostIt post, string key = "")
        {
            PostItField pf = new PostItField(post.Content);

            pf.SelectClick    += Pf_SelectClick;
            pf.ColorClick     += Pf_ColorClick;
            pf.FontColorClick += Pf_FontColorClick;
            pf.FixedClick     += Pf_FixedClick;
            pf.LostFocus      += Pf_LostFocus;
            pf.TextChanged    += Pf_TextChanged;
            pf.DownClick      += Pf_DownClick;
            pf.UpClick        += Pf_UpClick;

            SolidColorBrush defaultColor = (SolidColorBrush) new BrushConverter().ConvertFrom(FindResource("PostItBackground").ToString());
            SolidColorBrush textColor    = (SolidColorBrush) new BrushConverter().ConvertFrom(FindResource("Text").ToString());

            pf.Id = post.Id;
            pf.BackgroundColor = post.Color ?? defaultColor;
            pf.TextColor       = post.FontColor ?? textColor;
            pf.IsFixed         = post.Position == -1;

            int pos = PostItFields.Count > 0 && PostItFields[0].IsFixed ? 1 : 0;

            group.Children.Insert(pos, pf);
            PostItFields.Insert(pos, pf);

            if (key != "" && key.Length == 1)
            {
                pf.Text += key;
                pf.textField.SelectionStart = 1;
            }

            if (post.Id == -1)
            {
                pf.FocusTextField();
            }
        }