Example #1
0
 public FilterGroup(string name)
     : base(name)
 {
     itemsCore = new System.ComponentModel.BindingList <FilterTreeNode>();
     itemsCore.Add(new FilterItem("Item0"));
     itemsCore.Add(new FilterItem("Item1"));
 }
Example #2
0
    /// <summary>
    /// Adds the elements of the specified collection to the end of the <see cref="System.ComponentModel.BindingList{T}"/>,
    /// while only firing the <see cref="System.ComponentModel.BindingList{T}.ListChanged"/>-event once.
    /// </summary>
    /// <typeparam name="T">
    /// The type T of the values of the <see cref="System.ComponentModel.BindingList{T}"/>.
    /// </typeparam>
    /// <param name="bindingList">
    /// The <see cref="System.ComponentModel.BindingList{T}"/> to which the values shall be added.
    /// </param>
    /// <param name="collection">
    /// The collection whose elements should be added to the end of the <see cref="System.ComponentModel.BindingList{T}"/>.
    /// The collection itself cannot be null, but it can contain elements that are null,
    /// if type T is a reference type.
    /// </param>
    /// <exception cref="ArgumentNullException">values is null.</exception>
    public static void AddRange <T>(this System.ComponentModel.BindingList <T> bindingList, IEnumerable <T> collection)
    {
        // The given collection may not be null.
        if (collection == null)
        {
            throw new ArgumentNullException(nameof(collection));
        }
        // Remember the current setting for RaiseListChangedEvents
        // (if it was already deactivated, we shouldn't activate it after adding!).
        var oldRaiseEventsValue = bindingList.RaiseListChangedEvents;

        // Try adding all of the elements to the binding list.
        try
        {
            bindingList.RaiseListChangedEvents = false;
            foreach (var value in collection)
            {
                bindingList.Add(value);
            }
        }
        // Restore the old setting for RaiseListChangedEvents (even if there was an exception),
        // and fire the ListChanged-event once (if RaiseListChangedEvents is activated).
        finally
        {
            bindingList.RaiseListChangedEvents = oldRaiseEventsValue;
            if (bindingList.RaiseListChangedEvents)
            {
                bindingList.ResetBindings();
            }
        }
    }
Example #3
0
        static void _tmrReadLogging_Tick(object sender, EventArgs e)
        {
            try
            {
                using (var streamReader = new System.IO.StreamReader(string.Format(@"\\{0}\logging$\verbose.log", _remoteIP)))
                {
                    if (streamReader.BaseStream.Length < LastStreamOffset)
                    {
                        LastStreamOffset = 0;
                    }
                    streamReader.BaseStream.Seek(LastStreamOffset, SeekOrigin.Begin);

                    //read out of the file until the EOF
                    string line = "";
                    while ((line = streamReader.ReadLine()) != null)
                    {
                        var logLine = line.Split(';');
                        var logging = new LoggingInfo(logLine[0], logLine[1], logLine[2], logLine[3]);

                        Lines.Add(logging);
                    }

                    //update the last max offset
                    LastStreamOffset = streamReader.BaseStream.Position;
                }
            }
            catch (Exception exc)
            {
            }
        }
    public override Control Reconcile(IEnumerable<PricingItem> mlpSource_, IEnumerable<PricingItem> dsSource_)
    {
      var allCodes = mlpSource_.Union(dsSource_).Select(x => x.SymmetryCode).Distinct();

      var lines = new System.ComponentModel.BindingList<CloseItem>();

      foreach (var symcode in allCodes)
      {

        var line = new CloseItem();
        line.SymmetryCode = symcode;

        {
          var mlpitem = mlpSource_.Where(x => x.SymmetryCode.Equals(symcode)).FirstOrDefault();
          if (mlpitem != null) line.MLPPrice = mlpitem.Value;
        }

        {
          var dsItem = dsSource_.Where(x => x.SymmetryCode.Equals(symcode)).FirstOrDefault();
          if (dsItem != null) line.DSPrice = dsItem.Value;
        }

        lines.Add(line);
      }

      var grid = lines.DisplayInGrid(m_name,displayInShowForm_:false);
      grid.SetHeaderClickSort();
      return grid;
    }
