Beispiel #1
0
        void ribbon_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            RibbonTab rt = ribbon.SelectedItem as RibbonTab;

            this.selectedTabHeader = rt.Header.ToString();
            if (selectedTabHeader == "例1")
            {
                appMenu1.Visibility = System.Windows.Visibility.Collapsed;
                p1             = new Page1();
                frame1.Content = p1.Content;
            }
            else
            {
                appMenu1.Visibility = System.Windows.Visibility.Visible;
                p2             = new Page2();
                frame1.Content = p2.Content;
                switch (selectedTabHeader)
                {
                case "例2": p2.Init("球形和球形序列1", "ink2.isf"); break;

                case "例3": p2.Init("球形和球形序列2", "ink3.isf"); break;

                case "例4": p2.Init("矩形和矩形序列", "ink4.isf"); break;

                case "例5": p2.Init("图像和图像序列", "ink5.isf"); break;

                case "例6": p2.Init("渐变直线", "ink6.isf"); break;

                case "例7": p2.Init("曲线和文字", "ink7.isf"); break;
                }
            }
        }
        private void Login_Click(object sender, RoutedEventArgs e)
        {
            User user = new User();

            if (config == null)
            {
                MessageBox.Show("Config is invalid, Enter new values.");
            }
            if (config == null || checkBox.IsChecked == false)
            {
                config          = new Config();
                config.name     = textBox.Text;
                config.password = passwordBox.Password;
                config.port     = PORT_IN;
                config.ip       = getIPAddress();
                if (this.path == null || this.path == "")
                {
                    MessageBox.Show("You must enter a path.");
                    return;
                }
                config.path = this.path;
            }
            user.name        = config.name;
            user.password    = config.password;
            user.ip          = config.ip;
            user.port        = config.port;
            user.isAvailable = true;
            this.userData    = JsonConvert.SerializeObject(user);
            this.filesData   = JsonConvert.SerializeObject(this.getFiles(config.path));
            string answer = server.login(userData, filesData);

            if (answer != "User login.")
            {
                MessageBox.Show(answer);
            }
            else
            {
                using (StreamWriter file = System.IO.File.CreateText(@FILE_NAME))
                {
                    JsonSerializer serializer = new JsonSerializer();
                    serializer.Serialize(file, config);
                }
                Page2 page2 = new Page2(config, userData, filesData, this);
                this.Content = page2;
                //MessageBox.Show(answer);
            }
        }