CodeProject-New articles added Last week


New articles added Last week

Combo & List Boxes

  • Read Only Combo Box Provider - RanceDowner1234
    How to create a read only combo box user IExtenderProvider (Unedited)
    VB (VB 8.0, VB), .NET (.NET, .NET 2.0), WinForms, Dev, Intermediate

Dialogs and Windows

  • A Plugin Wizard Framework - Marc Clifton
    A wizard framework that supports plugins for the wizard pages (Unedited)
    C#, Windows, WinForms, Design, Arch, Dev, Intermediate

Grid & Data Controls

  • Extending the DataGridView - Chris_McGrath
    A few minor modifications to improve the DataGridView (Unedited)
    C# (C# 1.0, C# 2.0, C# 3.0, C#), .NET (.NET, .NET 2.0, .NET 3.5, .NET 3.0), WinForms, Beginner

  • Editable and Multi-Functional Datagridview - Viram
    The article or rather a code snippet demonstrates a simple application of insert, update, delete using datagridview. There are some unique features in this datagridview.
    VB.NET 2.0, Dev, Intermediate

Miscellaneous

  • Painless Persistence of Windows Forms positions - Phil Martin...
    A no-pain way of retaining your Windows Form positions between application runs (Unedited)
    C# (C# 1.0, C# 2.0, C# 3.0, C#), .NET (.NET, .NET 2.0, .NET 3.5), WinForms, Dev, Beginner, Intermediate

Status Bar

Ajax and Atlas

ASP.NET

Custom Controls

Silverlight

Web Security

  • .NET Role-Based Security in a Production Environment - Ralph in Boise
    Edit web.config to Update the Data Provider for Shared Hosting with Role-Based Security: SQL Server, ODBC, Active Directory, ADAM, SQLite, MySQL, Access, XML (Unedited)
    .NET (.NET 2.0, .NET 3.0, .NET 3.5, .NET), WebForms, ASP.NET, Arch, Dev, Beginner, Intermediate

Web Services

  • Web Services For Ecologists - Andrew Birt, Rahul Ravikumar
    A framework for distributing scientific models over the web (Unedited)
    C++, C#, Windows, Visual Studio, ATL, ASP.NET, Beginner

SharePoint Server