Example #5
0
        public ProfileManager()
        {
            Serializer = new XmlSerializer(typeof(User));

            CurrentUsers = new List <User>();

            CurrentPath = Directory.GetCurrentDirectory();

            TargetPath = Path.Combine(CurrentPath, "Profiles");

            try
            {
                ProfileFolder = Directory.CreateDirectory(TargetPath);
            }
            catch { throw; }

            UserNames = new System.ComponentModel.BindingList <string>();

            foreach (FileInfo folder in ProfileFolder.EnumerateFiles("*.xml"))
            {
                try
                {
                    ReadUserFromFile(folder.FullName);
                }
                catch
                {
                    throw;
                }
            }

            foreach (User usr in CurrentUsers)
            {
                UserNames.Add(usr.Name);
            }
        }
 public void Add(object obj)
 {
     if (obj == null)
     {
         throw new ArgumentNullException();
     }
     //if (obj is XObject) ((XObject)obj).SetParent(this is XElement ? (XElement)this : null);
     mElements.Add(obj);
 }
 /// <summary>
 /// 根据泛型IList 返回数据绑定的集合类。
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="dataArray"></param>
 /// <returns></returns>
 public System.ComponentModel.BindingList <T> CreateBindingList <T>(IList dataArray)
 {
     System.ComponentModel.BindingList <T> dataList = new System.ComponentModel.BindingList <T>();
     if (dataArray != null && dataArray.Count > 0)
     {
         foreach (T info in dataArray)
         {
             dataList.Add(info);
         }
     }
     return(dataList);
 }
Example #8
0
        public Action SearchDirectory(DirectoryInfo directory)
        {
            return(() =>
            {
                Queue <DirectoryInfo> folders = new Queue <DirectoryInfo>();
                var uik = false;
                folders.Enqueue(directory);
                var _already_mounted = already_mounted.Select(a => a.Name);
                while (folders.Count != 0)
                {
                    try
                    {
                        var currentFolder = folders.Dequeue();
                        _dispatcher.Invoke(() => lbl_status.Text = $"Searching Folder {currentFolder.FullName}");
                        foreach (var file in currentFolder.GetFiles("gameinfo.txt", System.IO.SearchOption.TopDirectoryOnly))
                        {
                            if (_already_mounted.Contains(currentFolder.Name))
                            {
                                Logger.Debug("Found already mounted game: {}", currentFolder.FullName);
                                continue;
                            }
                            var mount = new Mount(file.DirectoryName, currentFolder.Name);
                            Logger.Debug("Found Game: {}", currentFolder.FullName);
                            _dispatcher.Invoke(() => Results.Add(mount));
                            if (!uik)
                            {
                                uik = true; _dispatcher.Invoke(() => lst_results.StretchLastColumn());
                            }
                            // _dispatcher.Invoke(() => Text = $"Searching in {currentFolder.Name.Quote()} - {Results.Count} Results");
                            _dispatcher.Invoke(() => toolStripProgressBar1.ProgressBar.Value++);
                        }

                        foreach (var _current in currentFolder.GetDirectories("*", System.IO.SearchOption.TopDirectoryOnly))
                        {
                            folders.Enqueue(_current);
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ex is UnauthorizedAccessException || ex is DirectoryNotFoundException)
                        {
                        }
                        else
                        {
                            Logger.Error(ex.ToString());
                        }
                    }
                }
            });
        }
Example #9
0
        protected IList <TEntity> protectedSelect(IDataProvider dataProvider)
        {
            var          ret          = new System.ComponentModel.BindingList <TEntity>();
            SqlStatement sqlStatement = DbSqlFactories.BuildSelectSqlStatement(dataProvider.DatabaseContext.DbTranslator,
                                                                               this.entityInfo, whereExpr, range, order);

            dataProvider.ExecuteReader(sqlStatement, delegate(IDataReader dr)
            {
                while (dr.Read())
                {
                    DataReaderDeserializer deserializer = entityInfo.GetDataReaderDeserializer(dr);
                    do
                    {
                        ret.Add((TEntity)deserializer(dr));
                    }while (dr.Read());
                }
            });
            return(ret);
        }
Example #10
0
        public override void CreateROI(HalconDotNet.HWindow window, double row, double col)
        {
            HalconDotNet.HObject polygonXLD = new HalconDotNet.HObject();
            HalconDotNet.HTuple  tmpRows    = new HalconDotNet.HTuple();
            HalconDotNet.HTuple  tmpCols    = new HalconDotNet.HTuple();
            HalconDotNet.HTuple  tmpWights  = new HalconDotNet.HTuple();

            HalconDotNet.HTuple area    = new HalconDotNet.HTuple();
            HalconDotNet.HTuple r       = new HalconDotNet.HTuple();
            HalconDotNet.HTuple c       = new HalconDotNet.HTuple();
            HalconDotNet.HTuple pointer = new HalconDotNet.HTuple();

            try
            {
                polygonXLD.Dispose();
                HalconDotNet.HOperatorSet.DrawNurbs(out polygonXLD, window, "true", "true", "true", "true", 3,
                                                    out tmpRows, out tmpCols, out tmpWights);
                if (tmpRows.TupleLength() > 0)
                {
                    polygonXLD.Dispose();
                    HalconDotNet.HOperatorSet.GenContourPolygonXld(out polygonXLD, tmpRows, tmpCols);
                    HalconDotNet.HOperatorSet.AreaCenterXld(polygonXLD, out area, out r, out c, out pointer);

                    _locateRow = r[0].D;
                    _locateCol = c[0].D;

                    window.DispPolygon(tmpRows, tmpCols);
                    window.DispRectangle2(_locateRow, _locateCol, 0, 5, 5); //几何中心
                    this._numHandles = tmpRows.TupleLength() + 1;           //几何中心+边点

                    for (int i = 0; i < tmpRows.TupleLength(); i++)
                    {
                        _sizeRows.Add(tmpRows[i].D);
                        _sizeCols.Add(tmpCols[i].D);
                        window.DispRectangle2(tmpRows[i].D, tmpCols[i].D, 0, 2, 2);
                    }
                }
            }
            catch (HalconDotNet.HalconException hex)
            {
            }
        }
