Exemplo n.º 1
0
 public Sender(PluginInfo m)
 {
     this.m = m;
 }
Exemplo n.º 2
0
        public InputControlViewModel(PluginInfo m)
        {
            this.m = m;
            this.m.PropertyChanged += new PropertyChangedEventHandler((sender, e) =>
            {
                switch (e.PropertyName)
                {
                case nameof(m.PluginHost):
                    ((BindableBase)this.m.PluginHost).PropertyChanged += new PropertyChangedEventHandler((hsender, he) =>
                    {
                        switch (he.PropertyName)
                        {
                        case nameof(m.PluginHost.CurrentTicket):
                            Visibility = m.PluginHost.CurrentTicket == this.m ? Visibility.Visible : Visibility.Hidden;
                            break;
                        }
                    });
                    break;

                case nameof(m.CurrentTextBox):
                    CurrentTextBox = (InputControlTextBox)m.CurrentTextBox;
                    break;
                }
            });

            m.TextBoxes.CollectionChanged += new NotifyCollectionChangedEventHandler((sender, e) =>
            {
                try
                {
                    TextBoxes[(InputControlTextBox)e.OldStartingIndex] = m.TextBoxes[e.NewStartingIndex];
                }
                catch { }
            });

            TextBoxes = new ObservableDictionary <InputControlTextBox, string>();
            foreach (InputControlTextBox i in Enum.GetValues(typeof(InputControlTextBox)))
            {
                TextBoxes.Add(i, "");
            }

            TextBoxes.CollectionChanged += new NotifyCollectionChangedEventHandler((sender, e) =>
            {
                if ((InputControlTextBox)e.NewStartingIndex == InputControlTextBox.Month || (InputControlTextBox)e.NewStartingIndex == InputControlTextBox.Day)
                {
                    int month        = WideStringToInt(TextBoxes[InputControlTextBox.Month]);
                    int date         = WideStringToInt(TextBoxes[InputControlTextBox.Day]);
                    string dayOfWeek = " ";
                    try
                    {
                        DateTime today    = DateTime.Today;
                        DateTime dateTime = new DateTime(today.Year, month, date);
                        if (dateTime < today)
                        {
                            dateTime.AddYears(1);
                        }
                        dayOfWeek = week[(int)dateTime.DayOfWeek];
                    }
                    catch { }
                    DayOfWeek = dayOfWeek;
                }

                try
                {
                    KeyValuePair <InputControlTextBox, string> textBox = TextBoxes.First(t => m.TextBoxes[(int)t.Key] != t.Value);
                    m.TextBoxes[(int)textBox.Key] = textBox.Value;
                }
                catch { }

                if (CurrentTextBox != InputControlTextBox.Child && TextBoxes[CurrentTextBox].Length == 2)
                {
                    CurrentTextBox++;
                }
            });

            SideMenu = new DelegateCommand(() =>
            {
                m.PluginHost.GoToSideMenu();
            });

            GotFocus = new DelegateCommand <string>(param =>
            {
                CurrentTextBox = (InputControlTextBox)Enum.Parse(typeof(InputControlTextBox), param);
            });
        }