Ejemplo n.º 1
0
        static protected void DoTest(JoinResolver solver)
        {
            // loop through all graph class
            for (int n = 2; n <= 9; n++)
            {
                JoinGraph  graph;
                BigInteger expectC1;

                // expected nubmer are from section 6.9
                expectC1 = (BigInteger.Pow(n, 3) - n) / 6;
                graph    = new ClassChain().RandomGenerate(n);
                solver.Reset().Run(graph, expectC1);

                expectC1 = (BigInteger.Pow(n, 3) - (2 * BigInteger.Pow(n, 2)) + n) / 2;
                graph    = new ClassCycle().RandomGenerate(n);
                solver.Reset().Run(graph, expectC1);

                expectC1 = BigInteger.Pow(2, n - 2) * (n - 1);
                graph    = new ClassStar().RandomGenerate(n);
                solver.Reset().Run(graph, expectC1);

                expectC1 = (BigInteger.Pow(3, n) - BigInteger.Pow(2, n + 1) + 1) / 2;
                graph    = new ClassClique().RandomGenerate(n);
                solver.Reset().Run(graph, expectC1);

                // no theoretic number
                graph = new ClassTree().RandomGenerate(n);
                solver.Reset().Run(graph);
                graph = new ClassRandom().RandomGenerate(n);
                solver.Reset().Run(graph);
            }
        }
Ejemplo n.º 2
0
      private void _onProfileChanged(object sender, EventArgs e) {
         _classTree = new ClassTree(Shell.LoadedClasses);
         Selector.ItemsSource = _classTree.Roots;
         Selector.ContextMenuOpening += _onContextMenuOpening;
         Selector.PreviewMouseRightButtonDown += _onPreviewMouseRightButtonDown;
         Selector.ContextMenu = new ContextMenu();

         var maxDepth = _getMaxDepth(BplClass.Get<BplObject>());
         ExpandButtons.Children.Clear();
         for (var i = 1; i <= maxDepth; i++) {
            ExpandButtons.Children.Add(new Button {
               Content = i.ToString(),
               Margin = new Thickness(0),
               MinWidth = 20
            });
         }
      }
Ejemplo n.º 3
0
        } /* RunLogMsgQueueFlush */

        private void  LoadClassesFromDataBase()
        {
            classes = mainDbConn.MLClassLoadList();
            if (classes == null)
            {
                classes = new PicesClassList();
            }

            ClassTree.Nodes.Clear();

            ContextMenuStrip cms = new ContextMenuStrip();

            cms.Items.Add("Insert a new class", null, InsertAClass);

            PicesClass root = classes.RootNode;

            TreeNode tn = new TreeNode(root.Name);

            tn.ContextMenuStrip = cms;
            ClassTree.Nodes.Add(tn);

            if (root.Children != null)
            {
                foreach (PicesClass pc in root.Children)
                {
                    try
                    {
                        AddSubTreeToClassTree(pc, tn.Nodes, cms, 1);
                    }
                    catch (Exception eee5)
                    {
                        MessageBox.Show(this, "'AddSubTreeToClassTree' caused an exception while processing class[" + pc.Name + "]\n",
                                        eee5.ToString(), MessageBoxButtons.OK
                                        );
                    }
                }
            }

            ClassTree.ExpandAll();
        } /* LoadClassesFromDataBase */
Ejemplo n.º 4
0
        static public void Test()
        {
            var solver = new TDBasic();

            // loop through all graph class - can't use DPAlgorithm's DoTest() since the
            // expected numbers are not the same
            //
            for (int n = 2; n <= 10; n++)
            {
                JoinGraph  graph;
                BigInteger expectC1;

                // expected nubmer are from Phd 2.2.4 - shall be the same as DPSub
                expectC1 = BigInteger.Pow(2, n + 2) - (n * n) - (3 * n) - 4;
                graph    = new ClassChain().RandomGenerate(n);
                solver.Reset().Run(graph, expectC1);

                expectC1 = (1 + n) * BigInteger.Pow(2, n) - (2 * n * n) - 2;
                graph    = new ClassCycle().RandomGenerate(n);
                solver.Reset().Run(graph, expectC1);

                expectC1 = (2 * BigInteger.Pow(3, n - 1)) - BigInteger.Pow(2, n);
                graph    = new ClassStar().RandomGenerate(n);
                solver.Reset().Run(graph, expectC1);

                expectC1 = BigInteger.Pow(3, n) - BigInteger.Pow(2, n + 1) + 1;
                graph    = new ClassClique().RandomGenerate(n);
                solver.Reset().Run(graph, expectC1);

                // no theoretic number
                graph = new ClassTree().RandomGenerate(n);
                solver.Reset().Run(graph);
                graph = new ClassRandom().RandomGenerate(n);
                solver.Reset().Run(graph);
            }
        }
