Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Mikey_H

@Mikey_H
About
Posts
38
Topics
14
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • WPF DataGrid: Clipping on ColumnHeadersPresenter
    M Mikey_H

    Hello, I am having some issues with the display of the DataGridColumnHeadersPresenter in my custom DataGrid template. Example Screenshots I have taken the original ControlTemplate for DataGrid and altered the area related to the DataGridColumnHeadersPresenter and the select all Button. What I am experiencing when I load the application (Figure A) is the area taken up by the DataGridColumnHeadersPresenter is longer than it should be (on the right side) by 2 pixels (or whatever the margin is set to). It also appears clipped as it does not show the right side border or the corner radii. When I adjust the size of the window at runtime using the Window 'resizing handles' (Figure B) the appearance changes and the DataGridColumnHeadersPresenter appears as I expect it to. However when I resize it small enough so that the DataGrid's horizontal scroll becomes active (Figure C) it again appears clipped, this time being a few pixels shorter than the expected length. Custom Row, RowHeader, Cell and ColumnHeader styles are also in use, but removing them does not change this problem. Original

    <!--Left Column Header Corner -->
    <Button Command="{x:Static dg:DataGrid.SelectAllCommand}"
    Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type dg:DataGrid}}, Path=CellsPanelHorizontalOffset}"
    Template="{StaticResource SelectAllButtonTemplate}"
    Focusable="false"
    Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type dg:DataGrid}},
    Path=HeadersVisibility,
    Converter={x:Static dg:DataGrid.HeadersVisibilityConverter},
    ConverterParameter={x:Static dg:DataGridHeadersVisibility.All}}" />
    <!--Column Headers-->
    <dgp:DataGridColumnHeadersPresenter Grid.Column="1"
    Name="PART_ColumnHeadersPresenter"
    Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type dg:DataGrid}},
    Path=HeadersVisibility,
    Converter={x:Static dg:DataGrid.HeadersVisibilityConverter},
    ConverterParameter={x:Static dg:DataGridHeadersVisibility.Column}}"/>

    My Changes

    <tkp:DataGridColumnHeadersPresenter x:Name="PART_ColumnHeadersPresenter"

    WPF wpf csharp css wcf com

  • DataGrid RowHeaderTemplate bind to Item property
    M Mikey_H

    ObservableCollection<DataItem> DataItemCollection;

    class DataItem
    {
    DependencyProperty AProperty = DependencyProperty.Register("A",...)
    DependencyProperty BProperty = DependencyProperty.Register("B",...)

    public string A{...}
    public string B{...}
    }

    If I have my ItemsSource on my DataGrid bound to DataItemCollection, how would I go about binding AProperty or BProperty to a Label in my DataGridRowHeader template?

    tk:DataGrid.RowHeaderTemplate
    <DataTemplate>
    <Label Content="{Binding ...}"/>
    </DataTemplate>
    </tk:DataGrid.RowHeaderTemplate>

    WCF and WF wpf wcf question

  • Math errors in custom control
    M Mikey_H

    Control code:

    public class MathTester : Control, INotifyPropertyChanged
    {
    public static DependencyProperty ValueProperty =
    DependencyProperty.Register("Value",
    typeof(double), typeof(MathTester),
    new PropertyMetadata(OnValuePropertyChanged));

        public static DependencyProperty DivisorProperty =
            DependencyProperty.Register("Divisor",
            typeof(double), typeof(MathTester),
            new PropertyMetadata(OnDivisorPropertyChanged));
    
        public static DependencyProperty ResultProperty =
            DependencyProperty.Register("Result",
            typeof(double), typeof(MathTester),
            new PropertyMetadata(OnResultPropertyChanged));
    
        public static DependencyProperty DecimalsProperty =
            DependencyProperty.Register("Decimals",
            typeof(int), typeof(MathTester),
            new PropertyMetadata(15, OnDecimalsPropertyChanged));
    
        public static DependencyProperty RoundProperty =
            DependencyProperty.Register("Round",
            typeof(bool), typeof(MathTester),
            new PropertyMetadata(false, OnRoundPropertyChanged));
    
        public double Value
        {
            get { return (double)GetValue(ValueProperty); }
            set { SetValue(ValueProperty, value); }
        }
    
        public double Divisor
        {
            get { return (double)GetValue(DivisorProperty); }
            set { SetValue(DivisorProperty, value); }
        }
    
        public double Result
        {
            get { return (double)GetValue(ResultProperty); }
            set { SetValue(ResultProperty, value); }
        }
    
        public int Decimals
        {
            get { return (int)GetValue(DecimalsProperty); }
            set { SetValue(DecimalsProperty, value); }
        }
    
        public bool Round
        {
            get { return (bool)GetValue(RoundProperty); }
            set { SetValue(RoundProperty, value); }
        }
    
        static MathTester()
        {
            DefaultStyleKeyProperty.OverrideMetadata(typeof(MathTester), 
                new FrameworkPropertyMetadata(typeof(MathTester)));
        }
    
        public MathTester()
        {
            Divide();
        }
    
        private void Divide()
        {
            if (Value != 0 && Divisor != 0)
                if (Round == true && Decimals > 0 && Decimals < 16)
                    Result = Math.Round(Value / Diviso
    
    WCF and WF

  • Generic.xaml location
    M Mikey_H

    Great link, Thank you :thumbsup:

    WPF wpf question

  • Generic.xaml location
    M Mikey_H

    I have a folder structure like this....

    Project
    FolderA
    SubFolderAA
    Themes
    Generic.xaml
    ControlAA1.cs
    ControlAA2.cs
    SubFolderAB
    Themes
    Generic.xaml
    ControlAB1.cs
    FolderB
    FolderC

    I have recently added the folder SubFolderAB and control ControlAB1.cs with a Themes/Generic.xaml file. My control in ControlAB1.cs cannot locate the theme in the new Generic.xaml unless I move the Themes/Generic.xaml to the Project root folder (Project/Themes/Generic.xaml). The controls and styles in SubFolderAA are unaffected by any of this. What could be causing this behaviour?

    modified on Sunday, November 22, 2009 4:48 AM

    WPF wpf question

  • CellTemplate in GridView
    M Mikey_H

    Stab in the dark is no good :doh: :laugh: I have made some further discoveries on the matter. If I leave the bindings as they are, and add the following code behind to UICardArray

    foreach (ContentPresenter content in PART_StackPanel.Children)
    {
    content.Width = CardWidth;
    content.Height = CardHeight;
    }

    It all works 100% how I would expect it to work, autosized with no clipping. After finding this out I removed this code to its original state and added the following function to UICardArray

    public void ShowSizes()
    {
    foreach (ContentPresenter content in PART_StackPanel.Children)
    MessageBox.Show(content.ActualWidth.ToString() + ", " + content.ActualHeight.ToString());

            MessageBox.Show(ActualWidth.ToString() + ", " + ActualHeight.ToString());
        }
    

    then placed a test array in a test listview and ran the function.

    <ListView>
    <UserInterface_Elements_Cards:UICardArray x:Name="TestArray" ItemsSource="{Binding Path=TestCards, RelativeSource={RelativeSource AncestorType=Window}}"
    DisplayType="HoleCards"
    HorizontalAlignment="Center"
    CardWidth="18" CardHeight="25"/>
    </ListView>

    18x25px for each item(4 items), and 78x25px for the entire control (6px for margins between items), yet the listview again stretched the entire available window space. :confused: So I have a workaround for the problem, but I still don't understand what is going on here. Thanks for your help Mark :thumbsup: very much apprecited.

    WCF and WF wpf wcf com game-dev help

  • CellTemplate in GridView
    M Mikey_H

    I've tracked down where the issue is after recreating the UICardArray from the ItemsControl up. UICardArray.ItemTemplate

    Width="{Binding Path=CardWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type c:UICardArray}}}"
    Height="{Binding Path=CardHeight, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type c:UICardArray}}}"

    If I set these properties directly without the binding it all works fine. Why would this cause the ItemsControl to stretch? It appeared that the Items were the correct size using these bindings.

    WCF and WF wpf wcf com game-dev help

  • CellTemplate in GridView
    M Mikey_H

    Ok, I'm not sure how to get the ActualWidth/Height of a CellTemplate item, but adding Width and Height properties has altered the layout (it still cuts off the 'Game' column). I didn't think it would be the control itself as the rows didnt appear to be stretched vertically, and the SelectedItem background made it appear it was wrapping the content (vertically at least). Setting the width and height properties of the control in the CellTemplate is not an ideal option here, I would like the control to autosize. Below is the ControlTemplate for UICardArray. I have tried playing with Horizontal/VerticalAlignment and Width/Height with no success. I have some code behind that sets margins on Items that is called in MeasureOverride before calling base.MeasureOverride. I had disabled this, which has also caused no difference.

    <Style x:Key="{x:Type c:UICardArray}" TargetType="{x:Type c:UICardArray}">
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type c:UICardArray}">
    <StackPanel x:Name="PART_StackPanel"
    Orientation="Horizontal"
    IsItemsHost="True"/>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    <Setter Property="ItemTemplate">
    <Setter.Value>
    <DataTemplate DataType="{x:Type d:Card}">
    <c:UICard CardRank="{Binding Path=Rank}"
    CardSuit="{Binding Path=Suit}"
    Width="{Binding Path=CardWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type c:UICardArray}}}"
    Height="{Binding Path=CardHeight, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type c:UICardArray}}}"/>
    </DataTemplate>
    </Setter.Value>
    </Setter>
    </Style>

    WCF and WF wpf wcf com game-dev help

  • CellTemplate in GridView
    M Mikey_H

    Removing ItemContainerStyle only causes the content of the cell to be aligned to the left. UserInterface_Elements_Cards:UICardArray is a custom ItemsControl used to display a collection of

    public struct Card
    {
    public CardRank Rank;
    public CardSuit Suit;
    }

    public enum CardRank
    { Deuce, Three, Four, etc... }
    public enum CardSuit
    { Spades, Hearts, Diamonds, Clubs }

    in three different styles as seen in the screenshot. The ItemsTemplate for the ItemsControl has fixed width and height as default, and can be changed with CardWidth, CardHeight properties on UICardArray. The Items are presented in a StackPanel. The ActualWidth/Height of ListView is 765.18, 362. This does not change when expanding the window, only when contracting it. (The height stretches to the full height and most of the width of the window on startup, but then remains this size).

    modified on Wednesday, November 11, 2009 10:16 PM

    WCF and WF wpf wcf com game-dev help

  • CellTemplate in GridView
    M Mikey_H

    I have created a CellTemplate for use in my ListView(GridView) without the CellTemplate the layout is how it should be, but when the custom CellTemplate is used it causes the ListView to stretch to the maximum size allowed. What in my CellTemplate would cause this?

    <ListView ItemsSource="{Binding Path=HandsCollection, RelativeSource={RelativeSource AncestorType=Window}}" VerticalAlignment="Center" HorizontalAlignment="Center" SelectionMode="Single">
    <ListView.ItemContainerStyle>
    <Style TargetType="{x:Type ListViewItem}">
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    </Style>
    </ListView.ItemContainerStyle>
    <ListView.View>
    <GridView>
    <GridViewColumn Header="Date"
    DisplayMemberBinding="{Binding DateTime}"/>
    <GridViewColumn Header="Time"
    DisplayMemberBinding="{Binding DateTime.TimeOfDay}"/>
    <GridViewColumn Header="Game"
    DisplayMemberBinding="{Binding Path=HandType, Converter={StaticResource HandTypeToString}}"/>
    <GridViewColumn Header="Starting Hand">
    <GridViewColumn.CellTemplate>
    <DataTemplate>
    <UserInterface_Elements_Cards:UICardArray ItemsSource="{Binding StartingHand}"
    DisplayType="{Binding Path=HandType, Converter={StaticResource HandTypeToDisplayType}}"
    HorizontalAlignment="Center"
    CardWidth="18" CardHeight="25"/>
    </DataTemplate>
    </GridViewColumn.CellTemplate>
    </GridViewColumn>
    </GridView>
    </ListView.View>
    </ListView>

    Screenshot The listview should be centered and wrapping the content. Also note cutting off of content in 'Game' column. Any help is appreciated. -Mikey

    WCF and WF wpf wcf com game-dev help

  • DataTemplate triggers only on default enum property
    M Mikey_H

    I am having an issue in setting up a trigger to run off an enum property. It only seems to be triggering when the trigger is set to the default value. Do I need to add a ProperrtyChanged handler to do something? Class is derived from ItemsControl. This will trigger

    Code
    public static DependencyProperty DisplayTypeProperty =
    DependencyProperty.Register("DisplayType",
    typeof(UICardArrayDisplayType), typeof(UICardArray),
    new PropertyMetadata(UICardArrayDisplayType.Community));

    XAML
    <ui:UICardArray ItemsSource="{Binding Path=Cards}" DisplayType="HoleCards"/>

    DataTemplate
    <MultiTrigger>
    <MultiTrigger.Conditions>
    <Condition Property="c:UICardArray.DisplayType" Value="Community"/>
    <Condition Property="ItemsControl.AlternationIndex" Value="3"/>
    </MultiTrigger.Conditions>
    <Setter TargetName="CardDisplay" Property="Margin" Value="5,0,0,0"/>
    </MultiTrigger>

    This will not

    Code
    public static DependencyProperty DisplayTypeProperty =
    DependencyProperty.Register("DisplayType",
    typeof(UICardArrayDisplayType), typeof(UICardArray),
    new PropertyMetadata(UICardArrayDisplayType.HoleCards));

    XAML
    <ui:UICardArray ItemsSource="{Binding Path=Cards}" DisplayType="Community"/>

    DataTemplate
    <MultiTrigger>
    <MultiTrigger.Conditions>
    <Condition Property="c:UICardArray.DisplayType" Value="Community"/>
    <Condition Property="ItemsControl.AlternationIndex" Value="3"/>
    </MultiTrigger.Conditions>
    <Setter TargetName="CardDisplay" Property="Margin" Value="5,0,0,0"/>
    </MultiTrigger>

    Any help is appreciated

    WCF and WF wpf help database wcf design

  • Custom control disapears in Expression Blend
    M Mikey_H

    I have created a custom control using a lookless design. Whenever I edit the code in VS and then reload the project my control loses its visual and appears to have resized itself to 0px by 0px, if I try to resize the control its does not return the visual. Closing and reloading the project will fix this until the next time I edit my code. Is this a common issue? I will post the code for the control if someone thinks it is code related.

    WCF and WF help visual-studio design question

  • Custom control
    M Mikey_H

    Thanks Richard, but not quite what I am looking for. The control I am currently working on originated as a derived class of System.Windows.Controls.Panel. I got this to a point where I was happy with measure and arrange overrides of child objects. I wanted this container/panel to have a visual style to be applied to it, as well as the option to create alternate control templates. I changed the derived class from System.Windows.Controls.Panel to System.Windows.Controls.Control . At this point I lost the rendering of my control. I am looking for some information on how to get the rendering of this object back, also how to set a control template for it. Do I need to override any rendering code when working with a base class of System.Windows.Controls.Control? I have tried to use a control template in the way I would have used it for a control derived off another base class eg. SearchTextBox : TextBox DefaultStyleKeyProperty.OverrideMetadata(typeof(SearchTextBox), new FrameworkPropertyMetadata(typeof(SearchTextBox))); CustomControl : Control DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomControl), new FrameworkPropertyMetadata(typeof(CustomControl))); When I try to view this template in Blend I get the following error. Unable to cast object of type 'Microsoft.Expression.DesignSurface.ArtboardBorder' to type 'ParentOfCustomControl' (The custom control has a fixed Parent type which is derived from System.Windows.Controls.Grid)

    WPF tutorial

  • Custom control
    M Mikey_H

    Hello I am having difficulty finding an article / tutorial on how to create a custom control that derives from System.Windows.Controls.Control class using a ControlTemplate to display visuals. I find most of my search queries just return results for UserControl or deriving from another class (TextBox etc). Could someone please provide me a link if they know of one. Thank you. -Mike

    WPF tutorial

  • c# Regex Help
    M Mikey_H

    Do a search for Expresso, this program was recomended to me, and helped me learn regular expressions.

    C# question csharp graphics regex help

  • FileStream runtime issues (Updated) [modified]
    M Mikey_H

    Thanks for the help David, I appreciate it. I have tried this stuff already and I made an edit to original post, saying it is reading to the buffer and the issue is elsewhere (size of byte[] = size of string = size shown in file properties) (I should have made a reply pointing to the updated info also). I don't know anything about the encoding though, I tried utf8 as it was in the msdn sample, and it worked for the first section of the file, so I assumed this wasnt the issue. Also worth noting that after this code the string is put through a StringReader where I run regular expressions on it and convert the data from the hand info into a 'PokerHand' object, if I run the program without doing the 'save thing' each file returns 1 'PokerHand' object, if I do the 'save thing' it returns as many that are in the file.

    C# help game-dev data-structures testing beta-testing

  • FileStream runtime issues (Updated) [modified]
    M Mikey_H

    The messagebox shows a partial file, but when I open the file from win explorer and save the file (I'm not sure what this actually affects), then messagebox will show the complete file the next time the program is run. I forgot to point out in original post that the line where the file always ends (if not opened and saved) is at a variable position, there can be any number of lines before this, but this is where it will always end (Player wins $xxx).

    C# help game-dev data-structures testing beta-testing

  • FileStream runtime issues (Updated) [modified]
    M Mikey_H

    It is my intention to run this while another program writes to the text file. But I am not to that point yet. I am not running the other program while testing my own code here. These are previously saved files I'm attempting to read.

    C# help game-dev data-structures testing beta-testing

  • FileStream runtime issues (Updated) [modified]
    M Mikey_H

    I have my reasons for this, I am new to reading files, but I intend to be able to either read the whole file, or move to a specified start point and read from that point. I did look through the other classes available and it seemed FileStream was the only class capable of this (maybe I missed something). I had just simplified my code in an attempt to try and find what was going wrong.

    modified on Saturday, August 15, 2009 10:17 PM

    C# help game-dev data-structures testing beta-testing

  • FileStream runtime issues (Updated) [modified]
    M Mikey_H

    I am having some issues using a Filestream to read a text file. The file contains repeated segments of text in the format shown below. when I attempt to read it, it will not read the entire file, it will stop at the line shown (this line is at a variable position, there can be any number of lines before it). However... if I open the text file from windows explorer and save it (not altering the text), it has no problem reading the entire file the next time the program runs. Anyone have any ideas, or have run into this problem before? UPDATE: After doing some more testing, I've found that FileStream IS reading to the buffer, as I can write the contents of the buffer to a new text document, and the entire file is copied. The error appears to be occuring somewhere else. I have also tried the StreamReader class and it has the same issue.

    FileInfo m_fileInfo = new FileInfo("C:\\Programs\\PartyGaming\\PartyPoker\\HandHistory\\xxxxxxxxxx\\xxxxxxxxxx\\Speed #xxxxxxx_xxxxxxx.txt");
    long length = m_FileInfo.Length;
    byte[] buffer = new byte[length];

    using (FileStream stream = new FileStream(m_FileInfo.FullName, FileMode.Open, FileAccess.Read))
    {
    // Read data from file to the buffer
    for (long i = 0; i != length; i++)
    buffer[i] = (byte)stream.ReadByte();
    }

    After reading to byte array I am converting to a string for further process by a StreamReader object

    string data = new System.Text.UTF8Encoding(true).GetString(buffer);

    MessageBox.Show(data); // Shows incomplete file

    The file.....

    Game #xxxxxxxxxx starts.

    #Game No : xxxxxxxxxx
    ***** Hand History for Game xxxxxxxxxx *****
    $10 USD NL Texas Hold em - Wednesday, July xx, xxxxx EDT 2009
    Table Speed #xxxxxxx (Real Money)
    Seat 4 is the button
    Total number of players : 9
    Seat 7: xxxxx ( $9.11 USD )
    Seat 1: xxxxx ( $11.32 USD )
    Seat 6: xxxxx ( $10 USD )
    Seat 8: xxxxx ( $2 USD )
    Seat 9: xxxxx ( $12.33 USD )
    Seat 4: xxxxx ( $14.93 USD )
    Seat 2: xxxxx ( $2.63 USD )
    Seat 5: xxxxx ( $14.96 USD )
    Seat 3: xxxxx ( $18.61 USD )
    xxxxx posts small blind [$0.05 USD].
    xxxxx posts big blind [$0.10 USD].
    ** Dealing down cards **
    Dealt to xxxxx [ Qs 2h ]
    xxxxx calls [$0.10 USD]
    xxxxx calls [$0.10 USD]
    xxxxx raises [$0.20 USD]
    xxxxx folds
    xxxxx folds
    xxxxx folds
    xxxxx calls [$0.15 USD]
    xxxxx calls [$0.10 USD]
    xxxxx calls [$0.10 USD]
    xxxxx calls [$0.10 USD]
    ** Dealing Flop ** [ 4s, 6d, 9s ]
    xxxxx checks
    xxxxx checks
    xxxxx bets [$0.71 USD]
    xxxxx folds

    C# help game-dev data-structures testing beta-testing
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups