コード例 #1
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            EditorPage editor = new EditorPage();

            editor.Disappearing += (s, _e) => {
                if (editor.text == null)
                {
                    return;
                }

                Label label = new Label();
                var   text  = editor.text;
                label.Text = GetHeader(text);

                label.BackgroundColor = Color.Red;

                // Обработка жеста (tapped => клик)
                TapGestureRecognizer tap = new TapGestureRecognizer();
                tap.Tapped += (_s, __e) =>
                {
                    EditorPage _editor = new EditorPage(text);
                    _editor.Disappearing += (__s, ___e) =>
                    {
                        text       = _editor.text;
                        label.Text = GetHeader(text);
                    };
                    Navigation.PushAsync(_editor);
                };
                label.GestureRecognizers.Add(tap);
                //

                data.Children.Add(label);
            };
            Navigation.PushAsync(editor);
        }
コード例 #2
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            EditorPage editor = new EditorPage();

            editor.Disappearing += (s, _e) => {
                if (editor.text == null)
                {
                    return;
                }
                Frame frame = new Frame
                {
                    BorderColor = Color.Aqua
                };
                Label label = new Label();
                label.Text            = editor.text;
                label.BackgroundColor = Color.Beige;
                frame.Content         = label;
                var tapGestureRecognizer = new TapGestureRecognizer();
                tapGestureRecognizer.Tapped += (tapsender, tape) =>
                {
                    EditorPage editor2 = new EditorPage(label.Text);
                    editor2.Disappearing += (a, b) =>
                    {
                        label.Text = editor2.text;
                    };
                    Navigation.PushAsync(editor2);
                };
                label.GestureRecognizers.Add(tapGestureRecognizer);
                var swipe = new SwipeGestureRecognizer();

                if (left.Height > right.Height)
                {
                    swipe.Direction = SwipeDirection.Right;
                    swipe.Swiped   += (swipeSender, swipeEventArg) =>
                    {
                        right.Children.Remove(swipeSender as Frame);
                    };
                    frame.GestureRecognizers.Add(swipe);
                    right.Children.Add(frame);
                }
                else
                {
                    swipe.Direction = SwipeDirection.Left;
                    swipe.Swiped   += async(swipeSender, swipeEventArg) =>
                    {
                        if (await DisplayAlert("Confirm the deleting", "Are you sure?", "Yes!", "No"))
                        {
                            left.Children.Remove(frame);
                        }
                    };
                    frame.GestureRecognizers.Add(swipe);
                    left.Children.Add(frame);
                }
            };
            Navigation.PushAsync(editor);
        }
コード例 #3
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            EditorPage editor = new EditorPage();

            editor.Disappearing += (s, _e) => {
                if (editor.text == null)
                {
                    return;
                }
                Frame frame = new Frame
                {
                    BorderColor = Color.Aqua
                };
                Label label = new Label();
                label.Text            = editor.text;
                label.BackgroundColor = Color.Beige;
                frame.Content         = label;
                var tapGestureRecognizer = new TapGestureRecognizer();
                tapGestureRecognizer.Tapped += (tapsender, tape) =>
                {
                    EditorPage editor2 = new EditorPage(label.Text);
                    editor2.Disappearing += (a, b) =>
                    {
                        label.Text = editor2.text;
                    };
                    Navigation.PushAsync(editor2);
                };
                label.GestureRecognizers.Add(tapGestureRecognizer);
                var swipe = new SwipeGestureRecognizer();


                if (left.Height > right.Height)
                {
                    right.Children.Add(frame);
                    swipe.Direction = SwipeDirection.Right;
                    swipe.Swiped   += (sender_, e_) =>
                    {
                        right.Children.Remove(frame);
                    };
                }
                else
                {
                    left.Children.Add(frame);
                    swipe.Direction = SwipeDirection.Left;
                    swipe.Swiped   += (sender_, e_) =>
                    {
                        left.Children.Remove(frame);
                    };
                }
            };
            Navigation.PushAsync(editor);
        }
コード例 #4
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            EditorPage editor = new EditorPage();

            editor.Disappearing += (s, _e) => {
                if (editor.text == null)
                {
                    return;
                }

                Label label = new Label();
                label.Text = editor.text;

                label.BackgroundColor = Color.Red;

                data.Children.Add(label);
            };
            Navigation.PushAsync(editor);
        }
