Example #1
0
        private void ConnectBtn_Click(object sender, RoutedEventArgs e)
        {
            Connection connWin = new Connection();

            connWin.ShowDialog();
            if (connWin.DialogResult == true)
            {
                connStute.Text = "设备已连接";
            }
        }
Example #2
0
        private void Button_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            Connection connWin = new Connection();

            connWin.ShowDialog();
            if (connWin.DialogResult == true)
            {
                connStute.Text = "设备已连接";
            }
        }
Example #3
0
        /// <summary>
        /// Affiche le form de connection d'admin
        /// </summary>
        public void Connect_Admin()
        {
            Connection l_form = new Connection();

            l_form.ShowDialog();

            /*if (Check_Admin(l_form.M_s_Login, l_form.M_s_Password))
             * {
             *
             * }*/
        }
        private void ModifyConnection_Click(object sender, RoutedEventArgs e)
        {
            if (SelectedConnection == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(SelectedConnection.ConnectionString))
            {
                return;
            }

            string     name       = SelectedConnection.Name;
            Connection connection = new Connection(name, SelectedConnection.ConnectionString);
            bool?      result     = connection.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            var configExists = SharedConfigFile.ConfigFileExists(SelectedProject);

            if (!configExists)
            {
                CreateConfigFile(SelectedProject);
            }

            Expander.IsExpanded = false;

            AddOrUpdateConnection(SelectedProject, connection.ConnectionName, connection.ConnectionString, connection.OrgId, connection.Version, false);

            //Keep to refresh the connections in the list
            GetConnections();

            foreach (CrmConn conn in Connections.Items)
            {
                if (conn.Name != connection.ConnectionName)
                {
                    continue;
                }

                Connections.SelectedItem = conn;
                OnConnectionModified(new ConnectionModifiedEventArgs
                {
                    ModifiedConnection = conn
                });
                break;
            }
        }
Example #5
0
        public MainWindow()
        {
            InitializeComponent();
            this.Visibility = Visibility.Hidden;
            var login = new Connection();

            login.ShowDialog();
            if (SimpleIoc.Default.GetInstance <ConnectionVM>().Connected)
            {
                this.Visibility = Visibility.Visible;
                ((MainViewModel)this.DataContext).GetConfig();
                return;
            }
            this.Close();
        }
Example #6
0
        private void ModifyConnection_Click(object sender, RoutedEventArgs e)
        {
            if (_selectedConn == null)
            {
                return;
            }
            if (string.IsNullOrEmpty(_selectedConn.ConnectionString))
            {
                return;
            }

            string     name       = _selectedConn.Name;
            Connection connection = new Connection(name, _selectedConn.ConnectionString);
            bool?      result     = connection.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            var configExists = ConfigFileExists(_selectedProject);

            if (!configExists)
            {
                CreateConfigFile(_selectedProject);
            }

            Expander.IsExpanded = false;

            AddOrUpdateConnection(_selectedProject, connection.ConnectionName, connection.ConnectionString, connection.OrgId, connection.Version, false);

            GetConnections();
            foreach (CrmConn conn in Connections.Items)
            {
                if (conn.Name != connection.ConnectionName)
                {
                    continue;
                }

                Connections.SelectedItem = conn;
                GetPlugins(conn.ConnectionString);
                break;
            }
        }
Example #7
0
        private void AddConnection_Click(object sender, RoutedEventArgs e)
        {
            var connection = new Connection(null, null);

            bool?result = connection.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            var configExists = SharedConfigFile.ConfigFileExists(SelectedProject);

            if (!configExists)
            {
                CreateConfigFile(SelectedProject);
            }

            Expander.IsExpanded = false;

            AddOrUpdateConnection(SelectedProject, connection.ConnectionName, connection.ConnectionString, connection.OrgId, connection.Version, true);

            GetConnections();

            foreach (CrmConn conn in Connections.Items)
            {
                if (conn.Name != connection.ConnectionName)
                {
                    continue;
                }

                Connections.SelectedItem = conn;
                // TODO: Should this actually fire OnConnectionSelected?
                OnConnectionAdded(new ConnectionAddedEventArgs
                {
                    AddedConnection = conn
                });

                break;
            }
        }
