web browser

main
syneffort 2 years ago
parent e7c5f66c1b
commit 46000134f6
  1. 1
      PacticeSolution/ClockGadget/MainWindow.xaml
  2. 9
      PacticeSolution/MapFinder/App.xaml
  3. 17
      PacticeSolution/MapFinder/App.xaml.cs
  4. 10
      PacticeSolution/MapFinder/AssemblyInfo.cs
  5. 27
      PacticeSolution/MapFinder/Data/FoundLocale.cs
  6. 46
      PacticeSolution/MapFinder/MainWindow.xaml
  7. 50
      PacticeSolution/MapFinder/MainWindow.xaml.cs
  8. 14
      PacticeSolution/MapFinder/MapFinder.csproj
  9. 50
      PacticeSolution/MapFinder/Utility/KakaoAPI.cs
  10. 6
      PacticeSolution/PacticeSolution.sln

@ -21,6 +21,7 @@
<RowDefinition/> <RowDefinition/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Ellipse Grid.RowSpan="7" Fill="White" Opacity="0.6" <Ellipse Grid.RowSpan="7" Fill="White" Opacity="0.6"
Stroke="Black"
MouseDown="Ellipse_MouseDown"/> MouseDown="Ellipse_MouseDown"/>
<TextBlock x:Name="tbDate" <TextBlock x:Name="tbDate"
Grid.Row="2" Grid.Row="2"

@ -0,0 +1,9 @@
<Application x:Class="MapFinder.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MapFinder"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MapFinder
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MapFinder.Data
{
class FoundLocale
{
internal string Name { get; private set; }
internal double Lng { get; private set; }
internal double Lat { get; private set; }
public FoundLocale(string name, double lng, double lat)
{
this.Name = name;
this.Lng = lng;
this.Lat = lat;
}
public override string ToString()
{
return this.Name;
}
}
}

@ -0,0 +1,46 @@
<Window x:Class="MapFinder.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MapFinder"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="9*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="8*"/>
<ColumnDefinition Width="2*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Center">
검색어:
</TextBlock>
<TextBox x:Name="tbQuery"
Background="LightGray"
Grid.Column="1"
Margin="5,0,5,0"
VerticalAlignment="Center"/>
<Button x:Name="btnFind"
IsDefault="True"
VerticalAlignment="Center"
Grid.Column="2"
Content="검색"
Click="btnFind_Click"/>
<ListBox x:Name="lbxFound"
Background="Cyan"
Grid.Row="1"
SelectionChanged="lbxFound_SelectionChanged"/>
<WebBrowser x:Name="wbMain"
Source="https://map.kakao.com"
Grid.Row="1"
Grid.Column="1"
Grid.ColumnSpan="3"/>
</Grid>
</Window>

@ -0,0 +1,50 @@
using MapFinder.Data;
using MapFinder.Utility;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace MapFinder
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btnFind_Click(object sender, RoutedEventArgs e)
{
List<FoundLocale> localeList = KakaoAPI.Search(tbQuery.Text);
lbxFound.ItemsSource = localeList;
}
private void lbxFound_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (lbxFound.SelectedIndex == -1)
return;
FoundLocale selected = lbxFound.SelectedItem as FoundLocale;
if (selected == null)
return;
Uri uri = new Uri($"https://map.kakao.com/link/map/{selected.Name},{selected.Lat},{selected.Lng}");
wbMain.Source = uri;
}
}
}

@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
</Project>

@ -0,0 +1,50 @@
using MapFinder.Data;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.Encodings.Web;
using System.Threading.Tasks;
namespace MapFinder.Utility
{
static class KakaoAPI
{
internal static List<FoundLocale> Search(string query)
{
List<FoundLocale> localeList = new List<FoundLocale>();
string site = "https://dapi.kakao.com/v2/local/search/keyword.json";
string rquery = $"{site}?query={query}";
WebRequest request = WebRequest.Create(rquery);
string rkey = ""; // REST API KEY
string header = $"KakaoAK {rkey}";
request.Headers.Add("Authorization", header);
WebResponse response = request.GetResponse();
using (Stream resStream = response.GetResponseStream())
{
StreamReader reader = new StreamReader(resStream, Encoding.UTF8);
string json = reader.ReadToEnd();
dynamic dob = JsonConvert.DeserializeObject<dynamic>(json);
dynamic docs = dob["documents"];
JArray buff = docs;
int length = buff.Count;
for (int i = 0; i < length; i++)
{
string lname = docs[i]["place_name"];
double x = double.Parse(docs[i]["x"].ToString());
double y = double.Parse(docs[i]["y"].ToString());
localeList.Add(new FoundLocale(lname, x, y));
}
}
return localeList;
}
}
}

@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PacticeSolution", "PacticeS
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClockGadget", "ClockGadget\ClockGadget.csproj", "{AED102C2-9E4B-4DE6-A843-616856F687DB}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClockGadget", "ClockGadget\ClockGadget.csproj", "{AED102C2-9E4B-4DE6-A843-616856F687DB}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MapFinder", "MapFinder\MapFinder.csproj", "{4FCEAEAA-6A26-492F-95D1-9695F386DAB5}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -21,6 +23,10 @@ Global
{AED102C2-9E4B-4DE6-A843-616856F687DB}.Debug|Any CPU.Build.0 = Debug|Any CPU {AED102C2-9E4B-4DE6-A843-616856F687DB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AED102C2-9E4B-4DE6-A843-616856F687DB}.Release|Any CPU.ActiveCfg = Release|Any CPU {AED102C2-9E4B-4DE6-A843-616856F687DB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AED102C2-9E4B-4DE6-A843-616856F687DB}.Release|Any CPU.Build.0 = Release|Any CPU {AED102C2-9E4B-4DE6-A843-616856F687DB}.Release|Any CPU.Build.0 = Release|Any CPU
{4FCEAEAA-6A26-492F-95D1-9695F386DAB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4FCEAEAA-6A26-492F-95D1-9695F386DAB5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4FCEAEAA-6A26-492F-95D1-9695F386DAB5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4FCEAEAA-6A26-492F-95D1-9695F386DAB5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

Loading…
Cancel
Save