예제 #1
0
        private void lb1()
        {
            Random random = new Random();
            int    rand   = random.Next(0, listBox1.Items.Count);

            //listBox1.SetSelected(0, true);
            ListBox.ObjectCollection list = listBox1.Items;
            Random rng = new Random();
            int    n   = list.Count;

            while (n > 1)
            {
                n--;
                int    k     = rng.Next(n + 1);
                string value = (string)list[k];
                list[k] = list[n];
                list[n] = value;
            }
        }
        PopulateTopNByMetricUserSettingsListBox()
        {
            AssertValid();

            ListBox.ObjectCollection oItems =
                this.lbxTopNByMetricUserSettings.Items;

            oItems.Clear();

            foreach (TopNByMetricUserSettings oTopNByMetricUserSettings in
                     m_oTopNByMetricUserSettingsClone)
            {
                // Note that the TopNByMetricUserSettings.ToString() method
                // provides a description of the object that the
                // lbxTopNByMetricUserSettings ListBox will automatically display.

                oItems.Add(oTopNByMetricUserSettings);
            }
        }
예제 #3
0
파일: Form1.cs 프로젝트: WebDaD/M3UExporter
        private void copyMP3s(ListBox.ObjectCollection files, decimal starting_number, bool auto_pad, decimal padding, string target_folder, ProgressBar pb_progress)
        {
            if (auto_pad)
            {
                padding = (decimal)Math.Floor(Math.Log10(files.Count) + 1);
            }
            pb_progress.Maximum = files.Count;
            pb_progress.Step    = 1;
            int now = (int)starting_number;
            int i;

            for (i = 0; i < files.Count; i++)
            {
                string f = files[i] as string;
                try
                {
                    string f_name   = Path.GetFileName(f);
                    string new_name = target_folder + "\\" + now.ToString().PadLeft((int)padding, '0') + "_" + f_name;
                    File.Copy(f, new_name);
                    pb_progress.PerformStep();
                    now++;
                }
                catch (FileNotFoundException)
                {
                    DialogResult d = MessageBox.Show("File " + f + " has not been found...", "Error", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error);
                    if (d == System.Windows.Forms.DialogResult.Abort)
                    {
                        break;
                    }
                    else if (d == System.Windows.Forms.DialogResult.Retry)
                    {
                        i--;
                    }
                    else //Ignore
                    {
                        pb_progress.PerformStep();
                        now++;
                    }
                }
            }
            MessageBox.Show(i + " of " + files.Count + " Files have been copied.", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information);
            pb_progress.Value = 0;
        }
        private void LeggTilAlleBtn_Click(object sender, EventArgs e)
        {
            /*
             * Denne knappen fjerner alle elementer i FagkodeListebox
             * og legger dem i FagkodeSammenlignesListebox
             */

            ListBox.ObjectCollection elementer = FagkodeListbox.Items;

            foreach (var item in elementer)
            {
                FagkodeSammenlignesListebox.Items.Add(item);
            }

            while (FagkodeListbox.Items.Count > 0)
            {
                FagkodeListbox.Items.Remove(FagkodeListbox.Items[0]);
            }
        }
예제 #5
0
파일: Form1.cs 프로젝트: pabje/co02
        private int leerAnexos(ListBox.ObjectCollection items)
        {
            int cantidad = 0;

            foreach (string ruta in lbxAnexos.Items)
            {
                FileInfo file = new FileInfo(ruta);
                if (file.Exists)
                {
                    cantidad++;
                }
                else
                {
                    lbxAnexos.Items.RemoveAt(lbxAnexos.Items.IndexOf(ruta));
                }
            }

            return(cantidad);
        }
예제 #6
0
        //shuffle btn
        private void button1_Click(object sender, EventArgs e)
        {
            ListBox.ObjectCollection list = listBox1.Items;
            Random random = new Random();
            int    w      = list.Count;

            listBox1.BeginUpdate();
            while (w > 1)
            {
                w--;
                int    u     = random.Next(w + 1);
                object value = list[u];
                list[u]    = list[w];
                list[w]    = value;
                Player.URL = path[u];
            }
            listBox1.EndUpdate();
            listBox1.Invalidate();
        }
예제 #7
0
 //Create and hide until its done
 public Chart(ListBox shop, ListBox provider, ListBox provider_supplies)
 {
     InitializeComponent();
     chart1.SendToBack();
     chart1.Hide();
     Restart.Hide();
     count     = new List <string>();
     shops     = shop.Items;
     suppliers = provider.Items;
     supplies  = provider_supplies.Items;
     for (int j = 2013; j < 2015; j++)
     {
         for (int i = 1; i < 53; i++)
         {
             dates.Items.Add(i.ToString() + "_" + j.ToString());
         }
     }
     CreateVisuals();
 }
예제 #8
0
        private void btn_shuffle_Click(object sender, EventArgs e)
        {
            //Button to shuffle songs in the list box
            ListBox.ObjectCollection list = listBoxSongs.Items; //Refers to item in the listbox
            Random random = new Random();                       //Random generator
            int    w      = list.Count;                         //States how many items there are in the listbox

            listBoxSongs.BeginUpdate();
            while (w > 1)
            {
                w--;
                int    u     = random.Next(w + 1);
                object value = list[u];
                list[u] = list[w];
                list[w] = value;
            }
            listBoxSongs.EndUpdate();
            listBoxSongs.Invalidate();
        }
예제 #9
0
        /// <summary>
        /// This method allows all items to be displayed on the visual
        /// clipboard.
        /// </summary>
        private void AllowKeys()
        {
            // nothing to do if all items are already being displayed
            if (this.listBox.Items.Count == LocalClipboard.Keys.Count)
            {
                return;
            }

            // first, clear the visual part of the local clipboard
            ListBox.ObjectCollection myItems = this.listBox.Items;
            myItems.Clear();

            // traverse the keys in the local clipboard
            foreach (string key in LocalClipboard.Keys)
            {
                // add each item back to the visual clipboard
                myItems.Add(key);
            }
        }
예제 #10
0
 public new void Load(DesktopStorage storage)
 {
     using (var stream = storage.GetStream("Generic Commans.json", FileAccess.ReadWrite, FileMode.OpenOrCreate))
     {
         using (var file = new StreamReader(stream))
         {
             try
             {
                 var l = new ListBox.ObjectCollection(CommandsListBox, JsonConvert.DeserializeObject <string[]>(file.ReadToEnd()));
                 CommandsListBox.Items.AddRange(l);
             }
             catch (System.ArgumentNullException e)
             {
                 Logger.Log("Can't reand data from config for generic commands. Removing the file...");
                 storage.Delete("Generic Commans.json");
             }
         }
     }
 }
예제 #11
0
        private int AddAfter(int index, TreeNodeBase root)
        {
            if (root.allkids == null)
            {
                root.allkids = treeOwner.FetchKids(TokenObject, root);
            }
            ArrayList nodes = treeOwner.ProcessNodes(TokenObject, root.allkids);

            int numNodes = nodes.Count, nodesInList = treeListBox.Items.Count;
            int costOfRebuilding = 3 * (numNodes + nodesInList);
            int costOfInsertions = (1 + nodesInList - index) * numNodes;
            int i, newDepth = 1 + root.depth;

            if (costOfInsertions < costOfRebuilding)
            {
                foreach (TreeNodeBase curr in nodes)
                {
                    curr.depth = newDepth;
                    treeListBox.Items.Insert(++index, curr);
                }
            }
            else
            {
                ++index;
                ListBox.ObjectCollection items = treeListBox.Items;
                object[] allNodes = new object[numNodes + nodesInList];
                for (i = 0; i < index; i++)
                {
                    allNodes[i] = items[i];
                }
                for (; i < index + numNodes; i++)
                {
                    allNodes[i] = nodes[i - index];
                    ((TreeNodeBase)allNodes[i]).depth = newDepth;
                }
                for (; i < numNodes + nodesInList; i++)
                {
                    allNodes[i] = items[i - numNodes];
                }
                ReplaceContents(allNodes);
            }
            return(index);
        }
예제 #12
0
        private void ReadRunningApps()
        {
            lock (iniObj)
            {
                runningApps = new List <ProcessModel>();
                var iniFile = new IniFile();
                var procs   = iniFile.Read("RunningProcesses");
                if (!string.IsNullOrWhiteSpace(procs))
                {
                    var savedProcs = procs.Split(',').ToArray();
                    foreach (var savedProc in savedProcs)
                    {
                        var split = savedProc.Split(';').ToArray();

                        var proc = new ProcessModel
                        {
                            ProcessName    = split.Length > 0 ? split[0] : savedProc,
                            ProcessTitle   = split.Length > 1 ? split[1] : savedProc,
                            CreatedFromExe = split.Length > 2 ? split[2] == "Y" : false
                        };

                        if (!savedSelectedApps.Any(x => x.ProcessName == proc.ProcessName || x.ProcessTitle == proc.ProcessTitle))
                        {
                            runningApps.Add(proc);
                        }
                    }
                }

                dispatch.BeginInvoke(
                    DispatcherPriority.Normal,
                    (Action)(() =>
                {
                    lock (lockObj)
                    {
                        var objCol = new ListBox.ObjectCollection(procBox);
                        objCol.AddRange(runningApps.ToArray());
                        procBox.Items.Clear();
                        procBox.Items.AddRange(objCol);
                    }
                }));
            }
        }
