Пример #1
0
        public MainWindow()
        {
            InitializeComponent();

            informationSourcePanel = new InformationSourcePanel(messagesHistoryView);
            informationSourcePanel.chooseSourceBtn.Click += (s, e) => { SetInformationSource(); };
            manualModePanel = new ManualModePanel();
            manualModePanel.getRangeMessageBtn.Click += SendRequest;
            manualModePanel.getLastMessageBtn.Click  += SendRequest;
            currentRequestsPanel = new CurrentRequestsPanel();

            programStatusChangedDp.AddValueChanged(programStatus, ProgramStatusChanged);

            gsmUserPin = "";
            requests   = new Dictionary <string, Tuple <SmsRequest, Timer> >();
        }
Пример #2
0
        private static void IsPressedChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs args)
        {
            ManualModePanel panel = (ManualModePanel)depObj;

            if (!panel.IsPressed && panel.Parent != null)
            {
                animate = new ThicknessAnimation()
                {
                    From     = animationClock != null ? (Thickness)animate.GetCurrentValue(animate.From, animate.To, animationClock) : new Thickness(0, 0, 0, 0),
                    To       = new Thickness(-350, 0, 0, 0),
                    Duration = TimeSpan.FromSeconds(0.8)
                };
                animationClock     = animate.CreateClock();
                animate.Completed += (o, s) => {
                    if (!panel.IsPressed)
                    {
                        RemoveUserControl((Panel)LogicalTreeHelper.GetParent(panel), panel);
                    }
                };
                panel.BeginAnimation(MarginProperty, animate);
            }
            else if (panel.IsPressed && panel.Parent != null)
            {
                var parent = (Panel)LogicalTreeHelper.GetParent(panel);
                List <UserControl> userControls = parent.Children.OfType <UserControl>().ToList();
                animate = new ThicknessAnimation()
                {
                    From     = animationClock != null ? (Thickness)animate.GetCurrentValue(animate.From, animate.To, animationClock) : userControls.Count == 1 ? new Thickness(-350, 0, 0, 0) : new Thickness(-700, 0, 0, 0),
                    To       = new Thickness(0, 0, 0, 0),
                    Duration = TimeSpan.FromSeconds(userControls.Count > 1 ? 1 : 0.8)
                };
                animationClock     = animate.CreateClock();
                animate.Completed += (o, s) => {
                    if (userControls.Count > 1)
                    {
                        RemoveUserControl(parent, userControls[0]);
                    }
                };
                panel.BeginAnimation(MarginProperty, animate);
            }
        }