Пример #1
0
 private void ListViewItem_MouseDown(object sender, MouseButtonEventArgs e)
 {
     if (!CheckHasDuplicateAlias())
     {
         ViewColumnItem currentItem = (ViewColumnItem)((ListViewItem)sender).DataContext;
         Collection <ViewColumnItem> columnItems = (Collection <ViewColumnItem>)ColumnList.ItemsSource;
         foreach (var item in columnItems)
         {
             if (currentItem != item)
             {
                 item.RenameVisibility = System.Windows.Visibility.Collapsed;
                 item.ViewVisibility   = System.Windows.Visibility.Visible;
             }
         }
     }
     else
     {
         ViewColumnItem item = ((Collection <ViewColumnItem>)ColumnList.ItemsSource).FirstOrDefault(v => v.RenameVisibility == Visibility.Visible);
         if (item != null)
         {
             item.RenameVisibility = System.Windows.Visibility.Collapsed;
             item.ViewVisibility   = System.Windows.Visibility.Visible;
             item.AliasName        = tempOriginalName;
         }
     }
 }
Пример #2
0
        private void ListViewItem_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            ViewColumnItem item = (ViewColumnItem)((ListViewItem)sender).DataContext;

            tempOriginalName      = item.AliasName;
            item.RenameVisibility = System.Windows.Visibility.Visible;
            item.ViewVisibility   = System.Windows.Visibility.Collapsed;
        }
Пример #3
0
 private void SetRenameVisibility(object sender)
 {
     if (!isClosing)
     {
         TextBox        textBox = (TextBox)sender;
         ViewColumnItem item    = (ViewColumnItem)textBox.DataContext;
         if (CheckHasDuplicateAlias())
         {
             item.AliasName = tempOriginalName;
         }
         item.RenameVisibility = System.Windows.Visibility.Collapsed;
         item.ViewVisibility   = System.Windows.Visibility.Visible;
     }
 }
Пример #4
0
        private void RefreshColumnList(FeatureLayer featureLayer)
        {
            Collection <ViewColumnItem> viewColumnItems = new Collection <ViewColumnItem>();

            featureLayer.SafeProcess(() =>
            {
                foreach (var column in featureLayer.FeatureSource.GetColumns())
                {
                    if (!string.IsNullOrEmpty(column.ColumnName))
                    {
                        string alias        = featureLayer.FeatureSource.GetColumnAlias(column.ColumnName);
                        ViewColumnItem item = new ViewColumnItem(column, alias);
                        viewColumnItems.Add(item);
                    }
                }
            });

            if (CalculatedDbfColumn.CalculatedColumns.ContainsKey(featureLayer.FeatureSource.Id))
            {
                foreach (var column in CalculatedDbfColumn.CalculatedColumns[featureLayer.FeatureSource.Id])
                {
                    string         alias = featureLayer.FeatureSource.GetColumnAlias(column.ColumnName);
                    ViewColumnItem item  = new ViewColumnItem(column, alias, true);
                    item.EditAction = c =>
                    {
                        DbfColumn           dbfColumn = (DbfColumn)c;
                        Collection <string> columns   = new Collection <string>();
                        columns.Add(c.ColumnName);
                        string             tempAlias = featureLayer.FeatureSource.GetColumnAlias(dbfColumn.ColumnName);
                        AddDbfColumnWindow window    = new AddDbfColumnWindow(dbfColumn, columns, DbfColumnMode.Calculated, true, tempAlias);
                        window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                        window.Owner = Application.Current.MainWindow;
                        if (window.ShowDialog().GetValueOrDefault())
                        {
                            CalculatedDbfColumn newColumn = window.DbfColumn as CalculatedDbfColumn;
                            if (newColumn != null)
                            {
                                //Check does edit
                                CalculatedDbfColumn tempColumn = (CalculatedDbfColumn)c;
                                if (newColumn.ColumnName == tempColumn.ColumnName &&
                                    newColumn.CalculationType == tempColumn.CalculationType &&
                                    newColumn.ColumnType == tempColumn.ColumnType &&
                                    newColumn.DecimalLength == tempColumn.DecimalLength &&
                                    newColumn.Length == tempColumn.Length &&
                                    newColumn.LengthUnit == tempColumn.LengthUnit &&
                                    newColumn.MaxLength == tempColumn.MaxLength &&
                                    newColumn.AreaUnit == tempColumn.AreaUnit &&
                                    newColumn.TypeName == tempColumn.TypeName)
                                {
                                    return;
                                }

                                if (CheckHasDuplicatedColumn(newColumn))
                                {
                                    return;
                                }

                                if (CalculatedDbfColumn.CalculatedColumns.ContainsKey(featureLayer.FeatureSource.Id))
                                {
                                    CalculatedDbfColumn calColumn = (CalculatedDbfColumn)c;
                                    if (CalculatedDbfColumn.CalculatedColumns[featureLayer.FeatureSource.Id].Contains(calColumn))
                                    {
                                        CalculatedDbfColumn.CalculatedColumns[featureLayer.FeatureSource.Id].Remove(calColumn);
                                    }
                                    CalculatedDbfColumn.CalculatedColumns[featureLayer.FeatureSource.Id].Add(newColumn);
                                }
                                RefreshColumnList(featureLayer);
                            }
                        }
                    };

                    item.DeleteAction = c =>
                    {
                        if (CalculatedDbfColumn.CalculatedColumns.ContainsKey(featureLayer.FeatureSource.Id))
                        {
                            CalculatedDbfColumn calColumn = (CalculatedDbfColumn)c;
                            if (CalculatedDbfColumn.CalculatedColumns[featureLayer.FeatureSource.Id].Contains(calColumn))
                            {
                                CalculatedDbfColumn.CalculatedColumns[featureLayer.FeatureSource.Id].Remove(calColumn);
                                RefreshColumnList(featureLayer);
                            }
                        }
                    };
                    viewColumnItems.Add(item);
                }
            }

            ColumnList.ItemsSource = viewColumnItems;
        }