예제 #13
0
        private void reverse_btn_Click(object sender, EventArgs e)
        {
            ListBox lb = GetChildeControl <ListBox>(tc_Person.SelectedTab);

            ListBox.ObjectCollection items = lb.Items;

            lb.BeginUpdate();
            for (int i = 0, j = items.Count - 1; i < j; i++, j--)
            {
                object tempI = items[i];
                object tempJ = items[j];

                items.RemoveAt(j);
                items.RemoveAt(i);

                items.Insert(i, tempJ);
                items.Insert(j, tempI);
            }
            lb.EndUpdate();
        }
예제 #14
0
        /// <summary>
        /// Get the list of assemblies from the list on the screen.
        /// </summary>
        private string[] GetSerializedAssemblies()
        {
            if (listReferences.Items.Count > 0)
            {
                ListBox.ObjectCollection items = listReferences.Items;
                int      count = items.Count;
                string[] r     = new string[count];

                for (int i = 0; i < count; i++)
                {
                    r[i] = items[i].ToString();
                }

                return(r);
            }
            else
            {
                return(null);
            }
        }
예제 #15
0
 public frmTuples(String or, ListBox.ObjectCollection dims)
 {
     InitializeComponent();
     orientation = or;
     if (orientation == "Slicer")
     {
         lblDimTuples.Text = or + "set :";
         this.Text         = or + " Selection";
         lboDimensions.Items.AddRange(dims);
         selections = new ArrayList();
         this.btnAddTuple_Click(new Object(), new EventArgs());
     }
     else
     {
         lblDimTuples.Text = or + "sets :";
         this.Text         = or + "set Selection";
         lboDimensions.Items.AddRange(dims);
         selections = new ArrayList();
     }
 }
예제 #16
0
 private void addExButton_Click(object sender, EventArgs e)
 {
     if (textBoxEx.Text != null)
     {
         String stringEx = textBoxEx.Text;
         if (stringEx.Equals("") || listBoxEx.Items.Contains(stringEx))
         {
             //do nothing
         }
         else
         {
             listBoxEx.Items.Add(stringEx);
             ListBox.ObjectCollection myItems = listBoxEx.Items;
             string output = JsonConvert.SerializeObject(myItems);
             AraMonitoring.Properties.Settings.Default.ex = output;
             AraMonitoring.Properties.Settings.Default.Save();
             System.Console.WriteLine(output);
         }
     }
 }
예제 #17
0
        private void listboxMix()
        {
            // 리스트 박스 랜덤 섞기

            ListBox.ObjectCollection list = lstPlayer.Items;
            Random rng = new Random();
            int    n   = list.Count;

            lstPlayer.BeginUpdate();
            while (n > 1)
            {
                n--;
                int    k     = rng.Next(n + 1);
                object value = list[k];
                list[k] = list[n];
                list[n] = value;
            }
            lstPlayer.EndUpdate();
            lstPlayer.Invalidate();
        }
예제 #18
0
        private void processdirlist()
        {
            int index;

            //IEnumerator lb_enumerator =  lb_directories.Items.GetEnumerator();
            ListBox.ObjectCollection dirs_to_process = lb_directories.Items;

            foreach (String dir in directories)
            {
                processdirectory(dir);
                lb_directories.Invoke((MethodInvoker) delegate
                {
                    index = lb_directories.Items.IndexOf(dir);
                    if (index >= 0)
                    {
                        lb_directories.Items[index] = dir + " -- done";
                    }
                });
            }
        }
예제 #19
0
파일: Type5.cs 프로젝트: titu84/Exam
        string concateArray(ListBox.ObjectCollection arr)
        {
            string result = "";

            if (arr.Count > 0)
            {
                for (int i = 0; i < arr.Count; i++)
                {
                    if (i == arr.Count - 1)
                    {
                        result += arr[i].ToString();
                    }
                    else
                    {
                        result += arr[i].ToString() + ";";
                    }
                }
            }
            return(result);
        }
