0
내 wcf 서버가 작동, 계산기 전화 응용 프로그램에서 Windows 전화 작동합니다. 하지만 난 어떻게 wcf 서버에 애플 리케이션 계산을 연결 해야할지 모르겠다. 이 이름 Hesap어떻게 windows wcf 서버에 전화 8 애플 리케이션을 연결
WCF 서버에 코드
IMatemetik.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace WebServisMatematik16._07._2013
{
interface name "IMatematik" in both code and config file together.
[ServiceContract]
public interface IMatematik
{
[OperationContract]
decimal top(decimal s1, decimal s2);
[OperationContract]
decimal cik(decimal s1, decimal s2);
[OperationContract]
decimal bol(decimal s1, decimal s2);
[OperationContract]
decimal car(decimal s1, decimal s2);
}
}
Matematik.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
namespace WebServisMatematik16._07._2013
{
public class Matematik : IMatematik
{
public decimal top(decimal s1, decimal s2)
{
return s1 + s2;
}
public decimal cik(decimal s1, decimal s2)
{
return s1 - s2;
}
public decimal bol(decimal s1, decimal s2)
{
return s1/s2;
}
public decimal car(decimal s1, decimal s2)
{
return s1 * s2;
}
}
}
윈도우 폰 8의로 난 단지 서비스 referance에 추가 CODES
MainPage.xaml.cs를
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
namespace _17tem13WindowsPhoneHesapMak
{
public partial class MainPage : PhoneApplicationPage
{
public MainPage()
{
InitializeComponent();
}
decimal s1 = 0, s2 = 0, son = 0;
string islem = "";
private void Button1_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox1.Text + "1";
textBox2.Text = textBox2.Text + "1";
Hesap.MatematikClient istemci = new Hesap.MatematikClient();
istemci.topAsync(s1,s2);
}
private void Button5_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox1.Text + "5";
textBox2.Text = textBox2.Text + "5";
}
private void Button2_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox1.Text + "2";
textBox2.Text = textBox2.Text + "2";
}
private void Button3_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox1.Text + "3";
textBox2.Text = textBox2.Text + "3";
}
private void Button11_Click(object sender, RoutedEventArgs e)
{
s1 = Convert.ToInt32(textBox1.Text);
islem = "top";
textBox2.Text = textBox2.Text + "+";
textBox1.Text = "";
}
private void Button4_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox1.Text + "4";
textBox2.Text = textBox2.Text + "4";
}
private void Button6_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox1.Text + "6";
textBox2.Text = textBox2.Text + "6";
}
private void Button7_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox1.Text + "7";
textBox2.Text = textBox2.Text + "7";
}
private void Button8_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox1.Text + "8";
textBox2.Text = textBox2.Text + "8";
}
private void Button9_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox1.Text + "9";
textBox2.Text = textBox2.Text + "9";
}
private void Button10_Click(object sender, RoutedEventArgs e)
{
textBox1.Text = textBox1.Text + "0";
textBox2.Text = textBox2.Text + "0";
}
private void Button12_Click(object sender, RoutedEventArgs e)
{
s1 = Convert.ToInt32(textBox1.Text);
islem = "cik";
textBox2.Text = textBox2.Text + "-";
textBox1.Text = "";
}
private void Button13_Click(object sender, RoutedEventArgs e)
{
s1 = Convert.ToInt32(textBox1.Text);
islem = "bol";
textBox2.Text = textBox2.Text + "/";
textBox1.Text = "";
}
private void Button14_Click(object sender, RoutedEventArgs e)
{
s1 = Convert.ToInt32(textBox1.Text);
islem = "car";
textBox2.Text = textBox2.Text + "*";
textBox1.Text = "";
}
private void Button15_Click(object sender, RoutedEventArgs e)
{
s2 = Convert.ToInt32(textBox1.Text);
if (islem == "top")
{
son = s1 + s2;
textBox2.Text = textBox2.Text + "="+son.ToString();
textBox1.Text = son.ToString();
}
if (islem == "cik")
{
son = s1 - s2;
textBox2.Text = textBox2.Text + "=" + son.ToString();
textBox1.Text = son.ToString();
}
if (islem == "bol")
{
son = s1/s2;
textBox2.Text = textBox2.Text + "=" + son.ToString();
textBox1.Text = son.ToString();
}
if (islem == "car")
{
son = s1 * s2;
textBox2.Text = textBox2.Text + "=" + son.ToString();
textBox1.Text = son.ToString();
}
}
private void Button16_Click(object sender, RoutedEventArgs e)
{
textBox2.Text = "";
textBox1.Text = "";
s1 = 0;
s2 = 0;
}
// Sample code for building a localized ApplicationBar
//private void BuildLocalizedApplicationBar()
//{
// // Set the page's ApplicationBar to a new instance of ApplicationBar.
// ApplicationBar = new ApplicationBar();
// // Create a new button and set the text value to the localized string from AppResources.
// ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
// appBarButton.Text = AppResources.AppBarButtonText;
// ApplicationBar.Buttons.Add(appBarButton);
// // Create a new menu item with the localized string from AppResources.
// ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
// ApplicationBar.MenuItems.Add(appBarMenuItem);
//}
}
}
에서 MainPage.xaml는
<phone:PhoneApplicationPage
x:Class="_17tem13WindowsPhoneHesapMak.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- LOCALIZATION NOTE:
To localize the displayed strings copy their values to appropriately named
keys in the app's neutral language resource file (AppResources.resx) then
replace the hard-coded text value between the attributes' quotation marks
with the binding clause whose path points to that string name.
For example:
Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}"
This binding points to the template's string resource named "ApplicationTitle".
Adding supported languages in the Project Properties tab will create a
new resx file per language that can carry the translated values of your
UI strings. The binding in these examples will cause the value of the
attributes to be drawn from the .resx file that matches the
CurrentUICulture of the app at run time.
-->
<!--TitlePanel contains the name of the application and page title-->
<StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="Tolga" Style="{StaticResource PhoneTextNormalStyle}" Margin="12,0"/>
<TextBlock Text="Hesap makinesi" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<Grid.ColumnDefinitions>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Button x:Name="Button1" Content="1" HorizontalAlignment="Left" Margin="10,176,0,0" VerticalAlignment="Top" Click="Button1_Click" Height="120" Width="120"/>
<Button x:Name="Button2" Content="2" HorizontalAlignment="Left" Margin="112,176,0,0" VerticalAlignment="Top" Click="Button2_Click" Height="120" Width="120"/>
<Button x:Name="Button3" Content="3" HorizontalAlignment="Left" Margin="214,176,0,0" VerticalAlignment="Top" Click="Button3_Click" Height="120" Width="120"/>
<Button x:Name="Button4" Content="4" HorizontalAlignment="Left" Margin="10,277,0,0" VerticalAlignment="Top" Click="Button4_Click" Height="120" Width="120"/>
<Button x:Name="Button5" Content="5" HorizontalAlignment="Left" Margin="112,277,0,0" VerticalAlignment="Top" Click="Button5_Click" Height="120" Width="120"/>
<Button x:Name="Button6" Content="6" HorizontalAlignment="Left" Margin="214,277,0,0" VerticalAlignment="Top" Click="Button6_Click" Height="120" Width="120"/>
<Button x:Name="Button7" Content="7" HorizontalAlignment="Left" Margin="10,377,0,0" VerticalAlignment="Top" Click="Button7_Click" Height="120" Width="120"/>
<Button x:Name="Button8" Content="8" HorizontalAlignment="Left" Margin="112,377,0,0" VerticalAlignment="Top" Click="Button8_Click" Height="120" Width="120"/>
<Button x:Name="Button9" Content="9" HorizontalAlignment="Left" Margin="214,377,0,0" VerticalAlignment="Top" Click="Button9_Click" Height="120" Width="120"/>
<Button x:Name="Button10" Content="0" HorizontalAlignment="Left" Margin="214,477,0,0" VerticalAlignment="Top" Click="Button10_Click" Height="120" Width="120"/>
<Button x:Name="Button11" Content="+" HorizontalAlignment="Left" Margin="316,176,0,0" VerticalAlignment="Top" Click="Button11_Click" Height="120" Width="120" Grid.ColumnSpan="2"/>
<Button x:Name="Button12" Content="-" HorizontalAlignment="Left" Margin="316,277,0,0" VerticalAlignment="Top" Click="Button12_Click" Height="120" Width="120" Grid.ColumnSpan="2"/>
<Button x:Name="Button13" Content="/" HorizontalAlignment="Left" Margin="316,377,0,0" VerticalAlignment="Top" Click="Button13_Click" Height="120" Width="120" Grid.ColumnSpan="2"/>
<Button x:Name="Button14" Content="*" HorizontalAlignment="Left" Margin="316,477,0,0" VerticalAlignment="Top" Click="Button14_Click" Height="120" Width="120" Grid.ColumnSpan="2"/>
<Button x:Name="Button15" Content="=" HorizontalAlignment="Left" Margin="112,477,0,0" VerticalAlignment="Top" Click="Button15_Click" Height="120" Width="120" RenderTransformOrigin="0.458,0.467"/>
<Button x:Name="Button16" Content="C" Margin="10,477,326,0" VerticalAlignment="Top" Click="Button16_Click" Height="120" Grid.RowSpan="2"/>
</Grid>
<TextBox x:Name="textBox1" HorizontalAlignment="Left" Height="72" TextWrapping="Wrap" VerticalAlignment="Top" Width="456" Margin="10,10,0,0" Grid.Row="1"/>
<TextBox x:Name="textBox2" HorizontalAlignment="Left" Height="72" Margin="10,117,0,0" Grid.RowSpan="2" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="456"/>
<!--Uncomment to see an alignment grid to help ensure your controls are
aligned on common boundaries. The image has a top margin of -32px to
account for the System Tray. Set this to 0 (or remove the margin altogether)
if the System Tray is hidden.
Before shipping remove this XAML and the image itself.-->
<!--<Image Source="/Assets/AlignmentGrid.png" VerticalAlignment="Top" Height="800" Width="480" Margin="0,-32,0,0" Grid.Row="0" Grid.RowSpan="2" IsHitTestVisible="False" />-->
</Grid>
</phone:PhoneApplicationPage>