Audio and Video

  • Multimedia PeakMeter control - Ernest Laurentin
    Multimedia PeakMeter control - .NET version (Unedited)
    C# (C# 1.0, C# 2.0, C# 3.0, C#), .NET CF, .NET, GDI+, WinForms, Design, Dev, Beginner

  • Hands Gesture Recognition - Andrew Kirillov
    Some ideas about Hands Gesture Recognition in still images and video feeds, using the AForge.NET framework (C#).
    C#, Windows, .NET (.NET 2.0, .NET), WinForms, GDI+, DirectX, Arch, Dev, Intermediate

GDI+

  • GDI+ Code Generator - Richard Blythe
    Allows the user to draw vector graphic shapes, then converts them to GDI+ code. (Unedited)
    C# (C# 1.0, C# 2.0, C# 3.0, C#), .NET, GDI+, Design, Intermediate

SQL Reporting Services

.NET Framework

  • .NET 2.0 Configuration and Provider Model - Sergey Sorokin
    Use .NET 2.0 configuration features for building a pluggable provider framework for your application. (Unedited)
    C# (C# 1.0, C# 2.0, C# 3.0, C#), .NET (.NET, .NET 2.0, .NET 3.5, .NET 3.0), Visual Studio (VS2008, VS), Arch, Dev, Design, Intermediate

Libraries

  • Genetic Algorithm Library - Mladen Jankovic
    Framework for genetic algorithms (Unedited)
    C++, Windows, Win32, Visual Studio, MFC, STL, Arch, Dev, Design, Intermediate

LINQ

Windows Communication Foundation

  • WCF Error Handling and Fault Conversion - Sasha Goldshtein
    This article describes the WCF error-handling paradigm, and provides a mechanism for automatic mapping of exceptions to WCF faults.
    C#, Windows, WCF, Arch, Dev, Intermediate, Advanced

Windows Powershell

  • Saving Powershell commands across sessions - Gideon Engelberth
    A set of functions to provide the ability to save commands to be used in future Powershell sessions. (Unedited)
    Windows (WinXP, Win2003, Vista, Windows), .NET (.NET 2.0, .NET), SysAdmin, DBA, Dev, Intermediate

Windows Presentation Foundation

C / C++ Language

  • C++ Coding Practices Guide - Chesnokov Yuriy
    The article describes C++ coding styles and practices to be followed to develop robust and reliable code that is easily comprehended and maintained by other developers.
    C++ (VC6, VC7, VC7.1, VC8.0, C++), C++/CLI, C, Windows, .NET, MFC, WinForms, Dev, Intermediate

C#

  • EnumOperators - PIEBALDconsult
    A class to help ease the burden of not being able to specify enum as a generic constraint
    C#.NET 2.0, Dev, Intermediate

  • Plugins manager - Luca Bonotto
    A plugins manager class to menage a plugins structure (Unedited)
    C# (C# 1.0, C# 2.0, C# 3.0, C#)

  • C# DAL Method Code Generator - Saravanan.B
    Generates C# data access layer method code for SQL sever stored procedures (Unedited)
    C# (C# 2.0, C#), .NET (.NET, .NET 2.0), WinForms, Dev, Beginner

  • Developing Visual Studio Add-in to enforce company's standard modification history - Rahil Manasia
    Using Visual Studio.net to developing Add-in to enforce company's standard modification history (Unedited)
    C# (C# 1.0, C# 2.0, C# 3.0, C#), .NET, Visual Studio, Arch, Dev, Design, Beginner, Intermediate

VB.NET

  • Schema Generator - dnpro
    Utility to generate schema description from existing SQL Server database (Unedited)
    C# (C# 2.0, C#), VB 7.x, VB 8.0, VB 9.0, VB 6, .NET (.NET, .NET 2.0), WinForms, DBA, Dev, Intermediate

  • A Process viewer with alert notification - dnpro
    Simple process viewer that is capable of setting alerts for process events. (Unedited)
    VB (VB 9.0, VB), .NET (.NET, .NET 2.0), WinForms, SysAdmin, Dev, Intermediate

XML

Algorithms & Recipes

  • Wordmills are coming... - Chesnokov Yuriy
    The article describes how a computer-being can be trained to write text articles, poems, compose music, or paint contemporary paintings.
    C# (C# 1.0, C# 2.0, C# 3.0, C#), .NET (.NET, .NET 3.5), Dev, Intermediate

  • Using memory mapped files to conserve physical memory for large arrays - Mikael Svenson
    The article shows how to implement a value type array as a memory mapped file to conserve physical memory. (Unedited)
    C# (C# 2.0, C# 3.0, C#), .NET (.NET, .NET 3.5, .NET 2.0), Arch, Dev, Intermediate, Advanced

  • Evaluation Engine - Donald Snowdy
    The Evaluation Engine is a parser and interpreter that can be used to define rules for Business Rules Engine. (Unedited)
    C#, .NET, Visual Studio, WinForms, WebForms, Design, Arch, Dev, Intermediate, Advanced

Cryptography & Security

  • Creating a secure channel - Efi Merdler
    The purpose of this article is to explain how a secure channel is built. The article will explain the structure of a Very Simple Secured Protocol (VSSP) that sits above the TCP/IP layer.
    C# (C# 2.0, C#), Windows (Windows, WinXP), Dev, Intermediate, Advanced

Book Chapters

  • Building Spring 2 Enterprise Applications: Chapter 4: Spring AOP 2.0 - aPress
    The open-source Spring Framework has become a popular application framework for building enterprise Java apps. This chapter explores the newest features in Spring AOP (Aspect-Oriented Programming), including @AspectJ-style annotations, the AspectJ pointcut language, Spring AOP XML tags and more. (Unedited)
    Dev, Design, Advanced

Product Showcase

  • Static Analysis on Steroids: Parasoft BugDetective - Parasoft Corporation
    Data flow analysis enables early and effortless detection of critical runtime errors like exceptions, resource leaks, and security vulnerabilities. It can also check if exceptions reported from automated unit testing are "real bugs."
    C++, Java, .NET, Linux, Arch, Dev, QA, Intermediate

Articles updated added Last week

Miscellaneous

Progress Controls

Shell and IE programming

  • A File Checksum Shell Menu Extension Dll - Jeffrey Walton
    Create a File Checksum Shell Menu Extension using ATL and Crypto++ (Unedited)
    VC6, VC7, VC7.1, VC8.0, VC9.0NT4, Win2K, WinXP, Win2003, Vista, ATL, STL, COM, VS.NET2002, VS.NET2003, VS6, Dev, Intermediate

Ajax and Atlas

Applications & Tools

ASP.NET

ASP.NET Controls

  • Google's Static Map API WebControl - Florian DREVET
    Shows you how to build an image based WebControl displaying static maps with markers
    C# (C# 2.0, C#), .NET (.NET, .NET 2.0), ASP.NET, Dev, Design, Intermediate

Internet / Network

  • MailMergeLib - A .NET Mail Client Library - Norbert Bietsch
    MailMergeLib is a mail client library. It makes use of .NET System.Net.Mail and provides comfortable mail merge capabilities. MailMergeLib corrects a number of the most annoying bugs and RFC violations that .NET 2.0 to .NET 3.5 suffer from.
    C# 2.0, C# 3.0.NET 2.0, Win2K, WinXP, Win2003, Vista, ASP.NET, VS2005, VS2008, Dev, Beginner, Intermediate

Database

.NET Framework

Game Development

Libraries

  • DNS.NET Resolver (C#) - alphons
    Full implementation of a reusable DNS resolver component and a Dig.Net example application (Unedited)
    C# (C# 1.0, C# 2.0, C# 3.0, C#), Windows, .NET (.NET, .NET 2.0), Visual Studio (VS2005, VS), Dev, Advanced

Mobile Development

  • Termie : a simple RS232 terminal - milkplus
    Termie opens a serial port and allows you to communicate with it in a chat-like interface. (Unedited)
    C# (C# 2.0, C# 3.0, C#), Windows, .NET, Dev, Intermediate

Windows Presentation Foundation

Windows Workflow Foundation

C#

  • NArrange - .NET Code Organizer - James Nies
    Using NArrange to Organize C# Source Code (Unedited)
    C#, VB, .NET, Visual Studio, Dev, Intermediate

  • List Comprehensions for C# 2.0 - Frohwalt Egerer
    Writing nice list comprehensions for C# 2.0.
    C# (C# 2.0, C#), .NET, Dev, Intermediate

  • Index XML Documents with VTD-XML - Jimmy Zhang
    Introduce a simple, efficient, human-readable XML index called VTD+XML (Unedited)
    C, C# (C# 1.0, C# 2.0, C# 3.0, C#), Javascript, XML, CSS, HTML, ASM, MSIL, UML, Forth.NET, XSLT, Office, XBox, Windows (Windows, Win2K, WinXP, Win2003, Vista), WinCE, .NET CF, .NET (.NET, Mono, DotGNU, .NET 3.5), ASP, ASP.NET, Win32, Win64, SQL (SQL 2000, SQL 2005, SQL), IIS, GDI, GDI+, OpenGL, DirectX, LINQ, Ajax, WCF, XAML, WPF, COM, COM+, ADO, ADO.NET, VS.NET2002, VS.NET2003, VS2005, VS2008, Design, CEO, Arch, DBA, Dev, QA, Beginner, Intermediate, Advanced

  • Windows Services in Action I - Umut ŞİMŞEK
    Explains windows services basics and deployment with details. (Unedited)
    C# (C# 1.0, C# 2.0, C# 3.0, C#), Windows (Windows, NT4, Win2K, WinXP, Win2003, Vista, TabletPC, Embedded), .NET (.NET, .NET 3.5, .NET 3.0, .NET 1.0, .NET 1.1, .NET 2.0, Mono, DotGNU), Win32, Beginner

  • VTD-XML: XML Processing for the Future (Part II) - Jimmy Zhang
    Reveal XML processing issue #1 and explain why document-centric XML Processing is the future (Unedited)
    C#, XML, .NET (DotGNU, .NET), Dev

  • Multiple Ways to do Multiple Inserts - Neeraj Saluja
    Various ways to do Multiple Inserts in SQL Server 2000/2005 or Oracle Database using ADO.NET in single database round trip. (Unedited)
    C# (C# 1.0, C# 2.0, C#), .NET (.NET, .NET 1.1, .NET 2.0), ADO.NET, Dev, Intermediate

  • Schemaless C#-XML data binding with VTD-XML - Jimmy Zhang
    Agile, efficient XML data binding without schema (Unedited)
    C# (C# 1.0, C# 2.0, C# 3.0, C#), XML, .NET CF, .NET (.NET, .NET 3.5, .NET 3.0, .NET 1.0, .NET 1.1, .NET 2.0), ASP, Win32, Win64, ADO.NET, WCF, Ajax, Design, CEO, Arch, DBA, Dev, QA, Beginner, Intermediate, Advanced

C++ / CLI

  • DirectoryList 2.0 - nirvansk815
    A custom listbox control to help visually manipulate data (Unedited)
    C++ (C++, VC9.0), C++/CLI, .NET (.NET, .NET 2.0), Win32, Visual Studio (VS2005, VS2008, VS), WinForms, Intermediate

VB.NET

Algorithms & Recipes

  • C++ Strtk Tokenizer - Arash Partow
    A brief introduction to a tokenizer implementation in C++ (Unedited)
    C++ (VC7.1, VC8.0, C++), C++/CLI, C, Dev, Beginner

  • Implementing a super-fast, size-constrained generic cache - Alexander Mossin
    The article shows how to combine two of the most common data structures into a high-performance, self-organizing cache with a maximum size.
    C# (C# 1.0, C# 2.0, C# 3.0, C#), .NET (.NET, .NET 2.0, .NET 3.5, .NET 3.0), Dev, Intermediate

  • Genetic Algorithms in Artificial Neural Network Classification Problems - Chesnokov Yuriy
    The article demonstrating application of genetic algorithms for classification problems with artificial neural networks (Unedited)
    C++ (VC6, VC7, VC7.1, VC8.0, C++), C++/CLI, C, Windows, Dev, Intermediate

  • Permutations, Combinations and Variations using C# Generics - Adrian Akison
    Discusses the six major types of combinatorial collections with examples and formulas for counting. Expands with a C# generics-based set of classes for enumerating each meta-collection. (Unedited)
    C# (C# 2.0, C# 3.0, C#), .NET (.NET, .NET 2.0, .NET 3.5, .NET 3.0), Arch, Dev, QA, Design, Beginner, Intermediate

  • Inner Product Experiment: CPU, FPU vs. SSE* - Chesnokov Yuriy
    The article demonstrating inner product operation performed with shorts, ints, floats and doubles with CPU/FPU and SSE for comparison. (Unedited)
    C++ (VC6, VC7, VC7.1, VC8.0, C++), C++/CLI, C

  • Inner Product Experiment: C# vs. C/C++ - Chesnokov Yuriy
    The article demonstrating speed of inner product operation performed with shorts, ints, longs, floats, doubles and decimals in C# compared to C/C++ (Unedited)
    C#, Windows, .NET, Visual Studio, Dev, Intermediate

  • 2D Vector Class Wrapper SSE Optimized for Math Operations - Chesnokov Yuriy
    The article demonstrates a 2D vector wrapper, optimized with SSE intrinsics, for math operations with floating point precision.
    C++ (VC6, VC7, VC7.1, VC8.0, C++), C++/CLI, C, Dev, Intermediate

  • Backpropagation Artificial Neural Network in C++ - Chesnokov Yuriy
    The article demonstrating backpropagation artificial neural network console application with validation and test sets for performance estimation using uneven distribution metrics. (Unedited)
    C++ (VC6, VC7, VC7.1, VC8.0, C++), C++/CLI, C, Windows, Dev, Intermediate

Cryptography & Security

  • Cryptographic Interoperability: Digital Signatures - Jeffrey Walton
    Sign and verify messages using Crypto++, Java, and C#.
    C++ (VC7, VC7.1, VC8.0, C++), C# (C# 2.0, C# 3.0, C#), Java, Windows (Windows, Win2K, WinXP, Win2003, Vista), Win32, Dev, Intermediate

Threads, Processes & IPC

  • A C++ plugin ThreadPool design - Alex C. Punnen
    The Command Pattern and Chain of Responsibility for implementing a plugin ThreadPool library (Unedited)
    C++ (VC6, VC7, VC7.1, VC8.0, C++, VC9.0), Windows (Windows, WinXP, Win2003, Vista), Win32, STL, Arch, Dev, Design, Intermediate, Advanced

Design and Architecture

  • Secrets for Setting Up Continuous Integration - wallism
    A few simple tips that should help when you are considering setting up CI (Unedited)
    SQL, C# (C# 1.0, C# 2.0, C# 3.0, C#), VB (VB 7.x, VB 8.0, VB 9.0, VB), .NET (.NET, .NET 3.5, .NET 3.0, .NET 1.1, .NET 2.0), SQL (SQL 2005, SQL), WinForms, WebForms, ASP.NET, Arch, DBA, Dev, Beginner, Intermediate, Advanced

Hardware & System


26 new messages in 20 topics - digest

==============================================================================
TOPIC: How to add a path inside of a border using c# and wpf
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/6c32aa3e9052727f?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, May 16 2008 12:03 am
From: "moondaddy"


This was a big help as it shows me how to set different styles from
resources in c#. Now I need to change a control template in c#. Is this
possible? If so, then here's a control template applied in xaml:

<ContentControl x:Name="ConnectorGraph" Template="{DynamicResource
ShapeConnectorTemplate}" RenderTransformOrigin="0.5,0.5"
HorizontalAlignment="Right" VerticalAlignment="Center" Width="7"
Height="12" >


and I want to be able to change the template to xyzTemplate using c#.

If this is not allowed, then here's my problem. I have a content control
called "ShapeConnector" which uses a template to create a path in side of
it, and a gradient fill inside that path. The data trigger changes the
color of the fill when the IsMouseOver property changes. this is good.
however, when I'm doing a drag operation the IsMouseOver property doesn't
fire. So I need to manually change the gradient fill in the path. I was
going to do this from a HitTest method in the drag operation and when the
HitTest finds the ShapeConnector content control, I would then change the
fill color there.

One option might be to have a style for the gradient in the path, but I
don't know how to reference a style inside a template using c#. Here's the
xaml for the template:

<ControlTemplate x:Key="ShapeConnectorTemplate" TargetType="{x:Type
ContentControl}" >
<Path x:Name="MyPath" Style="{DynamicResource ConnectorPathStyle}"
RenderTransformOrigin="0.5,0.5" Height="12" Width="7" >
<Path.Fill>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0.181,0.5">
<GradientStop Color="#FF82D7EE" Offset="1"/>
<GradientStop Color="#FFFBFFFF" Offset="0.237"/>
</LinearGradientBrush>
</Path.Fill>
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="0,0" IsClosed="True">
<BezierSegment Point1="8,6" Point2="8,6"
Point3="0,12"/>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
<ControlTemplate.Triggers>