예제 #20
0
        AddItem <TItem, TContainedValue>
        (
            TItem item
        )
            where TItem : FormattableValue <TContainedValue>

            where TContainedValue : IEquatable <TContainedValue>,
        IComparable <TContainedValue>, IFormattable
        {
            AssertValid();

            ListBox.ObjectCollection oItems = this.Items;
            Int32 iItems = oItems.Count;
            Int32 iInsertionIndex;

            for (iInsertionIndex = 0; iInsertionIndex < iItems; iInsertionIndex++)
            {
                Debug.Assert(oItems[iInsertionIndex] is TItem);

                TItem oFormattableValue = (TItem)oItems[iInsertionIndex];

                Int32 iCompareTo = item.CompareTo(oFormattableValue);

                if (iCompareTo == 0)
                {
                    // The ListBox contains an item with the same contained value.
                    // Don't add another such item.

                    return;
                }

                if (iCompareTo < 0)
                {
                    break;
                }
            }

            this.ClearSelected();
            oItems.Insert(iInsertionIndex, item);
            this.SelectedIndex = iInsertionIndex;
        }
예제 #21
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Clear all NUTs from the list? You'll lose any unsaved work!", "Clear all NUTs?", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                listBox1.Items.Clear();
                listBox2.Items.Clear();
                Runtime.TextureContainers.Clear();
                ListBox.ObjectCollection items = listBox1.Items;
                for (int i = items.Count - 1; i >= 0; i--)
                {
                    Runtime.TextureContainers.RemoveAt(i);
                    Runtime.TextureContainers.ElementAt(i).Destroy();
                }
            }
            else if (dialogResult == DialogResult.No)
            {
                //do nothing. Alternatively the else if statement can be removed.
            }
        }
예제 #22
0
        private void Ordenar()
        {
            ListBox.ObjectCollection list            = lstNames.Items;
            List <string>            listStringNames = new List <string>();

            foreach (var item in list)
            {
                listStringNames.Add(item.ToString());
            }

            /*
             * listStringNames = (from s in listStringNames select s)
             * .OrderBy(x => x)
             * .ToList();*/
            listStringNames.Sort(); //Maneira Simples;
            lstNames.Items.Clear();
            foreach (var item in listStringNames)
            {
                lstNames.Items.Add(item);
            }
        }
예제 #23
0
파일: Form1.cs 프로젝트: Wieun/USW
        private void btnShuffle_Click(object sender, EventArgs e)
        {
            optUnsorted.Checked = true;
            ListBox.ObjectCollection list = lstNumberList.Items;
            Random rnd         = new Random();
            int    NoOfNumbers = list.Count;

            lstNumberList.BeginUpdate();
            while (NoOfNumbers > 1)
            {
                NoOfNumbers--;
                int    k     = rnd.Next(NoOfNumbers + 1);
                object value = list[k];
                list[k]           = list[NoOfNumbers];
                list[NoOfNumbers] = value;
            }
            lstNumberList.EndUpdate();
            lstNumberList.Invalidate();
            buttonManager();
            statistics();
        }
예제 #24
0
 private int GetIndexOf(object o)
 {
     ListBox.ObjectCollection items = Items;
     for (int i = 0; i < items.Count; i++)
     {
         if (items[i].Equals(o))
         {
             return(i);
         }
     }
     if (o == null)
     {
         throw new Exception("Object is null.");
     }
     string[] x = new string[items.Count];
     for (int i = 0; i < x.Length; i++)
     {
         x[i] = items[i].ToString();
     }
     throw new Exception(o + " is not contained. Values are " + StringUtils.Concat(",", x));
 }
예제 #25
0
        /// <summary>
        /// 将号码组合并分组
        /// </summary>
        /// <param name="nums"></param>
        /// <returns></returns>
        public void SetAllGroup(ListBox.ObjectCollection nums)
        {
            step1.Group.Clear();
            //获取组数计算组合
            int[]        arr            = GetArr(nums.Count);
            List <int[]> lstCombination = PermutationAndCombination <int> .GetCombination(arr, 4);

            int nIndex = 0;

            //根据下标将索引转换成号码组
            foreach (var item in lstCombination)
            {
                nIndex++;
                string[] value = new string[4];
                for (int i = 0; i < item.Length; i++)
                {
                    value[i] = Convert.ToString(nums[item[i]]);
                }
                step1.Group.TryAdd(nIndex, value);
            }
        }
