Browse Source

еще чуть-чуть

Barsik Kato 2 năm trước cách đây
mục cha
commit
3195b3b790
2 tập tin đã thay đổi với 19 bổ sung10 xóa
  1. 7 10
      Session1/Windows/AddAgent.xaml
  2. 12 0
      Session1/Windows/AddAgent.xaml.cs

+ 7 - 10
Session1/Windows/AddAgent.xaml

@@ -8,14 +8,14 @@
         Title="Добавление агента" Height="470" Width="800">
     <Grid>
         <Grid.ColumnDefinitions>
-            <ColumnDefinition Width="191*"/>
-            <ColumnDefinition Width="227*"/>
-            <ColumnDefinition Width="252*"/>
+            <ColumnDefinition Width="97*"/>
+            <ColumnDefinition Width="101*"/>
+            <ColumnDefinition Width="0*"/>
         </Grid.ColumnDefinitions>
         <GroupBox Header="Изображение">
             <StackPanel Grid.Column="0" VerticalAlignment="Center">
                 <Image x:Name="agentImg" Height="150" Width="150"></Image>
-                <TextBox x:Name="imgPath" Width="150"></TextBox>
+                <TextBox x:Name="imgPath" Width="150" TextChanged="imgPath_TextChanged"></TextBox>
                 <Button x:Name="addImage" Width="150" Click="addImage_Click">Добавить изображение</Button>
             </StackPanel>
         </GroupBox>
@@ -28,16 +28,16 @@
                     <ComboBox x:Name="agentType" Width="150"></ComboBox>
                 </GroupBox>
                 <GroupBox Header="Приоритет">
-                    <TextBox x:Name="agentPriority" Width="150"></TextBox>
+                    <TextBox x:Name="agentPriority" Width="150" PreviewTextInput="PreviewTextInput"></TextBox>
                 </GroupBox>
                 <GroupBox Header="Адрес">
                     <TextBox x:Name="agentAddress" Width="150"></TextBox>
                 </GroupBox>
                 <GroupBox Header="ИНН">
-                    <TextBox x:Name="agentINN" Width="150"></TextBox>
+                    <TextBox x:Name="agentINN" Width="150" PreviewTextInput="PreviewTextInput"></TextBox>
                 </GroupBox>
                 <GroupBox Header="КПП">
-                    <TextBox x:Name="agentKPP" Width="150"></TextBox>
+                    <TextBox x:Name="agentKPP" Width="150" PreviewTextInput="PreviewTextInput"></TextBox>
                 </GroupBox>
                 <GroupBox Header="Директор">
                     <TextBox x:Name="agentDirector" Width="150"></TextBox>
@@ -52,8 +52,5 @@
                 <Button x:Name="cancel" Click="cancel_Click">Отмена</Button>
             </StackPanel>
         </GroupBox>
-        <GroupBox Header="История реализации" Grid.Column="2">
-            <ListView x:Name="historyBox"></ListView>
-        </GroupBox>
     </Grid>
 </Window>

+ 12 - 0
Session1/Windows/AddAgent.xaml.cs

@@ -63,5 +63,17 @@ namespace Session1
             string filePath = openFileDialog.FileName;
             imgPath.Text = filePath;
         }
+
+        private void imgPath_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            agentImg.Source = new BitmapImage(new Uri(imgPath.Text, UriKind.Relative));
+        }
+
+        private void PreviewTextInput(object sender, TextCompositionEventArgs e)
+        {
+            char input = e.Text[0];
+            if (!Char.IsDigit(input))
+                e.Handled = true;
+        }
     }
 }