<DataTrigger Value="True">
<DataTrigger.Binding>
<Binding Path="IsMouseOver">
<Binding.RelativeSource>
<RelativeSource Mode="FindAncestor"
AncestorType="{x:Type FrameworkElement}" AncestorLevel="1"/>
</Binding.RelativeSource>
</Binding>
</DataTrigger.Binding>
<Setter Property="Fill" TargetName="MyPath">
<Setter.Value>
<LinearGradientBrush EndPoint="1,0.5"
StartPoint="0.181,0.5">
<GradientStop Color="#FFF7B030" Offset="0.835"/>
<GradientStop Color="#FFFFFDF6" Offset="0.058"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>


I'm thinking I wound need to chang the stype for "MyPath" in this line:

x:Name="MyPath" Style="{DynamicResource ConnectorPathStyle}"

but using c#.

What do you recomend?


"Linda Liu[MSFT]" <v-lliu@online.microsoft.com> wrote in message
news:yFbBZHmtIHA.4284@TK2MSFTNGHUB02.phx.gbl...
> Hi Moondaddy,
>
>>I need to dynamically add these content controls using c# at runtime and
> am having trouble referencing the styles and adding the path into the
> border.
>
> To retrieve resources in code, call the FrameworkElement.FindResource or
> TryFindResource method.
>
> The following is a sample to add the ContentControl named "btnOtM" to the
> Canvas in code. It requires to set the Name attribute in the Canvas
> element
> to "Canvas1" in your sample XAML snippet.
>
> private void Window_Loaded(object sender, RoutedEventArgs e)
> {
> // build a ContentControl
> ContentControl cc = new ContentControl();
> cc.Name = "btnOtM";
> cc.Width = 11;
> cc.Height = 10;
> Canvas.SetLeft(cc, 12);
> Canvas.SetTop(cc, 25);
>
> // build a Border
> Border b = new Border();
> b.Style =
> TryFindResource("FunctionConnectorSelectorButtonStyle") as Style;
>
>
> // build a PathGeometry
> Path p = new Path();
> p.Stroke = new
> SolidColorBrush(Color.FromArgb(0xFF,0,0x71,0x82));
> p.StrokeThickness = 1;
> PathGeometry pg = new PathGeometry();
> PathFigure pf = new PathFigure();
> pf.StartPoint = new Point(2, 2);
> pf.Segments.Add(new LineSegment(new Point(5, 2),true));
> pf.Segments.Add(new LineSegment(new Point(5, 6), true));
> pf.Segments.Add(new LineSegment(new Point(2, 6), true));
> pg.Figures.Add(pf);
>
> pf = new PathFigure();
> pf.StartPoint = new Point(5, 4);
> pf.Segments.Add(new LineSegment(new Point(8, 4), true));
> pg.Figures.Add(pf);
> p.Data = pg;
>
> b.Child = p;
> cc.Content = b;
> this.Canvas1.Children.Add(cc);
> }
>
> Hope this helps.
> If you have any question, please feel free to let me know.
>
> Sincerely,
> Linda Liu
> Microsoft Online Community Support
>
> Delighting our customers is our #1 priority. We welcome your comments and
> suggestions about how we can improve the support we provide to you. Please
> feel free to let my manager know what you think of the level of service
> provided. You can send feedback directly to my manager at:
> msdnmg@microsoft.com.
>
> ==================================================
> Get notification to my posts through email? Please refer to
> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
> ications.
>
> Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
> where an initial response from the community or a Microsoft Support
> Engineer within 1 business day is acceptable. Please note that each follow
> up response may take approximately 2 business days as the support
> professional working with you may need further investigation to reach the
> most efficient resolution. The offering is not appropriate for situations
> that require urgent, real-time or phone-based interactions or complex
> project analysis and dump analysis issues. Issues of this nature are best
> handled working with a dedicated Microsoft Support Engineer by contacting
> Microsoft Customer Support Services (CSS) at
> http://msdn.microsoft.com/subscriptions/support/default.aspx.
> ==================================================
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>
>


