My technology RoadMap

专著Microsoft平台,专著.Net
posts - 43, comments - 7, trackbacks - 0, articles - 1
  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理

公告

2007年8月28日

一个新的项目想用 WPF 来做,我做了小例子,做为可行性的分析。

主要是用到grid layout 的一些方法,贴出来供以后做参考。

using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApplication1
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        int mRow = -1;
        int mColumn = -1;
        MediaElement me;

        public Window1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
          
          
        }

        private void mediaElement1_DragEnter(object sender, DragEventArgs e)
        {
            MessageBox.Show(sender.ToString());
        }

        private void play_Click(object sender, RoutedEventArgs e)
        {
          
       
        }

        private void mediaElement1_Drop(object sender, DragEventArgs e)
        {

        }

        private void mediaElement1_MouseLeave(object sender, MouseEventArgs e)
        {
          
        }

        private void mediaElement1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (sender.GetType().ToString() == "System.Windows.Controls.Label")
            {
                if (mRow > -1)
                {
                    int Column = Grid.GetColumn(this.Lable1);
                    int Row = Grid.GetRow(this.Lable1);

                    //  int mRow = Grid.GetRow(this.mediaElement1);
                    //  int mColumn = Grid.GetColumn(this.mediaElement1);

                    Grid.SetColumn(me, Column);
                    Grid.SetRow(me, Row);

                    Grid.SetColumn(this.Lable1, mColumn);
                    Grid.SetRow(this.Lable1, mRow);

                    mRow = -1;
                }
            }
        }

        private void mediaElement2_DragEnter(object sender, DragEventArgs e)
        {
            
        }

        private void mediaElement1_MouseLeftButtonUp_1(object sender, MouseButtonEventArgs e)
        {
            me = sender as MediaElement;
           
            mRow = Grid.GetRow(me);
            mColumn = Grid.GetColumn(me);
        }

       
    }
}


xmal:

    <Grid Background="AliceBlue">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Label Background="Aqua" Grid.Column="0" Grid.Row="0" Name="Lable1" MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp" />
        <MediaElement Grid.Column="1" Grid.Row="1" Source="1.wmv"  Name="mediaElement1" AllowDrop="True" MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp_1" />
        <MediaElement Grid.Column="2" Grid.Row="2" Source="1.wmv"  Name="mediaElement4" AllowDrop="True" MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp_1" />
        <MediaElement Grid.Column="0" Grid.Row="1" Source="trexchicken.wmv"  Name="mediaElement2" AllowDrop="True"  MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp_1" />
        <MediaElement Grid.Column="3" Grid.Row="1" Source="trexchicken.wmv"  Name="mediaElement3" AllowDrop="True"  MouseLeftButtonUp="mediaElement1_MouseLeftButtonUp_1" />
        <Image Name="five" Grid.Column="2" Grid.Row="0" />
        <Button Height="23" Grid.Row="4" Name="button1" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="75" Click="button1_Click">Change</Button>
        <Button Height="23" Grid.Row="3" Name="play" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="75" Click="play_Click">play</Button>
    </Grid>

posted @ 2007-08-28 18:05 李大力 阅读(125) 评论(0) 编辑

今天我们终于完成第一个facebook项目,本想代码写得更漂亮些。不过PM吹得太急,先给他们看个效果。

以后会不断进行完善。

http://apps.facebook.com/friendsnetwork

posted @ 2007-08-28 17:59 李大力 阅读(67) 评论(0) 编辑