fix drag and drop bug
This commit is contained in:
parent
f7125ef57d
commit
f735e0f239
@ -50,17 +50,17 @@
|
||||
<Border BorderBrush="#000000" BorderThickness="1" HorizontalAlignment="Right" Height="24" Width="202" VerticalAlignment="Top" IsEnabled="True" Margin="580,210,0,0" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
|
||||
<ComboBox x:Name="BasemapChooser" HorizontalAlignment="Left" Height="24" Margin="9,-1,0,-1" VerticalAlignment="Top" Width="182" SelectionChanged="BasemapChooser_OnSelectionChanged" IsEnabled="True"/>
|
||||
</Border>
|
||||
<ToolBar HorizontalAlignment="Left" Height="29" Margin="0,20,0,0" VerticalAlignment="Top" Width="361">
|
||||
<Button x:Name="Btn_Add_Shp" Height="32" Width="32" Click="Menu_OpenShp_Click">
|
||||
<Button.Background>
|
||||
<ImageBrush ImageSource="D:\01_Development\10_Visual_Studio_Project\GisDevelop\GisDevelop_Exp\GisDevelop_Exp\add.png"/>
|
||||
</Button.Background>
|
||||
</Button>
|
||||
<Button x:Name="Btn_Add_Online" Height="32" Width="32" Click="Btn_Add_Online_OnClick">
|
||||
<Button.Background>
|
||||
<ImageBrush ImageSource="D:\01_Development\10_Visual_Studio_Project\GisDevelop\GisDevelop_Exp\GisDevelop_Exp\online.png"/>
|
||||
</Button.Background>
|
||||
</Button>
|
||||
</ToolBar>
|
||||
<!-- <ToolBar HorizontalAlignment="Left" Height="29" Margin="0,20,0,0" VerticalAlignment="Top" Width="361"> -->
|
||||
<!-- <Button x:Name="Btn_Add_Shp" Height="32" Width="32" Click="Menu_OpenShp_Click"> -->
|
||||
<!-- <Button.Background> -->
|
||||
<!-- <ImageBrush ImageSource="D:\01_Development\10_Visual_Studio_Project\GisDevelop\GisDevelop_Exp\GisDevelop_Exp\add.png"/> -->
|
||||
<!-- </Button.Background> -->
|
||||
<!-- </Button> -->
|
||||
<!-- <Button x:Name="Btn_Add_Online" Height="32" Width="32" Click="Btn_Add_Online_OnClick"> -->
|
||||
<!-- <Button.Background> -->
|
||||
<!-- <ImageBrush ImageSource="D:\01_Development\10_Visual_Studio_Project\GisDevelop\GisDevelop_Exp\GisDevelop_Exp\online.png"/> -->
|
||||
<!-- </Button.Background> -->
|
||||
<!-- </Button> -->
|
||||
<!-- </ToolBar> -->
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@ -526,7 +526,7 @@ namespace GisDevelop_Exp
|
||||
|
||||
if (listBoxItem == null) return;
|
||||
DataObject dataObj = new DataObject(listBoxItem.Content as CheckBox);
|
||||
DragDrop.DoDragDrop(LayerListBox, dataObj, DragDropEffects.Move);
|
||||
DragDrop.DoDragDrop(LayerListBox, listBoxItem, DragDropEffects.Move);
|
||||
}
|
||||
}
|
||||
|
||||
@ -539,8 +539,9 @@ namespace GisDevelop_Exp
|
||||
return;
|
||||
}
|
||||
|
||||
var sourcePerson = e.Data.GetData(typeof(CheckBox)) as CheckBox;
|
||||
if (sourcePerson == null)
|
||||
var sourceItem = e.Data.GetData(typeof(ListBoxItem)) as ListBoxItem;
|
||||
// var sourcePerson = sourceItem.Content;
|
||||
if (sourceItem == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -552,16 +553,16 @@ namespace GisDevelop_Exp
|
||||
}
|
||||
|
||||
var targetPerson = listBoxItem.Content as CheckBox;
|
||||
if (ReferenceEquals(targetPerson, sourcePerson))
|
||||
if (ReferenceEquals(listBoxItem, sourceItem))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int targetIndex = LayerListBox.Items.IndexOf(targetPerson);
|
||||
int sourceIndex = LayerListBox.Items.IndexOf(sourcePerson);
|
||||
LayerListBox.Items.Remove(sourcePerson);
|
||||
LayerListBox.Items.Insert(targetIndex, sourcePerson);
|
||||
MoveLayer(sourcePerson.ToolTip as string,targetPerson.ToolTip as string);
|
||||
int targetIndex = LayerListBox.Items.IndexOf(listBoxItem);
|
||||
int sourceIndex = LayerListBox.Items.IndexOf(sourceItem);
|
||||
LayerListBox.Items.Remove(sourceItem);
|
||||
LayerListBox.Items.Insert(targetIndex, sourceItem);
|
||||
MoveLayer(sourceItem.ToolTip as string,listBoxItem.ToolTip as string);
|
||||
}
|
||||
|
||||
private void AddLayerNameToList()
|
||||
@ -585,14 +586,16 @@ namespace GisDevelop_Exp
|
||||
};
|
||||
Console.WriteLine(pLayers[i].Name);
|
||||
cb.Content = pLayers[i].Name;
|
||||
cb.ToolTip = pLayers[i].Name;
|
||||
cb.ToolTip = cb.Content;
|
||||
cb.Name = pLayers[i].Name;
|
||||
cb.IsChecked = true;
|
||||
cb.Focusable = false;
|
||||
cb.Checked += new RoutedEventHandler(Checked_Layers_CheckBox);
|
||||
cb.Unchecked += new RoutedEventHandler(UnChecked_Layers_CheckBox);
|
||||
ListBoxItem listBoxItem = new ListBoxItem();
|
||||
LayerListBox.Items.Add(cb);
|
||||
listBoxItem.Content = cb;
|
||||
listBoxItem.ToolTip = pLayers[i].Name;
|
||||
LayerListBox.Items.Add(listBoxItem);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user