⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainview.xaml.cs

📁 ICE3.3.0--聊天程序服务器端demo
💻 CS
字号:
// **********************************************************************
//
// Copyright (c) 2003-2008 ZeroC, Inc. All rights reserved.
//
// This copy of Chat Demo is licensed to you under the terms
// described in the CHAT_DEMO_LICENSE file included in this
// distribution.
//
// **********************************************************************

using System;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;

namespace ChatDemoGUI
{
    public partial class MainView : Window
    {
        public MainView()
        {
            InitializeComponent();
            App app = (App)System.Windows.Application.Current;
            ObjectDataProvider odp = (ObjectDataProvider)app.Resources["ChatModel"];
            app.getCoordinator().setMainView(this);
            _model = (ChatModel)odp.Data;

            // Disable the browse back command
            NavigationCommands.BrowseBack.InputGestures.Clear();
            if(!loadWindowsPrefs())
            {
                Width = 400;
                Height = 540;
                ChatUtils.locateOnScreen(this);
            }
        }

        private void windowActivated(object sender,EventArgs e)
        {
            ((App)System.Windows.Application.Current).getCoordinator().setFocus();
        }

        private void logout(object sender,ExecutedRoutedEventArgs args)
        {
            ((App)System.Windows.Application.Current).getCoordinator().logout();
        }

        private void exit(object sender,ExecutedRoutedEventArgs args)
        {
            System.Windows.Application.Current.Shutdown(0);
        }

        private void isLogoutEnabled(object sender, CanExecuteRoutedEventArgs args)
        {
            args.CanExecute = _model.State == Coordinator.ClientState.Connected;
        }

        private void about(object sender,ExecutedRoutedEventArgs args)
        {
            String aboutMessage = "Chat Demo \n"
                                 + "Copyright \u00A9 2005-2008 ZeroC, Inc. All rights reserved.\n";
            string caption = "Chat Demo - About";
            MessageBoxImage icon = MessageBoxImage.Information;
            MessageBoxButton button = MessageBoxButton.OK;
            MessageBox.Show(aboutMessage, caption, button, icon);
        }

        private bool loadWindowsPrefs()
        {
            if(Properties.Settings.Default.WindowPrefs)
            {
                Width = Properties.Settings.Default.Width;
                Height = Properties.Settings.Default.Height;
                Top = Properties.Settings.Default.Top;
                Left = Properties.Settings.Default.Left;
            }
            return Properties.Settings.Default.WindowPrefs;
        }

        public void storeWindowPrefs()
        {
            Properties.Settings.Default.Width = Width;
            Properties.Settings.Default.Height = Height;
            Properties.Settings.Default.Top = Top;
            Properties.Settings.Default.Left = Left;
            Properties.Settings.Default.WindowPrefs = true;
            Properties.Settings.Default.Save();
        }

        private ChatModel _model;

        private void isLoginEnabled(object sender,CanExecuteRoutedEventArgs e)
        {
            e.CanExecute = _model.State == Coordinator.ClientState.ConnectionLost;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -