Пример #1
0
        protected override void Invoke(object parameter)
        {
            var args = parameter as RoutedEventArgs;

            if (args == null)
            {
                return;
            }

            var tabitem = VisualTreeHelperExtensions.FindAncestor <TabItem>(args.OriginalSource as DependencyObject);

            if (tabitem == null)
            {
                return;
            }

            var tabcontrol = VisualTreeHelperExtensions.FindAncestor <TabControl>(tabitem);

            if (tabcontrol == null)
            {
                return;
            }

            IRegion region = RegionManager.GetObservableRegion(tabcontrol).Value;

            if (region == null)
            {
                return;
            }

            //tabcontrol.Items.Remove(tabitem.Content);
            RemoveItemFromRegion(tabitem.Content, region);
        }
Пример #2
0
        private void Tb_LostFocus2(object sender, RoutedEventArgs e)
        {
            //if textbox is the last in the stackpanel then action is done so remove
            TextBox   tb    = sender as TextBox;
            FormEntry entry = tb.Tag as FormEntry;

            //if (entry.var2Type == 1)
            //{
            //    int weight;
            //    bool bFailed = false;
            //    if (!Int32.TryParse(tb.Text, out weight))
            //        bFailed = true;

            //    if (weight < 10 || weight > 85)
            //        bFailed = true;
            //    if (bFailed)
            //    {
            //        MessageBox.Show("invalid weight");
            //        return ;
            //    }
            //}
            Debug.WriteLine(string.Format("Tb_LostFocus2 {0} {1} ", tb.Tag, tb.Text));
            var sp    = VisualTreeHelperExtensions.FindAncestor <StackPanel>(tb);
            var grid  = VisualTreeHelperExtensions.FindAncestor <Grid>(sp);
            int index = sp.Children.IndexOf(tb);

            if (index + 1 == sp.Children.Count)
            {
                removeline(entry);

                //  CheckForFinish(block);
            }
            //  rootGrid.Children.Remove(sptest);
        }
Пример #3
0
        private void Navigate(DependencyObject originalSource)
        {
            var item = VisualTreeHelperExtensions.FindAncestor <TreeViewItem>(originalSource);

            if (item != null && item.Tag != null)
            {
                var navigatePath = item.Tag.ToString();
                _regionManager.RequestNavigate(RegionNames.MAIN_REGION, navigatePath);
            }
        }
Пример #4
0
        //check 1 can only be YES or Done
        private void Cb_Click1(object sender, RoutedEventArgs e)
        {
            CheckBox cb      = sender as CheckBox;
            bool     bDelete = false;

            FormEntry entry = cb.Tag as FormEntry;

            if (cb.Content as String == "Done")
            {
                bDelete = true;

                entry.checkbox1State = true;
            }
            else if (cb.Content as String == "Yes")    //no second input field
            {
                //if the next sibling in visual tree of checkbox parent (stackpanel) is a button then the
                //checkbox does not have an associated input that must be filled in. in this case delete also
                entry.checkbox1State = true;
                var sp    = VisualTreeHelperExtensions.FindAncestor <StackPanel>(cb);
                var grid  = VisualTreeHelperExtensions.FindAncestor <Grid>(sp);
                int index = grid.Children.IndexOf(sp);
                //check if this is last entry
                if (index == grid.Children.Count - 1)
                {
                    bDelete = true;
                }
                else
                {
                    Button but = grid.Children[index + 1] as Button;
                    if (but != null)
                    {
                        bDelete = true;
                    }
                }
            }

            if (bDelete)
            {
                removeline(entry);
                //   CheckForFinish(block);
                //buts.ForEach(b => rootGrid.Children.Remove(b));
                //stacks.ForEach(s => rootGrid.Children.Remove(s));
                //buts.Clear();
                //stacks.Clear();
            }
        }
Пример #5
0
        private void RaiseSupplierContactDelete(object args)
        {
            var button      = (args as RoutedEventArgs).OriginalSource as Button;
            var listboxItem = VisualTreeHelperExtensions.FindAncestor <ListBoxItem>(button);
            var contact     = listboxItem.DataContext as Contact;

            ConfirmationRequest.Raise(new Confirmation
            {
                Title   = "确认",
                Content = "删除联系人" + contact.Name + "?",
            }, r =>
            {
                if (r.Confirmed)
                {
                    CurrentSupplier.Contacts.Remove(contact);
                }
            });
        }
Пример #6
0
        private void RaiseSupplierContactUpdate(object args)
        {
            var button      = (args as RoutedEventArgs).OriginalSource as Button;
            var listboxItem = VisualTreeHelperExtensions.FindAncestor <ListBoxItem>(button);
            var contact     = listboxItem.DataContext as Contact;

            SupplierContactUpdateRequest.Raise(new SupplierContactCreateUpdateNotif(contact)
            {
                Title = "更新联系人"
            }, r =>
            {
                if (r.Confirmed)
                {
                    contact.Name        = r.NewContact.Name;
                    contact.Position    = r.NewContact.Position;
                    contact.Phone       = r.NewContact.Phone;
                    contact.MobilePhone = r.NewContact.MobilePhone;
                    contact.QQ          = r.NewContact.QQ;
                    contact.WeChat      = r.NewContact.WeChat;
                    contact.MobilePhone = r.NewContact.MobilePhone;
                    contact.Email       = r.NewContact.Email;
                }
            });
        }