private void DrawPairBlocked(Graphics g, RectangleF rect, PairData pairData) { // quote name on top string title = pairData.quoteName; float width = g.MeasureString(title, Style.Fonts.Small).Width; using (Brush brush = new SolidBrush(Style.Colors.Primary.Light1)) { g.DrawString(title, Style.Fonts.Small, brush, rect.X + (rect.Width / 2) - (width / 2), rect.Y + 5); } // blocked text string text = "BLOCKED"; width = g.MeasureString(text, Style.Fonts.Small).Width; using (Brush brush = new SolidBrush(Style.Colors.Secondary.Dark1)) { g.DrawString(text, Style.Fonts.Small, brush, rect.X + (rect.Width / 2) - (width / 2), rect.Y + (rect.Height / 2) - (Style.Fonts.Small.Height / 2)); } // borders using (Pen pen = new Pen(Style.Colors.Primary.Main, 2)) { g.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height); } }
public static Exp ToExp(this Data?data) { return(data switch { null => CoreImplementations.emptyList, NumData n => n.Value, PairData pair => CoreImplementations.Pair(pair.Value.ToExp(), pair.Next.ToExp()), _ => throw new NotSupportedException($"{data}") });
protected override bool IsNumberValid(int[] numberToCheck) { // Check ascending left to right if (!base.IsNumberValid(numberToCheck)) { return(false); } PopulatePairData(numberToCheck); return(PairData.Where(p => p.Value >= 2).Count() > 0); }
/// <summary> /// Добавляет информацию о валютной паре. /// </summary> /// <param name="data">Информация о валютной паре.</param> /// <returns>Идентификатор созданной записи.</returns> public async Task <long> AddPairDataAsync(CreateOrUpdateCurrencyData data) { var pairToAdd = new PairData { PairName = data.PairName, BuyPrice = data.BuyPrice, SellPrice = data.SellPrice, LastTradePrice = data.LastTradePrice, HighPrice = data.HighPrice, LowPrice = data.LowPrice, Volume = data.Volume, Updated = data.Updated }; await _apiDbContext.Pairs.AddAsync(pairToAdd); await _apiDbContext.SaveChangesAsync(); return(pairToAdd.PairId); }
protected PairData GetDictionaryPair(string key, int value) { PairData pairData = new PairData(); pairData.serializableTemplate = GetTemplate(); pairData.serializableTemplate.key = key; pairData.serializableTemplate.value = value; pairData.serializedObject = new SerializedObject(pairData.serializableTemplate); SerializedProperty keyProperty = pairData.serializedObject.FindProperty("key"); SerializedProperty valueProperty = pairData.serializedObject.FindProperty("value"); float viewWidth = EditorGUIUtility.currentViewWidth * 0.5f - 40; GUILayout.BeginHorizontal(); EditorGUILayout.DelayedTextField(keyProperty, GUIContent.none, GUILayout.Width(viewWidth)); EditorGUILayout.DelayedIntField(valueProperty, GUIContent.none, GUILayout.Width(viewWidth)); if (GUILayout.Button("Delete", GUILayout.Width(50))) { _deleteKey = key; } GUILayout.EndHorizontal(); return(pairData); }
private List <PairData> runSystem(List <Data> datas) { List <PairData> pairs = new List <PairData>(); foreach (var data1 in datas) { foreach (var data2 in datas) { if (data1.id != data2.id) { AntiplagiarismSystem system = new AntiplagiarismSystem(); ComparationInput input = prepareInput(data1, data2); double score = system.run(input); PairData pair = new PairData(); pair.data1 = data1; pair.data2 = data2; pair.score = score; pairs.Add(pair); } } } return(pairs); }
public override void OnInspectorGUI() { List <PairData> items = new List <PairData>(); var scriptableData = (ScriptableData)target; var localSerializedObject = new SerializedObject(target); _deleteKey = null; _addKey = null; if (_initialPair == null) { _initialPair = new PairData(); _initialPair.serializableTemplate = GetTemplate(); } SerializedProperty stringProperty = localSerializedObject.FindProperty(GetMemberName(() => scriptableData.stringProperty)); SerializedProperty intProperty = localSerializedObject.FindProperty(GetMemberName(() => scriptableData.intProperty)); SerializedProperty dictionaryProperty = localSerializedObject.FindProperty(GetMemberName(() => scriptableData.dictionaryProperty)); EditorGUILayout.PropertyField(stringProperty); EditorGUILayout.PropertyField(intProperty); EditorGUI.BeginChangeCheck(); if (dictionaryProperty != null) { dictionaryProperty.isExpanded = EditorGUILayout.Foldout( dictionaryProperty.isExpanded, dictionaryProperty.displayName ); if (dictionaryProperty.isExpanded) { UpdateInitialPair(scriptableData); foreach (var keyValuePair in scriptableData.dictionaryProperty) { items.Add(GetDictionaryPair(keyValuePair.Key, keyValuePair.Value)); } } } if (EditorGUI.EndChangeCheck()) { _initialPair.serializedObject.ApplyModifiedProperties(); int itemsCount = items.Count; if (_deleteKey != null && scriptableData.dictionaryProperty.ContainsKey(_deleteKey)) { scriptableData.dictionaryProperty.Remove(_deleteKey); } for (int i = 0; i < itemsCount; i++) { PairData pairData = items[i]; pairData.serializedObject.ApplyModifiedProperties(); string pairKey = pairData.serializableTemplate.key; if (pairKey != _deleteKey && (scriptableData.dictionaryProperty.ContainsKey(pairKey) || pairKey == _addKey)) { scriptableData.dictionaryProperty[pairKey] = pairData.serializableTemplate.value; } } } localSerializedObject.ApplyModifiedProperties(); }
private void DrawPairBox(Graphics g, RectangleF rect, PairData pairData) { // quote name on top string title = pairData.quoteName; float width = g.MeasureString(title, Style.Fonts.Small).Width; using (Brush brush = new SolidBrush(Style.Colors.Primary.Light1)) { g.DrawString(title, Style.Fonts.Small, brush, rect.X + (rect.Width / 2) - (width / 2), rect.Y + 5); } // base name in bottom right title = pairData.baseName; width = g.MeasureString(title, Style.Fonts.Small).Width; using (Brush brush = new SolidBrush(Style.Colors.Primary.Dark1)) { g.DrawString(title, Style.Fonts.Small, brush, rect.X + rect.Width - width - 5, rect.Y + rect.Height - Style.Fonts.Small.Height - 5); } // variables if (pairData.variables != null) { float posY = rect.Y + 25; using (Brush brushBackground = new SolidBrush(Style.Colors.Primary.Dark2)) { using (Brush brushValid = new SolidBrush(Style.Colors.Primary.Main)) { using (Brush brushInvalid = new SolidBrush(Style.Colors.Primary.Dark1)) { using (Brush brushText = new SolidBrush(Style.Colors.Background)) { using (Pen pen = new Pen(brushText)) { for (int i = 0; i < pairData.variables.Length; i++) { // variable boxes g.FillRectangle(brushBackground, rect.X + 5, posY, rect.Width - 10, 15); // variable bar double min = PairData.minimums[i]; double max = PairData.maximums[i]; double mult = pairData.variables[i]; if (mult < min) { mult = 0; } else if (mult > max) { mult = 1; } else { mult = (mult - min) / (max - min); } Brush barBrush = mult > 0.5 ? brushValid : brushInvalid; g.FillRectangle(barBrush, rect.X + 5, posY, (float)mult * (rect.Width - 10), 15); // variable name g.DrawString(PairData.varTitles[i], Style.Fonts.Small, brushText, new PointF(rect.X + 6, posY + 2)); posY += 20; } // center line g.DrawLine(pen, rect.X + (rect.Width / 2), rect.Y + 20, rect.X + (rect.Width / 2), rect.Y + 80); } } } } } } using (Pen pen = new Pen(Style.Colors.Primary.Main, 2)) { g.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height); } }