コード例 #5
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            EditorPage editor = new EditorPage();

            editor.Disappearing += (s, _e) => {
                string newName;
                string newFile;
                if (left.Height > right.Height)
                {
                    newName = right.Children.Count + "Right.txt";
                    newFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), newName);
                    add(editor.text, true, newFile);
                }
                else
                {
                    newName = left.Children.Count + "Left.txt";
                    newFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), newName);
                    add(editor.text, false, newFile);
                }
                File.WriteAllText(newFile, editor.text);
            };
            Navigation.PushAsync(editor);
        }
コード例 #6
0
        public void add(string text, bool right_, string path)
        {
            if (text == null)
            {
                return;
            }
            int  size  = (text.Length >= 10) ? 10 : text.Length;
            Note frame = new Note
            {
                BorderColor = Color.Aqua,
                InnerText   = text,
                Path        = path,
                Right       = right_
            };
            StackLayout box   = new StackLayout();
            Label       label = new Label();

            label.Text            = text.Substring(0, size);
            label.BackgroundColor = Color.Beige;
            label.LineBreakMode   = LineBreakMode.WordWrap;
            Label label1 = new Label
            {
                Text = File.GetCreationTime(path).ToString()
            };

            box.Children.Add(label);
            box.Children.Add(label1);
            frame.Content = box;
            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (tapsender, tape) =>
            {
                EditorPage editor2 = new EditorPage(frame.InnerText);
                editor2.Disappearing += (a, b) =>
                {
                    frame.InnerText = editor2.text;
                    int length = (editor2.text.Length > 10) ? 10 : editor2.text.Length;
                    label.Text = editor2.text.Substring(0, length);
                    File.WriteAllText(frame.Path, editor2.text);
                    label1.Text = File.GetLastWriteTime(path).ToString();
                };
                Navigation.PushAsync(editor2);
            };
            label.GestureRecognizers.Add(tapGestureRecognizer);
            box.GestureRecognizers.Add(tapGestureRecognizer);
            label1.GestureRecognizers.Add(tapGestureRecognizer);
            frame.GestureRecognizers.Add(tapGestureRecognizer);
            var    pan    = new PanGestureRecognizer();
            double totalX = 0;

            pan.PanUpdated += async(panSender, panArgs) =>
            {
                switch (panArgs.StatusType)
                {
                case GestureStatus.Canceled:
                case GestureStatus.Started:
                    frame.TranslationX = 0;
                    break;

                case GestureStatus.Completed:
                    if (((panSender as Note).Right && totalX > 0) || (!(panSender as Note).Right && totalX < 0))
                    {
                        if (await DisplayAlert("Confirm the deleting", "Are you sure?", "Yes!", "No"))
                        {
                            File.Delete((panSender as Note).Path);
                            if ((panSender as Note).Right)
                            {
                                right.Children.Remove(panSender as Note);
                            }
                            else
                            {
                                left.Children.Remove(panSender as Note);
                            }
                            BigRename();
                            Balance();
                        }
                        totalX = 0;
                    }
                    frame.TranslationX = 0;
                    break;

                case GestureStatus.Running:
                    if (((panSender as Note).Right && panArgs.TotalX > 0) || (!(panSender as Note).Right && panArgs.TotalX < 0))
                    {
                        (panSender as Note).TranslationX = panArgs.TotalX;
                        totalX = panArgs.TotalX;
                    }
                    break;
                }
            };
            frame.GestureRecognizers.Add(pan);

            var    label_pan = new PanGestureRecognizer();
            double totalX_   = 0;

            label_pan.PanUpdated += async(panSender, panArgs) =>
            {
                switch (panArgs.StatusType)
                {
                case GestureStatus.Canceled:
                case GestureStatus.Started:
                    frame.TranslationX = 0;
                    break;

                case GestureStatus.Completed:
                    if (((((panSender as Label).Parent).Parent as Note).Right && totalX_ > 0) ||
                        (!(((panSender as Label).Parent).Parent as Note).Right && totalX_ < 0))
                    {
                        if (await DisplayAlert("Confirm the deleting", "Are you sure?", "Yes!", "No"))
                        {
                            File.Delete((((panSender as Label).Parent).Parent as Note).Path);
                            if ((((panSender as Label).Parent).Parent as Note).Right)
                            {
                                right.Children.Remove(((panSender as Label).Parent).Parent as Note);
                            }
                            else
                            {
                                left.Children.Remove(((panSender as Label).Parent).Parent as Note);
                            }
                            BigRename();
                            Balance();
                        }
                        totalX_ = 0;
                    }
                    (((panSender as Label).Parent).Parent as Note).TranslationX = 0;
                    break;

                case GestureStatus.Running:
                    if (((((panSender as Label).Parent).Parent as Note).Right && panArgs.TotalX > 0) ||
                        (!(((panSender as Label).Parent).Parent as Note).Right && panArgs.TotalX < 0))
                    {
                        (((panSender as Label).Parent).Parent as Note).TranslationX = panArgs.TotalX;
                        totalX_ = panArgs.TotalX;
                    }
                    break;
                }
            };
            label.GestureRecognizers.Add(label_pan);
            label1.GestureRecognizers.Add(label_pan);
            if (right_)
            {
                right.Children.Add(frame);
            }
            else
            {
                left.Children.Add(frame);
            }
        }
コード例 #7
0
        public void add(string text, bool right_)
        {
            Frame frame = new Frame
            {
                BorderColor = Color.Aqua
            };
            Label label = new Label();

            label.Text            = text;
            label.BackgroundColor = Color.Beige;
            frame.Content         = label;
            var tapGestureRecognizer = new TapGestureRecognizer();

            tapGestureRecognizer.Tapped += (tapsender, tape) =>
            {
                EditorPage editor2 = new EditorPage(label.Text);
                editor2.Disappearing += (a, b) =>
                {
                    label.Text = editor2.text;
                };
                Navigation.PushAsync(editor2);
            };
            label.GestureRecognizers.Add(tapGestureRecognizer);
            var pan = new PanGestureRecognizer();

            if (right_)
            {
                double totalX = 0;
                pan.PanUpdated += async(panSender, panArgs) =>
                {
                    switch (panArgs.StatusType)
                    {
                    case GestureStatus.Canceled:
                    case GestureStatus.Started:
                        frame.TranslationX = 0;
                        break;

                    case GestureStatus.Completed:
                        if (totalX > 0)
                        {
                            if (await DisplayAlert("Confirm the deleting", "Are you sure?", "Yes!", "No"))
                            {
                                right.Children.Remove(panSender as Frame);
                            }
                            totalX = 0;
                        }
                        frame.TranslationX = 0;
                        break;

                    case GestureStatus.Running:
                        if (panArgs.TotalX > 0)
                        {
                            frame.TranslationX = panArgs.TotalX;
                            totalX             = panArgs.TotalX;
                        }
                        break;
                    }
                };
                frame.GestureRecognizers.Add(pan);
                right.Children.Add(frame);
            }
            else
            {
                left.Children.Add(frame);
            }
        }
コード例 #8
0
        private void Button_Clicked(object sender, EventArgs e)
        {
            EditorPage editor = new EditorPage();

            editor.Disappearing += (s, _e) => {
                if (editor.text == null)
                {
                    return;
                }
                Frame frame = new Frame
                {
                    BorderColor = Color.Aqua
                };
                Label label = new Label();
                label.Text            = editor.text;
                label.BackgroundColor = Color.Beige;
                frame.Content         = label;
                var tapGestureRecognizer = new TapGestureRecognizer();
                tapGestureRecognizer.Tapped += (tapsender, tape) =>
                {
                    EditorPage editor2 = new EditorPage(label.Text);
                    editor2.Disappearing += (a, b) =>
                    {
                        label.Text = editor2.text;
                    };
                    Navigation.PushAsync(editor2);
                };
                label.GestureRecognizers.Add(tapGestureRecognizer);
                var swipe = new SwipeGestureRecognizer();

                string newName;
                if (left.Height > right.Height)
                {
                    swipe.Direction = SwipeDirection.Right;
                    swipe.Swiped   += (swipeSender, swipeEventArg) =>
                    {
                        right.Children.Remove(swipeSender as Frame);
                    };
                    frame.GestureRecognizers.Add(swipe);
                    right.Children.Add(frame);

                    newName = counterRight++ + "Right.txt";
                }
                else
                {
                    swipe.Direction = SwipeDirection.Left;
                    swipe.Swiped   += async(swipeSender, swipeEventArg) =>
                    {
                        if (await DisplayAlert("Confirm the deleting", "Are you sure?", "Yes!", "No"))
                        {
                            left.Children.Remove(frame);
                        }
                    };
                    frame.GestureRecognizers.Add(swipe);
                    left.Children.Add(frame);

                    newName = counterLeft++ + "Left.txt";
                }

                string newFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), newName);
                File.WriteAllText(newFile, label.Text);
            };
            Navigation.PushAsync(editor);
        }