== 2 of 2 ==
Date: Fri, May 16 2008 1:34 am
From: "moondaddy"


I thought I found a solution but it doesn't have any effect on the
appearance of the path. I got a reference to the path using
VisualTreeHelper.GetChild method and then set a style on the path, but it
didn't change the appearance. Here's the c#:

System.Windows.Shapes.Path path =
(System.Windows.Shapes.Path)VisualTreeHelper.GetChild(foundTargetConnector.ConnectorGraph,
0);
Console.WriteLine(path.ToString());
path.Style = TryFindResource("ConnectorPathMouseOverStyle") as Style;

Here's the content of the user control that has the path I'm trying to
change:

<Grid x:Name="ConnectorGrid" Background="Transparent"
Style="{DynamicResource FunctionConnectorGridLeftStyle}" Width="20"
Height="12" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="13"/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>


<ContentControl x:Name="ConnectorGraph" Template="{DynamicResource
ShapeConnectorTemplate}" RenderTransformOrigin="0.5,0.5"
HorizontalAlignment="Right"
VerticalAlignment="Center" Width="7" Height="12" >
<ContentControl.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</ContentControl.RenderTransform>
</ContentControl>
</Grid>


and here's the 2 styles I want to use to change the appearance of the path
in the control template:

<Style x:Key="ConnectorPathStyle" TargetType="{x:Type Path}">
<Setter Property="Stroke" Value="#FF24BFE2"/>
<Setter Property="StrokeThickness" Value="0.5"/>
<Setter Property="Fill">
<Setter.Value>
<LinearGradientBrush EndPoint="1,0.5"
StartPoint="0.181,0.5">
<GradientStop Color="#FF82D7EE" Offset="1"/>
<GradientStop Color="#FFFBFFFF" Offset="0.237"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>

<Style x:Key="ConnectorPathMouseOverStyle" TargetType="{x:Type Path}">
<Setter Property="Stroke" Value="#FF24BFE2"/>
<Setter Property="StrokeThickness" Value="0.5"/>
<Setter Property="Fill">
<Setter.Value>
<LinearGradientBrush EndPoint="1,0.5"
StartPoint="0.181,0.5">
<GradientStop Color="#FFF7B030" Offset="0.835"/>
<GradientStop Color="#FFFFFDF6" Offset="0.058"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</Style>

and here's the control template


<ControlTemplate x:Key="ShapeConnectorTemplate" TargetType="{x:Type
ContentControl}" >
<Path x:Name="MyPath" Style="{DynamicResource ConnectorPathStyle}"
RenderTransformOrigin="0.5,0.5" Height="12" Width="7" >
<Path.Fill>
<LinearGradientBrush EndPoint="1,0.5"
StartPoint="0.181,0.5">
<GradientStop Color="#FF82D7EE" Offset="1"/>
<GradientStop Color="#FFFBFFFF" Offset="0.237"/>
</LinearGradientBrush>
</Path.Fill>
<Path.Data>
<PathGeometry>
<PathGeometry.Figures>
<PathFigure StartPoint="0,0" IsClosed="True">
<BezierSegment Point1="8,6" Point2="8,6"
Point3="0,12"/>
</PathFigure>
</PathGeometry.Figures>
</PathGeometry>
</Path.Data>
</Path>
<ControlTemplate.Triggers>

<DataTrigger Value="True">
<DataTrigger.Binding>
<Binding Path="IsMouseOver">
<Binding.RelativeSource>
<RelativeSource Mode="FindAncestor"
AncestorType="{x:Type FrameworkElement}" AncestorLevel="1"/>
</Binding.RelativeSource>
</Binding>
</DataTrigger.Binding>
<Setter Property="Fill" TargetName="MyPath">
<Setter.Value>
<LinearGradientBrush EndPoint="1,0.5"
StartPoint="0.181,0.5">
<GradientStop Color="#FFF7B030" Offset="0.835"/>
<GradientStop Color="#FFFFFDF6" Offset="0.058"/>
</LinearGradientBrush>
</Setter.Value>
</Setter>
</DataTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>

any advice would be great.

Thanks.

