コード例 #1
0
ファイル: TestModel.cs プロジェクト: Yuanxiangz/WorkSpace
        public TestModel()
        {
            BlotterCommandList = new List<BlotterCommand>();
            BlotterCommandList.Add(new BlotterCommand() { CommandType = BlotterCommandType.Create, CommandHandler = () => MessageBox.Show("Create button!"), LayOut = BlotterCommandLayOut.Botton });
            BlotterCommandList.Add(new BlotterCommand() { CommandType = BlotterCommandType.Delete, CommandHandler = () => MessageBox.Show("Delete button!"), LayOut = BlotterCommandLayOut.Botton });

            Elements = new List<object>();
            Elements.Add(new Car() { Name = "Benz" });
            Elements.Add(new Desk() { Name = "HighDesk" });
        }
コード例 #2
0
        /// <summary>
        /// Get the child processes for a given process
        /// </summary>
        /// <param name="process"></param>
        /// <returns></returns>
        public static List<Process> GetChildProcesses(this Process process)
        {
            var results = new List<Process>();

            // query the management system objects for any process that has the current
            // process listed as it's parentprocessid
            string queryText = string.Format("select processid from win32_process where parentprocessid = {0}", process.Id);
            using (var searcher = new ManagementObjectSearcher(queryText))
            {
                foreach (var obj in searcher.Get())
                {
                    object data = obj.Properties["processid"].Value;
                    if (data != null)
                    {
                        // retrieve the process
                        var childId = Convert.ToInt32(data);
                        var childProcess = Process.GetProcessById(childId);

                        // ensure the current process is still live
                        if (childProcess != null)
                            results.Add(childProcess);
                    }
                }
            }
            return results;
        }
コード例 #3
0
        public static System.Collections.ObjectModel.ObservableCollection<string> GeneratePassPhrases()
        {
            if (!System.IO.File.Exists("words.txt"))
                DownloadWordList();

            if (!System.IO.File.Exists("words.txt"))
                throw new Exception("Could not download word list");

            string[] words = System.IO.File.ReadAllLines("words.txt");
            List<string> phrases = new List<string>();

            for (int j = 0; j < 1000; j++)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < 4; i++)
                {
                    if (i > 0) sb.Append(" ");

                    int d = Randomness.GetValue(0, words.Length - 1);

                    string word = words[d];
                    if (i == 0 && word.Length > 1)
                        word = word.Capitalize();

                    sb.Append(word);
                }
                sb.Append(".....");
                phrases.Add(sb.ToString());
            }
            return new System.Collections.ObjectModel.ObservableCollection<string>(phrases);
        }
コード例 #4
0
ファイル: DatabaseManager.cs プロジェクト: ITbob/UML2
        public List<String> checkProjects()
        {
            List<String> list = new List<String>();
            using (System.Data.SQLite.SQLiteConnection con = new System.Data.SQLite.SQLiteConnection("data source=databaseFile.db3"))
            {
                using (System.Data.SQLite.SQLiteCommand com = new System.Data.SQLite.SQLiteCommand(con))
                {
                    con.Open();

                    com.CommandText = "Select * FROM LASTPROJECTS";

                    using (System.Data.SQLite.SQLiteDataReader reader = com.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            Console.WriteLine(reader["address"]);

                            if (!File.Exists(reader["address"].ToString()))
                                list.Add(reader["address"].ToString());
                        }
                    }
                    con.Close();
                }
            }
            if(list.Count > 0)
                removeProject(list);

            return getLastProjects();
        }
コード例 #5
0
 public List<string> separadorEspacios(string cadena)
 {
     List<string> tokenizer = new List<string>();
     string [] n = cadena.Split(' ');
     foreach (string item in n)
     {
         tokenizer.Add(item);
     }
     return tokenizer;
 }
