Ejemplo n.º 1
0
 public static System.Windows.Forms.ListBox.ObjectCollection get_ItemsTSS(
     System.Windows.Forms.ListBox target)
 {
     System.Windows.Forms.ListBox.ObjectCollection objColl = new System.Windows.Forms.ListBox.ObjectCollection(target);
     objColl.Add("Testing");
     objColl.Add("Testing1");
     objColl.Add("Testing2");
     return(objColl);
 }
Ejemplo n.º 2
0
        void Gamilt(int k, ref System.Windows.Forms.ListBox.ObjectCollection Items)
        {
            int y  = Lib.arrPath[k - 1];
            int LL = 0;

            if (Nodes[y].Edge != null)
            {
                LL = Nodes[y].Edge.Length;
                for (int i = 0; i < LL; i++)
                {
                    int u = Nodes[y].Edge[i].numNode;
                    if (k == Nodes.Length + 1)
                    {
                        Lib.arrPath[k] = u;
                        Items.Add(SetPath(0)); // вывести путь
                    }
                    else
                    if (!Nodes[u].visit)
                    {
                        Lib.arrPath[k] = u;
                        Nodes[u].visit = true;     // отметить посещенный
                        Gamilt(k + 1, ref Items);
                        Nodes[u].visit = false;    // отметить посещенный
                    }
                }
            }
        }
Ejemplo n.º 3
0
        PopulateSourceColumnsCheckedListBox()
        {
            AssertValid();

            System.Windows.Forms.ListBox.ObjectCollection oItems =
                clbSourceColumns.Items;

            oItems.Clear();

            // Attempt to get the non-empty range of the active worksheet of the
            // selected source workbook.

            Range oNonEmptyRange;

            if (!TryGetSourceWorkbookNonEmptyRange(out oNonEmptyRange))
            {
                return;
            }

            Boolean bSourceColumnsHaveHeaders =
                cbxSourceColumnsHaveHeaders.Checked;

            // Get the first row and column of the non-empty range.

            Range oFirstRow = oNonEmptyRange.get_Resize(1, Missing.Value);
            Range oColumn   = oNonEmptyRange.get_Resize(Missing.Value, 1);

            Object [,] oFirstRowValues = ExcelUtil.GetRangeValues(oFirstRow);

            // Loop through the columns.

            Int32 iNonEmptyColumns = oNonEmptyRange.Columns.Count;
            Int32 iColumnOneBased  = oColumn.Column;

            for (Int32 i = 1; i <= iNonEmptyColumns; i++, iColumnOneBased++)
            {
                String sColumnLetter = ExcelUtil.GetColumnLetter(
                    ExcelUtil.GetRangeAddress((Range)oColumn.Cells[1, 1]));

                // Get the value of the column's first cell, if there is one.

                String sFirstCellValue;

                if (!ExcelUtil.TryGetNonEmptyStringFromCell(oFirstRowValues, 1,
                                                            i, out sFirstCellValue))
                {
                    sFirstCellValue = null;
                }

                String sItemText = GetSourceColumnItemText(sFirstCellValue,
                                                           sColumnLetter, bSourceColumnsHaveHeaders);

                oItems.Add(new ObjectWithText(iColumnOneBased, sItemText));

                // Move to the next column.

                oColumn = oColumn.get_Offset(0, 1);
            }
        }
Ejemplo n.º 4
0
        void GamiltC(int k, ref System.Windows.Forms.ListBox.ObjectCollection Items)
        {
            int sum   = 0;
            int count = 0;
            int y     = Lib.arrPath[k - 1]; // номер узла
            int LL    = 0;

            if (Nodes[y].Edge != null)
            {
                LL = Nodes[y].Edge.Length;
                for (int i = 0; i < LL; i++)
                {
                    sum = Nodes[y].Edge[i].A;

                    int u = Nodes[y].Edge[i].numNode; // номер соседнего узла
                    if (k == Nodes.Length + 1)        // прошли по всем узлам
                    {
                        Lib.arrPath[k] = u;
                        int m = Test(y); // у узла "y" есть ребро, показыающее на begNode
                        if (m != -1)     // если цикл замкнут
                        {
                            sumDist += Nodes[y].Edge[m].A;
                            Items.Add(SetPath(sumDist)); // вывести путь

                            count++;
                            Program.formListBox.progressBar1.Value = count;
                            Program.formListBox.progressBar1.Refresh();

                            PathGam p = new PathGam();
                            p.sum = sumDist;
                            for (int j = 1; j < k; j++)
                            {
                                p.path.Add(Lib.arrPath[j]);
                            }
                            Lib.pathsGam.Add(p);

                            sumDist -= Nodes[y].Edge[m].A;
                            return;
                        }
                    }
                    else
                    if (!Nodes[u].visit)
                    {
                        Lib.arrPath[k] = u;
                        sumDist       += sum;
                        Nodes[u].visit = true;     // отметить посещенный

                        GamiltC(k + 1, ref Items);

                        sumDist       -= sum;
                        Nodes[u].visit = false;    // отменить посещенный
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void SetEvent(GEDCOMRecordWithEvents record, string evName, string date)
        {
            int[]             val = new int[3];
            GEDCOMCustomEvent evt = fBase.Context.CreateEventEx(record, evName, "", "");

            try
            {
                string prefix = "";
                if (date.IndexOf("п.") == 0)
                {
                    prefix = "AFT ";
                    date   = date.Remove(0, 2);
                }
                else if (date.IndexOf("после") == 0)
                {
                    prefix = "AFT ";
                    date   = date.Remove(0, 5);
                }
                else if (date.IndexOf("до") == 0)
                {
                    prefix = "BEF ";
                    date   = date.Remove(0, 2);
                }
                else if (date.IndexOf("ок.") == 0)
                {
                    prefix = "ABT ";
                    date   = date.Remove(0, 3);
                }
                else if (date.IndexOf("около") == 0)
                {
                    prefix = "ABT ";
                    date   = date.Remove(0, 5);
                }

                date = date.Trim();

                string   tmp  = "";
                string[] toks = date.Split('.');
                if (toks.Length > 3)
                {
                    throw new ImporterException("date failed");
                }
                string ym = "";

                for (int i = 0; i < toks.Length; i++)
                {
                    tmp = toks[i];

                    int x = tmp.IndexOf("/");
                    if (x >= 0)
                    {
                        ym  = tmp.Substring(x + 1, tmp.Length - x - 1);
                        tmp = tmp.Remove(x, ym.Length + 1);
                    }

                    val[i] = int.Parse(tmp);
                }

                if (toks.Length != 1)
                {
                    if (toks.Length != 2)
                    {
                        if (toks.Length == 3)
                        {
                            tmp = val[0].ToString() + " " + GEDCOMCustomDate.GEDCOMMonthArray[val[1] - 1] + " " + val[2].ToString();
                        }
                    }
                    else
                    {
                        tmp = GEDCOMCustomDate.GEDCOMMonthArray[val[0] - 1] + " " + val[1].ToString();
                    }
                }
                else
                {
                    tmp = val[0].ToString();
                }

                tmp = prefix + tmp;
                if (ym != "")
                {
                    tmp = tmp + "/" + ym;
                }

                evt.Date.ParseString(tmp);
            }
            catch (Exception)
            {
                fLog.Add(">>>> " + fLangMan.LS(ILS.LSID_ParseError_DateInvalid) + " \"" + date + "\"");
            }
        }