picpic2006
Topic Author
Posts: 67
Joined: 07 Nov 2013, 15:59

Popup windows management

22 Nov 2013, 10:13

Hello,

First i download the new version of noesis, i test the touch manipulation and it is very cool. I'm very happy because i just start to work on a project on ipad and it will be very useful.

Second: i try to make a dropshadoweffect on blend but i seem that noesis doesn't show it in unity, it just ignore it with out alert. I saw on forum that you haven't implement it for now. I'm correct ?

Thirst i try to make a popup window like in wpf but noesis doesn't supporte it. How can i manage this kind of thing. I have the idee to make a user control that i can load and or destroy a runtime in unity. Is it for you the correct way to acheive it.

Thanks you
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Popup windows management

22 Nov 2013, 20:26

Hello,

First i download the new version of noesis, i test the touch manipulation and it is very cool. I'm very happy because i just start to work on a project on ipad and it will be very useful.

Second: i try to make a dropshadoweffect on blend but i seem that noesis doesn't show it in unity, it just ignore it with out alert. I saw on forum that you haven't implement it for now. I'm correct ?
You are right, effects is a feature not yet implemented. We will add appropriate warnings to notify about it if someone uses them in a xaml.
Thirst i try to make a popup window like in wpf but noesis doesn't supporte it. How can i manage this kind of thing. I have the idee to make a user control that i can load and or destroy a runtime in unity. Is it for you the correct way to acheive it.

Thanks you
When you say a popup window, do you mean a modal window? or just some panel that is shown over everything else?
 
picpic2006
Topic Author
Posts: 67
Joined: 07 Nov 2013, 15:59

Re: Popup windows management

23 Nov 2013, 10:27

Yes that it i have to manage a windows that is shown over a hud, but i need to manage enable it and hide by code. I made a user control that i load at runtine but i need to remove it from inside this user control with a close btn on this popup. Sorry i can t give you my code exemple i m on my phone. Thanks
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Popup windows management

23 Nov 2013, 11:37

I made this simple test, hope this is what you are looking for...

First the main window, where HUD is defined and where popup window will be added:
<UserControl
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="PopupTest.MainWindow">

    <Grid x:Name="LayoutRoot">

        <!-- HUD is defined here -->

        <Button x:Name="ShowPopup"
            Content="Show Popup"
            HorizontalAlignment="Right" VerticalAlignment="Bottom"
            Margin="20" Padding="20,10"/>

        <!-- PopupWindow is added on top here -->

    </Grid>

</UserControl>
using UnityEngine;
using System;
using Noesis;

namespace PopupTest
{

[Extended]
[UserControlSource("Assets/PopupTest/MainWindow.xaml")]
public class MainWindow : UserControl
{
    private PopupWindow _popupWindow = null;
    
    public void OnPostInit()
    {
        Button showPopup = FindName<Button>("ShowPopup");
        showPopup.Click += OnShowPopup;
    }
    
    private void OnShowPopup(BaseComponent sender, RoutedEventArgs e)
    {
        if (this._popupWindow == null)
        {
            this._popupWindow = new PopupWindow();
            
            Grid layoutRoot = FindName<Grid>("LayoutRoot");
            layoutRoot.GetChildren().Add(this._popupWindow);
        }
        
        this._popupWindow.SetVisibility(Visibility.Visible);
    }
}

}
Next the popup window user control:
<UserControl
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="PopupTest.PopupWindow">

    <Grid Background="#80000000">
        <Border Background="Silver" CornerRadius="10" Padding="10"
            HorizontalAlignment="Center" VerticalAlignment="Center">
            <StackPanel>
                <TextBlock Text="Header" FontWeight="Bold" FontSize="20"/>
                <TextBlock Text="Some text comes here" Margin="10,20"/>
                <Button x:Name="Close" Content="Close" HorizontalAlignment="Right" Padding="20,10"/>
            </StackPanel>
        </Border>
    </Grid>

</UserControl>
using UnityEngine;
using System;
using Noesis;

namespace PopupTest
{

[Extended]
[UserControlSource("Assets/PopupTest/PopupWindow.xaml")]
public class PopupWindow : UserControl
{
    public void OnPostInit()
    {
        Button close = FindName<Button>("Close");
        close.Click += OnClose;
    }
    
    private void OnClose(BaseComponent sender, RoutedEventArgs e)
    {
        SetVisibility(Visibility.Collapsed);
    }
}

}
;)
 
