Share:

RightEffectRow.cs | Drag Object To Scroll In WPF C# | Amit Padhiyar | Saatody

RightEffectRow.cs

Drag object using MouseLeftButtonDown, MouseLeftButtonUp and MouseMove. When we drag object using mouse and if object's any part is going outside parent panel then the parent panel margin automatically update and try to in that object.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Input;
using System.Collections.Generic;
using System.Windows.Threading;

namespace EffectFeatures
{
    public class RightEffectRow : Grid
    {
        public RightEffect RE = new RightEffect();
        public static UIElement UI = new UIElement();
        public void Initialize()
        {
            try
            {
                this.Children.Clear();
                Repaint();
                Resize();
                Event();
                Refresh();
                UI = this;
                this.Children.Add(RE);
                RE.Initialize();
            }
            catch (Exception e) { }
        }
        public void Repaint()
        {
            try
            {

            }
            catch (Exception e) { }
        }
        public void Resize()
        {
            try
            {

            }
            catch (Exception e) { }
        }
        public void Event()
        {
            try
            {

            }
            catch (Exception e) { }
        }
        public void Refresh()
        {
            try
            {
                DispatcherTimer timer = new DispatcherTimer();
                timer.Interval = new TimeSpan(0, 0, 0, 0, 0);
                timer.IsEnabled = false;
                timer.Tick += (sender, e) =>
                {
                    if (RE.EventCommand == "Down")
                    {
                        // X1
                        System.Console.WriteLine("1] : " + RE.Margin.Left);
                        System.Console.WriteLine("2] : " + (-RightEffectRowContainer.Left));
                        if (RE.Margin.Left <= (-RightEffectRowContainer.Left))
                        {
                            MyRowTest.Go(RightEffectRowContainer.Left + ((-RightEffectRowContainer.Left) - RE.Margin.Left));
                            System.Console.WriteLine("---------------------");
                        }

                        // X2
                        double X2 = RE.Margin.Left + RE.ActualWidth;
                        double ViewX2 = (-RightEffectRowContainer.Left) + 1400;
                        if (X2 >= ViewX2)
                        {
                            MyRowTest.Go(RightEffectRowContainer.Left - (X2 - ViewX2));
                        }
                    }
                };
                timer.Start();
            }
            catch (Exception e) { }
        }
    }
}

Comments

Popular posts from this blog

Get Color From Pixel C# WPF | Saatody | Amit Padhiyar

Basic Audio Operations With MP3 And Wave Files Using NAudio C#

Create Drag And Drop Operation Between DevExpress GridControl And Custom WPF UI | Saatody | Amit Padhiyar