Example #11
0
        private static DataModel.MetadataItem ExtractItem(
            System.ComponentModel.BindingList <DataModel.MetadataItem> list,
            ActiveQueryBuilder.Core.MetadataItem mi,
            int parentID
            )
        {
            var o = new DataModel.MetadataItem( );

            {
                o.MetadataProvider = mi.SQLContext?.MetadataProvider.Description;
                o.SyntaxProvider   = mi.SQLContext?.SyntaxProvider.Description;
                o.ID       = list.Count;
                o.ParentID = parentID;
                if (mi.Parent != null)
                {
                    o.ParentType = System.Enum.GetName(typeof(ActiveQueryBuilder.Core.MetadataType), mi.Parent.Type);
                }
                o.Type     = System.Enum.GetName(typeof(ActiveQueryBuilder.Core.MetadataType), mi.Type);
                o.IsSystem = mi.System;
                //
                // o.RootName = item.Root?.Name;
                o.Server     = mi.Server?.Name;
                o.Database   = mi.Database?.Name;
                o.Schema     = mi.Schema?.Name;
                o.ObjectName = mi.Object?.Name;
                //
                o.NameFullQualified  = mi.NameFull;
                o.NameFullQualified += mi.NameFull.EndsWith(".") ? "<?>" : "";
                o.NameQuoted         = mi.NameQuoted;
                o.AltName            = mi.AltName;
                o.Field              = mi.Name != null ? mi.Name : "<?>";
                //
                //
                o.HasDefault  = mi.Default;
                o.Description = mi.Description;
                o.Tag         = mi.Tag;
                o.UserData    = mi.UserData;
            }
            list.Add(o);
            return(o);
        }
Example #12
0
    public override Control Reconcile(IEnumerable<PricingItem> mlpSource_, IEnumerable<PricingItem> dsSource_)
    {
      var allCodes = mlpSource_.Union(dsSource_).Select(x => x.SymmetryCode).Distinct();

      var lines = new System.ComponentModel.BindingList<CompareItem>();

      foreach(var symCode in allCodes)
      {
        var mlpItem = mlpSource_.Where(x => x.SymmetryCode.Equals(symCode)).FirstOrDefault();

        var dsItem = dsSource_.Where(x => x.SymmetryCode.Equals(symCode))
          // want to see the underlying price source (will be tweb most of the time, else reuters)
          .Where(x => x.QuoteSourceCode.Equals("SYM")).FirstOrDefault();

        var line = new CompareItem();

        if(mlpItem!=null)
        {
          line.SetCommon(mlpItem);
          line.MLPPrice = mlpItem.Value;
        }

        if(dsItem!=null)
        {
          line.SetCommon(dsItem);
          line.DSSnapCode = dsItem.SnapCode;
          line.DSPrice = dsItem.Value;
          //line.DSSources = string.Join(",", dsSource_.Where(x => x.SymmetryCode.Equals(symCode) && !x.QuoteSourceCode.Equals("SYM")).Select(x => x.QuoteSourceCode).OrderBy(x=>x).ToArray());
          line.DSSources = string.Join(", ", dsSource_.Where(x => x.SymmetryCode.Equals(symCode) && !x.QuoteSourceCode.Equals("SYM")).OrderBy(x=>x.QuoteSourceCode).Select(x => string.Format("{0}:{1}", x.QuoteSourceCode, x.Value)).ToArray());
        }
        lines.Add(line);
      }

      var control = new CurveCompareControl();
      control.Create(lines);
      //control.DisplayInShowForm(string.Format("{0} curve", m_codeBase));
      return control;
    }