Example #8
0
        private void AddConnection_Click(object sender, RoutedEventArgs e)
        {
            Connection connection = new Connection(null, null);
            bool?      result     = connection.ShowDialog();

            if (!result.HasValue || !result.Value)
            {
                return;
            }

            var configExists = ConfigFileExists(_selectedProject);

            if (!configExists)
            {
                CreateConfigFile(_selectedProject);
            }

            Expander.IsExpanded      = false;
            Customizations.IsEnabled = true;
            Solutions.IsEnabled      = true;

            bool change = AddOrUpdateConnection(_selectedProject, connection.ConnectionName, connection.ConnectionString, connection.OrgId, connection.Version, true);

            if (!change)
            {
                return;
            }

            GetConnections();
            foreach (CrmConn conn in Connections.Items)
            {
                if (conn.Name != connection.ConnectionName)
                {
                    continue;
                }

                Connections.SelectedItem = conn;
                GetPlugins(conn.ConnectionString);
                break;
            }
        }
        private void SaveToDatabaseButton_Click(object sender, RoutedEventArgs e)
        {
            if (mainWindow.neuralNetwork == null)
            {
                return;
            }

            mainWindow.neuralNetwork.Name = NameTextBox.Text;
            Connection connectionWindow = new Connection();

            connectionWindow.ShowDialog();

            string connString = "Server = " + connectionWindow.Address + ";";

            connString += "Database = " + connectionWindow.Database + ";";
            connString += "Uid = " + connectionWindow.Username + ";";
            connString += "Pwd = " + connectionWindow.Password + ";";

            MySqlConnection database = new MySqlConnection(connString);

            //check if database contains necessary tables
            try
            {
                database.Open();
            }
            catch (Exception exc)
            {
                if (exc.Message.ToLower().Contains("unknown database"))
                {
                    GenerateDatabase(connectionWindow.Address, connectionWindow.Username, connectionWindow.Password, connectionWindow.Database);
                }
            }

            try
            {
                if (database.State == System.Data.ConnectionState.Closed)
                {
                    database.Open();
                }

                string          cmdText = "";
                MySqlCommand    cmd     = new MySqlCommand(null, database);
                MySqlDataReader reader;

                cmd.CommandText = "select * from NeuralNetwork where Name = \"" + mainWindow.neuralNetwork.Name + "\"";
                reader          = cmd.ExecuteReader();
                if (reader.HasRows)
                {
                    return;
                }

                reader.Close();

                cmdText         = "insert into NeuralNetwork(Name,LearningRate) values (\"" + mainWindow.neuralNetwork.Name + "\", " + mainWindow.neuralNetwork.LearningRate.ToString(System.Globalization.CultureInfo.InvariantCulture) + ");";
                cmd.CommandText = cmdText;
                cmd.ExecuteNonQuery();

                foreach (Layer layer in mainWindow.neuralNetwork.Layers)
                {
                    int currentLayerID = 0;
                    cmdText         = "insert into Layer (ActivationFunction,Name) values(\"" + layer.activationFunction.ToString() + "\",\"" + mainWindow.neuralNetwork.Name + "\");";
                    cmd.CommandText = cmdText;
                    cmd.ExecuteNonQuery();

                    cmd.CommandText = "select * from Layer where Name = \"" + mainWindow.neuralNetwork.Name + "\"";
                    reader          = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        currentLayerID = reader.GetInt32("idLayer");
                    }
                    reader.Close();

                    foreach (Neuron neuron in layer.Neurons)
                    {
                        int currentNeuronID = 0;
                        cmdText         = "insert into Neuron (Bias,idLayer) values(" + neuron.Bias.ToString(System.Globalization.CultureInfo.InvariantCulture) + "," + currentLayerID.ToString() + ");";
                        cmd.CommandText = cmdText;
                        cmd.ExecuteNonQuery();

                        cmd.CommandText = "select * from Neuron where idLayer = " + currentLayerID;
                        reader          = cmd.ExecuteReader();

                        while (reader.Read())
                        {
                            currentNeuronID = reader.GetInt32("idNeuron");
                        }
                        reader.Close();

                        foreach (Dendrite dendrite in neuron.Dendrites)
                        {
                            cmdText         = "insert into Dendrite (Weight,idNeuron) values(" + dendrite.Weight.ToString(System.Globalization.CultureInfo.InvariantCulture) + "," + currentNeuronID.ToString() + ");";
                            cmd.CommandText = cmdText;
                            cmd.ExecuteNonQuery();
                        }
                    }
                }
                if (database.State == System.Data.ConnectionState.Open)
                {
                    database.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Example #10
0
        private void LoadFromDatabaseButton_Click(object sender, RoutedEventArgs e)
        {
            NeuralNetwork   network;
            List <Layer>    layers           = new List <Layer>();
            List <Neuron>   neurons          = new List <Neuron>();
            List <Dendrite> dendrites        = new List <Dendrite>();
            Connection      connectionWindow = new Connection();

            int learningRate;

            connectionWindow.ShowDialog();

            string connString = "Server = " + connectionWindow.Address + ";";

            connString += "Database = " + connectionWindow.Database + ";";
            connString += "Uid = " + connectionWindow.Username + ";";
            connString += "Pwd = " + connectionWindow.Password + ";";

            using (MySqlConnection connection = new MySqlConnection(connString))
            {
                int    currentNeuronID = 0, currentLayerID = 0;
                double currentNeuronBias           = 0;
                ActivationFunctions currentLayerAF = 0;

                MySqlCommand    cmd = new MySqlCommand(string.Empty, connection);
                MySqlDataReader reader;

                try
                {
                    if (connection.State != System.Data.ConnectionState.Open)
                    {
                        connection.Open();
                    }

                    cmd.CommandText = "SELECT * FROM neuron where neuron.idLayer = (select min(layer.idLayer) from layer where layer.Name = \"" + NameTextBox.Text + "\");";
                    reader          = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        neurons.Add(new Neuron(0));
                    }

                    layers.Add(new Layer(new List <Neuron>(neurons), ActivationFunctions.Sigmoid));
                    neurons.Clear();

                    reader.Close();

                    cmd.CommandText = CommandStrings.NetworkLoadCmd;
                    reader          = cmd.ExecuteReader();

                    while (reader.Read())
                    {
                        if (reader.GetInt32(2) != currentNeuronID)
                        {
                            if (dendrites.Count > 0)
                            {
                                neurons.Add(new Neuron(new List <Dendrite>(dendrites), currentNeuronBias));
                                dendrites.Clear();
                            }
                            currentNeuronID   = reader.GetInt32(2);
                            currentNeuronBias = Double.Parse(reader.GetString(3).Replace('.', ','));
                        }

                        if (reader.GetInt32(4) != currentLayerID)
                        {
                            if (neurons.Count != 0)
                            {
                                layers.Add(new Layer(new List <Neuron>(neurons), currentLayerAF));
                                neurons.Clear();
                                dendrites.Clear();
                            }
                            currentLayerID = reader.GetInt32(4);
                            currentLayerAF = (ActivationFunctions)Enum.Parse(typeof(ActivationFunctions), reader.GetString(5));
                        }
                        dendrites.Add(new Dendrite(Double.Parse(reader.GetString(1).Replace('.', ','))));
                    }

                    neurons.Add(new Neuron(dendrites, currentNeuronBias));
                    layers.Add(new Layer(neurons, currentLayerAF));
                    mainWindow.neuralNetwork = new NeuralNetwork(layers, Double.Parse(reader.GetString(6).Replace('.', ',')));
                    reader.Close();

                    if (connection.State == System.Data.ConnectionState.Open)
                    {
                        connection.Close();
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
        }
Example #11
0
        private void managementGroupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            m_managementPack.Clear();
            Connection Connection = new Connection();
            Connection.ShowDialog();
            if (Connection.DialogResult != DialogResult.OK)
            {
                return;
            }
            this.ManagementGroup = Connection.Server;
            try
            {
                if (Connection.User != "")
                {
                    ManagementGroupConnectionSettings emgs = new ManagementGroupConnectionSettings(Connection.Server);
                    string[] user = Connection.User.Split('\\');
                    emgs.Domain = user[0];
                    emgs.UserName = user[1];
                    SecureString password = new SecureString();
                    foreach (char c in Connection.Password)
                    {
                        password.AppendChar(c);
                    }
                    emgs.Password = password;
                    emg = new ManagementGroup(emgs);

                }
                else
                {
                    emg = new ManagementGroup(Connection.Server);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            BackgroundWorker MGConnector = new BackgroundWorker();

            MGConnector.DoWork += MGConnector_DoWork;
            MGConnector.RunWorkerCompleted += MGConnector_RunWorkerCompleted;
            m_progressDialog = new ProgressDialog();
            MGConnector.RunWorkerAsync(MPLoadingProgress);

            m_progressDialog.ShowDialog();
            MultipleMPSelectionForm form = new MultipleMPSelectionForm(MPList);
            DialogResult r = form.ShowDialog();
            if (r != DialogResult.Cancel && form.ChosenMP.Count > 0)
            {
                foreach (ManagementPack item in form.ChosenMP)
                {
                    this.m_managementPack.Add(item.Name, item);
                }
                Mode = MPMode.ManagementGroup;
                ProcessManagementPacks();
            }
        }
Example #12
0
        public static void startClient()
        {
            Connection conn = new Connection(Ip, port);

            conn.ShowDialog();
        }
Example #13
0
 private void FECipherVit_Load(object sender, EventArgs e)
 {
     File.Delete("decktemp");
     Player = new User();
     Rival = new User();
     msgProcessor = new MsgProcessor(this);
     string[] CardDataTemp = File.ReadAllLines("CardData.fe0db", Encoding.UTF8);
     CardData = new List<string[]>();
     foreach (string carddatumtemp in CardDataTemp)
     {
         string[] temp = carddatumtemp.Split(new char[] { ',' }, StringSplitOptions.None);
         CardData.Add(temp);
     }
     CardData.Sort(delegate (string[] x, string[] y)
     {
         return Convert.ToInt32(x[0]) - Convert.ToInt32(y[0]);
     });
     try
     {
         pictureBoxCardInfo.Image = Image.FromFile(@"img/back.jpg");
     }
     catch
     {
         pictureBoxCardInfo.Image = pictureBoxCardInfo.ErrorImage;
     }
     ConnectionRenew();
     connection = new Connection(this);
     connection.ShowDialog();
     ContextMenuStripRenew();
     UpdateThread = new Thread(new ThreadStart(CheckUpdate));
     UpdateThread.Start();
 }
Example #14
0
 private void SetFtpSettings()
 {
     Connection cnForm = new Connection();
     if (cnForm.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         this._ftpServerIp = cnForm.ServerIp;
         this._ftpServerPort = cnForm.Port;
         this._user = cnForm.UserLogin;
         this._password = cnForm.UserPassword;
     }
 }
Example #15
0
 private void FECipherVit_Load(object sender, EventArgs e)
 {
     if (SpeVer.Contains("Compi"))
     {
         DisablePlaying();
     }
     if (SpeVer.Contains("Judge"))
     {
         开启裁判功能ToolStripMenuItem.Visible = true;
     }
     File.Delete("decktemp");
     Player = new User(this);
     Rival = new User(this);
     msgProcessor = new MsgProcessor(this);
     report = res.GetString("report_string1", Thread.CurrentThread.CurrentUICulture) + DateTime.Now.ToString();
     try
     {
         string[] CardDataTemp;
         if (Language == Language.Chinese)
         {
             CardDataTemp = File.ReadAllLines("CardData.fe0db", Encoding.UTF8);
         }
         else
         {
             CardDataTemp = File.ReadAllLines("CardData_En.fe0db", Encoding.UTF8);
         }
         CardData = new Dictionary<string, string[]>();
         foreach (string carddatumtemp in CardDataTemp)
         {
             if (carddatumtemp.Contains("USO"))
             {
                 continue;
             }
             string[] temp = carddatumtemp.Split(new char[] { ',' }, StringSplitOptions.None);
             if (Language == Language.English && temp.Length >= 19)
             {
                 temp[4] = temp[4].Replace("%%", ",");
                 temp[16] = temp[16].Replace("%%", ",");
                 temp[17] = temp[17].Replace("%%", ",");
             }
             CardData.Add(temp[0], temp);
             if (temp.Length >= 19 && temp[18] == "2")
             {
                 string[] temp2 = (string[])temp.Clone();
                 temp2[0] += "+";
                 temp2[2] += "+";
                 CardData.Add(temp2[0], temp2);
             }
         }
         DatabaseVer = int.Parse(CardData["0"][2]);
         try
         {
             pictureBoxCardInfo.Image = Image.FromFile(@"img/back.jpg");
         }
         catch
         {
             pictureBoxCardInfo.Image = pictureBoxCardInfo.ErrorImage;
         }
     }
     catch
     {
         MessageBox.Show(res.GetString("LoadCardData_string1", Thread.CurrentThread.CurrentUICulture), res.GetString("LoadCardData_caption", Thread.CurrentThread.CurrentUICulture));
         Application.Exit();
     }
     if (Language == Language.Chinese)
     {
         UpdateGetMsgTextBox("欢迎使用FECipherVit。\r\n程序版本号:" + Version.ToString() + " " + SpeVer + "\r\n数据库版本号:" + DatabaseVer.ToString());
     }
     else
     {
         UpdateGetMsgTextBox("Welcome to FECipherVit.\r\nVersion: " + Version.ToString() + " " + SpeVer + "\r\nDatabase version: " + DatabaseVer.ToString());
     }
     ConnectionRenew();
     connection = new Connection(this);
     connection.ShowDialog();
     historychecker = new HistoryChecker(this);
     ContextMenuStripRenew();
     CreateThumbnailsThread = new Thread(new ThreadStart(CheckCardImgs));
     CreateThumbnailsThread.Start();
 }