コード例 #1
0
        public Form_GraphicDepth(Connector.QuikConnector trader, TElement trElement, object parent)
        {
            InitializeComponent();

            this.Parent = (MainForm)parent;
            if (this.Parent.IsNull())
            {
                this.Close();
            }

            this.Trader = trader;
            if (this.Trader.IsNull())
            {
                this.Close();
            }

            this.TrElement = trElement;
            if (this.TrElement.IsNull())
            {
                this.Close();
            }

            //Инициализация графика
            this.GraphicStock = new NSGraphic.Graphic(TrElement.Security.Params.MinPriceStep);
            //Загружаем список пользовательских инструментов
            this.LoadListTradeSec();
        }
コード例 #2
0
        /// <summary>
        /// Get the specified element from the pipeline.
        /// </summary>
        /// <remarks>
        /// If the pipeline contains multiple elements of the requested type,
        /// this method will return null.
        /// </remarks>
        /// <typeparam name="TElement">
        /// The type of the <see cref="IFlowElement"/> to get
        /// </typeparam>
        /// <returns>
        /// An instance of the specified <see cref="IFlowElement"/> if the
        /// pipeline contains one.
        /// Null is returned if there is no such instance or there are
        /// multiple instances of that type.
        /// </returns>
        public TElement GetElement <TElement>()
            where TElement : class, IFlowElement
        {
            TElement            result = null;
            List <IFlowElement> elements;

            if (_elementsByType.TryGetValue(typeof(TElement), out elements))
            {
                try
                {
                    result = elements.SingleOrDefault() as TElement;
                }
                catch (InvalidOperationException)
                {
                    result = null;
                }
            }
            else if (_elementsByType.Any(e => typeof(TElement).IsAssignableFrom(e.Key)))
            {
                var matches = _elementsByType.Where(e => typeof(TElement).IsAssignableFrom(e.Key));
                if (matches.Count() == 1 &&
                    matches.Single().Value.Count == 1)
                {
                    result = matches.Single().Value.Single() as TElement;
                }
            }

            return(result);
        }