Example #13
0
    public override Control Reconcile(IEnumerable<PricingItem> mlpSource_, IEnumerable<PricingItem> dsSource_)
    {
      var allCodes = mlpSource_.Union(dsSource_).Select(x => x.SymmetryCode).Distinct();

      var lines = new System.ComponentModel.BindingList<BondReconcileLine>();

      foreach(var symCode in allCodes)
      {
        var mlpItem = mlpSource_.Where(x => x.SymmetryCode.Equals(symCode)).FirstOrDefault();

        var dsItem = dsSource_.Where(x => x.SymmetryCode.Equals(symCode)).FirstOrDefault();

        var line = new BondReconcileLine();

        if(mlpItem!=null)
        {
          line.SetCommon(mlpItem);
          line.MLPPrice = mlpItem.Value;
        }

        if(dsItem!=null)
        {
          line.SetCommon(dsItem);
          line.DSPrice = dsItem.Value;
          line.DS_Source = dsItem.QuoteSourceCode;
        }
        lines.Add(line);
      }

      var control = new BondCompareControl();
      control.Create(lines);
      return control;
      //var grid = lines.DisplayInGrid(string.Format("{0} . Bond CleanPrice Reconciliation",m_name),displayInShowForm_:false);
      //grid.SetHeaderClickSort();
      //return grid;
    }
        bool isPsp1 = false;     //Hack, but works.

        public WeaponParamFile(string inFilename, byte[] rawData, byte[] subHeader, int[] ptrs, int baseAddr)
        {
            header   = subHeader;
            filename = inFilename;
            byte[] tempData = new byte[rawData.Length];
            Array.Copy(rawData, tempData, rawData.Length);
            calculatedPointers = new int[ptrs.Length]; //It may be populated now, but NOT FINAL UNTIL IT'S FINAL.
            for (int i = 0; i < ptrs.Length; i++)
            {
                calculatedPointers[i] = ptrs[i] - baseAddr;
                int    ptrLoc = BitConverter.ToInt32(rawData, calculatedPointers[i]);
                byte[] temp   = BitConverter.GetBytes(ptrLoc - baseAddr);
                Array.Copy(temp, 0, tempData, calculatedPointers[i], temp.Length);
            }
            int          numEntries = 14; //Max number of weapons per manufacturer.
            MemoryStream rawStream  = new MemoryStream(tempData);
            BinaryReader rawReader  = new BinaryReader(rawStream);

            rawStream.Seek(4, SeekOrigin.Begin);
            int fileLength = rawReader.ReadInt32(); //Use to check dummy pointers? The file can happily go over!
            int headerLoc  = rawReader.ReadInt32();

            rawStream.Seek(0x14, SeekOrigin.Begin);
            if (rawReader.ReadInt32() == 0x61726761)
            {
                dataType   = 2;
                numEntries = 80;
            }

            rawStream.Seek(headerLoc, SeekOrigin.Begin);
            int equipPacketLoc = rawReader.ReadInt32();

            weaponClassValue = rawReader.ReadInt32();
            int[] dataLocs        = new int[4];
            int   lowestDataLoc   = 0xFFFFFF;
            int   lowestDataIndex = -1;
            int   secondDataLoc   = headerLoc;
            int   secondDataIndex = -1;

            for (int i = 0; i < 4; i++)
            {
                dataLocs[i] = rawReader.ReadInt32();
                if (dataLocs[i] != 0 && dataLocs[i] < lowestDataLoc)
                {
                    lowestDataLoc   = dataLocs[i];
                    lowestDataIndex = i;
                }
            }
            for (int i = 0; i < 4; i++)
            {
                if (dataLocs[i] != 0 && dataLocs[i] != lowestDataLoc && dataLocs[i] < secondDataLoc)
                {
                    secondDataLoc   = dataLocs[i];
                    secondDataIndex = i;
                }
            }
            byte[][] validWeapons = new byte[4][];
            if (dataType == 2)
            {
                packetCount = rawReader.ReadByte();
                weaponType  = rawReader.ReadByte();
                equipStat   = rawReader.ReadInt16();
            }

            int[] weaponCounts = new int[4];

            int indexLoc = (int)rawStream.Position;

            byte[] firstFour = rawReader.ReadBytes(4);
            byte   expected  = 0;

            for (int i = 0; i < 4; i++)
            {
                if (firstFour[i] != 0xFF && firstFour[i] != expected)
                {
                    isPsp1      = true;
                    packetCount = rawReader.ReadByte();
                    weaponType  = rawReader.ReadByte();
                    equipStat   = rawReader.ReadInt16();
                    break;
                }
                else if (firstFour[i] == expected)
                {
                    expected++;
                }
            }

            if (!isPsp1)
            {
                rawStream.Seek(indexLoc, SeekOrigin.Begin);
                for (int i = 0; i < 4; i++)
                {
                    validWeapons[i] = rawReader.ReadBytes(numEntries);
                    for (int j = 0; j < validWeapons[i].Length; j++)
                    {
                        if (validWeapons[i][j] != 0xFF)
                        {
                            weaponCounts[i]++;
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < 4; i++)
                {
                    if (dataLocs[i] != 0)
                    {
                        bool found = false;
                        for (int j = i + 1; j < 4; j++)
                        {
                            if (dataLocs[j] != 0)
                            {
                                weaponCounts[i] = (dataLocs[j] - dataLocs[i]) / 38;
                                found           = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            weaponCounts[i] = (headerLoc - dataLocs[i]) / 38;
                        }
                    }
                }
            }

            if (dataType != 2 && !isPsp1)
            {
                packetCount = rawReader.ReadByte();
                weaponType  = rawReader.ReadByte();
                equipStat   = rawReader.ReadInt16();
            }
            if (!isPsp1 && (lowestDataIndex == -1 || weaponCounts[lowestDataIndex] * 0x40 <= secondDataLoc - lowestDataLoc))
            {
                dataType = 1;
                throw new Exception("v1 weapons file not supported yet");
                //entry
            }
            if (equipPacketLoc < lowestDataLoc && packetCount > 0)
            {
                rawStream.Seek(equipPacketLoc, SeekOrigin.Begin);
                equipPacket = rawReader.ReadBytes(packetCount * 8);
                //parsedPackets = new EquipPacket[packetCount];
                for (int i = 0; i < packetCount; i++)
                {
                    EquipPacket tempPacket = new EquipPacket();
                    tempPacket.Value1 = BitConverter.ToInt16(equipPacket, i * 8 + 0);
                    tempPacket.Value2 = BitConverter.ToInt16(equipPacket, i * 8 + 2);
                    tempPacket.Value3 = BitConverter.ToInt16(equipPacket, i * 8 + 4);
                    tempPacket.Value4 = BitConverter.ToInt16(equipPacket, i * 8 + 6);
                    parsedPackets.Add(tempPacket);
                }
            }
            parsedWeapons = new Weapon[4][];
            for (int j = 0; j < 4; j++)
            {
                if (isPsp1 && dataLocs[j] != 0)
                {
                    parsedWeapons[j] = new Weapon[weaponCounts[j] - ((sbyte)firstFour[j])];
                }
                else if (isPsp1)
                {
                    parsedWeapons[j] = new Weapon[0];
                }
                else
                {
                    parsedWeapons[j] = new Weapon[numEntries];
                }
                if (dataLocs[j] != 0)
                {
                    for (int i = 0; i < parsedWeapons[j].Length; i++)
                    {
                        parsedWeapons[j][i]         = new Weapon();
                        parsedWeapons[j][i].IsValid = false;
                        if ((isPsp1 && (i + ((sbyte)firstFour[j]) >= 0)) || (!isPsp1 && validWeapons[j][i] != 0xFF))
                        {
                            if (isPsp1)
                            {
                                rawStream.Seek(dataLocs[j] + (i + ((sbyte)firstFour[j])) * 38, SeekOrigin.Begin);
                            }
                            else
                            {
                                rawStream.Seek(dataLocs[j] + validWeapons[j][i] * 38, SeekOrigin.Begin);
                            }
                            parsedWeapons[j][i].IsValid        = true;
                            parsedWeapons[j][i].AttackName     = rawReader.ReadByte();
                            parsedWeapons[j][i].ShootEffect    = rawReader.ReadByte();
                            parsedWeapons[j][i].WeaponModel    = rawReader.ReadByte();
                            parsedWeapons[j][i].SelectedRange  = rawReader.ReadByte();
                            parsedWeapons[j][i].MinATP         = rawReader.ReadInt16();
                            parsedWeapons[j][i].MaxATP         = rawReader.ReadInt16();
                            parsedWeapons[j][i].Ata            = rawReader.ReadInt16();
                            parsedWeapons[j][i].StatusEffect   = rawReader.ReadByte();
                            parsedWeapons[j][i].StatusLevel    = rawReader.ReadByte();
                            parsedWeapons[j][i].MaxTargets     = rawReader.ReadByte();
                            parsedWeapons[j][i].AvailableRaces = rawReader.ReadByte();
                            parsedWeapons[j][i].ReqATP         = rawReader.ReadInt16();
                            byte rankEle = rawReader.ReadByte();
                            parsedWeapons[j][i].Rank        = (byte)(rankEle & 0xF);
                            parsedWeapons[j][i].DropElement = (byte)(rankEle >> 4);
                            parsedWeapons[j][i].DropPercent = rawReader.ReadByte();
                            parsedWeapons[j][i].SoundEffect = rawReader.ReadByte();
                            parsedWeapons[j][i].SetID       = rawReader.ReadByte();
                            parsedWeapons[j][i].BasePP      = rawReader.ReadInt16();
                            short tempPP = rawReader.ReadInt16();
                            if (tempPP != 0)
                            {
                                parsedWeapons[j][i].RegenPP = (short)((5 * parsedWeapons[j][i].BasePP) / tempPP);
                            }
                            else
                            {
                                parsedWeapons[j][i].RegenPP = 0;
                            }
                            parsedWeapons[j][i].AtpMod = rawReader.ReadInt16();
                            parsedWeapons[j][i].DfpMod = rawReader.ReadInt16();
                            parsedWeapons[j][i].AtaMod = rawReader.ReadInt16();
                            parsedWeapons[j][i].EvpMod = rawReader.ReadInt16();
                            parsedWeapons[j][i].StaMod = rawReader.ReadInt16();
                            parsedWeapons[j][i].TpMod  = rawReader.ReadInt16();
                            parsedWeapons[j][i].MstMod = rawReader.ReadInt16();
                            if (isPsp1)
                            {
                                parsedWeapons[j][i].MaxTargets = (byte)(parsedWeapons[j][i].StatusLevel & 0xF);
                                if ((parsedWeapons[j][i].AvailableRaces & 0x40) != 0)
                                {
                                    parsedWeapons[j][i].DropElement |= 0x8;
                                }
                                parsedWeapons[j][i].AvailableRaces &= 0x3F;
                                parsedWeapons[j][i].StatusLevel   >>= 4;
                            }
                        }
                    }
                }
                else
                {
                    for (int i = 0; i < parsedWeapons[j].Length; i++)
                    {
                        parsedWeapons[j][i] = new Weapon();
                    }
                }
            }
        }
Example #15
0
    public static void Test()
    {

      var model = new RvolSolveModel(
        targetVol_: 0.0121519,
        cov_: Singleton<SI.Data.CovarianceSource>.Instance.GetCovariance(DateTime.Today.AddDays(-1d)),
        ccys_: Singleton<SI.Data.FXIDs>.Instance.Select(x => new CurrencyLine(
          ccy_: x,
          expectedReturn_: 0.1,
          minWt_: x.IsGroup(Data.FXGroup.G10) ? -0.31 : -0.1215914,
          maxWeight_: x.IsGroup(Data.FXGroup.G10) ? 0.31 : 0.1215914)).ToArray()
        )
      {
        SumOfWeightsMin = 0d,
        SumOfWeightsMax = 1d,
      };

      new RvolSolver().SolveQuadratic(model);

      Console.WriteLine("ben");

      return;

      var result = Singleton<ExcelOptimizer>.Instance.DoIt(
        model.CurrencyLines.Length,
        model.TargetVol,
        model.Covar.Data,
        model.CurrencyLines.Select(x => x.ExpectedReturn).ToArray(),
        ExtensionMethods.CreateArrayRep<double>(0d, model.CurrencyLines.Length),
        ExtensionMethods.CreateArrayRep<double>(0d, model.CurrencyLines.Length),
        model.CurrencyLines.Select(x => x.MinWeight).ToArray(),
        model.CurrencyLines.Select(x => x.MaxWeight).ToArray(),
        1d,
        1d,
        "2W",
        DateTime.Today);

      Singleton<ExcelOptimizer>.Instance.Dispose();

      var list = new System.ComponentModel.BindingList<CompareResult>();

      for (int i = 0; i < model.CurrencyLines.Length; ++i)
      {
        list.Add(
          new CompareResult()
          {
            Currency = model.CurrencyLines[i].Ccy.Code,
            SolverFoundation = model.CurrencyLines[i].Weight,
            XLL = result.Wts[i]
          });
      }

      list.DisplayInGrid("result comparison");
    }
Example #16
0
        private void MySearchCallback(IAsyncResult result)
        {
            // Create an EventHandler delegate.
            UpdateSearchButtonHandler updateSearch = new UpdateSearchButtonHandler(UpdateSearchButtonEvent);

            // Invoke the delegate on the UI thread.
            this.Invoke(updateSearch, new object[] { new BoolArgs(true) });
            RequestState rs = (RequestState)result.AsyncState;

            try {
                // Get the WebRequest from RequestState.
                WebRequest req = rs.Request;

                // Call EndGetResponse, which produces the WebResponse object
                //  that came from the request issued above.
                WebResponse resp = req.EndGetResponse(result);

                //  Start reading data from the response stream.
                System.IO.Stream responseStream = resp.GetResponseStream();

                // Store the response stream in RequestState to read
                // the stream asynchronously.
                rs.ResponseStream = responseStream;
                xmlReader         = new System.Xml.XmlTextReader(responseStream);
                xmlDoc            = new System.Xml.XmlDocument();
                xmlDoc.Load(xmlReader);
                xmlReader.Close();
                resp.Close();
                req = null;
            } catch (WebException we) {
                rs.Request.Abort();
                rs.Request = null;
                toolStripStatusLabel1.Text = "Search failed.";
                MessageBox.Show(we.Message, "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                if (currentResultPage < totalResultPages)
                {
                    moreButton.Show();
                }

                return;
            }

            int nResults = Convert.ToInt32(xmlDoc.GetElementsByTagName("numResults")[0].InnerText);

            if (nResults > 0)
            {
                totalResultPages           = nResults / 20 + 1;
                toolStripStatusLabel1.Text = "Items found: " + nResults;
                toolStripStatusLabel2.Text = "Showing page " + currentResultPage.ToString() + " of " + totalResultPages.ToString();
            }
            else
            {
                MessageBox.Show("Your query didn't return any results from Infoseek.\nTry some other search term or regular Infoseek\nwildcards like '*', '?', '^'", "No match", MessageBoxButtons.OK, MessageBoxIcon.Information);
                toolStripStatusLabel1.Text = "Ready";
                toolStripStatusLabel2.Text = "";
                return;
            }
            System.Xml.XmlNodeList memberNodes = xmlDoc.SelectNodes("//result");
            foreach (System.Xml.XmlNode node in memberNodes)
            {
                InfoseekResult ir        = new InfoseekResult();
                ProgramTitle   progTitle = new ProgramTitle();
                ir.InfoseekID  = node.SelectSingleNode("id").InnerText;
                ir.ProgramName = node.SelectSingleNode("title").InnerText;
                ir.Year        = node.SelectSingleNode("year").InnerText;
                ir.Publisher   = node.SelectSingleNode("publisher").InnerText;
                ir.ProgramType = node.SelectSingleNode("type").InnerText;
                ir.Language    = node.SelectSingleNode("language").InnerText;
                ir.Score       = node.SelectSingleNode("score").InnerText;
                ir.PicInlayURL = node.SelectSingleNode("picInlay").InnerText;
                infoList.Add(ir);
                progTitle.Title = ir.ProgramName;
                // ProgramTitleList.Add(progTitle);
                AddItemToListBox(infoListBox, infoList.Count - 1, ir.ProgramName,
                                 ir.PicInlayURL, ir.Publisher, ir.ProgramType,
                                 ir.Year, ir.Language, ir.Score);
            }
        }
Example #17
0
    public static IList<SwapsSummaryRow> GetListAsSummaryRows(bool forceGetStats_=false)
    {
      var list = new System.ComponentModel.BindingList<SwapsSummaryRow>();

      foreach (var inst in GetList())
      {
        if (forceGetStats_)
          inst.Stats.ToString();
        list.Add(new SwapsSummaryRow(inst,null));
      }

      return list;
    }
Example #18
0
        public static void ReadTapeInfo(String filename)
        {
            for (int f = 0; f < PZXFile.blocks.Count; f++)
            {
                PZX_TapeInfo info = new PZX_TapeInfo();

                if (PZXFile.blocks[f] is PZXFile.BRWS_Block)
                {
                    info.Info = ((PZXFile.BRWS_Block)PZXFile.blocks[f]).text;
                }
                else if (PZXFile.blocks[f] is PZXFile.PAUS_Block)
                {
                    info.Info = ((PZXFile.PAUS_Block)PZXFile.blocks[f]).duration.ToString() + " t-states   (" +
                                Math.Ceiling(((double)(((PZXFile.PAUS_Block)PZXFile.blocks[f]).duration) / (double)(69888 * 50))).ToString() + " secs)";
                }
                else if (PZXFile.blocks[f] is PZXFile.PULS_Block)
                {
                    info.Info = ((PZXFile.PULS_Block)PZXFile.blocks[f]).pulse[0].duration.ToString() + " t-states   ";
                }
                else if (PZXFile.blocks[f] is PZXFile.STOP_Block)
                {
                    info.Info = "Stop the tape.";
                }
                else if (PZXFile.blocks[f] is PZXFile.DATA_Block)
                {
                    PZXFile.DATA_Block _data = (PZXFile.DATA_Block)PZXFile.blocks[f];
                    int d = (int)(_data.count / 8);

                    //Determine if it's a standard data block suitable for flashloading
                    //Taken from PZX FAQ:
                    // In the common case of the standard loaders you would simply test that
                    //each sequence consists of two non-zero pulses, and that the total duration
                    // of the sequence s0 is less than the total duration of sequence s1
                    if ((_data.p0 == 2 && _data.p1 == 2) &&
                        (_data.s0[0] != 0 && _data.s0[1] != 0 && _data.s1[0] != 0 && _data.s1[1] != 0) &&
                        (_data.s0[0] + _data.s0[1] < _data.s1[0] + _data.s1[1]))
                    {
                        info.IsStandardBlock = true;
                    }

                    //Check for standard header
                    if ((d == 19) && (_data.data[0] == 0))
                    {
                        //Check checksum to ensure it's a standard header
                        byte checksum = 0;
                        for (int x = 0; x < _data.data.Count - 1; x++)
                        {
                            checksum ^= _data.data[x];
                        }

                        if (checksum == _data.data[18])
                        {
                            int type = _data.data[1];
                            if (type == 0)
                            {
                                String _name = GetStringFromData(_data.data.ToArray(), 2, 10);
                                info.Info = "Program: \"" + _name + "\"";
                                ushort _line = System.BitConverter.ToUInt16(_data.data.ToArray(), 14);
                                if (_line > 0)
                                {
                                    info.Info += " LINE " + _line.ToString();
                                }
                            }
                            else if (type == 1)
                            {
                                String _name = GetStringFromData(_data.data.ToArray(), 2, 10);
                                info.Info = "Num Array: \"" + _name + "\"" + "  " + Convert.ToChar(_data.data[15] - 32) + "(" + _data.data[12].ToString() + ")";
                            }
                            else if (type == 2)
                            {
                                String _name = GetStringFromData(_data.data.ToArray(), 2, 10);
                                info.Info = "Char Array: \"" + _name + "\"" + "  " + Convert.ToChar(_data.data[15] - 96) + "$(" + _data.data[12].ToString() + ")";
                            }
                            else if (type == 3)
                            {
                                String _name = GetStringFromData(_data.data.ToArray(), 2, 10);
                                info.Info = "Bytes: \"" + _name + "\"";
                                ushort _start  = System.BitConverter.ToUInt16(_data.data.ToArray(), 14);
                                ushort _length = System.BitConverter.ToUInt16(_data.data.ToArray(), 12);
                                info.Info += " CODE " + _start.ToString() + "," + _length.ToString();
                            }
                            else
                            {
                                info.Info = ((PZXFile.DATA_Block)PZXFile.blocks[f]).count.ToString() + " bits  (" + Math.Ceiling((double)(((PZXFile.DATA_Block)PZXFile.blocks[f]).count) / (double)8).ToString() + " bytes)";
                            }
                        }
                        else
                        {
                            info.Info = "";
                        }
                    }
                    else
                    {
                        info.Info = ((PZXFile.DATA_Block)PZXFile.blocks[f]).count.ToString() + " bits  (" + Math.Ceiling((double)(((PZXFile.DATA_Block)PZXFile.blocks[f]).count) / (double)8).ToString() + " bytes)";
                    }
                }
                else if (PZXFile.blocks[f] is PZXFile.PZXT_Header)
                {
                    //info.Info = ((PZXFile.PZXT_Header)(PZXFile.blocks[f])).Title;
                    continue;
                }

                info.Block = PZXFile.blocks[f].tag;
                tapeBlockInfo.Add(info);
            }
        }
Example #19
0
        public void Main()
        {
            SortedList <int, string>       sl = new SortedList <int, string>();       // поддерживает массив элементов, которые хранятся отсортированными
            SortedDictionary <int, string> sd = new SortedDictionary <int, string>(); // применяет структуру красно черного дерева.

            IEnumerable       ienumberable = Enumerable.Range(1, 2);
            IEnumerable <int> ienumerablet = Enumerable.Range(1, 2);
            ICollection       icollection  = new List <int>()
            {
                1, 2
            };
            ICollection <int> icollectiont = new List <int>()
            {
                1, 2
            };
            IList <int> ilistt = new List <int>()
            {
                1, 2
            };
            ISet <int> isett = new HashSet <int>(); isett.Add(1);
            IDictionary <int, string> idictionarytkeytvalue = new Dictionary <int, string>()
            {
                { 1, "1" }, { 2, "2" }
            };
            ICollection <KeyValuePair <int, string> > icollectionkeyvaluepairtkeytvalue = new List <KeyValuePair <int, string> >(); icollectionkeyvaluepairtkeytvalue.Add(new KeyValuePair <int, string>(1, "1"));
            HashSet <string>   hashsett    = new HashSet <string>(); hashsett.Add("str");
            SortedSet <string> sortedsett  = new SortedSet <string>(); sortedsett.Add("str");
            LinkedList <int>   linkedListt = new LinkedList <int>(); linkedListt.AddFirst(1);

            System.ComponentModel.BindingList <int> bindingList          = new System.ComponentModel.BindingList <int>(); bindingList.Add(1); bindingList.AddingNew += BindingList_AddingNew; bindingList.ListChanged += BindingList_ListChanged;
            ObservableCollection <int>         ibservable                = new ObservableCollection <int>(); ibservable.Add(1);
            KeyedCollection <int, string>      keyedcollectiontkeytvalue = null; //keyedcollectiontkeytvalue.GetKeyForItem();
            ConcurrentDictionary <int, string> conDict = new ConcurrentDictionary <int, string>();
            IProducerConsumerCollection <int>  pcc     = null;
            BlockingCollection <int>           bct     = new BlockingCollection <int>(); bct.Add(1);
            ConcurrentBag <int>       cbi  = new ConcurrentBag <int>(); cbi.Add(1);
            ConcurrentQueue <int>     cqi  = new ConcurrentQueue <int>();
            ConcurrentStack <int>     csi  = new ConcurrentStack <int>();
            IReadOnlyCollection <int> roci = new List <int>().AsReadOnly();
        }