Professional, Software

Part 6: 3dStack View in Search Application

Finally I got around to adding 3d stack control to search application. I don’t think it is really useful from real application perspective but I wanted to add something that would be hard to do with just html.

showstack searchview

 I added a button called Show stack to grid view. When you click on this button, same results are shown using 3dstack control. In this view, new button (movenext) is added that can be used to go through pictures in 3D view.

Creating 3D Stack control instance

First part was to create the 3D view control when the search is completed. It stays invisible till user clicks on show stack button.

void SearchCompleted(IAsyncResult asyncResult)
{
    ...
    progressui.StopProgress();
    this.Children.Remove(progressui);
    progressui = null;
    this.Children.Add(gridview);
    gridview.SetValue(Canvas.TopProperty, 50);
    gridview.SetValue(Canvas.LeftProperty, 0);

    showstack = new Button();
    showstack.Text = "Show Stack";
    showstack.Click += new EventHandler(showstack_Click);
    this.Children.Add(showstack);
    if (stack != null)
    {
        this.Children.Remove(stack);
        this.Children.Remove(movenext);
        stack = null;
        movenext = null;
    }
    stack = new StackThreeD();
    stack.NumberOfFrames = 5;
    stack.Frames = frames;
    stack.Height = 600;
    stack.Width = 600;

    movenext = new Button();
    movenext.Text = "Move Next";
    movenext.Click += new EventHandler(movenext_Click);
    movenext.SetValue(Canvas.LeftProperty, 150);

    stack.Visibility = Visibility.Hidden;
    movenext.Visibility = Visibility.Hidden;

    this.Children.Add(stack);
    this.Children.Add(movenext);

    ...
}

ShowStack Button Behavior

When user clicks on showstack button, that is when move next becomes visible.

void showstack_Click(object sender, EventArgs e)
{
    if (stackstate == false)
    {
        movenext.Visibility = Visibility.Visible;
        gridview.Visibility = Visibility.Hidden;
        stack.Visibility = Visibility.Visible;
        showstack.Text = "Hide Stack";
        stackstate = true;
    }
    else
    {
        stackstate = false;
        showstack.Text = "Show Stack";
        gridview.Visibility = Visibility.Visible;
        stack.Visibility = Visibility.Hidden;
        movenext.Visibility = Visibility.Hidden;
    }
}

 

MoveNext Behavior

void movenext_Click(object sender, EventArgs e)
{
    stack.MoveNext();
}

 

Source code for updated application is here.

Standard