Исправлено
This commit is contained in:
parent
a2c4204b1f
commit
6306915f5b
2 changed files with 10 additions and 41 deletions
|
|
@ -11,8 +11,16 @@
|
|||
</ContentPage.ToolbarItems>
|
||||
|
||||
<ContentPage.Content>
|
||||
<AbsoluteLayout>
|
||||
<GraphicsView x:Name="canvasView"
|
||||
HeightRequest="800"
|
||||
WidthRequest="800" />
|
||||
<!-- Поле для редактирования текста -->
|
||||
<Entry x:Name="textEditor"
|
||||
IsVisible="False"
|
||||
BackgroundColor="White"
|
||||
TextColor="Black"
|
||||
FontSize="18" />
|
||||
</AbsoluteLayout>
|
||||
</ContentPage.Content>
|
||||
</ContentPage>
|
||||
|
|
@ -6,7 +6,7 @@ namespace NotesDataAnalyst
|
|||
|
||||
public partial class GraphPage : ContentPage
|
||||
{
|
||||
private readonly Entry _textEditor; // Ïîëå äëÿ ââîäà òåêñòà
|
||||
|
||||
private PointF _initialNodePosition; // Õðàíèò íà÷àëüíóþ ïîçèöèþ íîäû
|
||||
private PointF _initialTouchPosition; // Õðàíèò íà÷àëüíóþ ïîçèöèþ êàñàíèÿ
|
||||
private SizeF _initialNodeSize; // Õðàíèò íà÷àëüíûé ðàçìåð íîäû
|
||||
|
|
@ -20,16 +20,7 @@ namespace NotesDataAnalyst
|
|||
{
|
||||
InitializeComponent();
|
||||
|
||||
// Ñîçäàåì ñêðûòîå ïîëå äëÿ ðåäàêòèðîâàíèÿ òåêñòà
|
||||
_textEditor = new Entry
|
||||
{
|
||||
IsVisible = false,
|
||||
BackgroundColor = Colors.Transparent,
|
||||
FontSize = 18,
|
||||
TextColor = Colors.Black
|
||||
};
|
||||
_textEditor.Completed += OnTextEditorCompleted; // Ñîõðàíÿåì òåêñò ïðè çàâåðøåíèè ââîäà
|
||||
this.Add(_textEditor);
|
||||
|
||||
|
||||
// Íàñòðàèâàåì Drawable äëÿ îòðèñîâêè óçëîâ è ñâÿçåé
|
||||
var graphDrawable = new GraphDrawable(_nodes, _connections);
|
||||
|
|
@ -49,38 +40,8 @@ namespace NotesDataAnalyst
|
|||
{
|
||||
var node = _selectedNode;
|
||||
|
||||
var tapPosition = e.GetPosition((View)sender);
|
||||
if (tapPosition.HasValue)
|
||||
{
|
||||
var touchPoint = new PointF((float)tapPosition.Value.X, (float)tapPosition.Value.Y);
|
||||
_selectedNode = _nodes.FirstOrDefault(node => IsPointInsideNode(touchPoint, node));
|
||||
|
||||
if (_selectedNode != null)
|
||||
{
|
||||
// Ïîçèöèîíèðóåì è ïîêàçûâàåì òåêñòîâîå ïîëå
|
||||
_textEditor.Text = _selectedNode.Text;
|
||||
_textEditor.IsVisible = true;
|
||||
_textEditor.Focus();
|
||||
AbsoluteLayout.SetLayoutBounds(_textEditor, new Rect(_selectedNode.Position.X + 5, _selectedNode.Position.Y + 5, _selectedNode.Size.Width - 10, 30));
|
||||
}
|
||||
}
|
||||
|
||||
Debug.WriteLine("Íàæàòà íîäà - {node}");
|
||||
}
|
||||
|
||||
private void OnTextEditorCompleted(object sender, EventArgs e)
|
||||
{
|
||||
// Ñîõðàíÿåì òåêñò â íîäó
|
||||
if (_selectedNode != null)
|
||||
{
|
||||
_selectedNode.Text = _textEditor.Text;
|
||||
_textEditor.IsVisible = false;
|
||||
canvasView.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void OnChildClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (_selectedNode != null)
|
||||
|
|
|
|||
Loading…
Reference in a new issue