"moondaddy" <moondaddy@newsgroup.nospam> wrote in message
news:%23J0exLytIHA.4260@TK2MSFTNGP05.phx.gbl...
> This was a big help as it shows me how to set different styles from
> resources in c#. Now I need to change a control template in c#. Is this
> possible? If so, then here's a control template applied in xaml:
>
> <ContentControl x:Name="ConnectorGraph" Template="{DynamicResource
> ShapeConnectorTemplate}" RenderTransformOrigin="0.5,0.5"
> HorizontalAlignment="Right" VerticalAlignment="Center" Width="7"
> Height="12" >
>
>
> and I want to be able to change the template to xyzTemplate using c#.
>
> If this is not allowed, then here's my problem. I have a content control
> called "ShapeConnector" which uses a template to create a path in side of
> it, and a gradient fill inside that path. The data trigger changes the
> color of the fill when the IsMouseOver property changes. this is good.
> however, when I'm doing a drag operation the IsMouseOver property doesn't
> fire. So I need to manually change the gradient fill in the path. I was
> going to do this from a HitTest method in the drag operation and when the
> HitTest finds the ShapeConnector content control, I would then change the
> fill color there.
>
> One option might be to have a style for the gradient in the path, but I
> don't know how to reference a style inside a template using c#. Here's
> the xaml for the template:
>
> <ControlTemplate x:Key="ShapeConnectorTemplate" TargetType="{x:Type
> ContentControl}" >
> <Path x:Name="MyPath" Style="{DynamicResource ConnectorPathStyle}"
> RenderTransformOrigin="0.5,0.5" Height="12" Width="7" >
> <Path.Fill>
> <LinearGradientBrush EndPoint="1,0.5" StartPoint="0.181,0.5">
> <GradientStop Color="#FF82D7EE" Offset="1"/>
> <GradientStop Color="#FFFBFFFF" Offset="0.237"/>
> </LinearGradientBrush>
> </Path.Fill>
> <Path.Data>
> <PathGeometry>
> <PathGeometry.Figures>
> <PathFigure StartPoint="0,0" IsClosed="True">
> <BezierSegment Point1="8,6" Point2="8,6"
> Point3="0,12"/>
> </PathFigure>
> </PathGeometry.Figures>
> </PathGeometry>
> </Path.Data>
> </Path>
> <ControlTemplate.Triggers>
>
> <DataTrigger Value="True">
> <DataTrigger.Binding>
> <Binding Path="IsMouseOver">
> <Binding.RelativeSource>
> <RelativeSource Mode="FindAncestor"
> AncestorType="{x:Type FrameworkElement}" AncestorLevel="1"/>
> </Binding.RelativeSource>
> </Binding>
> </DataTrigger.Binding>
> <Setter Property="Fill" TargetName="MyPath">
> <Setter.Value>
> <LinearGradientBrush EndPoint="1,0.5"
> StartPoint="0.181,0.5">
> <GradientStop Color="#FFF7B030" Offset="0.835"/>
> <GradientStop Color="#FFFFFDF6" Offset="0.058"/>
> </LinearGradientBrush>
> </Setter.Value>
> </Setter>
> </DataTrigger>
> </ControlTemplate.Triggers>
> </ControlTemplate>
>
>
> I'm thinking I wound need to chang the stype for "MyPath" in this line:
>
> x:Name="MyPath" Style="{DynamicResource ConnectorPathStyle}"
>
> but using c#.
>
> What do you recomend?
>
>
> "Linda Liu[MSFT]" <v-lliu@online.microsoft.com> wrote in message
> news:yFbBZHmtIHA.4284@TK2MSFTNGHUB02.phx.gbl...
>> Hi Moondaddy,
>>
>>>I need to dynamically add these content controls using c# at runtime and
>> am having trouble referencing the styles and adding the path into the
>> border.
>>
>> To retrieve resources in code, call the FrameworkElement.FindResource or
>> TryFindResource method.
>>
>> The following is a sample to add the ContentControl named "btnOtM" to the
>> Canvas in code. It requires to set the Name attribute in the Canvas
>> element
>> to "Canvas1" in your sample XAML snippet.
>>
>> private void Window_Loaded(object sender, RoutedEventArgs e)
>> {
>> // build a ContentControl
>> ContentControl cc = new ContentControl();
>> cc.Name = "btnOtM";
>> cc.Width = 11;
>> cc.Height = 10;
>> Canvas.SetLeft(cc, 12);
>> Canvas.SetTop(cc, 25);
>>
>> // build a Border
>> Border b = new Border();
>> b.Style =
>> TryFindResource("FunctionConnectorSelectorButtonStyle") as Style;
>>
>>
>> // build a PathGeometry
>> Path p = new Path();
>> p.Stroke = new
>> SolidColorBrush(Color.FromArgb(0xFF,0,0x71,0x82));
>> p.StrokeThickness = 1;
>> PathGeometry pg = new PathGeometry();
>> PathFigure pf = new PathFigure();
>> pf.StartPoint = new Point(2, 2);
>> pf.Segments.Add(new LineSegment(new Point(5, 2),true));
>> pf.Segments.Add(new LineSegment(new Point(5, 6), true));
>> pf.Segments.Add(new LineSegment(new Point(2, 6), true));
>> pg.Figures.Add(pf);
>>
>> pf = new PathFigure();
>> pf.StartPoint = new Point(5, 4);
>> pf.Segments.Add(new LineSegment(new Point(8, 4), true));
>> pg.Figures.Add(pf);
>> p.Data = pg;
>>
>> b.Child = p;
>> cc.Content = b;
>> this.Canvas1.Children.Add(cc);
>> }
>>
>> Hope this helps.
>> If you have any question, please feel free to let me know.
>>
>> Sincerely,
>> Linda Liu
>> Microsoft Online Community Support
>>
>> Delighting our customers is our #1 priority. We welcome your comments and
>> suggestions about how we can improve the support we provide to you.
>> Please
>> feel free to let my manager know what you think of the level of service
>> provided. You can send feedback directly to my manager at:
>> msdnmg@microsoft.com.
>>
>> ==================================================
>> Get notification to my posts through email? Please refer to
>> http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
>> ications.
>>
>> Note: The MSDN Managed Newsgroup support offering is for non-urgent
>> issues
>> where an initial response from the community or a Microsoft Support
>> Engineer within 1 business day is acceptable. Please note that each
>> follow
>> up response may take approximately 2 business days as the support
>> professional working with you may need further investigation to reach the
>> most efficient resolution. The offering is not appropriate for situations
>> that require urgent, real-time or phone-based interactions or complex
>> project analysis and dump analysis issues. Issues of this nature are best
>> handled working with a dedicated Microsoft Support Engineer by contacting
>> Microsoft Customer Support Services (CSS) at
>> http://msdn.microsoft.com/subscriptions/support/default.aspx.
>> ==================================================
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>>
>
>

==============================================================================
TOPIC: Style trigger not firing in wpf app
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/4d677c0e3747bc15?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 12:24 am
From: v-lliu@online.microsoft.com (Linda Liu[MSFT])


Hi Moondaddy,

Thank you for your confirmation. I'm glad to hear that the problem is
solved now.

If you have any other questions in the future, please don't hesitate to
contact us. It's always our pleasure to be of assistance!

Have a nice weekend!

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

==============================================================================
TOPIC: XML Serialization and Internationalization
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/d9839c1ecd6e8061?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, May 16 2008 12:26 am
From: Marc Gravell


How are you doing the serialization? My understanding is that
XmlSerializer will use invariant formatting for common types...

Are you doing any of the serialization yourself? Perhaps via
IXmlSerializable?

Marc


== 2 of 2 ==
Date: Fri, May 16 2008 1:28 am
From: Joachim Van den Bogaert


Could you please give an example of your xml? I tried it out with an
xsd, an xml and a class.
The result showed me that integers were stored without formatting
(which was expected).

Joachim

This is what it looks like:
____________________
XSD:
____________________

<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="TestClass" targetNamespace="http://tempuri.org/
TestClass.xsd" elementFormDefault="qualified" xmlns="http://
tempuri.org/TestClass.xsd" xmlns:mstns="http://tempuri.org/
TestClass.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="TestClass">
<xs:complexType>
<xs:sequence>
<xs:element name="Amount" type="xs:int">
</xs:element>
<xs:element name="Language" type="xs:language" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

____________________
class:
____________________

using System.Xml.Serialization;