コード例 #6
0
 public List<string> separadorLineas(string cadena)
 {
     List<string> tokenizer = new List<string>();
     string[] n = cadena.Split(new string[] { Environment.NewLine}, StringSplitOptions.None );
     foreach (string item in n)
     {
         tokenizer.Add(item);
     }
     return tokenizer;
 }
コード例 #7
0
 /// <summary>
 /// Gets the list of available WIA devices.
 /// </summary>
 /// <returns></returns>
 public static List<string> GetDevices()
 {
     List<string> devices = new List<string>();
     WIA.DeviceManager manager = new WIA.DeviceManager();
     foreach (WIA.DeviceInfo info in manager.DeviceInfos)
     {
         devices.Add(info.DeviceID);
     }
     return devices;
 }
コード例 #8
0
 public MainViewModel()
 {
     CurrentColor = GetPaletteColor();
     Model = new Model3DGroup();
     Voxels = new List<Voxel>();
     Highlighted = new List<Model3D>();
     ModelToVoxel = new Dictionary<Model3D, Voxel>();
     OriginalMaterial = new Dictionary<Model3D, Material>();
     Voxels.Add(new Voxel(new Point3D(0, 0, 0), CurrentColor));
     UpdateModel();
 }
コード例 #9
0
ファイル: Controller.cs プロジェクト: TBA187/AlcoholCalc
        public List<Person> CreatePersons()
        {
            List<Person> personlist = new List<Person>();
            Person person1 = new Person();
            Person person2 = new Person();

            personlist.Add(person1);
            personlist.Add(person2);

            person1.Username = "******";
            person1.Password = "******";
            person1.Gender = "Male";
            person1.Weight = 110;

            person2.Username = "******";
            person2.Password = "******";
            person2.Gender = "Female";
            person2.Weight = 50;

            return personlist;
        }
コード例 #10
0
ファイル: XML.cs プロジェクト: InglouriousBasterd667/ISP-labs
        static void Main(string[] args)
        {

            Matrix mat = new Matrix(2, 2);
            mat.Initialize(20);
            int a = 33;
            Serializer x = new Serializer();
            List<int> l = new List<int>();
            l.Add(5);
            x.WriteObject(mat,@"C:\qwer.xml");
            var b = x.ReadObject(@"C:\qwer.xml");

        }
コード例 #11
0
ファイル: DbControl.cs プロジェクト: RuzikM/Chat
        public List<string> GetUsersList()
        {
            List<string> userlist = new List<string>();

                    Usersname.CommandText = "SELECT name FROM message";
                    SQLiteDataReader r = Usersname.ExecuteReader();
                    while (r.Read())
                    {
                       userlist.Add(Convert.ToString(r["name"]));

                    }

            return userlist;
        }
コード例 #12
0
ファイル: MainWindow.xaml.cs プロジェクト: JoelWeber/xaml-sdk
        public MainWindow()
        {
            InitializeComponent();
            List<Location> locations = new List<Location>();

            locations.Add(new Location() { ContinentCode = "EU", CountryID = 2 });


            ((GridViewComboBoxColumn)this.radGridView.Columns[0]).ItemsSource = Locations.Continents;
            this.radGridView.ItemsSource = locations;

            //We need to sense when the combo selection is changed and submit the value immediately
            //otherwise the value will be submited on leaving the cell which is too late for our needs. 
            this.AddHandler(RadComboBox.SelectionChangedEvent, new System.Windows.Controls.SelectionChangedEventHandler(comboSelectionChanged));
        }
コード例 #13
0
 public List<string> LoadMusic()
 {
     List<string> data = new List<string>();
     try
     {
         string line;
         System.IO.StreamReader file = new System.IO.StreamReader("radio.txt");
         while ((line = file.ReadLine()) != null)
         {
             data.Add(line);
         }
     }
     catch (Exception) { }
     return data;
 }
