Пример #1
0
        /// <summary>
        /// Occurs when main window is loaded.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            // Getting table as AutoCollection element.
            var table = tableDescriptor.GetField <AutoCollection>("table");

            // Overriding default remove (`-`) button handler.
            table.OnRemoveClick += delegate(object taget)
            {
                if (table.SelectedIndex >= 0)
                {
                    // Removeing element from server.
                    RemoveItem(((TableRowDescriptor)table.SelectedField.Value).id);

                    // removing element from table.
                    table.RemoveAt(table.SelectedIndex);
                }
            };

            // Hiding main window.
            this.Hide();

            // Requesting connection.
            var connectionWindow = new Window()
            {
                MinHeight             = 265,
                MaxHeight             = 265,
                MinWidth              = 350,
                MaxWidth              = 350,
                WindowStyle           = WindowStyle.None,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            // Close the app if connection canceled.
            serverCnnectionFormDescriptor.cancel += delegate()
            {
                connectionWindow.Close();
                this.Close();
            };

            // Validating connection.
            serverCnnectionFormDescriptor.Connect = delegate()
            {
                bool result = ValidateConnection();

                if (result)
                {
                    this.Show();
                    connectionWindow.Close();

                    // Requesting data.
                    RefreshData();
                }
            };

            // Creating auto layout view and applying the descriptor.
            var connectionFormView = new AutoLayoutVeiw();

            connectionFormView.OnLayout(serverCnnectionFormDescriptor);

            // Oppening the window.
            connectionWindow.Content = connectionFormView;
            connectionWindow.ShowDialog();
        }