//
// This source code was auto-generated by xsd, Version=2.0.50727.42.
//


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true,
Namespace="http://tempuri.org/TestClass.xsd")]
[System.Xml.Serialization.XmlRootAttribute(Namespace="http://
tempuri.org/TestClass.xsd", IsNullable=false)]
public partial class TestClass {

private int amountField;

private string languageField;

/// <remarks/>
public int Amount {
get {
return this.amountField;
}
set {
this.amountField = value;
}
}

/// <remarks/>

[System.Xml.Serialization.XmlElementAttribute(DataType="language")]
public string Language {
get {
return this.languageField;
}
set {
this.languageField = value;
}
}
}

____________________
Unit test:
____________________

[Test]
public void SerializationLocalozation()
{
TestClass tc = new TestClass();
tc.Amount = 1000;
StreamWriter writerEnUS = new
StreamWriter("SerializationTest_en_US.xml");
StreamWriter writerNlNL = new
StreamWriter("SerializationTest_nl_NL.xml");
Thread.CurrentThread.CurrentCulture =
CultureInfo.GetCultureInfo("en-US");
tc.Language =
Thread.CurrentThread.CurrentCulture.ToString();
XmlSerializer xmls = new XmlSerializer(typeof(TestClass));
xmls.Serialize(writerEnUS, tc);
writerEnUS.Close();
Thread.CurrentThread.CurrentCulture =
CultureInfo.GetCultureInfo("nl-NL");
tc.Language =
Thread.CurrentThread.CurrentCulture.ToString();
xmls.Serialize(writerNlNL, tc);
writerNlNL.Close();
}

____________________
Resulting xml en-US:
____________________

<?xml version="1.0" encoding="utf-8"?>
<TestClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/
TestClass.xsd">
<Amount>1000</Amount>
<Language>en-US</Language>
</TestClass>

____________________
Resulting xml nl-NL:
____________________

<?xml version="1.0" encoding="utf-8"?>
<TestClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://tempuri.org/
TestClass.xsd">
<Amount>1000</Amount>
<Language>nl-NL</Language>
</TestClass>

==============================================================================
TOPIC: Linking to datagrids together
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/a958723bfae50e6c?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, May 16 2008 12:31 am
From: Cdude


How do i make it so that each time i select a different row in my
datagradview i want the data in my other to change accordingly.For
example, i will have invoices in the one grid and purchased items in
the other and when i select a invoice i want to bring up all the item
linked to the invoice


== 2 of 2 ==
Date: Fri, May 16 2008 1:09 am
From: Marc Gravell


You need to set exactly the same DataSource for each, and use DataMember
(on the second grid) to specify the property to use to obtain the
sub-data. This ensures that the same "currency manager" is used when
binding the outer items; here's a C# 3 example, but works the same in C#
2...

Marc

using System.Collections.Generic;
using System.Windows.Forms;
class Foo
{
public string Name { get; set; }
List<Bar> bars = new List<Bar>();
public List<Bar> Bars { get { return bars; } }
}
class Bar
{
public string Desc { get; set; }
}
static class Program
{
static void Main()
{
List<Foo> list = new List<Foo> {
new Foo {
Name = "Fred",
Bars = {
new Bar {Desc="abc"},
new Bar {Desc="def"}
}
}, new Foo {
Name = "Barney",
Bars = {
new Bar {Desc="ghi"}
}
}
};
Application.EnableVisualStyles();
Application.Run
(
new Form
{
Width = 600,
Text = "Linked bindings",
Controls =
{
new DataGridView {
Dock = DockStyle.Fill,
DataSource = list,
DataMember = "Bars"
},
new DataGridView
{
Dock = DockStyle.Left,
DataSource = list
}

}
}
);
}
}

==============================================================================
TOPIC: DateType that can be: True, False or Null?
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/b0a02adb2f139f85?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 12:39 am
From: Joachim Van den Bogaert


With NUnit referenced, try this to find out whether DBNull and null
are the same (you will find they are not):

[TestFixture]
public class Test
{
[Test]
public void NullDBNullEqual()
{
Assert.AreEqual(null, DBNull.Value);
}
}

Joachim

==============================================================================
TOPIC: GridView not Showing Headers When there are No Rows
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/37e7d88601d9c16a?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 12:35 am
From: Marc Gravell


Hmmm... I would have expected to work. I'm sorry, but I don't know. If
you don't get any other takers, I would recommend posting on an asp
group, since there will be many GridView experts there...

Marc

==============================================================================
TOPIC: VS2008 intellisense hiding an extension method.
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/d64459fc3b2441f2?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 12:37 am
From: Marc Gravell


>> Anyone willing to install the SP1 beta and try it?

It is identical on SP1 beta.

Which by the way is really, really good (IMO). The IDE feels much more
responsive; warnings / errors appear immeditely, for example.

Marc

==============================================================================
TOPIC: foreach on Collection, List, IList, ICollection, ...
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/997339e74b74f614?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 12:37 am
From: Dansk

Thank you for your answers, they really make sense to me.


Dansk a écrit :
> Hi all,
>
> Can I assume that when I loop throw a Collection, List, IList,
> ICollection, ... by using foreach, I first get the element of index 0,
> then index 2, and so on until the last one ?
>
> Thanks for your answers,
>
> Dansk.

==============================================================================
TOPIC: NullReferencException in DLinq lambda method
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/143a67d94b8f784f?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 12:39 am
From: Marc Gravell


> new operator in query creates new object. so order.Customer *cannot*
> be null.

No - the "new Customer" in the query posted only applies to the
anonymous type you are generating. It says nothing at all about whether
order.Customer is null or not.

Try simply enumerating the orders, and listing what Customer is...

Marc

==============================================================================
TOPIC: invisible gui
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/66f42bb971d1705c?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 12:44 am
From: v-lliu@online.microsoft.com (Linda Liu[MSFT])


Hi Dave,

When a Form is loaded, it's Load event is fired first. The Form won't show
until all lines of code in its Load event handler finish executing. After
that, the Form's Activated event is fired and then the Shown event.

If the Form does some time-consuming work in the Activated or Shown event
handler, the UI of the Form will be blocked, i.e. all controls on the Form
are not painted properly or not responsive. This is because the main UI
thread is busy and doesn't have a chance to paint/refresh the UI of the
Form.

To show a Form and then do some time-consuming work without blocking the
UI, I suggest that you do the time-consuming work in a separate thread. You
can create a Thread instance or call the BeginInvoke method on the delegate
to the time-consuming method to do it, if you're using .NET 1.x.

If you're using .NET 2.0, I recommend you use the BackgroundWorker
component, which provides a concise multiple-threads programming model and
is very easy to use. You can start a BackgroundWorker in the Form's Load
event handler in your practice.

For more information on how to use the BackgroundWorker component, please
refer to the following MSDN document:
http://msdn.microsoft.com/en-us/library/system.componentmodel.backgroundwork
er.aspx

Hope this helps.
If you have anything unclear, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

==============================================================================
TOPIC: Why can't a static member be abstract or an override?
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/84df4cc2bb43b19f?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, May 16 2008 1:27 am
From: Orla Sorensen


I've read this topic, but is still don't know what to do.
I would like my code to be as following, but gets an error due to
subject. Is there any way arround this problem, I would really like to
keep the methode test1 in the super class1, since it's quit complex, but
need the methode to use the value val depending on the subclass class2.

namespace ConsoleApplication1
{
abstract class Class1
{
public abstract static int val
{
get;
}

public static void test1()
{
Console.WriteLine(val);
}
}

class Class2 : Class1
{
public static override int val
{
get { return 10; }
}
}

class Program
{
static void Main(string[] args)
{
Class2.test1();
}
}
}

*** Sent via Developersdex http://www.developersdex.com ***


== 2 of 2 ==
Date: Fri, May 16 2008 4:38 am
From: "Peter Morris"


It would be better to show what you REALLY want rather than something that
probably resembles it.

==============================================================================
TOPIC: End thread
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/d367f6b353cbf6d2?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, May 16 2008 1:34 am
From: Sylfelin


Hello,

I start a very long process in thread.
When function is ending (very long process is finish), i leave thne
function and thread.

In this case, that becomes the thread ?

It is automatically destroyed and memory released in the next garbage
collector ?

Thank's

--

--------------------------
Merci
Sylfelin


== 2 of 2 ==
Date: Fri, May 16 2008 3:08 am
From: "Jon Skeet [C# MVP]"


On May 16, 9:34 am, Sylfelin <sylfelin_EN_TR...@cegetel.net> wrote:
> I start a very long process in thread.
> When function is ending (very long process is finish), i leave thne
> function and thread.
>
> In this case, that becomes the thread ?
>
> It is automatically destroyed and memory released in the next garbage
> collector ?

If it's a manually created thread, then yes the thread will die when
the task is completed. For a thread-pool thread, the thread will live
on for the next task.

Jon

==============================================================================
TOPIC: left join with DLinq associatons
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/c8a7a849f2b7e485?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 1:46 am
From: "Andrus"


Northwind has Employees table containing 3 employees:

EmployeeID FirstName ReportToEmployee
1 Andrew NULL
2 Nancy 1
3 Bob 2


I need to create list of employee and its manager first names *including*
employee Andrew. For Andrew, first name can be null or empty string.:

Andrew NULL
Nancy Andrew
Bob Nancy


I tried

Northwind db = CreateDB();
var query = from e in db.Employees
select new {
Name = e.FirstName,
ReportsTo = e.ReportsToEmployee.FirstName
};
var list = query.ToList();

But this returns only 2 members, without Andrew.
How to return 3 entities, including Andrew ?

Andrus.

Employee class is defined as

[Table(Name = "employees")]
public partial class Employee {

[AutoGenId]
private int employeeID;

[Column(Storage = "employeeID", Name = "employeeid", DbType =
"integer(32,0)", IsPrimaryKey = true, IsDbGenerated = true, CanBeNull =
false, Expression = "nextval('employees_employeeid_seq')")]
public int EmployeeID {
get
{
return employeeID;
}
set
{
if (value != employeeID)
{
employeeID = value;
}
}
}

private string firstName;
[Column(Storage = "firstName", Name = "firstname", DbType = "character
varying(10)", CanBeNull = false, Expression = null)]
public string FirstName
{
get
{
return firstName;
}
set
{
if (value != firstName)
{
firstName = value;
}
}
}

private int? reportsTo;
[Column(Storage = "reportsTo", Name = "reportsto", DbType =
"integer(32,0)", Expression = null)]
public int? ReportsTo {
get
{
return reportsTo;
}
set
{
if (value != reportsTo)
{
reportsTo = value;
}
}
}

[Association(Storage = null, OtherKey = "EmployeeID", Name =
"fk_emp_reportstoemp")]
public EntityMSet<Employee> Employees {
get
{
return null;
}
}

[Association(Storage = null, OtherKey = "EmployeeID", Name =
"employeeterritories_employeeid_fkey")]
public EntitySet<EmployeeTerritory> EmployeeTerritories {
get
{
return null;
}
}

[Association(Storage = null, OtherKey = "EmployeeID", Name =
"fk_order_product")]
public EntitySet<Order> Orders
{
get
{
return null;
}
}

private System.Data.Linq.EntityRef<Employee> reportsToEmployee;
[Association(Storage = "reportsToEmployee", ThisKey = "ReportsTo", Name =
"fk_emp_reportstoemp")]
public Employee ReportsToEmployee
{
get
{
return reportsToEmployee.Entity;
}
set
{
reportsToEmployee.Entity = value;
}
}
}


==============================================================================
TOPIC: copy text and images from DataGridView to Clipboard (for Word)?
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/cb614b2ad663c463?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 1:57 am
From: Robert


Hi!

I want to fill the clipboard programmatically in oder to manual copy the
data to word.
The data consists of cells of a grid which contains text or images.
Using the standard copy/paste of the dataGridView only the text-cells
are copied and pasted in word,
the image-cells are empty.
How can I build an IDataObject that can contain text and images like it
is possible when copy from word to word?

Thanks for any hints or links.

*** Sent via Developersdex http://www.developersdex.com ***

==============================================================================
TOPIC: ActiveX .NET Drag&Drop control work fine in windows form not in web
Form
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/42aeccad9098f4e7?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 2:07 am
From: deccio


I have create an activex Control with Visual studio 2005 and framework
2.0 in c# to add drag & drop functionality to upload multi file.
When I use it in a windows form it work fine. Infact if I select 3
files from a windows explorer and I move it in a listbox in my
activeX, I find my 3 files added in the listbox but if I use my
activeX in a web form and I select 3 file from a windows explorer in
the listBox find only 1 file the file on which the mouse is on when
the drag & drop operation begin.

I post some code..

private void listBox1_DragDrop(object sender, DragEventArgs e)
{
Array a = (Array)e.Data.GetData(DataFormats.FileDrop);

if (a != null)
{
// if i execute the activeX in a windows Form the
a.Length property value is the exact number of file that i have
selected
// if i execute the activeX in a web Form the
a.Length property value is always 1 for (int i =0 ;
i< a.Length; i++)
{ string s
= a.GetValue(i).ToString();

if (!listBox1.Items.Contains(s))
{
string filename =
System.IO.Path.GetFileName(s);
listBox1.Items.Add(filename);
}
}
}
}


Anyone knows why in web Form The value of a.Length is Always 1?

Thanks wery much

==============================================================================
TOPIC: Question on Program Hanging
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/5d6ba192c2eae291?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 3:04 am
From: stcheng@online.microsoft.com (Steven Cheng [MSFT])


Hi Robert,

Have you got any progress on this issue or does those information help
some? Since such hanging or crash problem is likely to be hard for
troubleshooting, especially in production environment. If you still have no
luck on this and feel it an urgent issue, I would suggest you consider
contacting CSS for incident based support:

Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>From: stcheng@online.microsoft.com (Steven Cheng [MSFT])
>Organization: Microsoft
>Date: Wed, 14 May 2008 04:55:02 GMT
>Subject: RE: Question on Program Hanging

>
>Hi Robert,
>
>As for such hang behavior problem, generally, if we can not get clear clus
>from code logic, it will require some debugging work on it (such as find
>the blocking thread and resource).
>
>Not sure whether you've already read some about managed debugging on
>application hang, here are some good blog article about managed debugging:
>
>#.NET Debugging Demos Lab 1: Hang
>http://blogs.msdn.com/tess/archive/2008/02/04/net-debugging-demos-lab-1-han
g
>.aspx
>
>#.NET Hang Debugging Walkthrough
>http://blogs.msdn.com/tess/archive/2006/10/16/net-hang-debugging-walkthroug
h
>.aspx
>
>BTW, as you provided the code snippet and the potential block point, how
>did you originally track down to it? Also, it seems there are many method
>calls on a custom class, has it accessed any particular resource or
objects
>that may cause problem?
>
>Sincerely,
>
>Steven Cheng
>
>Microsoft MSDN Online Support Lead
>
>
>Delighting our customers is our #1 priority. We welcome your comments and
>suggestions about how we can improve the support we provide to you. Please
>feel free to let my manager know what you think of the level of service
>provided. You can send feedback directly to my manager at:
>msdnmg@microsoft.com.
>
>==================================================
>Get notification to my posts through email? Please refer to
>http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#noti
f
>ications.
>
>Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
>where an initial response from the community or a Microsoft Support
>Engineer within 1 business day is acceptable. Please note that each follow
>up response may take approximately 2 business days as the support
>professional working with you may need further investigation to reach the
>most efficient resolution. The offering is not appropriate for situations
>that require urgent, real-time or phone-based interactions or complex
>project analysis and dump analysis issues. Issues of this nature are best
>handled working with a dedicated Microsoft Support Engineer by contacting
>Microsoft Customer Support Services (CSS) at
>http://msdn.microsoft.com/subscriptions/support/default.aspx.
>==================================================
>This posting is provided "AS IS" with no warranties, and confers no rights.
>
>--------------------
>>From: "Microsoft" <Robert12345@nospam.nospam>
>>Subject: Question on Program Hanging
>>Date: Tue, 13 May 2008 12:22:45 -0400
>
>>Hi
>>
>>I have a c# program that continually runs 24/7 and performs a variety of
>>tasks based on a timer.
>>
>>There is one routine that hangs every Saturday morning without fail. If I
>>restart the program throughout the week is still hangs. I can restart it
>>immediatly after the hang and it runs fine until next Saturday.
>>
>>There is nothing different about Saturday that I can think of.
>>
>>Any help tracking this down would be appreciated!
>>
>>
>>Thanks
>>
>>Robert
>>
>>
>>
>>Here is the code snip:
>>
>>af.AddToFile(Constants.c_LogFile,DateTime.Now.ToString() + " Start Grab
>New
>>Invoices") ; // Simply writes out to a log file
>>
>>ds = gds.GrabTheData("NewInvoices"); // ar_GetEmailInvoice01 - Puts data
>>into a dataset
>>
>>af.AddToFile(Constants.c_LogFile,DateTime.Now.ToString() + " End Grab New
>>Invoices") ;
>>
>>af.AddToFile(Constants.c_LogFile, DateTime.Now.ToString() + " Start For
>>each");
>>
>>af.AddToFile(Constants.c_LogFile, DateTime.Now.ToString() + " Start For
>each
>>Next");
>>
>>
>>
>>// ****************************************** HANGS Here or
>>
>>tempRowCount = ds.Tables[0].Rows.Count;
>>
>>// ****************************************** HANGS Here
>>
>>af.AddToFile(Constants.c_LogFile, DateTime.Now.ToString() + " Row Count "
>+
>>tempRowCount.ToString() ) ;
>>
>>foreach (DataRow dr in ds.Tables[0].Rows)
>>
>>{
>>
>> af.AddToFile(Constants.c_LogFile,DateTime.Now.ToString() + " Email the
>>Invoice") ;
>>
>> CreateInvoice(dr["CustNum"].ToString(),dr["OrdNum"].ToString()) ;
>>
>> EmailInvoice(dr["CustNum"].ToString(),dr["OrdNum"].ToString()) ;
>>
>>
>>
>> gds.CustNum = dr["CustNum"].ToString() ;
>>
>> gds.QuoteNum = dr["OrdNum"].ToString() ;
>>
>> gds.UpdateTheData("InvoicesEmailed") ;
>>
>>}
>>
>>af.AddToFile(Constants.c_LogFile,DateTime.Now.ToString() + " Exiting") ;
>>
>>
>>
>>
>>
>
>


==============================================================================
TOPIC: Retrieving Unique Items from a List
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/42b1bbc264a5b81b?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 3:14 am
From: amir


Hello Peter and Tim,

Linq was my first approach but I am bogged down with the users not having
the latest framework and and compatible machine. However, the TryGetValue is
the right solution.

Thanks much fellas.

"Peter Duniho" wrote:

> On Thu, 15 May 2008 15:40:02 -0700, amir <amir@discussions.microsoft.com>
> wrote:
>
> > [...]
> > foreach (item in the list)
> > mylist = list.findall(item);
> > foreach(myitem in mylist)
> > dosomething
> >
> > the problem occurs in the outer foreach where it already has processed
> > some
> > items from the original list. how do i exclude them?
>
> If you really must process your list items in groups according to your
> FindAll() results, I think using LINQ as Tim suggests would work well.
> However, I have to wonder why you want to do this. Nothing in the code
> you posted indicates an actual need to do this, and it seems like you'd be
> better off just enumerating the list and processing each element one by
> one. The way you've shown it, you've basically got an O(N^2) algorithm
> even if we assume you somehow address the duplicated item issue at no cost
> (which isn't a realistic assumption).
>
> If you can't use LINQ and you must process in groups, an alternative
> solution would be to use a Dictionary where the key for the dictionary is
> the same as whatever criteria you're using for the FindAll() search.
> Then, when enumerating each item in the list, rather than doing work
> during that enumeration, simply build up lists of elements in your
> Dictionary based on that key, and then enumerate those lists later:
>
> Dictionary<KeyType, List<ListItem>> dict = new Dictionary<KeyType,
> List<ListItem>>();
>
> foreach (ListItem item in list)
> {
> List<ListItem> listDict;
>
> if (!dict.TryGetValue(item.KeyProperty, out listDict))
> {
> listDict = new List<ListItem>();
> dict.Add(item.KeyProperty, listDict);
> }
>
> listDict.Add(item);
> }
>
> foreach (List<ListItem> listItems in dict.Values)
> {
> foreach (ListItem item in listItems)
> {
> // do something
> }
> }
>
> That's only O(N) instead of O(N^2) and IMHO makes it a bit more clear that
> you specifically are trying to group the items before processing.
>
> Pete
>

==============================================================================
TOPIC: How to determine whether an object is a VALID COM object
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/94b508d170b74cb7?hl=en
==============================================================================

== 1 of 2 ==
Date: Fri, May 16 2008 4:07 am
From: abhimanyu


I have a method Marshal.IsComObject(...) that returns TRUE if an
object is a COM object.
I have an object of Excel.Worksheet that I released using
Marshal.ReleaseComObject(...). I want to iterate over a collection of
Excel.Worksheet and find out which is disposed.
Currently the workaround for me (bad one) is

try
{
string name = worksheet.Name;
}
catch(Exception e)
{
// this one was release as I cannot access it
worksheet = null;
}

Is there any other method through which I can check for a VALID(not
released) COM object?

Regards,


== 2 of 2 ==
Date: Fri, May 16 2008 5:07 am
From: Jeroen Mostert


abhimanyu wrote:
> I have a method Marshal.IsComObject(...) that returns TRUE if an
> object is a COM object.
> I have an object of Excel.Worksheet that I released using
> Marshal.ReleaseComObject(...). I want to iterate over a collection of
> Excel.Worksheet and find out which is disposed.

There's no way to determine whether an object is disposed other than using
it and getting an ObjectDisposedException. And that's actually the *good*
scenario. If you were working with pure COM, you'd have no way at all of
knowing whether an interface pointer was valid, and you'd likely just get a
crash if you use an invalid one.

You must keep track of when an object was disposed yourself. In general, do
not dispose objects until you're certain (or have made certain) that nobody
will use them anymore, then you can omit keeping track.

> Currently the workaround for me (bad one) is
>
> try
> {
> string name = worksheet.Name;
> }
> catch(Exception e)

Catch specific exception types, not Exception. The call to worksheet.Name
could fail for multiple reasons, not all of which should simply be silently
discarded.

> {
> // this one was release as I cannot access it
> worksheet = null;
> }
>
> Is there any other method through which I can check for a VALID(not
> released) COM object?
>
If you know you released the object, why do you need to check for it here?
Somewhere inbetween you discarded information or failed to propagate it.

Why don't you set the reference to null when you release it, rather than
when you find out it was released? If the worksheet is in a collection, why
don't you remove it from the collection?

--
J.
http://symbolsprose.blogspot.com

==============================================================================
TOPIC: Using ConfigurationManager to modify another project's app.config
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/aa5f5982cf8d8400?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 5:00 am
From: PRATAP singh


Hi,
i tried the way that u guided but it pops this build error:

Error
'System.Configuration.ConfigurationElement.this[System.Configurat
ion.ConfigurationProperty]' is inaccessible due to its protection level

how can i change the protection level of config file to resolve the
issue?

*** Sent via Developersdex http://www.developersdex.com ***

==============================================================================
TOPIC: How to update a value in a Dictionary<K, V>
http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/d31166442a14467a?hl=en
==============================================================================

== 1 of 1 ==
Date: Fri, May 16 2008 5:25 am
From: amir


do i have to remove the pair and then reinsert it or can i just update the
value of the dictionary