picpic2006
Topic Author
Posts: 67
Joined: 07 Nov 2013, 15:59

Re: Popup windows management

23 Nov 2013, 12:22

Yes thanks it was exacly what i made ! The only thing i couldn't manage befor was the visibility mode !
I tryed with the setisEnabled by it didn't work.
:D

Thanks you very much for your time.
 
picpic2006
Topic Author
Posts: 67
Joined: 07 Nov 2013, 15:59

Re: Popup windows management

24 Nov 2013, 21:01

Hello,

I continue to work on my popup window who is done by a user control, i try to acheive a binding to my title label and a description text block. I did a test by finding the component in the xaml with findname. It work just fine. But i wan't to understand binding data and i try to do with notifyproperchanged but it does nothing i have no error but i still havn't got any text on my popup. I give you my little test to show.

my usercontrol
using Noesis;
using System;
using UnityEngine;

[Noesis.Extended]
[Noesis.UserControlSource("Assets/xaml_GUI/PopUp.xaml")]

public class PopUpControl : Noesis.UserControl
{
	//try to binding
	private string _title;
	public String Title
    {
        get { return _title; }
        set {
			if (_title != value)
			{
				_title = value; 
				NotifyPropertyChanged("Title");
			}
		}
    }

	#region value
	
	Storyboard Appearanim;
	Grid grid;
	Label TitleLabel;
	TextBlock DescriptionText;
	
	#endregion
	
    public void OnPostInit()
	{
		grid = FindName<Grid>("grid");//grid pour l'anim de la popup
		Appearanim = FindName<Storyboard>("AppearStoryBoard");
		TitleLabel = FindName<Label>("Title");
		DescriptionText = FindName<TextBlock>("Description");
		
		Button closBtn = FindName<Button>("Close");//button de fermeture de la popup
		closBtn.Click += OnbtnClick;
    }
   
	#region callback
	void OnbtnClick(BaseComponent sender, RoutedEventArgs args)
	{
		Debug.Log("Hide popup");
		SetVisibility(Visibility.Hidden);
	}//callback click
	
	#endregion
	
	#region Function
	
	public void ShowPopup()
	{
		SetVisibility(Visibility.Visible);
		if(Appearanim != null)
		Appearanim.Begin(this.grid);
	}//montre la popup avec storyboard
	
	
	//Hard Do this is working!!!
	public void SetTitle(string _s)
	{
		TitleLabel.SetContent(_s);
	}
	
	public void SetDescription(string _s)
	{
		DescriptionText.SetText(_s);
	}
	