Ejemplo n.º 5
0
 public static void Init()
 {
     FileTree  = new FileTree();
     Values    = new List <CmdValue>();
     ClassTree = new ClassTree();
 }
Ejemplo n.º 6
0
 public void SelectClass(ClassTree classTree)
 {
     selectedClass = classTree;
     GameManager.CreatePlayer();
 }
Ejemplo n.º 7
0
#pragma warning disable SA1124 // Do not use regions
        #region CopyRegion

        // Copy from here
#pragma warning disable SA1649 // File name must match first type name
#pragma warning disable SA1402 // File may only contain a single class
        public void PrintTree(ClassTree tree, bool child, IEnumerable <PlcType> knownTypes)
        {
            if (knownTypes == null)
            {
                throw new ArgumentException("knownTypes must not be null", nameof(knownTypes));
            }

            knownTypes = knownTypes.ToArray();
            if (child)
            {
                WriteLine(string.Empty);
            }

            WriteLine($"public static class {tree.Name}");
            WriteLine("{");
            PushIndent("    ");
            var written      = false;
            var writtenProps = new List <string>();

            foreach (var prop in tree.Symbols)
            {
                if (written)
                {
                    WriteLine(string.Empty);
                }

                written = true;
                if (prop.ArrayInfo != null)
                {
                    var typeString = this.GetCsharpTypeAsClassNameString(prop.Type.TypeName);
                    if (typeString == string.Empty)
                    {
                        typeString = prop.Type.TypeName;
                        if (knownTypes.Select(x => x.TypeName).Contains(typeString))
                        {
                            var propName = prop.Name.Split('.').Last();
                            WriteLine($"public static {typeString}ArrayAddress{prop.ArrayInfo.Count()}DUnconnected {propName} {{ get; }} = new {typeString}ArrayAddress{prop.ArrayInfo.Count()}DUnconnected({prop.BitSize}, \"{prop.Name}\");");
                            writtenProps.Add(propName);
                        }
                        else
                        {
                            written = false;
                        }
                    }
                    else
                    {
                        var propName = prop.Name.Split('.').Last();
                        WriteLine($"public static {typeString}ArrayAddress{prop.ArrayInfo.Count()}DUnconnected {propName} {{ get; }} = new {typeString}ArrayAddress{prop.ArrayInfo.Count()}DUnconnected({prop.BitSize}, \"{prop.Name}\");");
                        writtenProps.Add(propName);
                    }
                }
                else
                {
                    var stringType = this.GetCsharpTypeAsClassNameString(prop.Type.TypeName);
                    if (stringType == string.Empty)
                    {
                        stringType = prop.Type.TypeName;
                        if (knownTypes.Select(x => x.TypeName).Contains(stringType))
                        {
                            var propName = prop.Name.Split('.').Last();
                            WriteLine($"public static {stringType} {propName} {{ get; }} = new {stringType} (\"{prop.Name}\");");
                            writtenProps.Add(propName);
                        }
                        else
                        {
                            written = false;
                        }
                    }
                    else
                    {
                        var propName = prop.Name.Split('.').Last();
                        WriteLine($"public static {stringType}AddressUnconnected {propName} {{ get; }} = new {stringType}AddressUnconnected({prop.BitSize}, \"{prop.Name}\");");
                        writtenProps.Add(propName);
                    }
                }
            }

            ;
            foreach (var childTree in tree.Children)
            {
                if (!writtenProps.Contains(childTree.Name))
                {
                    this.PrintTree(childTree, true, knownTypes);
                }
            }

            PopIndent();
            WriteLine("}");
            if (!child)
            {
                WriteLine(string.Empty);
            }
        }
Ejemplo n.º 8
0
      private void _rebuildTree() {
         Tree = new ClassTree(RootClasses, IsHierarchical);

         Selector.ItemsSource = Tree.TopLevel;
         Selector.ContextMenuOpening += _onContextMenuOpening;
         Selector.MouseMove += _onMouseMove;
         Selector.PreviewMouseRightButtonDown += _onPreviewMouseRightButtonDown;
         Selector.ContextMenu = new ContextMenu();
         if (IsHierarchical) {
            Selector.ClearValue(TemplateProperty);
         } else {
            Selector.Template = (ControlTemplate)FindResource("@FlatTreeTemplate");
         }

         var maxDepth = _getMaxDepth(BplClass.Get<BplObject>());
         ExpandButtons.Children.Clear();
         if (IsHierarchical) {
            for (var i = 1; i <= maxDepth; i++) {
               ExpandButtons.Children.Add(new Button {
                  Content = i.ToString(),
                  Margin = new Thickness(0),
                  MinWidth = 20
               });
            }
         }
      }