コード例 #3
0
        public IEnumerable <Trainee> GetAllTrainee(Func <Trainee, bool> predicat = null)
        {
            LoadDataTrainee();
            IEnumerable <Trainee> allTrainee = from TElement in TraineeRoot.Elements()
                                               select new Trainee()
            {
                TraineeId                     = TElement.Element("TraineeId").Value,
                TraineeFirstName              = TElement.Element("TraineeFirstName").Value,
                TraineeLastName               = TElement.Element("TraineeLastName").Value,
                TraineeGender                 = (Gender)Enum.Parse(typeof(Gender), TElement.Element("TraineeGender").Value),
                TraineePhoneNumber            = TElement.Element("TraineePhoneNumber").Value,
                TraineeEmailAddress           = TElement.Element("TraineeEmailAddress").Value,
                TraineeAddress                = Address.Parse(TElement.Element("TraineeAddress").Value),
                TraineeDateOfBirth            = DateTime.Parse(TElement.Element("TraineeDateOfBirth").Value),
                TraineeLearingCar             = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TraineeLearingCar").Value),
                TraineeGearbox                = (TypeOfGearbox)Enum.Parse(typeof(TypeOfGearbox), TElement.Element("TraineeGearbox").Value),
                TraineeNameOfSchool           = TElement.Element("TraineeNameOfSchool").Value,
                TraineeNameOfTeacher          = TElement.Element("TraineeNameOfTeacher").Value,
                TraineeNumOfDrivingLessons    = int.Parse(TElement.Element("TraineeNumOfDrivingLessons").Value),
                TraineeHasGlasses             = bool.Parse(TElement.Element("TraineeHasGlasses").Value),
                IfTraineePassedAnInternalTest = bool.Parse(TElement.Element("IfTraineePassedAnInternalTest").Value)
            };

            if (predicat == null)//no condition
            {
                return(allTrainee);
            }
            else
            {
                return(allTrainee.Where(predicat));
            }
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: Socol111/QLuaConnector
 /// <summary> Получение формы со стаканом и графиком </summary>
 /// <param name="sec"></param>
 /// <returns></returns>
 private Form_GraphicDepth ShowGraphicDepth(Securities sec)
 {
     try
     {
         var form = ListFormsDepth.FirstOrDefault(f => !f.isClose && f.TrElement.Security == sec);
         if (form == null)
         {
             var elTr = this.DataTrading.Collection.FirstOrDefault(e => e.Security == sec);
             if (elTr == null)
             {
                 elTr = new TElement(sec);
                 this.DataTrading.Add(elTr);
                 elTr.Create();
             }
             form = new Form_GraphicDepth(Trader, elTr, this);
             ListFormsDepth.Add(form);
         }
         if (form != null)
         {
             form.Show();
         }
         return(form);
     }
     catch (Exception ee)
     {
         MessageBox.Show(ee.ToString());
     }
     return(null);
 }
コード例 #5
0
ファイル: PageObject.cs プロジェクト: kolbasik/NUITests
        public TElement GetElement <TElement>() where TElement : PageElement, new()
        {
            var element = new TElement();

            element.Initialize(Browser);
            return(element);
        }
コード例 #6
0
ファイル: Seq.cs プロジェクト: highwayns/opencv.net
        /// <summary>
        /// Copies the elements of the sequence to a new array.
        /// </summary>
        /// <typeparam name="TElement">The type of the elements in the sequence.</typeparam>
        /// <returns>A new array instance containing all the elements in the sequence.</returns>
        public TElement[] ToArray <TElement>() where TElement : struct
        {
            var array = new TElement[Count];

            CopyTo(array);
            return(array);
        }
コード例 #7
0
 internal static void RemoveAt(TList list, long index)
 {
     if (list == null)
     {
         throw new ArgumentNullException("list");
     }
     if (index < 0)
     {
         throw new ArgumentOutOfRangeException("index");
     }
     list.InvokeInMonitorLock(() =>
     {
         if (index >= list.Count)
         {
             throw new ArgumentOutOfRangeException("index");
         }
         TElement item         = list._firstNode;
         TElement previousItem = null;
         for (long i = 0L; i < index; i++)
         {
             previousItem = item;
             if ((item = item._nextNode) == null)
             {
                 throw new ArgumentOutOfRangeException("index");
             }
         }
         list.InvokeInChange(() =>
         {
             RaiseRemovingItem(list, item, index);
             if (index == 0)
             {
                 if (list.Count == 1)
                 {
                     list._firstNode = list._lastNode = null;
                     list.Count      = 0;
                 }
                 else if ((list._firstNode = item._nextNode)._nextNode == null)
                 {
                     list._lastNode = list._firstNode;
                     list.Count     = 1;
                 }
                 else
                 {
                     list.Count--;
                 }
             }
             else
             {
                 if ((previousItem._nextNode = item._nextNode)._nextNode == null)
                 {
                     list._lastNode = previousItem;
                 }
                 list.Count--;
             }
             item._container = null;
             item._nextNode  = null;
         });
         RaiseItemRemoved(list, item, index);
     });
 }
コード例 #8
0
        public IEnumerable <Test> GetAllTest(Func <Test, bool> predicat = null)
        {
            LoadDataTest();
            IEnumerable <Test> allTest = from TElement in TestRoot.Elements()
                                         select new Test()
            {
                TestNumber        = int.Parse(TElement.Element("TestNumber").Value),
                TesterId          = TElement.Element("TesterId").Value,
                TraineeId         = TElement.Element("TraineeId").Value,
                DateTimeOfTest    = DateTime.Parse(TElement.Element("DateTimeOfTest").Value),
                TestExitAddress   = Address.Parse(TElement.Element("TestExitAddress").Value),
                TestCriterion     = Criterion.Parse(TElement.Element("TestCriterion").Value),
                TestResult        = (PassOrFail)Enum.Parse(typeof(PassOrFail), TElement.Element("TestResult").Value),
                TestTypeOfCar     = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TestTypeOfCar").Value),
                TestTypeOfGearbox = (TypeOfGearbox)Enum.Parse(typeof(TypeOfGearbox), TElement.Element("TestTypeOfGearbox").Value),
                TesterNote        = TElement.Element("TesterNote").Value,
            };

            if (predicat == null)//no condition
            {
                return(allTest);
            }
            else
            {
                return(allTest.Where(predicat));
            }
        }
コード例 #9
0
 internal static void Add(TList list, TElement item)
 {
     if (list == null)
     {
         throw new ArgumentNullException("list");
     }
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     list.InvokeInMonitorLock(() => RaiseItemAdded(list, item, item.GetInMonitorLock(() =>
     {
         ValidateItemOrphaned(list, item);
         return(list.GetInChange(() =>
         {
             long i = list.Count;
             RaiseAddingItem(list, item, i);
             if (list._firstNode == null)
             {
                 list._firstNode = list._lastNode = item;
                 list.Count = 1;
             }
             else
             {
                 list._lastNode._nextNode = item;
                 list._lastNode = item;
                 list.Count++;
             }
             item._container = list;
             return i;
         }));
     })));
 }
コード例 #10
0
 internal static long IndexOf(TList list, TElement item)
 {
     if (list == null)
     {
         throw new ArgumentNullException("list");
     }
     return(list.GetInMonitorLock(() =>
     {
         if (item != null && item.GetInMonitorLock(() => item._container != null && ReferenceEquals(item._container, list)))
         {
             if (item._nextNode == null)
             {
                 return list.Count - 1;
             }
             long index = -1L;
             for (TElement node = list._firstNode; node != null; node = node._nextNode)
             {
                 index++;
                 if (ReferenceEquals(node, item))
                 {
                     return index;
                 }
             }
         }
         return -1L;
     }));
 }
コード例 #11
0
        public IEnumerable <Tester> GetAllTesters(Func <Tester, bool> predicat = null)
        {
            LoadDataTester();
            IEnumerable <Tester> allTester = from TElement in TesterRoot.Elements()
                                             select new Tester()
            {
                isActive                   = bool.Parse(TElement.Element("isActive").Value),
                TesterId                   = TElement.Element("TesterId").Value,
                TesterLastName             = TElement.Element("TesterLastName").Value,
                TesterFirstName            = TElement.Element("TesterFirstName").Value,
                TesterDateOfBirth          = DateTime.Parse(TElement.Element("TesterDateOfBirth").Value),
                TesterFamilyStatus         = (FamilyStatus)Enum.Parse(typeof(FamilyStatus), TElement.Element("TesterFamilyStatus").Value),
                TesterGender               = (Gender)Enum.Parse(typeof(Gender), TElement.Element("TesterGender").Value),
                TesterHasGlasses           = bool.Parse(TElement.Element("TesterHasGlasses").Value),
                TesterPhoneNumber          = TElement.Element("TesterPhoneNumber").Value,
                TesterEmailAddress         = TElement.Element("TesterEmailAddress").Value,
                TesterAddress              = Address.Parse(TElement.Element("TesterAddress").Value),
                TesterYearsOfExperience    = int.Parse(TElement.Element("TesterYearsOfExperience").Value),
                TesterMaxNumOfTestsPerWeek = int.Parse(TElement.Element("TesterMaxNumOfTestsPerWeek").Value),
                TesterSpecialization       = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TesterSpecialization").Value),
                MaxiDistanceFromAddress    = double.Parse(TElement.Element("MaxiDistanceFromAddress").Value),
                Help_Matrix                = TElement.Element("MatrixTesterworkdays").Value,
            };

            if (predicat == null)//no condition
            {
                return(allTester);
            }
            else
            {
                return(allTester.Where(predicat));
            }
        }
コード例 #12
0
 internal static TElement Get(TList list, long index)
 {
     if (index < 0L)
     {
         throw new IndexOutOfRangeException();
     }
     return(list.GetInMonitorLock(() =>
     {
         if (index < list.Count)
         {
             TElement node = list._firstNode;
             for (long i = 0; i < index; i++)
             {
                 if (node == null)
                 {
                     break;
                 }
                 node = node._nextNode;
             }
             if (node != null)
             {
                 return node;
             }
         }
         throw new IndexOutOfRangeException();
     }));
 }
コード例 #13
0
 private static void RaiseRemovingItem(TList list, TElement currentNode, long index)
 {
     WithAll(
         () => list.OnRemovingItem(currentNode, index),
         () => currentNode.OnRemoving(index)
         );
 }
コード例 #14
0
        public Form_CopySecurity(Connector.QuikConnector trader, TElement trElement)
        {
            InitializeComponent();

            this.TrElement = trElement;
            this.Trader    = trader;
        }
コード例 #15
0
        public Trainee GetTrainee(string id, TypeOfCar car)
        {
            LoadDataTrainee();
            Trainee returnT = new Trainee();

            returnT = (from TElement in TraineeRoot.Elements()
                       where (TElement.Element("TraineeId").Value == id) && ((TypeOfCar)Enum.Parse(typeof(TypeOfCar), (TElement.Element("TraineeLearingCar").Value)) == car)
                       select new Trainee
            {
                TraineeId = TElement.Element("TraineeId").Value,
                TraineeFirstName = TElement.Element("TraineeFirstName").Value,
                TraineeLastName = TElement.Element("TraineeLastName").Value,
                TraineeGender = (Gender)Enum.Parse(typeof(Gender), TElement.Element("TraineeGender").Value),
                TraineePhoneNumber = TElement.Element("TraineePhoneNumber").Value,
                TraineeEmailAddress = TElement.Element("TraineeEmailAddress").Value,
                TraineeAddress = Address.Parse(TElement.Element("TraineeAddress").Value),
                TraineeDateOfBirth = DateTime.Parse(TElement.Element("TraineeDateOfBirth").Value),
                TraineeLearingCar = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TraineeLearingCar").Value),
                TraineeGearbox = (TypeOfGearbox)Enum.Parse(typeof(TypeOfGearbox), TElement.Element("TraineeGearbox").Value),
                TraineeNameOfSchool = TElement.Element("TraineeNameOfSchool").Value,
                TraineeNameOfTeacher = TElement.Element("TraineeNameOfTeacher").Value,
                TraineeNumOfDrivingLessons = int.Parse(TElement.Element("TraineeNumOfDrivingLessons").Value),
                TraineeHasGlasses = bool.Parse(TElement.Element("TraineeHasGlasses").Value),
                IfTraineePassedAnInternalTest = bool.Parse(TElement.Element("IfTraineePassedAnInternalTest").Value)
            }).FirstOrDefault();
            return(returnT);
        }
コード例 #16
0
        public Tester GetTester(string id)
        {
            LoadDataTester();
            Tester returnT = new Tester();

            returnT = (from TElement in TesterRoot.Elements()
                       where TElement.Element("TesterId").Value == id
                       select new Tester
            {
                isActive = bool.Parse(TElement.Element("isActive").Value),
                TesterId = TElement.Element("TesterId").Value,
                TesterLastName = TElement.Element("TesterLastName").Value,
                TesterFirstName = TElement.Element("TesterFirstName").Value,
                TesterDateOfBirth = DateTime.Parse(TElement.Element("TesterDateOfBirth").Value),
                TesterFamilyStatus = (FamilyStatus)Enum.Parse(typeof(FamilyStatus), TElement.Element("TesterFamilyStatus").Value),
                TesterGender = (Gender)Enum.Parse(typeof(Gender), TElement.Element("TesterGender").Value),
                TesterHasGlasses = bool.Parse(TElement.Element("TesterHasGlasses").Value),
                TesterPhoneNumber = TElement.Element("TesterPhoneNumber").Value,
                TesterEmailAddress = TElement.Element("TesterEmailAddress").Value,
                TesterAddress = Address.Parse(TElement.Element("TesterAddress").Value),
                TesterYearsOfExperience = int.Parse(TElement.Element("TesterYearsOfExperience").Value),
                TesterMaxNumOfTestsPerWeek = int.Parse(TElement.Element("TesterMaxNumOfTestsPerWeek").Value),
                TesterSpecialization = (TypeOfCar)Enum.Parse(typeof(TypeOfCar), TElement.Element("TesterSpecialization").Value),
                MaxiDistanceFromAddress = double.Parse(TElement.Element("MaxiDistanceFromAddress").Value),
                Help_Matrix = TElement.Element("MatrixTesterworkdays").Value,
            }).FirstOrDefault();
            return(returnT);
        }
コード例 #17
0
        public bool IsAvailable(TElement aElement)
        {
            bool ret = false;

            //
            switch (aElement)
            {
            case TElement.EElementThread:
                ret = (Thread != null);
                break;

            case TElement.EElementProcess:
                ret = (Process != null);
                break;

            case TElement.EElementCodeSegments:
                ret = (CodeSegments != null);
                break;

            case TElement.EElementStack:
                ret = (Stack != null);
                break;

            case TElement.EElementRegisters:
                ret = (Registers != null);
                break;
            }
            //
            return(ret);
        }
コード例 #18
0
		public Form_ActivateStopOrders(Connector.QuikConnector trader, TElement trElement)
		{
			InitializeComponent();

			this.Trader = trader;
			this.TrElement = trElement;
		}
コード例 #19
0
 private static void RaiseItemRemoved(TList list, TElement oldNode, long index)
 {
     WithAll(
         () => list.OnItemRemoved(oldNode, index),
         () => oldNode.OnRemoved(list, index)
         );
 }
コード例 #20
0
 private static void RaiseItemAdded(TList list, TElement currentNode, long index)
 {
     WithAll(
         () => list.OnItemAdded(currentNode, index),
         () => currentNode.OnAdded(index)
         );
 }
コード例 #21
0
			public int Compare(TElement el)
			{
				TValue value;

				if (_parent != null)
				{
					var parentCompare = _parent.Compare(el);

					if (parentCompare < 0)
						return parentCompare;

					value = _valueSelector(el);

					if (parentCompare > 0)
					{
						_max = value;
						_hasValue = true;
						return parentCompare;
					}
				}
				else
				{
					value = _valueSelector(el);
				}

				if (!_hasValue)
				{
					_max = value;
					_hasValue = true;
					return 1;
				}

				int compare;

				if (_customComparer == null)
				{
					if (value == null)
					{
						if (_max == null)
							compare = 0;
						else
							compare = -_max.CompareTo(value);
					}
					else
					{
						compare = value.CompareTo(_max);
					}
				}
				else
				{
					compare = _customComparer.Compare(value, _max);
				}

				compare *= _sign;

				if (compare > 0)
					_max = value;

				return compare;
			}
コード例 #22
0
 private static void RaiseAddingItem(TList list, TElement newNode, long index)
 {
     WithAll(
         () => list.OnAddingItem(newNode, index),
         () => newNode.OnAdding(list, index)
         );
 }
コード例 #23
0
        public static TElement Create <TElement>()
            where TElement : ConfigElement, new()
        {
            var e = new TElement();

            e.SetDefaults();
            return(e);
        }
コード例 #24
0
 internal static bool Contains(TList list, TElement item)
 {
     if (list == null)
     {
         throw new ArgumentNullException("list");
     }
     return(item != null && item.GetInMonitorLock(() => item._container != null && ReferenceEquals(item._container, list)));
 }
コード例 #25
0
 public Form_Strategy_morePrev(Connector.QuikConnector trader, TElement trEl)
 {
     this.Trader = trader;
     InitializeComponent();
     this.TrElement = trEl;
     this.Text      = trEl.Security.ToString();
     this.Init();
 }
コード例 #26
0
 private static void RaiseReplacingItem(TList list, TElement currentNode, TElement newNode, long index)
 {
     WithAll(
         () => list.OnReplacingItem(currentNode, newNode, index),
         () => RaiseRemovingItem(list, currentNode, index),
         () => RaiseAddingItem(list, newNode, index)
         );
 }
コード例 #27
0
 private static void RaiseItemReplaced(TList list, TElement oldNode, TElement currentNode, long index)
 {
     WithAll(
         () => RaiseItemAdded(list, currentNode, index),
         () => RaiseItemRemoved(list, oldNode, index),
         () => list.OnItemReplaced(oldNode, currentNode, index)
         );
 }
コード例 #28
0
            /// <summary>
            /// Recursively computes the value of the automaton on a given sequence.
            /// </summary>
            /// <param name="sequence">The sequence to compute the value on.</param>
            /// <param name="sequencePosition">The current position in the sequence.</param>
            /// <param name="valueCache">A lookup table for memoization.</param>
            /// <returns>The value computed from the current state.</returns>
            private Weight DoGetValue(
                TSequence sequence, int sequencePosition, Dictionary <IntPair, Weight> valueCache)
            {
                var    stateIndexPair = new IntPair(this.Index, sequencePosition);
                Weight cachedValue;

                if (valueCache.TryGetValue(stateIndexPair, out cachedValue))
                {
                    return(cachedValue);
                }

                EpsilonClosure closure = this.GetEpsilonClosure();

                Weight value = Weight.Zero;
                int    count = Automaton <TSequence, TElement, TElementDistribution, TSequenceManipulator, TThis> .SequenceManipulator.GetLength(sequence);

                bool isCurrent = sequencePosition < count;

                if (isCurrent)
                {
                    TElement element = Automaton <TSequence, TElement, TElementDistribution, TSequenceManipulator, TThis> .SequenceManipulator.GetElement(sequence, sequencePosition);

                    for (int closureStateIndex = 0; closureStateIndex < closure.Size; ++closureStateIndex)
                    {
                        State  closureState       = closure.GetStateByIndex(closureStateIndex);
                        Weight closureStateWeight = closure.GetStateWeightByIndex(closureStateIndex);

                        for (int transitionIndex = 0; transitionIndex < closureState.transitionCount; transitionIndex++)
                        {
                            Transition transition = closureState.transitions[transitionIndex];
                            if (transition.IsEpsilon)
                            {
                                continue; // The destination is a part of the closure anyway
                            }

                            State  destState  = this.Owner.states[transition.DestinationStateIndex];
                            Weight distWeight = Weight.FromLogValue(transition.ElementDistribution.GetLogProb(element));
                            if (!distWeight.IsZero && !transition.Weight.IsZero)
                            {
                                Weight destValue = destState.DoGetValue(sequence, sequencePosition + 1, valueCache);
                                if (!destValue.IsZero)
                                {
                                    value = Weight.Sum(
                                        value,
                                        Weight.Product(closureStateWeight, transition.Weight, distWeight, destValue));
                                }
                            }
                        }
                    }
                }
                else
                {
                    value = closure.EndWeight;
                }

                valueCache.Add(stateIndexPair, value);
                return(value);
            }
コード例 #29
0
 /// <summary>
 /// Adds a transition labeled with a given element to the current state.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="weight">The transition weight.</param>
 /// <param name="destinationStateIndex">
 /// The destination state of the added transition.
 /// If the value of this parameter is <see langword="null"/>, a new state will be created.</param>
 /// <param name="group">The group of the added transition.</param>
 /// <returns>The destination state of the added transition.</returns>
 public StateBuilder AddTransition(
     TElement element,
     Weight weight,
     int?destinationStateIndex = null,
     int group = 0)
 {
     return(this.AddTransition(
                ElementDistributionFactory.CreatePointMass(element), weight, destinationStateIndex, group));
 }
コード例 #30
0
 /// <summary>
 /// Adds a transition labeled with a given element to the current state.
 /// </summary>
 /// <param name="element">The element.</param>
 /// <param name="weight">The transition weight.</param>
 /// <param name="destinationStateIndex">
 /// The destination state of the added transition.
 /// If the value of this parameter is <see langword="null"/>, a new state will be created.</param>
 /// <param name="group">The group of the added transition.</param>
 /// <returns>The destination state of the added transition.</returns>
 public StateBuilder AddTransition(
     TElement element,
     Weight weight,
     int?destinationStateIndex = null,
     int group = 0)
 {
     return(this.AddTransition(
                new TElementDistribution {
         Point = element
     }, weight, destinationStateIndex, group));
 }