	#endregion
	
}
my xaml
<UserControl
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
	mc:Ignorable="d"
	x:Class="PopUpControl"
	x:Name="UserControl"
	d:DesignWidth="640" d:DesignHeight="480" Width="1024" Height="768">
	<UserControl.Resources>
		<Storyboard x:Key="AppearStoryBoard" x:Name="AppearStoryBoard">
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" Storyboard.TargetName="grid">
				<EasingDoubleKeyFrame KeyTime="0" Value="-0.052"/>
				<EasingDoubleKeyFrame KeyTime="0:0:1" Value="1">
					<EasingDoubleKeyFrame.EasingFunction>
						<ElasticEase EasingMode="EaseOut"/>
					</EasingDoubleKeyFrame.EasingFunction>
				</EasingDoubleKeyFrame>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" Storyboard.TargetName="grid">
				<EasingDoubleKeyFrame KeyTime="0" Value="0.052"/>
				<EasingDoubleKeyFrame KeyTime="0:0:1" Value="1">
					<EasingDoubleKeyFrame.EasingFunction>
						<ElasticEase EasingMode="EaseOut"/>
					</EasingDoubleKeyFrame.EasingFunction>
				</EasingDoubleKeyFrame>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)" Storyboard.TargetName="grid">
				<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
				<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0">
					<EasingDoubleKeyFrame.EasingFunction>
						<ElasticEase EasingMode="EaseOut"/>
					</EasingDoubleKeyFrame.EasingFunction>
				</EasingDoubleKeyFrame>
			</DoubleAnimationUsingKeyFrames>
			<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)" Storyboard.TargetName="grid">
				<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
				<EasingDoubleKeyFrame KeyTime="0:0:1" Value="0">
					<EasingDoubleKeyFrame.EasingFunction>
						<ElasticEase EasingMode="EaseOut"/>
					</EasingDoubleKeyFrame.EasingFunction>
				</EasingDoubleKeyFrame>
			</DoubleAnimationUsingKeyFrames>
		</Storyboard>
		<Style x:Key="CloseBtn" TargetType="{x:Type Button}">
			<Setter Property="Template">
				<Setter.Value>
					<ControlTemplate TargetType="{x:Type Button}">
						<Grid>
							<VisualStateManager.VisualStateGroups>
								<VisualStateGroup x:Name="CommonStates">
									<VisualState x:Name="Normal"/>
									<VisualState x:Name="MouseOver">
										<Storyboard>
											<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(Shape.Fill)" Storyboard.TargetName="ellipse">
												<DiscreteObjectKeyFrame KeyTime="0">
													<DiscreteObjectKeyFrame.Value>
														<RadialGradientBrush>
															<GradientStop Color="#FF057FB8" Offset="0"/>
															<GradientStop Color="#009ADFFF" Offset="1"/>
														</RadialGradientBrush>
													</DiscreteObjectKeyFrame.Value>
												</DiscreteObjectKeyFrame>
											</ObjectAnimationUsingKeyFrames>
										</Storyboard>
									</VisualState>
									<VisualState x:Name="Pressed"/>
									<VisualState x:Name="Disabled"/>
								</VisualStateGroup>
							</VisualStateManager.VisualStateGroups>
							<Ellipse x:Name="ellipse" HorizontalAlignment="Left" Height="56" VerticalAlignment="Top" Width="56" Fill="#00000000"/>
							<Path Data="M22.6665,0 L33.3335,0 33.3335,22.6665 56,22.6665 56,33.3335 33.3335,33.3335 33.3335,56 22.6665,56 22.6665,33.3335 0,33.3335 0,22.6665 22.6665,22.6665 z" RenderTransformOrigin="0.500000001634869,0.5" Stretch="Fill">
								<Path.Fill>
									<LinearGradientBrush StartPoint="0.5,0" MappingMode="RelativeToBoundingBox" EndPoint="0.5,1">
										<GradientStop Color="#FF5B0000" Offset="1"/>
										<GradientStop Color="#FFB80000"/>
									</LinearGradientBrush>
								</Path.Fill>
								<Path.RenderTransform>
									<TransformGroup>
										<ScaleTransform/>
										<SkewTransform/>
										<RotateTransform Angle="-45"/>
										<TranslateTransform/>
									</TransformGroup>
								</Path.RenderTransform>
							</Path>
							<Path Data="M22.666501,51.087759 L33.3335,51.087759 33.3335,51.309045 22.666501,51.309045 z M22.666501,42.60283 L33.3335,42.60283 33.3335,46.087759 22.666501,46.087759 z M22.666501,33.940774 L33.3335,33.940774 33.3335,37.60283 22.666501,37.60283 z M0,25.101938 L56,25.101938 56,28.642545 33.3335,28.642545 33.3335,28.940774 22.666501,28.940774 22.666501,28.642545 0,28.642545 z M22.666501,16.43988 L33.3335,16.43988 33.3335,17.975545 56,17.975545 56,20.101938 0,20.101938 0,17.975545 22.666501,17.975545 z M22.666501,8.3081527 L33.3335,8.3081527 33.3335,11.43988 22.666501,11.43988 z M22.666501,0 L33.3335,0 33.3335,3.3081522 22.666501,3.3081522 z" Margin="0,4.691,0,0" RenderTransformOrigin="0.500000005518652,0.454287254260614" Stretch="Fill" Fill="#1DFFFFFF">
								<Path.RenderTransform>
									<TransformGroup>
										<ScaleTransform/>
										<SkewTransform/>
										<RotateTransform Angle="-45"/>
										<TranslateTransform/>
									</TransformGroup>
								</Path.RenderTransform>
							</Path>
						</Grid>
						<ControlTemplate.Triggers>
							<Trigger Property="IsFocused" Value="True"/>
							<Trigger Property="IsDefaulted" Value="True"/>
							<Trigger Property="IsMouseOver" Value="True"/>
							<Trigger Property="IsPressed" Value="True"/>
							<Trigger Property="IsEnabled" Value="False"/>
						</ControlTemplate.Triggers>
					</ControlTemplate>
				</Setter.Value>
			</Setter>
		</Style>
	</UserControl.Resources>
	<UserControl.Triggers>
		<EventTrigger RoutedEvent="FrameworkElement.Loaded">
			<BeginStoryboard Storyboard="{StaticResource AppearStoryBoard}"/>
		</EventTrigger>
	</UserControl.Triggers>

	<Grid x:Name="LayoutRoot" Width="1024" Height="768" HorizontalAlignment="Center" VerticalAlignment="Center">
		<Grid x:Name="grid" HorizontalAlignment="Left" Height="748" VerticalAlignment="Top" Width="1004" Margin="20,10,0,0" RenderTransformOrigin="0.5,0.5">
			<Grid.RenderTransform>
				<TransformGroup>
					<ScaleTransform/>
					<SkewTransform/>
					<RotateTransform/>
					<TranslateTransform/>
				</TransformGroup>
			</Grid.RenderTransform>
			<Rectangle x:Name="rectangle" Height="460" Width="620" RadiusY="19" RadiusX="19" RenderTransformOrigin="0.5,0.5">
				<Rectangle.Stroke>
					<ImageBrush/>
				</Rectangle.Stroke>
				<Rectangle.RenderTransform>
					<TransformGroup>
						<ScaleTransform/>
						<SkewTransform/>
						<RotateTransform/>
						<TranslateTransform/>
					</TransformGroup>
				</Rectangle.RenderTransform>
				<Rectangle.Fill>
					<ImageBrush ImageSource="/UnityGUI_Blend;component/pathwork01.jpg" TileMode="Tile" Stretch="UniformToFill" Opacity="0.155">
						<ImageBrush.RelativeTransform>
							<TransformGroup>
								<ScaleTransform CenterY="0.5" CenterX="0.5" ScaleY="-1" ScaleX="-0.3"/>
								<SkewTransform CenterY="0.5" CenterX="0.5"/>
								<RotateTransform CenterY="0.5" CenterX="0.5" Angle="45"/>
								<TranslateTransform/>
							</TransformGroup>
						</ImageBrush.RelativeTransform>
					</ImageBrush>
				</Rectangle.Fill>
			</Rectangle>
			<Button x:Name="Close" Content="Button" HorizontalAlignment="Left" Height="56" Margin="745.666,153,0,0" Style="{DynamicResource CloseBtn}" VerticalAlignment="Top" Width="56" RenderTransformOrigin="0.5,0.5">
				<Button.RenderTransform>
					<TransformGroup>
						<ScaleTransform/>
						<SkewTransform/>
						<RotateTransform/>
						<TranslateTransform/>
					</TransformGroup>
				</Button.RenderTransform>
			</Button>
			<Label x:Name="Title" Content="{Binding PopUpControl.Title}"  HorizontalAlignment="Left" Height="33.333" Margin="221.334,153,0,0" VerticalAlignment="Top" Width="505.334" FontSize="21.333"/>
			<TextBlock x:Name="Description" HorizontalAlignment="Left" Height="184" Margin="221.334,202.667,0,0" TextWrapping="Wrap" Text="{Binding Description}" VerticalAlignment="Top" Width="388"/>
		</Grid>
	</Grid>