コード例 #14
0
ファイル: confidence.cs プロジェクト: ecntrk/Haixiu
        public void evaluateConfidence(double[] data)
        {
            output = this.confiRecog.recognizeEmotion(data);
            List<KeyValuePair<double, int>> lst = new List<KeyValuePair<double,int>>();

            //checking for multiple emo category:
            for (int i = 0; i < this.emoCategory; i++)
            {
                if (output[i] > this.emoThreshold)
                {
                    lst.Add(new KeyValuePair<double, int>(output[i], i));
                }
            }
            getConfidence(lst);
        }
コード例 #15
0
 public List<string> ForStatementAnalizer(string forStatement)
 {
     string aux = statementFilter(forStatement, "for");
     var forValues = new List<string>();
     if (!aux.Contains("Error"))
     {
         var iteratRestrict = aux.Split(';');
         foreach (string rest in iteratRestrict)
         {
             forValues.Add(rest);
         }
         if (forValues.Count != 3) {
             /////verificar asignacion de variable como primera entrada(int i = 0), condicion(i<n) y expresion final(i++)////////////
         }
     }
     return forValues;
 }
コード例 #16
0
ファイル: SQL.cs プロジェクト: seth-list/MySQL_MSSQL_csharp
        public override List<string> getAllColumns(String database, String table)
        {
            List<string> data = new List<string>();

            try
            {
                var connectionString = string.Format("Data Source=.\\SQLExpress;Integrated Security=SSPI;" +
                    "Database=" + database + ";");

                sqlConnection = new SqlConnection(connectionString);
                sqlConnection.Open();

                try
                {
                    using (sqlConnection)
                    {

                        //Select * From DBNAME.INFORMATION_SCHEMA.COLUMNS
                        SqlCommand command = sqlConnection.CreateCommand();
                        command.CommandText = String.Format("SELECT COLUMN_NAME FROM "
                            + "INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '{0}' ", table);
                        //========================================================
                        SqlDataReader Reader;

                        Reader = command.ExecuteReader();

                        while (Reader.Read())
                        {
                            data.Add(Reader.GetValue(0).ToString());
                        }

                        sqlConnection.Close();
                    }
                }
                catch (SqlException ex)
                {
                    System.Windows.MessageBox.Show(ex.ToString());
                }
            }
            catch (InvalidOperationException ex)
            {
                System.Windows.MessageBox.Show(ex.ToString());
            }

            return data;
        }
コード例 #17
0
ファイル: DbControl.cs プロジェクト: RuzikM/Chat
        public List<string> GetMessage(string names)
        {
            List<string> tmpmessage = new List<string>();

            Int64 integer;

            integer = Int64.Parse(Usersname.CommandText = "SELECT id FROM users WHERE name=names");

            string mes;
            mes = Usersname.CommandText = "SELECT messages FROM message WHERE us_id=integer".ToString();
            SQLiteDataReader m = Usersname.ExecuteReader();
            while (m.Read())
            {
                tmpmessage.Add(Convert.ToString(m["messages"]));

            }

            Usersmess.ExecuteNonQuery(); // chgitem es piti lini te che
               return tmpmessage;
        }
コード例 #18
0
 protected void AddPropError(string propertyName, string errorMsg)
 {
     if (string.IsNullOrEmpty(propertyName))
     {
         return;
     }
     if (_validationErrors.ContainsKey(propertyName))
     {
         List<string> errors;
         if (_validationErrors.TryGetValue(propertyName, out errors))
         {
             errors.Add(errorMsg);
         }
     }
     else
     {
         List<string> errors = new List<string>();
         errors.Add(errorMsg);
         _validationErrors.Add(propertyName, errors);
     }
 }
