Ejemplo n.º 1
0
        private void buttonCloseJoin_Click(object sender, RoutedEventArgs e)
        {
            ContentPresenter obj = App.FindVisualParent <ContentPresenter>(sender as DependencyObject);

            if (obj == null)
            {
                return;
            }
            JoinTable join = obj.DataContext as JoinTable;

            JoinTables.Remove(join);
        }
Ejemplo n.º 2
0
        public JoinTable(JoinTable referrer, ForeignKeyConstraint constraint, JoinDirection direction)
        {
            _joinBy        = constraint;
            _joinDirection = direction;
            Table tbl = constraint.Table;

            _referrer = referrer;
            if (referrer == null)
            {
                _kind = JoinKind.Root;
            }
            else
            {
                _kind = referrer.Kind;
                if (_kind == JoinKind.Root)
                {
                    _kind = JoinKind.Inner;
                }
                if (_kind != JoinKind.LeftOuter && _kind != JoinKind.FullOuter)
                {
                    foreach (string c in constraint.Columns)
                    {
                        Column col = tbl.Columns[c];
                        if (!col.NotNull)
                        {
                            _kind = JoinKind.LeftOuter;
                            break;
                        }
                    }
                }
            }
            switch (direction)
            {
            case JoinDirection.ReferFrom:
                _table          = constraint.Table;
                ReferrerColumns = (string[])constraint.RefColumns.Clone();
                JoinColumns     = (string[])constraint.Columns.Clone();
                break;

            case JoinDirection.ReferTo:
                _table          = constraint.ReferenceConstraint.Table;
                ReferrerColumns = (string[])constraint.Columns.Clone();
                JoinColumns     = (string[])constraint.RefColumns.Clone();
                break;

            default:
                throw new NotImplementedException();
            }
            InitVisibleColumns();
        }
Ejemplo n.º 3
0
        private void buttonAddJoin_Click(object sender, RoutedEventArgs e)
        {
            ContentPresenter obj       = App.FindVisualParent <ContentPresenter>(sender as DependencyObject);
            ContextMenu      menu      = Resources["ContextMenuJoinTableCandidates"] as ContextMenu;
            JoinTable        joinTable = obj.Content as JoinTable;

            menu.DataContext = joinTable;
            menu.ItemsSource = null;
            List <RefTable> l = new List <RefTable>();

            RefTable.AddRefTables(l, joinTable.SelectableForeignKeys, JoinDirection.ReferTo);
            RefTable.AddRefTables(l, (joinTable.Table as Table).ReferFrom, JoinDirection.ReferFrom);
            menu.ItemsSource     = l;
            menu.PlacementTarget = sender as UIElement;
            menu.Placement       = System.Windows.Controls.Primitives.PlacementMode.Bottom;
            menu.IsOpen          = true;
        }
Ejemplo n.º 4
0
        private void ButtonJoinTableColumns_Click(object sender, RoutedEventArgs e)
        {
            //ListBoxItem item = App.FindLogicalParent<ListBoxItem>(sender as DependencyObject);
            ListBoxItem item = App.FindVisualParent <ListBoxItem>(sender as DependencyObject);
            JoinTable   tbl  = item?.DataContext as JoinTable;

            if (tbl == null)
            {
                return;
            }
            ColumnCheckListWindow win = new ColumnCheckListWindow();

            win.Owner  = Window.GetWindow(this);
            win.Target = tbl;
            WindowLocator.LocateNearby(sender as FrameworkElement, win, NearbyLocation.DownLeft);
            win.Closed += ColumnCheckListWindow_Closed;
            win.Show();
        }
Ejemplo n.º 5
0
        private void TargetPropertyChanged(DependencyPropertyChangedEventArgs e)
        {
            JoinTables.Clear();
            JoinTable jt = new JoinTable()
            {
                Alias = "a", Table = Target, Kind = JoinKind.Root
            };

            jt.PropertyChanged += JoinTable_PropertyChanged;
            JoinTables.Add(jt);
            //dataGridColumns.ItemsSource = Target.Columns;
            DataGridControllerResult.Table = Target;
            sortFields.Target = Target;
            //dataGridReferTo.ItemsSource = Target.ReferTo;
            //dataGridReferedBy.ItemsSource = Target.ReferFrom;
            UpdateTextBoxSource();
            UpdateTextBoxTemplateSql();
            UpdateHiddenLevelDisplayItems();
            Dispatcher.Invoke(Fetch, DispatcherPriority.ApplicationIdle);
        }
Ejemplo n.º 6
0
        private void MenuItemAddJoin_Click(object sender, RoutedEventArgs e)
        {
            MenuItem item = (sender as MenuItem);

            if (item == null)
            {
                return;
            }
            RefTable refTbl = item.DataContext as RefTable;

            if (refTbl == null)
            {
                return;
            }
            ContextMenu menu = App.FindVisualParent <ContextMenu>(item);

            if (menu == null)
            {
                return;
            }
            JoinTable join = menu.DataContext as JoinTable;

            JoinTables.Add(new JoinTable(join, refTbl.Constraint, refTbl.Direction));
        }