</UserControl>
the call
popup = new PopUpControl();	
			root.FindName<Grid>("Main").GetChildren().Add(popup);
			popup.Title = "bonjour";//doesn't work
			popup.SetDescription("Here the description of the Product");//work
I'm pretty shure i missing some thing but i can't see what :oops: !

Thanks
 
User avatar
sfernandez
Site Admin
Posts: 1915
Joined: 22 Dec 2011, 19:20

Re: Popup windows management

25 Nov 2013, 13:03

The binding path is not correctly specified. You want to bind your Label content with the Title property (Binding.Path) of the user control (Binding.ElementName). This is done this way:
<UserControl
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
   xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
   xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
   mc:Ignorable="d"
   x:Class="PopUpControl"
   x:Name="MyPopupControl"
   d:DesignWidth="640" d:DesignHeight="480" Width="1024" Height="768">

    <!-- ... -->

    <Label x:Name="Title" Content="{Binding Title, ElementName=MyPopupControl}"  HorizontalAlignment="Left" Height="33.333" Margin="221.334,153,0,0" VerticalAlignment="Top" Width="505.334" FontSize="21.333"/>

    <!-- ... -->

</UserControl>
 
picpic2006
Topic Author
Posts: 67
Joined: 07 Nov 2013, 15:59

Re: Popup windows management

25 Nov 2013, 19:23

I will test it, i currently download the plugin thanks for all

Who is online

Users browsing this forum: No registered users and 1 guest