예제 #26
0
 public F_Encheres(Gerant _unGerant, ListBox.ObjectCollection _itemsLapinsEquipe, ListBox.ObjectCollection _itemLapinsLibres, int _pos, Label count, Label budget)
 {
     InitializeComponent();
     btn_refresh.Click     += F_Encheres_Click;
     btn_valider.Click     += Btn_valider_Click;
     tb_offre.TextChanged  += Tb_offre_TextChanged;
     this.position          = _pos;
     this.unGerant          = _unGerant;
     this.itemLapinsLibres  = _itemLapinsLibres;
     this.itemsLapinsEquipe = _itemsLapinsEquipe;
     this.leLapin           = (Lapins)this.itemLapinsLibres[this.position];
     this.items_Count       = count;
     this.gerantBudget      = budget;
     this.l_vitesse.Text    = this.leLapin.Vitesse.ToString();
     this.l_endurance.Text  = this.leLapin.Endurance.ToString();
     this.l_chance.Text     = this.leLapin.Chance.ToString();
     this.l_leLapin.Text    = this.leLapin.ToString();
     this.l_offreA.Text     = this.leLapin.OffreMinimal.ToString() + " $";
     this.l_valeurL.Text    = this.leLapin.Valeur.ToString() + " $";
     this.l_prixMax.Text    = (this.leLapin.Valeur * 1.10).ToString() + " $";
 }
예제 #27
0
        private void btnConvert_Click(object sender, EventArgs e)
        {
            if (!File.Exists(toolPath + "/texconv.exe"))
            {
                MessageBox.Show("Cannot find texconv.exe under tool directory.\n\nPlease ensure ModSDK is installed.", "Error (01)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (!Directory.Exists(gamePath))
            {
                MessageBox.Show("Game path is wrong.\n\nPlease ensure game is installed.", "Error (02)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            currentfiles = 0;
            Items        = lbfolderList.Items;
            var asyncThreadParamInit = new ThreadStart(doConvertAll);
            //doConvertAll();
            var mthd = new Thread(asyncThreadParamInit);

            mthd.Start();
        }
예제 #28
0
        private string getCommonPart(ListBox.ObjectCollection fnames)
        {
            string res = "";

            try
            {
                res = Path.GetFileNameWithoutExtension(fnames[0].ToString());
                if (fnames.Count > 1)
                {
                    int    posOfCommonPart = -1;
                    string f1 = Path.GetFileNameWithoutExtension(fnames[0].ToString());
                    for (int j = 1; j < fnames.Count; j++)
                    {
                        string f2 = Path.GetFileNameWithoutExtension(fnames[j].ToString());
                        for (int i = Math.Min(f1.Length, f2.Length); i > 0; i--)
                        {
                            if (f1.Substring(0, i) == f2.Substring(0, i))
                            {
                                if (posOfCommonPart > 0)
                                {
                                    posOfCommonPart = Math.Min(posOfCommonPart, i);
                                }
                                else
                                {
                                    posOfCommonPart = i;
                                }

                                break;
                            }
                        }
                    }
                    if (posOfCommonPart > 0)
                    {
                        res = f1.Substring(0, posOfCommonPart);
                    }
                }
            }
            catch { }
            return(res);
        }
예제 #29
0
        public void writeXmlCategory(ListBox.ObjectCollection items)
        {
            XmlTextWriter xwriter = new XmlTextWriter("savefile.xml", Encoding.Unicode);

            xwriter.WriteStartDocument();
            xwriter.WriteStartElement("XMLFILE");
            xwriter.WriteStartElement("Title");
            xwriter.WriteString("Kategorier");
            xwriter.WriteEndElement();
            foreach (String item in items)

            {
                xwriter.WriteStartElement("Item");
                xwriter.WriteString(item);
                xwriter.WriteEndElement();
            }
            xwriter.WriteEndElement();
            xwriter.WriteEndDocument();

            xwriter.Close();
            MessageBox.Show("Sparat!");
        }
예제 #30
0
 public void bindServer(ListBox.ObjectCollection listBox)
 {
     listBox2.Items.Clear();
     foreach (string sIP in listBox)
     {
         //string URL = "http://" + sIP + "/api/health/makehealthy?u=healthadmin&p=WTp75Lu9Tc";
         string         URL     = "http://" + sIP + "/api/health/makehealthy?u=healthadmin&p=healthy2018";
         HttpWebRequest request = WebRequest.Create(URL) as HttpWebRequest;
         using (HttpWebResponse s = (HttpWebResponse)request.GetResponse())
         {
             int scode = (int)s.StatusCode;
             if (scode == 200)
             {
                 listBox2.Items.Add(sIP + ":Bind");
             }
             else
             {
                 listBox2.Items.Add(sIP + ":Not able Bind");
             }
         }
     }
 }