Wednesday, October 31, 2018

Exchange Server Version



            string exchangeVersion = "";
            exchangeVersion = OwaTools.GetExchangeServerVersion("foo.bar@outlook.com", "pwd", "https://outlook.office365.com/EWS/Exchange.asmx");


using Microsoft.Exchange.WebServices.Data;


        /// <summary>
        /// gets Exchange Server Version
        /// </summary>
        /// <param name="userName">Domain\Username or email adress in some cases (office365)</param>
        /// <param name="userPassword">pwd</param>
        /// <param name="uri">https://server/EWS/EWS/Exchange.asmx e.g. https://outlook.office365.com/EWS/Exchange.asmx  </param>
        /// <returns></returns>
        public static string GetExchangeServerVersion(string userName, string userPassword, string uri)
        {
            var service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);
            service.Credentials = new NetworkCredential(userName, userPassword);
            service.Url = new Uri(uri);
            ServicePointManager.ServerCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true; // ignore invalid or self signed certificates
            var inbox = Folder.Bind(service, WellKnownFolderName.Contacts);
            var esi = inbox.Service.ServerInfo;
            return esi.VersionString;
        }

Monday, October 01, 2018

wpf Default Style überschreiben, Datatrigger

                        <TextBox x:Name="Tb_Id" Text="bla">
                            <TextBox.Style>
                                <Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
                                    <Setter Property="ToolTip" Value="tip1"></Setter>
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Id}" Value="ded371c8-ca5c-416f-9879-6325650e279b">
                                            <Setter Property="ToolTip" Value="Tip2"></Setter>
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </TextBox.Style>

                        </TextBox>

wpf datatemplate usercontrol

<UserControl x:Class="isiQiri.ConfigTool.View.SupportView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             >
    <UserControl.Resources>
        <DataTemplate DataType="{x:Type class1}">
            <StackPanel Orientation="Horizontal" >
                <TextBlock Text="Shift"></TextBlock>
            </StackPanel>
        </DataTemplate>

        <DataTemplate DataType="{x:Type class2}">
            <StackPanel Orientation="Horizontal" DataContext="{Binding}">
                <TextBlock Text="EditorViewModel: " />
            </StackPanel>
        </DataTemplate>
     
    </UserControl.Resources>

   
    <StackPanel>


   <ContentControl Content="{Binding}"></ContentControl>