Пример #1
0
        private static void OnWriteLinkChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            LinkedTextBox myLink = d as LinkedTextBox;

            myLink.WriteLink = e.NewValue as string;
            UpdateLinkedBoxes(myLink);
        }
Пример #2
0
 private static void UpdateLinkedBoxes(LinkedTextBox myLink)
 {
     if (!String.IsNullOrWhiteSpace(myLink.WriteLink))
     {
         foreach (LinkedTextBox link in _links)
         {
             if (link.ReadLink1 == myLink.WriteLink)
             {
                 if (myLink.BoxType == LinkedTextBoxType.Number)
                 {
                     try
                     {
                         link._linkedContent1 = Convert.ToInt32(myLink.Text);
                         link.updateContents();
                     }
                     catch (Exception) { }
                 }
                 else
                 {
                     link._linkedContent1 = myLink.Text;
                     link.updateContents();
                 }
             }
             if (link.ReadLink2 == myLink.WriteLink)
             {
                 if (myLink.BoxType == LinkedTextBoxType.Number)
                 {
                     try
                     {
                         link._linkedContent2 = Convert.ToInt32(myLink.Text);
                         link.updateContents();
                     }
                     catch (Exception) { }
                 }
                 else
                 {
                     link._linkedContent2 = myLink.Text;
                     link.updateContents();
                 }
             }
         }
     }
 }
Пример #3
0
        private static void OnTextFormatChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            LinkedTextBox myLink = d as LinkedTextBox;

            myLink.updateContents();
        }
Пример #4
0
        private static void OnReadLinkChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            LinkedTextBox      myLink   = d as LinkedTextBox;
            string             newValue = e.NewValue as string;
            DependencyProperty dp       = e.Property;

            if (dp == ReadLink1Property)
            {
                myLink.ReadLink1 = newValue;
            }
            else
            {
                myLink.ReadLink2 = newValue;
            }

            // A read link ID has been updated so search for a write link with that ID and update contents
            if (!String.IsNullOrWhiteSpace(newValue))
            {
                foreach (LinkedTextBox link in _links)
                {
                    if ((!String.IsNullOrWhiteSpace(link.WriteLink)) && (link.WriteLink == newValue))
                    {
                        if (dp == ReadLink1Property)
                        {
                            if (myLink.BoxType == LinkedTextBoxType.Normal)
                            {
                                myLink._linkedContent1 = link.Text;
                            }
                            else
                            {
                                try
                                {
                                    myLink._linkedContent1 = Convert.ToInt32(link.Text);
                                    myLink.updateContents();
                                }
                                catch (Exception) { }
                            }
                        }
                        else
                        {
                            if (myLink.BoxType == LinkedTextBoxType.Normal)
                            {
                                myLink._linkedContent2 = link.Text;
                            }
                            else
                            {
                                try
                                {
                                    myLink._linkedContent2 = Convert.ToInt32(link.Text);
                                    myLink.updateContents();
                                }
                                catch (Exception) { }
                            }
                        }
                        myLink.updateContents();

                        break;
                    }
                }
            }
        }