public virtual void Process(Type @class, TPrinter printer) { // NOTE: CHANGE IT!!! AssemblySelector selector = AssemblySelector.Get(@class.Assembly); ClassInclude defaultClassInclude = selector.GetClassInclude(@class, printer.Diagram); ClassSelector classSelector = ClassSelector.Get(@class, defaultClassInclude); printer.BeginClass(ModelUtils.ToClassType(@class), PlantUmlUtils.GetSimpleName(@class), PlantUmlUtils.GetGenerics(@class), PlantUmlUtils.GetStereotypes(@class)?.ToArray()); this.ProcessMembersIfChecked(classSelector, ModelUtils.GetConstructors(@class), printer); this.ProcessMembersIfChecked(classSelector, ModelUtils.GetMethods(@class), printer); this.ProcessMembersIfChecked(classSelector, ModelUtils.GetProperties(@class), printer); this.ProcessMembersIfChecked(classSelector, ModelUtils.GetEvents(@class), printer); this.ProcessMembersIfChecked(classSelector, ModelUtils.GetFields(@class), printer); printer.EndClass(); //this.ProcessNestedIfChecked(classSelector, ModelUtils.GetNestedTypes(@class), printer); this.ProcessMembersIfChecked(classSelector, ModelUtils.GetGeneralizations(@class), printer); this.ProcessMembersIfChecked(classSelector, ModelUtils.GetAssociations(@class), printer); this.ProcessMembersIfChecked(classSelector, ModelUtils.GetDependencies(@class), printer); }
public void ClassSelector_ParseTest() { string text1 = ".a"; ITextProvider tp = new StringTextProvider(text1); TokenStream tokens = Helpers.MakeTokenStream(tp); ClassSelector d = new ClassSelector(); Assert.IsTrue(d.Parse(new ItemFactory(tp, null), tp, tokens)); Assert.IsNotNull(d.ClassName); Assert.IsNotNull(d.Dot); text1 = ". a"; tp = new StringTextProvider(text1); tokens = Helpers.MakeTokenStream(tp); d = new ClassSelector(); Assert.IsTrue(d.Parse(new ItemFactory(tp, null), tp, tokens)); Assert.IsNull(d.ClassName); Assert.IsNotNull(d.Dot); text1 = "a"; tp = new StringTextProvider(text1); tokens = Helpers.MakeTokenStream(tp); d = new ClassSelector(); Assert.IsFalse(d.Parse(new ItemFactory(tp, null), tp, tokens)); text1 = ".a[b=c]"; tp = new StringTextProvider(text1); tokens = Helpers.MakeTokenStream(tp); d = new ClassSelector(); Assert.IsTrue(d.Parse(new ItemFactory(tp, null), tp, tokens)); Assert.IsNotNull(d.ClassName); Assert.IsNotNull(d.Dot); }
private void ProcessMembersIfChecked <T>(ClassSelector classSelector, IEnumerable <T> members, TPrinter printer) { foreach (T member in members) { if (classSelector.Check(member, printer.Diagram)) { this.provider.GetProcessor <T>().Process(member, printer); } } }
private void ProcessNestedIfChecked(ClassSelector classSelector, IEnumerable <Type> nestedTypes, TPrinter printer) { foreach (Type nestedType in nestedTypes) { if (classSelector.CheckNested(nestedType, printer.Diagram)) { this.provider.GetProcessor <Type>().Process(nestedType, printer); } } }
protected override void CreateChildElements() { base.CreateChildElements(); this.minMaxCloseButtonsStackLayoutPanel = new StackLayoutPanel(); this.minMaxCloseButtonsStackLayoutPanel.EqualChildrenHeight = true; this.Children.Add(this.minMaxCloseButtonsStackLayoutPanel); this.systemButtons = new StackLayoutPanel(); this.systemButtons.Class = "SystemButtonsStackLayout"; this.systemButtons.Orientation = Orientation.Horizontal; this.systemButtons.Alignment = ContentAlignment.MiddleRight; this.minMaxCloseButtonsStackLayoutPanel.Children.Add(this.systemButtons); this.minimizeButton = new RadImageButtonElement(); this.minimizeButton.StateManager = new RibbonBarSystemButtonStateManager().StateManagerInstance; this.minimizeButton.ThemeRole = "RibbonMinimizeButton"; this.minimizeButton.Class = "MinimizeButton"; this.minimizeButton.Image = Properties.Resources.ribbon_minimize; this.minimizeButton.Click += new EventHandler(this.OnMinimize); ClassSelector selector = new ClassSelector("ButtonFill"); ClassSelector borderSelector = new ClassSelector("ButtonBorder"); selector.GetSelectedElements(this.minimizeButton).First.Value.Class = "CaptionButtonFill"; borderSelector.GetSelectedElements(this.minimizeButton).First.Value.Class = "CaptionButtonBorder"; this.systemButtons.Children.Add(minimizeButton); this.maximizeButton = new RadImageButtonElement(); this.maximizeButton.StateManager = new RibbonBarSystemButtonStateManager().StateManagerInstance; this.maximizeButton.ThemeRole = "RibbonMaximizeButton"; this.maximizeButton.Class = "MaximizeButton"; this.maximizeButton.Image = Properties.Resources.ribbon_maximize; this.maximizeButton.Click += new EventHandler(this.OnMaximizeRestore); selector.GetSelectedElements(this.maximizeButton).First.Value.Class = "CaptionButtonFill"; borderSelector.GetSelectedElements(this.maximizeButton).First.Value.Class = "CaptionButtonBorder"; this.systemButtons.Children.Add(maximizeButton); this.closeButton = new RadImageButtonElement(); this.closeButton.StateManager = new RibbonBarSystemButtonStateManager().StateManagerInstance; this.closeButton.ThemeRole = "RibbonCloseButton"; this.closeButton.Class = "CloseButton"; this.closeButton.Image = Properties.Resources.ribbon_close; this.closeButton.Click += new EventHandler(this.OnClose); selector.GetSelectedElements(this.closeButton).First.Value.Class = "CaptionButtonFill"; borderSelector.GetSelectedElements(this.closeButton).First.Value.Class = "CaptionButtonBorder"; this.systemButtons.Children.Add(closeButton); this.captionText = new TextPrimitive(); this.captionText.Class = "TitleCaption"; this.captionText.TextAlignment = ContentAlignment.MiddleCenter; captionText.SetValue(RibbonBarCaptionLayoutPanel.CaptionTextProperty, true); captionText.BindProperty(TextPrimitive.TextProperty, this, RadItem.TextProperty, PropertyBindingOptions.OneWay); this.captionText.FontChanged += new EventHandler(captionText_FontChanged); }
public ClassSelectorTests() { var classes = new List <Class>(); var hero = Class.CreateForTesting("Fighter", DiceSides.d10); var bartender = Class.CreateForTesting("Bartender", DiceSides.d4); classes.Add(hero); classes.Add(bartender); classGateway = EntityGateway <Class> .LoadFromList(classes); subject = new ClassSelector(classGateway); }
private void RenameClass_btn_Click(object sender, RoutedEventArgs e) { if (ProjectSelector.Validate() && ClassSelector.Validate() && NameSelector.Validate()) { if (GlobalFunction.ProjectBackupPrompt(ProjectSelector.Directory, ProjectSelector.FileName)) { RenameClassAndReferences(); MessageBox.Show("Your class has been renamed\nFollow steps on next page to open your project for the first time"); Tutorial Temp = new Tutorial(); Temp.Show(); Close(); } } }
public void OnElementSelectorKeyChanged(RadElement element, RadPropertyChangedEventArgs changeArgs) { if (changeArgs.Property == RadItem.VisualStateProperty && !this.hasVisualSelectors) { return; } string oldSelectorValue = changeArgs.OldValue as string; int oldSelectorKey = -1; Debug.Assert(oldSelectorValue != null); //TODO: decouple if (changeArgs.Property == RadElement.ClassProperty) { oldSelectorKey = ClassSelector.GetSelectorKey(oldSelectorValue); } else if (changeArgs.Property == RadItem.VisualStateProperty) { oldSelectorKey = VisualStateSelector.GetSelectorKey(oldSelectorValue); } IEnumerable <StylesheetTreeNode> nodeList = null; if (oldSelectorKey != -1) { //Optimization LinkedList <StylesheetTreeNode> mappedNodes; if (this.nodesByKey.TryGetValue(oldSelectorKey, out mappedNodes)) { nodeList = mappedNodes; } } else { nodeList = this.RootNode.Nodes; } if (nodeList != null) { //TODO: optimization possible //Detach element should traverse the element tree and prepare cache for AttachElement call later foreach (StylesheetTreeNode node in nodeList) { node.DetachElement(element); } } this.AttachElement(element); }
public ICollection <StylesheetTreeNode> FindNodes(RadElement element) { //TODO too coupled to RadElement and its properties LinkedList <StylesheetTreeNode> result = new LinkedList <StylesheetTreeNode>(); if (nodes == null) { return(result); } RadItem item = element as RadItem; StylesheetTreeNode foundNode; if (item != null && item.StateManager != null /*&& !string.IsNullOrEmpty(item.VisualState)*/) { //Opptimization for Old themes if (this.hasVisualStateSelectors) { foreach (string itemState in item.StateManager.GetStateFallbackList(item)) { if (this.nodes.TryGetValue(VisualStateSelector.GetSelectorKey(itemState), out foundNode)) { result.AddLast(foundNode); break; } } } } if (!string.IsNullOrEmpty(element.Class)) { if (this.nodes.TryGetValue(ClassSelector.GetSelectorKey(element.Class), out foundNode)) { result.AddLast(foundNode); } } if (!string.IsNullOrEmpty(element.Name) && this.nodes.TryGetValue(NameSelector.GetSelectorKey(element.Name), out foundNode)) { result.AddLast(foundNode); } if (this.nodes.TryGetValue(element.GetThemeEffectiveType().GetHashCode(), out foundNode)) { result.AddLast(foundNode); } return(result); }
public override bool IsCompatible(RadObject element) { IStylableNode stylableNode = element as IStylableNode; ClassSelector internalSelector1 = this.internalSelector as ClassSelector; if (internalSelector1 != null) { return(internalSelector1.ElementClass == stylableNode.Class); } TypeSelector internalSelector2 = this.internalSelector as TypeSelector; if (internalSelector2 != null) { return((object)internalSelector2.ElementType == (object)element.GetType()); } return(true); }
public void ClassSelectorInvalidClassNameTest() { string[] tests = new string[] { ". a", ".#", }; foreach (string test in tests) { ITextProvider tp = new StringTextProvider(test); TokenStream ts = Helpers.MakeTokenStream(tp); ClassSelector classSelector = new ClassSelector(); Assert.IsTrue(classSelector.Parse(new ItemFactory(tp, null), tp, ts)); Assert.IsNull(classSelector.ClassName, "Invalid ClassName parsed correctly for CSS '{0}'", test); Assert.IsNotNull(classSelector.Dot); } }
public void ClassSelectorInvalidTest() { string[] tests = new string[] { "a", "#abc", "*", "+", ">", "|foo", }; foreach (string test in tests) { ITextProvider tp = new StringTextProvider(test); TokenStream ts = Helpers.MakeTokenStream(tp); ClassSelector classSelector = new ClassSelector(); Assert.IsFalse(classSelector.Parse(new ItemFactory(tp, null), tp, ts), "Invalid CSS '{0}' parsed correctly", test); } }
public void ClassSelectorValidTest() { string[] tests = new string[] { ".a", ".a[b=c]", ".*", }; foreach (string test in tests) { ITextProvider tp = new StringTextProvider(test); TokenStream ts = Helpers.MakeTokenStream(tp); ClassSelector classSelector = new ClassSelector(); Assert.IsTrue(classSelector.Parse(new ItemFactory(tp, null), tp, ts), "Valid CSS '{0}' parsed incorrectly", test); Assert.IsNotNull(classSelector.ClassName, "ClassName not parsed correct for CSS '{0}'", test); Assert.IsNotNull(classSelector.Dot, "ClassSelector.Dot not parsed correct for CSS '{0}'", test); } }
private void radButton1_Click(object sender, EventArgs e) { ClassSelector selector = new ClassSelector("ButtonBorder"); BorderPrimitive border; if (this.selectedButton != null) { border = (BorderPrimitive)selector.GetSelectedElements(this.selectedButton).First.Value; border.ForeColor = this.oldBorderColor; } this.selectedButton = (sender as RadButton).ButtonElement; border = (BorderPrimitive)selector.GetSelectedElements(this.selectedButton).First.Value; border.ForeColor = Color.Red; this.menuBurn.Enabled = true; this.menuEmail.Enabled = true; this.menuOpenWidth.Enabled = true; this.menuPrint.Enabled = true; }
void menuitem_添加class_Click(object sender, System.Windows.RoutedEventArgs e) { ClassSelector frm = new ClassSelector(this.InterfaceItemNode.Module.ProjectID.Value); if (frm.ShowDialog() == true) { var value = frm.SelectedValue; TreeNodeBase parent = value.Parent; while (!(parent is EJClient.Forms.InterfaceCenter.Nodes.DLLNode)) { parent = parent.Parent; } string filepath = ((EJClient.Forms.InterfaceCenter.Nodes.DLLNode)parent).FilePath; EJ.InterfaceInModule data = new EJ.InterfaceInModule() { ModuleID = InterfaceItemNode.Module.id, x = (int)m_RightButtonDownPoint.X, y = (int)m_RightButtonDownPoint.Y, Type = typeof(ClassView).FullName, }; UI.ClassView view = new ClassView(value, filepath, data); try { data.JsonData = view.GetJsonData(); data.id = Helper.Client.InvokeSync <int>("UpdateInterfaceInModule", data); data.ChangedProperties.Clear(); view.Margin = new Thickness(m_RightButtonDownPoint.X, m_RightButtonDownPoint.Y, 0, 0); m_Grid.Children.Add(view); } catch (Exception ex) { MessageBox.Show(MainWindow.instance, ex.Message); } } }
static void Main(string[] args) { int classIndex = 0; int raceIndex = 0; Character character = new Character(); character.Race = RaceSelector.SelectRace(); character.CharachterClass = ClassSelector.BuildClass(); Console.WriteLine(); Console.WriteLine("You have chosen: " + ClasessData.Classes[classIndex]); Console.WriteLine("You have chosen: " + RacesData.Races[raceIndex]); Console.WriteLine("Time to set your stats"); var command = Console.ReadLine(); StatRollerService.SetStates(character.Race, character); Console.WriteLine("Time to choose your background"); Console.WriteLine("This will help you with extra set of skills to select"); Console.WriteLine("Your background also informers your charachters traits. These charachter traits are suggestions, not absolute rules"); Console.WriteLine("But your background is way more than only your skills. For more details, read the players manual. Starting at page 126"); SkillListBuilder.SelectSkills(character); BuildTextFile.PrintCharachterToTextFile(character); }
public virtual void Process(Assembly assembly, TPrinter printer) { AssemblySelector selector = AssemblySelector.Get(assembly); // Check in which diagram can be used. foreach (string diagram in selector.GetDiagrams()) { printer.BeginDiagram(diagram); foreach (Type @class in assembly.DefinedTypes.Where(@class => [email protected]())) { ClassSelector classSelector = ClassSelector.Get(@class); // Is pointed out with a 'DiagramAttribute' OR 'ClassDiagramAttribute'. if (selector.Check(@class, diagram) || classSelector.GetClassInclude(diagram) != ClassInclude.None) { this.provider.GetProcessor <Type>().Process(@class, printer); } } printer.EndDiagram(); } }
private string FindRuleSetInFile(IEnumerable <string> extensions, string className, out RuleSet rule) { string root = ProjectHelpers.GetProjectFolder(peekableItem._textbuffer.GetFileName()); string result = null; bool isLow = false, isMedium = false; rule = null; foreach (string ext in extensions) { ICssParser parser = CssParserLocator.FindComponent(ProjectHelpers.GetContentType(ext.Trim('.'))).CreateParser(); foreach (string file in Directory.EnumerateFiles(root, "*" + ext, SearchOption.AllDirectories)) { if (file.EndsWith(".min" + ext, StringComparison.OrdinalIgnoreCase) || file.Contains("node_modules") || file.Contains("bower_components") || file.Contains("\\obj\\Release") || file.Contains("\\obj\\Debug\\") || file.Contains("\\obj\\publish\\")) { continue; } string text = File.ReadAllText(file); int index = text.IndexOf("." + className, StringComparison.Ordinal); if (index == -1) { continue; } StyleSheet css = parser.Parse(text, true); var visitor = new CssItemCollector <ClassSelector>(false); css.Accept(visitor); IEnumerable <ClassSelector> selectors = visitor.Items.Where(c => c.ClassName.Text == className); ClassSelector high = selectors.FirstOrDefault(c => c.FindType <AtDirective>() == null && (c.Parent.NextSibling == null || c.Parent.NextSibling.Text == ",")); if (high != null) { rule = high.FindType <RuleSet>(); return(file); } ClassSelector medium = selectors.FirstOrDefault(c => c.Parent.NextSibling == null || c.Parent.NextSibling.Text == ","); if (medium != null && !isMedium) { rule = medium.FindType <RuleSet>(); result = file; isMedium = true; continue; } ClassSelector low = selectors.FirstOrDefault(); if (low != null && !isLow && !isMedium) { rule = low.FindType <RuleSet>(); result = file; isLow = true; } } } return(result); }
private string FindFile(IEnumerable <string> extensions, out int position) { string root = ProjectHelpers.GetProjectFolder(TextView.TextBuffer.GetFileName()); position = -1; bool isLow = false, isMedium = false; string result = null; foreach (string ext in extensions) { ICssParser parser = CssParserLocator.FindComponent(ProjectHelpers.GetContentType(ext.Trim('.'))).CreateParser(); foreach (string file in Directory.EnumerateFiles(root, "*" + ext, SearchOption.AllDirectories)) { if (file.EndsWith(".min" + ext, StringComparison.OrdinalIgnoreCase) || file.Contains("node_modules") || file.Contains("bower_components")) { continue; } string text = File.ReadAllText(file); int index = text.IndexOf("." + _className, StringComparison.Ordinal); if (index == -1) { continue; } Microsoft.WebTools.Languages.Css.TreeItems.StyleSheet css = parser.Parse(text, true); var visitor = new CssItemCollector <ClassSelector>(false); css.Accept(visitor); IEnumerable <ClassSelector> selectors = visitor.Items.Where(c => c.ClassName.Text == _className); ClassSelector high = selectors.FirstOrDefault(c => c.FindType <AtDirective>() == null && (c.Parent.NextSibling == null || c.Parent.NextSibling.Text == ",")); if (high != null) { position = high.Start; return(file); } ClassSelector medium = selectors.FirstOrDefault(c => c.Parent.NextSibling == null || c.Parent.NextSibling.Text == ","); if (medium != null && !isMedium) { position = medium.Start; result = file; isMedium = true; continue; } ClassSelector low = selectors.FirstOrDefault(); if (low != null && !isMedium && !isLow) { position = low.Start; result = file; isLow = true; continue; } } } return(result); }
public static void Main(string[] args) { StreamWriter output = new StreamWriter("InferenceTest.txt"); try { //Set Output Console.SetOut(output); Console.WriteLine("## Inference Test Suite"); //Load the Test RDF TurtleParser ttlparser = new TurtleParser(); Graph g = new Graph(); //ttlparser.TraceParsing = true; ttlparser.Load(g, "InferenceTest.ttl"); Console.WriteLine("Inference Test Data Loaded OK"); Console.WriteLine(); Console.WriteLine("Graph contains the following Triples:"); foreach (Triple t in g.Triples) { Console.WriteLine(t.ToString()); } Console.WriteLine(); //Select everything that is exactly a Car Console.WriteLine("# Selecting things whose class is exactly Car"); ExactClassSelector carsel = new ExactClassSelector(g, g.CreateUriNode("eg:Car")); Test(g, carsel); Console.WriteLine(); //Select everything that is any sort of Car Console.WriteLine("# Selecting things whose class is Car or a subclass thereof"); ClassSelector allcarsel = new ClassSelector(g, g.CreateUriNode("eg:Car")); Test(g, allcarsel); Console.WriteLine(); //Select everything that is a SportsCar or superclass thereof Console.WriteLine("# Selecting things whose class is SportsCar or superclass thereof"); Console.WriteLine("# Thus things which are Cars are selected but not PeopleCarriers since they are a sibling class and not a superclass"); WideningClassSelector wcarsel = new WideningClassSelector(g, g.CreateUriNode("eg:SportsCar")); Test(g, wcarsel); Console.WriteLine(); //Select everything that is exactly a Jumbo Jet Console.WriteLine("# Selecting things whose class is exactly JumboJet"); ExactClassSelector jjsel = new ExactClassSelector(g, g.CreateUriNode("eg:JumboJet")); Test(g, jjsel); Console.WriteLine(); //Select everything that is an Air Vehicle Console.WriteLine("# Selecting things which are Air Vehicles"); ClassSelector avsel = new ClassSelector(g, g.CreateUriNode("eg:AirVehicle")); Test(g, avsel); Console.WriteLine(); //Select everything that has a defined Speed Console.WriteLine("# Selecting things which have exactly Speed defined"); HasExactPropertySelector spsel = new HasExactPropertySelector(g.CreateUriNode("eg:Speed")); Test(g, spsel); Console.WriteLine(); //Select things with a limited Speed Console.WriteLine("# Selecting things which have a Limited Speed defined"); HasExactPropertySelector lspsel = new HasExactPropertySelector(g.CreateUriNode("eg:LimitedSpeed")); Test(g, lspsel); Console.WriteLine(); //Select things with any kinds of Speed Console.WriteLine("# Selecting things which have any kinds of Speed defined"); HasPropertySelector allspsel = new HasPropertySelector(g, g.CreateUriNode("eg:Speed")); Test(g, allspsel); Console.WriteLine(); //Now stick the Graph in a Triple Store with a Reasoner attached Console.WriteLine("# Using a Triple Store with an RDFS Reasoner attached"); TripleStore store = new TripleStore(); store.AddInferenceEngine(new RdfsReasoner()); g.BaseUri = new Uri("http://example.org/Inference"); //Add a couple of additional Triples, their types must be inferred g.Assert(new Triple(g.CreateUriNode("eg:AudiA8"), g.CreateUriNode("eg:Speed"), (180).ToLiteral(g))); g.Assert(new Triple(g.CreateUriNode("eg:SpaceShuttle"), g.CreateUriNode("eg:AirSpeed"), (17500).ToLiteral(g))); //Add the Graph to the store, this is when inference occurs store.Add(g); Console.WriteLine("Triple Store contains the following Triples"); foreach (Triple t in store.Triples) { Console.WriteLine(t.ToString()); } Console.WriteLine(); //Select things which are a Car Console.WriteLine("# Selecting things which are a Car (or subclass thereof)"); HasPropertyValueSelector carsel2 = new HasPropertyValueSelector(g.CreateUriNode("rdf:type"), g.CreateUriNode("eg:Car")); Test(store, carsel2); Console.WriteLine(); //Select things which are Air Vehicles Console.WriteLine("# Selecting things which are Air Vehicles"); HasPropertyValueSelector avsel2 = new HasPropertyValueSelector(g.CreateUriNode("rdf:type"), g.CreateUriNode("eg:AirVehicle")); Test(store, avsel2); Console.WriteLine(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } output.Close(); }