コード例 #19
0
ファイル: MainWindow.xaml.cs プロジェクト: jigjosh/xaml-sdk
 public MainWindow()
 {
     InitializeComponent();
     RadGridView1.GroupRenderMode = Telerik.Windows.Controls.GridView.GroupRenderMode.Nested;
     List<TestClass> items = new List<TestClass>();
     for (int i = 0; i < 100; i++)
     {
         for (int j = 0; j < 2; j++)
         {
             for (int k = 0; k < 2; k++)
             {
                 items.Add(new TestClass()
                 {
                     MyProperty1 = string.Format("Prop1_{0}", i),
                     MyProperty2 = string.Format("Prop2_{0}", j),
                     MyProperty3 = string.Format("Prop3_{0}", k),
                 });
             }
         }
     }
     DataContext = items;
 }
コード例 #20
0
ファイル: Threadplay.cs プロジェクト: GillllllBOOM/ThereMe
 public int play(string foo)
 {
     try
     {
         StreamReader sr = new StreamReader(foo, Encoding.Default);
         String line;
         List<int> wave = new List<int>();
         while ((line = sr.ReadLine()) != null)
         {
             wave.Add(int.Parse(line));
         }
         if (wave.Count % 2 != 0)
             return -2;
         Thread t = new Thread(new ParameterizedThreadStart(cplay));
         t.Start(wave);
     }
     catch
     {
         Console.WriteLine("音频不存在");
         return -1;
     }
     return 0;
 }
コード例 #21
0
ファイル: SQL.cs プロジェクト: seth-list/MySQL_MSSQL_csharp
        public override List<string> getAllDataBases()
        {
            connect();

            MySqlCommand command = connection.CreateCommand();
            command.CommandText = "SHOW DATABASES;";
            //========================================================
            MySqlDataReader Reader;
            List<string> data = new List<string>();

            try
            {
                Reader = command.ExecuteReader();

                while (Reader.Read())
                {
                    //добавление баз данных всех
                    data.Add(Reader.GetValue(0).ToString());
                }

                disconnect();
            }
            catch (MySqlException ex)
            {
                System.Windows.MessageBox.Show(ex.ToString());
            }

            data.Remove("information_schema");
            data.Remove("performance_schema");
            data.Remove("mysql");

            return data;
        }
コード例 #22
0
ファイル: SQL.cs プロジェクト: seth-list/MySQL_MSSQL_csharp
        public override List<string> getAllTables(String database)
        {
            List<string> data = new List<string>();
            DataTable table = null;

            try
            {
                var connectionString = string.Format("Data Source=.\\SQLExpress;Integrated Security=SSPI;" +
                    "Database=" + database + ";");

                sqlConnection = new SqlConnection(connectionString);

                try
                {
                    using (sqlConnection)
                    {
                        sqlConnection.Open();
                        table = sqlConnection.GetSchema("Tables");
                        sqlConnection.Close();
                    }
                }
                catch (SqlException ex)
                {
                    System.Windows.MessageBox.Show(ex.ToString());
                }

                if (table != null)
                {
                    foreach (DataRow row in table.Rows)
                    {
                        //2 элемент это база данных
                        data.Add(row.ItemArray[2].ToString());
                    }
                }
                return data;
            }
            catch (InvalidOperationException ex)
            {
                System.Windows.MessageBox.Show(ex.ToString());
            }
            return data;
        }
コード例 #23
0
ファイル: SQL.cs プロジェクト: seth-list/MySQL_MSSQL_csharp
        public override List<List<string>> getDataOfTable(String database, String table)
        {
            List<List<string>> data = new List<List<string>>();

            try
            {
                var connectionString = string.Format("Data Source=.\\SQLExpress;Integrated Security=SSPI;" +
                    "Database=" + database + ";");

                sqlConnection = new SqlConnection(connectionString);
                sqlConnection.Open();

                try
                {
                    using (sqlConnection)
                    {

                        //Select * From DBNAME.INFORMATION_SCHEMA.COLUMNS
                        SqlCommand command = sqlConnection.CreateCommand();
                        command.CommandText = String.Format("SELECT * FROM {0} ", table);
                        //========================================================
                        SqlDataReader Reader;

                        Reader = command.ExecuteReader();

                        while (Reader.Read())
                        {
                            List<string> row = new List<string>();

                            for (int i = 0; i < Reader.FieldCount; i++)
                            {
                                row.Add(Reader.GetValue(i).ToString());
                            }

                            data.Add(row);
                        }

                        sqlConnection.Close();
                    }
                }
                catch (SqlException ex)
                {
                    System.Windows.MessageBox.Show(ex.ToString());
                }
            }
            catch (InvalidOperationException ex)
            {
                System.Windows.MessageBox.Show(ex.ToString());
            }

            return data;
        }
コード例 #24
0
ファイル: SQL.cs プロジェクト: seth-list/MySQL_MSSQL_csharp
        public override List<string> getAllColumns(String database, String table)
        {
            connect();

            MySqlCommand command = connection.CreateCommand();
            command.CommandText = String.Format("SHOW COLUMNS FROM {0} FROM {1}",
                table, database);
            //========================================================
            MySqlDataReader Reader;

            List<string> data = new List<string>();

            try
            {
                Reader = command.ExecuteReader();

                while (Reader.Read())
                {
                    data.Add(Reader.GetValue(0).ToString());
                }

                disconnect();
            }
            catch (MySqlException ex)
            {
                System.Windows.MessageBox.Show(ex.ToString());
            }

            return data;
        }
コード例 #25
0
ファイル: Memory.cs プロジェクト: hapex/OS-Simulator
        // Omnipresence goes here (knowledge of what files will be done)
        public void Establish_List(FileInfo[] files)
        {
            var temp = new List<FileInfo>();

            Random rand = new Random();

            for (int i = 0; i < 1000 ; i +=1)
            {
                FileInfo fi = files[rand.Next(files.Length)];
                temp.Add(fi);
            }
                // make new
            _AllFiles = new List<FileInfo>(temp).ToArray();
        }
コード例 #26
0
ファイル: SQL.cs プロジェクト: seth-list/MySQL_MSSQL_csharp
        public override List<string> getAllTables(String database)
        {
            connect();

            MySqlCommand command = connection.CreateCommand();
            command.CommandText = "show tables from " + database + ";";
            //========================================================
            MySqlDataReader Reader;

            List<string> data = new List<string>();

            try
            {
                Reader = command.ExecuteReader();

                while (Reader.Read())
                {
                    data.Add(Reader.GetValue(0).ToString());
                }

                disconnect();
            }
            catch (MySqlException ex)
            {
                System.Windows.MessageBox.Show(ex.ToString());
            }

            return data;
        }
