Ejemplo n.º 1
0
Archivo: Window.cs Proyecto: dfr0/moon
		public void DragResize (WindowResizeEdge resizeEdge)
		{
			NativeMethods.window_drag_resize (native/* resizeEdge*/);
		}
Ejemplo n.º 2
0
        public MainPage()
        {
            InitializeComponent();

            // OutOfBrowserで動作しているかどうか確認
            if (!Application.Current.IsRunningOutOfBrowser)
            {
                showOutOfBrowserError();
                return;
            }

            // アップデートの確認
            Application.Current.CheckAndDownloadUpdateCompleted +=
                new CheckAndDownloadUpdateCompletedEventHandler(Current_CheckAndDownloadUpdateCompleted);
            Application.Current.CheckAndDownloadUpdateAsync();

            Application.Current.Exit += new EventHandler(Current_Exit);

            statusTextHideTimer = new DispatcherTimer();
            statusTextHideTimer.Interval = TimeSpan.FromSeconds(4);
            statusTextHideTimer.Tick += delegate(object sender, EventArgs e)
            {
                statusTextHideTimer.Stop();
                statusTextOut.Begin();
            };

            ApplyVisualSettings();
            tweetsPanel.ApplySettings();

            // アカウントの情報をロード
            twitter.Account = TwitterAccount.CreateFromApplicationSettings();

            // サウンドの読み込み
            for (int j=0; j<5; j++) {
                MediaElement me = new MediaElement();
                me.AutoPlay = false;
                me.Source = new Uri(string.Format("/Sounds/piyo{0}.mp3", j), UriKind.Relative);
                newItemSounds.Add(me);
                LayoutRoot.Children.Add(me);
            }

            // Tweetsパネルの設定
            tweetsPanel.Tweets = tweets;
            tweetsPanelContainer.SizeChanged += (sender, e) =>
            {
                tweetsPanel.DelayLayout();
            };

            var mainWindow = Application.Current.MainWindow;

            // ドラッグによる移動とリサイズ
            var cursorIndex = 0;
            var cursors = new Cursor[] {
                Cursors.Arrow, Cursors.SizeWE, Cursors.SizeWE,
                Cursors.SizeNS, Cursors.SizeNWSE, Cursors.SizeNESW,
                Cursors.SizeNS, Cursors.SizeNESW, Cursors.SizeNWSE };

            LayoutRoot.MouseMove += (s, e) =>
            {
                Cursor cursor = null;
                if (mainWindow.WindowState == WindowState.Normal)
                {
                    Point pt = e.GetPosition(LayoutRoot);
                    int index = 0;
                    if (pt.X < 6) index = 1;
                    else if (pt.X >= LayoutRoot.ActualWidth - 6) index = 2;

                    if (pt.Y < 6) index += 3;
                    else if (pt.Y >= LayoutRoot.ActualHeight - 6) index += 6;

                    cursorIndex = index;
                    cursor = cursors[index];
                }
                else
                {
                    cursorIndex = 0;
                }
                if (LayoutRoot.Cursor != cursor) LayoutRoot.Cursor = cursor;
            };

            LayoutRoot.MouseLeftButtonDown += (sender, e) =>
            {
                if (cursorIndex == 0) {
                    if (!(e.OriginalSource.GetType().FullName == "MS.Internal.RichTextBoxView"))
                    {
                        mainWindow.DragMove();
                        e.Handled = true;
                    }
                }
                else {
                    WindowResizeEdge [] edges = new WindowResizeEdge [] {
                        WindowResizeEdge.Left,  WindowResizeEdge.Left,      WindowResizeEdge.Right,
                        WindowResizeEdge.Top,   WindowResizeEdge.TopLeft,   WindowResizeEdge.TopRight,
                        WindowResizeEdge.Bottom,WindowResizeEdge.BottomLeft, WindowResizeEdge.BottomRight
                    };
                    mainWindow.DragResize(edges[cursorIndex]);
                }
            };

            // 最大化
            maximizeButton.Click += (sender, e) =>
            {
                switch (mainWindow.WindowState)
                {
                    case WindowState.Normal:
                        mainWindow.WindowState = WindowState.Maximized;
                        break;
                    case WindowState.Maximized:
                        mainWindow.WindowState = WindowState.Normal;
                        break;
                }
            };

            // 最小化
            minimizeButtonn.Click += (sender, e) =>
            {
                mainWindow.WindowState = WindowState.Minimized;
            };

            // 閉じる
            closeButton.Click += (sender, e) =>
            {
                mainWindow.Close();
            };

            /*
            // ツールバーパネルを自動的に隠す
            toolbarPanelOut.Begin();

            toolbarPanel.MouseLeave += (sender, e) =>
            {
                toolbarPanelIn.Stop();
                toolbarPanelOut.Begin();
            };

            toolbarPanel.MouseEnter += (sender, e) =>
            {
                toolbarPanelOut.Stop();
                toolbarPanelIn.Begin();
            };
             * */

            // カラム数を読み込み
            tweetsPanel.Columns = Math.Max(1, App.Settings.Columns);

            // ツイートをログから読み込み
            tweets.Load("home.xml");

            // 自動的リロードタイマーを設定
            autoReloadTimer.Interval = TimeSpan.FromSeconds(App.Settings.AutoReload);
            autoReloadTimer.Tick += delegate(object sender, EventArgs e)
            {
                reloadTimeLine();
            };
            autoReloadTimer.Start();

            // ビジュアル設定が変更されたときに表示中のツイートコントロールをすべて更新して
            // レイアウトしなおす
            App.Settings.VisualChanged += delegate(object sender2)
            {
                ApplyVisualSettings();
                tweetsPanel.ApplySettings();
            };

            // アカウント設定が変更されたときリロードする
            App.Settings.AccountChanged += delegate(object sender)
            {
                twitter.Account = TwitterAccount.CreateFromApplicationSettings();
                autoReloadTimer.Stop();
                autoReloadTimer.Start();
                reloadTimeLine(true);
            };

            // 設定が変更されたときリロードする
            App.Settings.Changed += delegate(object sender)
            {
                autoReloadTimer.Interval = TimeSpan.FromSeconds(App.Settings.AutoReload);
            };

            uiHideTimer.Tick += (s, e) =>
            {
                showToolbar(false);
                uiHideTimer.Stop();
            };
            uiHideTimer.Interval = TimeSpan.FromSeconds(3);
            uiHideTimer.Start();

            this.MouseMove += (s, e) =>
            {
                if (toolbarPanel.Opacity < 1)
                {
                    //toolbarPanelOut.Stop();
                    //toolbarPanelIn.Begin();
                    showToolbar(true);
                }
                uiHideTimer.Start();
            };
        }
Ejemplo n.º 3
0
 public void BeginUserWindowResize(WindowResizeEdge edge)
 {
     NativeMethods.AreaBeginUserWindowResize(handle, edge);
 }
Ejemplo n.º 4
0
 public static extern void AreaBeginUserWindowResize(IntPtr area, WindowResizeEdge edge);
Ejemplo n.º 5
0
Archivo: Window.cs Proyecto: shana/moon
		public void DragResize (WindowResizeEdge resizeEdge)
		{
			Console.WriteLine ("System.Windows.Window.DragResize (): NIEX");
			throw new NotImplementedException ();
		}
Ejemplo n.º 6
0
 public void DragResize(WindowResizeEdge resizeEdge)
 {
 }