private void OnEnable() { patternDefinition = (PatternDefinition)serializedObject.targetObject; finishedDelayProp = serializedObject.FindProperty("finishedDelay"); simultaneousProp = serializedObject.FindProperty("simultaneous"); simultaneousList = new ReorderableListProperty(simultaneousProp); nextPossibleProp = serializedObject.FindProperty("nextPossible"); nextPossibleList = new ReorderableListProperty(nextPossibleProp); autoPlacedProp = serializedObject.FindProperty("autoPlaced"); countProp = serializedObject.FindProperty("count"); startRotationProp = serializedObject.FindProperty("startRotation"); distanceFromCenterProp = serializedObject.FindProperty("distanceFromCenter"); rotationSpeedProp = serializedObject.FindProperty("rotationSpeed"); spawnPointsProp = serializedObject.FindProperty("spawnPoints"); spawnPointsList = new ReorderableListProperty(spawnPointsProp, true, DrawSpawnPoint, (i) => { return(EditorGUIUtility.singleLineHeight + 2f); }); spawnPointsList.List.draggable = false; sequenceProp = serializedObject.FindProperty("sequence"); sequenceList = new ReorderableListProperty(sequenceProp, true, DrawSequenceElement, SequenceElementHeight); SceneView.onSceneGUIDelegate += SceneGUI; styleBoldPopup = new GUIStyle(EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("MiniPopup")); styleBoldPopup.font = EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).FindStyle("BoldLabel").font; }
/// <summary> /// パターンの出現回数を辞書に追加します。 /// </summary> /// <param name="fields">フィールドのスライム配置状態</param> /// <param name="pattern">パターン</param> /// <param name="maxIndex">インデックスの最大値</param> /// <param name="dic">パターン出現回数記録辞書</param> private void AddPatternCount(uint[] fields, PatternDefinition pattern, int maxIndex, Dictionary <int, double> dic) { // 1行ずつずらしたユニットを作成 var mergedField = DiProvider.GetContainer().GetInstance <MergedFieldsGenerator>().GetNext(fields); foreach (var field in mergedField) { for (var w = 0; w <= FieldContextConfig.VerticalLineLength - pattern.Width; w++) { for (var h = 0; h <= FieldContextConfig.FieldUnitLineCount - pattern.Height; h++) { var shiftedPattern = ((pattern.PatternDigit >> (1 * w)) << (FieldContextConfig.OneLineBitCount * h)); var key = ((field & shiftedPattern) >> (FieldContextConfig.OneLineBitCount * h)) << (1 * w); var index = pattern.GetIndex(key); index += maxIndex; if (dic.ContainsKey(index)) { dic[index]++; } else { dic[index] = 1d; } } } } }
public void MultiNamespaceTwoDottedAtBeginningMatches() { var def = PatternDefinition.BuildUpDefinition("..MyClass.MyMethod", true); def.IsMatching(TestHelpers.GetMethodDefinition(typeof(MyNamespace.Inner.AndMore.MyClass), "MyMethod")).Should().BeTrue(); def.IsMatching(TestHelpers.GetMethodDefinition(typeof(MyNamespace.Inner.AndMore.MyClass), "OtherMethod")).Should().BeFalse(); }
public void FullSpecifiedMatches() { var def = PatternDefinition.BuildUpDefinition("Mynamespace.MyClass.MyMethod", true); def.IsMatching(TestHelpers.GetMethodDefinition(typeof(MyNamespace.MyClass), "MyMethod")).Should().BeTrue(); def.IsMatching(TestHelpers.GetMethodDefinition(typeof(MyNamespace.MyClass), "OtherMethod")).Should().BeFalse(); }
public static PatternDefinition AddNewPatternDefinition(string appPath) { PatternDefinition newPattern = PatternDefinition.CreateNew(); SavePatternDefinition(appPath, newPattern); return(newPattern); }
public void MatchEveryPublicClass() { var def = PatternDefinition.BuildUpDefinition("..[public]*.*", true); def.IsMatching(TestHelpers.GetMethodDefinition(typeof(MyNamespace.Inner.AndMore.MyClass), "MyMethod")).Should().BeTrue(); def.IsMatching(TestHelpers.GetMethodDefinition(typeof(MyNamespace.MyClass), "MyMethod")).Should().BeTrue(); def.IsMatching(TestHelpers.GetMethodDefinition(typeof(MyNamespace.OtherClass), "MyMethod")).Should().BeFalse(); }
public static PatternDefinition CopyPatternDefinition(string appPath, PatternDefinition source) { PatternDefinition dest = PatternDefinition.Copy(source); SavePatternDefinition(appPath, dest); return(dest); }
public void MultiNamespaceUsingStar() { var def = PatternDefinition.BuildUpDefinition("MyNamespace.*.AndMore.MyClass.MyMethod", true); def.IsMatching(TestHelpers.GetMethodDefinition(typeof(MyNamespace.Inner.AndMore.MyClass), "MyMethod")).Should().BeTrue(); def.IsMatching(TestHelpers.GetMethodDefinition(typeof(MyNamespace.Other.AndMore.MyClass), "MyMethod")).Should().BeTrue(); def.IsMatching(TestHelpers.GetMethodDefinition(typeof(MyNamespace.MyClass), "MyMethod")).Should().BeFalse(); }
private void AddButton_Click(object sender, EventArgs e) { PatternDefinition pattern = SettingFileAccessor.AddNewPatternDefinition(Application.StartupPath); patternList.Add(pattern); ShowPatternList(); }
/// <summary> /// Constructor /// </summary> /// <param name="fileName">Database file name</param> /// <param name="patternDef">Analyzing pattern definition</param> public IntermediateLogReader(String fileName, PatternDefinition patternDef) { log.In(fileName, patternDef); this.colDefList = patternDef.ColumnDefinitionList; connection = SQLiteUtil.OpenConnection(fileName); log.Out(); }
public static void DeletePatternDefinition(string appPath, PatternDefinition pattern) { string patternPath = CreatePatternDefinitionPath(appPath); string filePath = patternPath + @"\" + pattern.PatternName + "_" + pattern.ID + SettingsConstants.EXTENSION_PATTERN_FILE; if (File.Exists(filePath)) { File.Delete(filePath); } }
public void ParsingParameters() { var def = PatternDefinition.ParseFromConfig(new XElement("On", new XAttribute("pattern", "..*.*"), new XAttribute("logParam", true), new XAttribute("otherParam", "Test")), true); def.Parameters.Count.Should().Be(2); def.Parameters.Keys.Should().Contain("logParam"); def.Parameters.Keys.Should().Contain("otherParam"); def.Parameters["logParam"].Should().Be("true"); def.Parameters["otherParam"].Should().Be("Test"); }
private void PatternListView_SelectedIndexChanged(object sender, EventArgs e) { if (PatternListView.SelectedIndices.Count == 0 || PatternListView.SelectedIndices[0] == 0) { this.SelectedPattern = defaultPattern; } else { this.SelectedPattern = PatternList[PatternListView.SelectedIndices[0] - 1]; } }
private void PatternListBox_SelectedIndexChanged(object sender, EventArgs e) { if (PatternListBox.SelectedIndex == -1) { return; } PatternDefinition target = patternList[PatternListBox.SelectedIndex]; ShowPatternDetail(target); }
public void ParseRules() { RenderingRuleSet rules; TypesRegistry typesRegistry = ParseRules(@"..\..\..\GroundTruth\Rules\HikingMapRules.txt", out rules); Assert.AreEqual(51, rules.RulesCount); RenderingRule rule; int i = 0; rule = rules[i++]; Assert.AreEqual("Land", rule.RuleName); Assert.AreEqual(RenderingRuleTargets.Areas, rule.Targets); rule = rules[i++]; Assert.AreEqual("Marsh", rule.RuleName); Assert.AreEqual(RenderingRuleTargets.Areas, rule.Targets); rule = rules[i++]; Assert.AreEqual("Forest", rule.RuleName); Assert.AreEqual(RenderingRuleTargets.Areas, rule.Targets); rule = rules[i++]; Assert.AreEqual("Park", rule.RuleName); Assert.AreEqual(RenderingRuleTargets.Areas, rule.Targets); rule = rules[i++]; Assert.AreEqual("Farm", rule.RuleName); Assert.AreEqual(RenderingRuleTargets.Areas, rule.Targets); rule = rules[i++]; Assert.AreEqual("Farmyard", rule.RuleName); Assert.AreEqual(RenderingRuleTargets.Areas, rule.Targets); rule = rules[i++]; Assert.AreEqual("Fell", rule.RuleName); Assert.AreEqual(RenderingRuleTargets.Areas, rule.Targets); rule = rules[i++]; Assert.AreEqual("Residential", rule.RuleName); Assert.AreEqual(RenderingRuleTargets.Areas, rule.Targets); rule = rules[i++]; Assert.AreEqual("Water", rule.RuleName); Assert.AreEqual(RenderingRuleTargets.Areas, rule.Targets); // check point patterns Assert.AreEqual(11, typesRegistry.Patterns.Count); PatternDefinition patternDefinition = typesRegistry.Patterns["IconPeak"]; Assert.IsNotNull(patternDefinition); }
public void SetVisuals(Animator animator, SpriteRenderer renderer) { animator.runtimeAnimatorController = SpriteDefinition.GetDefinition(_visuals); if (animator.runtimeAnimatorController == null) { animator.runtimeAnimatorController = _defaultVisuals; } renderer.material = PatternDefinition.GetDefinition(_patterns); if (renderer.material == null) { renderer.material = _defaultPattern; } }
public void SortRestrictionTestNextLevelSpecifiedVsNextlevelAll3() { var def1 = PatternDefinition.BuildUpDefinition("*", true); var def2 = PatternDefinition.BuildUpDefinition("Whatever..*.Cre", true); var def3 = PatternDefinition.BuildUpDefinition("..*.Equals", true); var list = new List <PatternDefinition> { def1, def2, def3 }; list.Sort(); list[0].Should().BeSameAs(def2); list[1].Should().BeSameAs(def3); list[2].Should().BeSameAs(def1); }
public void SortRestrictionTest() { var def1 = PatternDefinition.BuildUpDefinition("*", true); var def2 = PatternDefinition.BuildUpDefinition("..[public]*.[public|method]*", true); var def3 = PatternDefinition.BuildUpDefinition("..[public|internal]*.[public|method]*", true); var list = new List <PatternDefinition> { def1, def2, def3 }; list.Sort(); list[0].Should().BeSameAs(def3); list[1].Should().BeSameAs(def2); list[2].Should().BeSameAs(def1); }
/// <summary> /// Constructor /// </summary> /// <param name="fileName">Database file name</param> /// <param name="patternDef">Analyzing pattern</param> public IntermediateLogWriter(string fileName, PatternDefinition patternDef) { log.In(fileName, patternDef); this.regex = new Regex(patternDef.RegularExpression); this.columnDefList = patternDef.ColumnDefinitionList; if (File.Exists(fileName) == false) { CreateDB(fileName, patternDef.ColumnDefinitionList); } connection = SQLiteUtil.OpenConnection(fileName); log.Out(); }
private void CloneButton_Click(object sender, EventArgs e) { if (PatternListBox.SelectedIndex == -1) { return; } PatternDefinition source = patternList[PatternListBox.SelectedIndex]; PatternDefinition dest = SettingFileAccessor.CopyPatternDefinition(Application.StartupPath, source); patternList.Add(dest); ShowPatternList(); }
public static List <PatternDefinition> LoadPatternDefinitionList(string appPath) { List <PatternDefinition> patternList = new List <PatternDefinition>(); string patternPath = CreatePatternDefinitionPath(appPath); string[] files = Directory.GetFiles(patternPath, "*" + SettingsConstants.EXTENSION_PATTERN_FILE); foreach (string file in files) { PatternDefinition pattern = DeserializePatternDefinition(file); patternList.Add(pattern); } return(patternList); }
private void DeleteButton_Click(object sender, EventArgs e) { if (PatternListBox.SelectedIndex == -1 || PatternListBox.SelectedIndex > patternList.Count - 1) { return; } PatternDefinition target = patternList[PatternListBox.SelectedIndex]; SettingFileAccessor.DeletePatternDefinition(Application.StartupPath, target); patternList.Remove(target); ShowPatternList(); }
private void TestButton_Click(object sender, EventArgs e) { if (PatternListBox.SelectedIndex == -1) { MessageBox.Show(Properties.Resources.MessageChoosePattern); return; } PatternDefinition target = patternList[PatternListBox.SelectedIndex]; RegexTestForm form = new RegexTestForm(target.RegularExpression); if (form.ShowDialog() == DialogResult.OK) { target.RegularExpression = form.RegularExpression; ShowPatternDetail(target); } }
public override void calculateDistance(PatternDefinition d, Bitmap b) { Color c1, c2; long dist = 0; // resize b2 to match b1 b = new Bitmap(b, d.Pattern.Size); for (int x = 0; x < d.Pattern.Width; x++) { for (int y = 0; y < d.Pattern.Height; y++) { c1 = d.Pattern.GetPixel(x, y); c2 = b.GetPixel(x, y); dist += absD(c1.R, c2.R) + absD(c1.G, c2.G) + absD(c1.B, c2.B); } } Value = dist; }
private void UpdateButton_Click(object sender, EventArgs e) { if (PatternListBox.SelectedIndex == -1) { return; } PatternDefinition target = patternList[PatternListBox.SelectedIndex]; PatternDefinition updated = CreateEditingPattern(target); patternList.Insert(PatternListBox.SelectedIndex, updated); patternList.Remove(target); SettingFileAccessor.SavePatternDefinition(Application.StartupPath, updated); MessageBox.Show(Properties.Resources.MessageSaveSetting); ShowPatternList(); }
private void ShowPatternDetail(PatternDefinition target) { PatternNameTextBox.Text = target.PatternName; RegexTextBox.Text = target.RegularExpression; ColumnDefinitionDataGrid.Rows.Clear(); foreach (ColumnDefinition col in target.ColumnDefinitionList) { ColumnDefinitionDataGrid.Rows.Add(); // 新規行が存在するため、Countから新規行を引いた2を指定 DataGridViewRow row = ColumnDefinitionDataGrid.Rows[ColumnDefinitionDataGrid.Rows.Count - 2]; row.Cells[COL_INDEX_COLUMN_NAME].Value = col.ColumnName; row.Cells[COL_INDEX_IS_DATETIME].Value = col.IsDateTimeField; row.Cells[COL_INDEX_DATETIME_FORMAT].Value = col.DateTimeFormat; row.Cells[COL_INDEX_VISIBLE].Value = !col.Visble; row.Cells[COL_INDEX_HASHABLE].Value = col.Hashable; row.Cells[COL_INDEX_RESIABLE].Value = col.Resizable; } }
public void SortTest() { var def1 = PatternDefinition.BuildUpDefinition("MyNs.Inner.Other.[public]MyClass.MyMethod", true); var def2 = PatternDefinition.BuildUpDefinition("MyNs.Inner.Other.[public]MyClass.My*", true); var def3 = PatternDefinition.BuildUpDefinition("MyNs.Inner.Other.My*.MyMethod", true); var def4 = PatternDefinition.BuildUpDefinition("MyNs.Inner.Other.*.*", true); var def5 = PatternDefinition.BuildUpDefinition("MyNs..Other.*.*", true); var def6 = PatternDefinition.BuildUpDefinition("..*.*", true); var list = new List <PatternDefinition> { def6, def4, def1, def3, def5, def2 }; list.Sort(); list[0].Should().BeSameAs(def1); list[1].Should().BeSameAs(def2); list[2].Should().BeSameAs(def3); list[3].Should().BeSameAs(def4); list[4].Should().BeSameAs(def5); list[5].Should().BeSameAs(def6); }
public FilteringRangeSettingDialog(FlatProject project, List <FileValue> fileValueList) { InitializeComponent(); this.patternDef = project.PatternDefinition; this.rangeCriteria = SearchCriteria.Copy(project.RangeCriteria); this.fileValueList = fileValueList; foreach (FileValue value in fileValueList) { LogFileNameComboBox.Items.Add(value.Name); } if (LogFileNameComboBox.Items.Count > 0) { LogFileNameComboBox.SelectedIndex = 0; } ShowRangeFilterValues(); }
private void NewProjectSettingDialog_Load(object sender, EventArgs e) { EncodingCombobox.SelectedIndex = 0; SelectedPattern = defaultPattern; PatternList = SettingFileAccessor.LoadPatternDefinitionList(Application.StartupPath); if (PatternList != null) { foreach (PatternDefinition pattern in PatternList) { ListViewItem item = new ListViewItem(pattern.PatternName); item.SubItems.Add(pattern.RegularExpression); PatternListView.Items.Add(item); } if (PatternListView.Items.Count > 0) { PatternListView.Items[0].Selected = true; } } }
private PatternDefinition CreateEditingPattern(PatternDefinition target) { PatternDefinition updatedPattern = new PatternDefinition(); updatedPattern.ID = target.ID; updatedPattern.PatternName = PatternNameTextBox.Text; updatedPattern.RegularExpression = RegexTextBox.Text; int order = 0; foreach (DataGridViewRow row in ColumnDefinitionDataGrid.Rows) { // Ignore last row because it's new row if (row == ColumnDefinitionDataGrid.Rows[ColumnDefinitionDataGrid.Rows.Count - 1]) { break; } ColumnDefinition col = new ColumnDefinition(); if (row.Cells[0].Value == null) { col.ColumnName = ""; } else { col.ColumnName = (string)row.Cells[0].Value; } if (row.Cells[COL_INDEX_IS_DATETIME].Value == null) { col.IsDateTimeField = false; } else { col.IsDateTimeField = (bool)row.Cells[COL_INDEX_IS_DATETIME].Value; } if (row.Cells[COL_INDEX_DATETIME_FORMAT].Value == null) { col.DateTimeFormat = ""; } else { col.DateTimeFormat = (string)row.Cells[COL_INDEX_DATETIME_FORMAT].Value; } if (row.Cells[COL_INDEX_VISIBLE].Value == null) { col.Visble = true; } else { col.Visble = !(bool)row.Cells[COL_INDEX_VISIBLE].Value; } if (row.Cells[COL_INDEX_HASHABLE].Value == null) { col.Hashable = false; } else { col.Hashable = (bool)row.Cells[COL_INDEX_HASHABLE].Value; } if (row.Cells[COL_INDEX_RESIABLE].Value == null) { col.Resizable = false; } else { col.Resizable = (bool)row.Cells[COL_INDEX_RESIABLE].Value; } col.Order = order; updatedPattern.ColumnDefinitionList.Add(col); order++; } return(updatedPattern); }
public PatternExpression(PatternDefinition pattern) { _defaults = pattern.Defaults; Initialize(pattern.Pattern); }