コード例 #27
0
ファイル: Prog1.cs プロジェクト: nitpicker/stackpeek
        static Dictionary<string, FunctionStat> ProcessingCallStack(string rawTextLog)
        {
            string[] perRecord = rawTextLog.Split(new string[] { recordSep }, StringSplitOptions.None);
            List<string> PrevCallStackString = null;
            List<string> CurCallStackString = new List<string>();
            string curRunningFn = null;
            string prevRunningFn = null;
            Dictionary<string, FunctionStat> histogram = new Dictionary<string, FunctionStat>();

            foreach (string l in perRecord)
            {
                Regex regex = new Regex(@"tsc: ([\w]+ [\w]+) ([\d]+.[\d]+) \(([\d]+.[\d]+)\) rip:([\w]+)");
                Match match = regex.Match(l);
                //bool bFound = false;
                double curTimestamp = 0;
                double previousTimestamp = 0;
                // Read current callstack
                if (match.Success)
                {
                    curTimestamp = double.Parse(match.Groups[2].Value);
                    string temp = l.Trim();
                    CurCallStackString.Clear();
                    foreach (string l2 in temp.Split('\n'))
                    {
                        Regex regex2 = new Regex(@"Pc:([\w]+) AddrReturn:([\w]+) \(([\w\+]+)\) Frame:([\w]+)");
                        Match match2 = regex2.Match(l2);
                        if (match2.Success)
                        {
                            CurCallStackString.Add(l2);
                        }
                    }
                }
                // Compare cur/prev callstack to figure out running fn
                if (PrevCallStackString != null && PrevCallStackString.Count != 0 && CurCallStackString.Count != 0)
                {
                    for (int i = 0; i != CurCallStackString.Count - 1; i++)
                    {
                        for (int j = 0; j != PrevCallStackString.Count - 1; j++)
                        {
                            //Console.WriteLine("i {0} j {1}", i, j);
                            if (CurCallStackString[i] == PrevCallStackString[j] &&
                                CurCallStackString[i + 1] == PrevCallStackString[j + 1] &&
                                IsInFilter(getNameOnlyFunction(CurCallStackString[i])) == false)
                            {
                               // bFound = true;
                                curRunningFn = CurCallStackString[i];
                                goto _break;
                            }
                        }
                    }
                _break: ;
                    //Console.WriteLine("--- curRunningFn: {0} prevRunningFn: {1}", curRunningFn, prevRunningFn);
                }
                // update the current fn
                if (curRunningFn != null && curRunningFn == prevRunningFn)
                {
                    string fnName = getNameOnlyFunction(curRunningFn);
                    //Console.WriteLine("Fn: {0}", fnName);
                    UpdateTimeHistogram(ref histogram, fnName, curTimestamp - previousTimestamp);
                }
                prevRunningFn = curRunningFn;
                previousTimestamp = curTimestamp;
                // update prev callstack
                PrevCallStackString = null;
                PrevCallStackString = CurCallStackString.ToList();
            }
            return histogram;
        }
コード例 #28
0
        public static bool Read(string filePath)
        {
            try
            {
                var reader = new StreamReader(File.OpenRead(@filePath));
                fileNames = new List<string>();
                utterances = new List<string>();
                count = 0;
                while (!reader.EndOfStream)
                {
                    var line = reader.ReadLine();
                    var values = line.Split('\t');

                    fileNames.Add(values[0]);
                    utterances.Add(values[1]);
                    count += 1;
                }

                curIndex = 0;
                Console.WriteLine(fileNames.ToString());
                return true;
            }
            catch (Exception e)
            {
                return false;
            }
        }
コード例 #29
0
ファイル: SQL.cs プロジェクト: seth-list/MySQL_MSSQL_csharp
        public override List<string> getAllDataBases()
        {
            connect();
            DataTable databases = null;

            try
            {
                using (sqlConnection)
                {
                    sqlConnection.Open();
                    databases = sqlConnection.GetSchema("Databases");
                    sqlConnection.Close();
                }
            }
            catch (SqlException ex)
            {
                System.Windows.MessageBox.Show(ex.ToString());
            }

            List<string> data = new List<string>();
            if (databases != null)
            {
                foreach (DataRow row in databases.Rows)
                {
                    data.Add(row.ItemArray[0].ToString());
                }
            }

            data.Remove("master");
            data.Remove("model");
            data.Remove("msdb");
            data.Remove("tempdb");

            return data;
        }
コード例 #30
0
ファイル: SQL.cs プロジェクト: seth-list/MySQL_MSSQL_csharp
        public override List<List<string>> getDataOfTable(String database, String table)
        {
            connect();

            MySqlCommand command = connection.CreateCommand();
            command.CommandText = String.Format("USE {0}; SELECT * FROM {1};",
                database, table);
            //========================================================
            MySqlDataReader Reader;

            List<List<string>> data = new List<List<string>>();

            try
            {
                Reader = command.ExecuteReader();

                while (Reader.Read())
                {
                    List<string> row = new List<string>();

                    for (int i = 0; i < Reader.FieldCount; i++)
                    {
                        row.Add(Reader.GetValue(i).ToString());
                    }

                    data.Add(row);
                }

                disconnect();
            }
            catch (MySqlException ex)
            {
                System.Windows.MessageBox.Show(ex.ToString());
            }

            return data;
        }