Beispiel #1
0
        public void StartEditDatabase(DatabaseData srcDatabaseData)
        {
            DatabaseData dstDatabaseData = model.SetDatabaseAsEdit(srcDatabaseData);

            TreeForm.SetDatabaseDefinition(dstDatabaseData);
            TreeForm.SetEditMode(true);
        }
Beispiel #2
0
        /// <summary>
        /// ابتدا یال های گراف را بر اساس صعودی مرتب می کنیم (برای نزولی می توان در تری فورم کامپیر تو را تغیر داد یا متد زیر را به وسیله ی معکوس کردن نزولی کرد
        /// سپس لیستی از نود ها درخت می سازیم و هر سری یک پارت به وسیله ی میک دیسجوین ست درست می کنیم و در آن می ریزیم می دانیم نود نامبر ها همان ایندکس های تمپ ورتکست نیز هستند
        /// (علاوه بر اینکه ایندکس های ورتکست های خود گراف نیز هستند)
        ///  در آخر می آیم می بینیم اگه دونود که سر و ته ادج هستند در یک ست از دیسجوینت ست نیستند برشان می داریم
        /// </summary>
        /// <param name="graph"></param>
        /// <returns></returns>
        public static List <Edge <T> > KruskalUseTreeDisjointSt(Graph.G_LinkedListForm <T> graph)
        {
            List <Edge <T> > tempEdges   = graph.Edges;
            List <Edge <T> > resultEdges = new List <Edge <T> >();
            List <TreeNode <Vertex <T> > > tempVertices = new List <TreeNode <Vertex <T> > >();

            tempEdges.Sort();
            foreach (var graphVertex in graph.Vertices)
            {
                TreeNode <Vertex <T> > a = TreeForm <Vertex <T> > .Make(graphVertex);

                tempVertices.Add(a);
            }

            for (int i = 0; i < tempEdges.Count; i++)
            {
                if (!TreeForm <Vertex <T> > .Find(tempVertices[tempEdges[i].FirstVertex.NodeNumber]).Equals(TreeForm <Vertex <T> > .Find(tempVertices[tempEdges[i].SecondVertex.NodeNumber])))
                {
                    resultEdges.Add(tempEdges[i]);
                    TreeForm <Vertex <T> > .Union(tempVertices[tempEdges[i].FirstVertex.NodeNumber], tempVertices[tempEdges[i].SecondVertex.NodeNumber]);
                }
            }



            return(resultEdges);
        }
Beispiel #3
0
 public void RemoveDatabase(DatabaseData databaseData)
 {
     if (model.RemoveDatabase(databaseData))
     {
         TreeForm.RemoveDatabaseDefinition(databaseData.Definition.Path);
     }
 }
Beispiel #4
0
        public void DatabaseCreated()
        {
            DatabaseData databaseData = model.GetDatabasedata();

            TreeForm.SetDatabaseDefinition(databaseData);
            TreeForm.SetEditMode(true);
            rrdDbForm.SetDatabaseDefinition(databaseData);
        }
Beispiel #5
0
        public bool OpenDatabase(string databasePath)
        {
            DatabaseData databaseData = model.AddDatabase(databasePath);

            TreeForm.SetDatabaseDefinition(databaseData);
            rrdDbForm.SetDatabaseDefinition(databaseData);
            TreeForm.SetEditMode(false);
            return(true);
        }
Beispiel #6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            TreeForm f1 = new TreeForm();

            Application.Run(f1);
            ConnectionManager.CloseConnection();
        }
 /// <summary>
 /// Shows the given min-priority queue with the given title, provided leftToShow is
 /// positive.
 /// </summary>
 /// <param name="q">The min-priority queue.</param>
 /// <param name="leftToShow">If positive, the drawing will be shown.</param>
 /// <param name="title">The form title.</param>
 /// <returns>leftToShow - 1 if leftToShow is positive, or leftToShow
 /// otherwise.</returns>
 private decimal Show(MinPriorityQueue <int, string> q, decimal leftToShow,
                      string title)
 {
     if (leftToShow > 0)
     {
         TreeForm f = q.HeapDrawing;
         f.Text = title;
         f.Show();
         leftToShow--;
     }
     return(leftToShow);
 }
Beispiel #8
0
        public void Run()
        {
            if (rrdDbForm == null)
            {
                rrdDbForm = new RrdDbForm();
                rrdDbForm.RegisterController(this);
            }

            TreeForm.RegisterController(this);
            TreeForm.ShowHint = WeifenLuo.WinFormsUI.Docking.DockState.DockLeft;
            view.AddDockingPanel(TreeForm);
            view.AddDockingPanel(rrdDbForm);
        }
Beispiel #9
0
        public void DatabaseUpdated(DatabaseData srcDatabaseData)
        {
            DatabaseData reloadedData;

            if (srcDatabaseData != null)
            {
                reloadedData = model.ReloadDatabase(srcDatabaseData);
            }
            else
            {
                reloadedData = model.EditingDatabaseData;
            }
            rrdDbForm.SetDatabaseDefinition(reloadedData);
            TreeForm.SetDatabaseDefinition(reloadedData);
        }
Beispiel #10
0
 public void CloseApp()
 {
     if (model.EditingDatabaseData == null)
     {
         return;
     }
     if (model.DatabaseDirty)
     {
         string savePath = TreeForm.SaveDataBase(model.EditingDatabaseData.Definition.getPath());
         if (savePath == string.Empty)
         {
             return;
         }
         CreateDatabase(savePath);
     }
 }
Beispiel #11
0
 // Show tree form
 public void showTreeForm(Excel.Workbook workbook)
 {
     try
     {
         if (treeForm == null)
         {
             treeForm = new TreeForm(workbook, configXML);
         }
         else
         {
             treeForm.setApplication(workbook);
         }
         treeForm.Show();
         treeForm.startUp();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #12
0
 // Show tree form
 public void showTreeForm(Word.Document document)
 {
     try
     {
         if (treeForm == null)
         {
             treeForm = new TreeForm(document, configXML);
         }
         else
         {
             treeForm.setApplication(document);
         }
         treeForm.Show();
         treeForm.startUp();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Beispiel #13
0
 // Show tree form
 public void showTreeForm(PowerPoint.Presentation presentation)
 {
     try
     {
         presentation.Save(); // Saves the document
         if (treeForm == null)
         {
             treeForm = new TreeForm(presentation.FullName, configXML);
         }
         else
         {
             treeForm.setApplication(presentation.FullName);
         }
         treeForm.Show();
         treeForm.startUp();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 /// <summary>
 /// Event handler for the opening a graph; constructs a tree
 /// </summary>
 /// <param name="sender">general object passed in</param>
 /// <param name="e">event object passed in</param>
 private void uxLoadGraph_Click(object sender, EventArgs e)
 {
     try
     {
         UndirectedGraph graph;
         MSTNode         node;
         TreeForm        tf;
         if (uxOpenDialog.ShowDialog() == DialogResult.OK)
         {
             graph = ReadGraph(uxOpenDialog.FileName);
             node  = graph.GetMinSpanningTree();
             tf    = new TreeForm(node, 100);
             tf.Show();
             uxTour.Text = node.Walk();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
Beispiel #15
0
        public void CreateDatabase(string databasePath)
        {
            if (model.EditingDatabaseData == null)
            {
                throw new ApplicationException("Not in edit mode");
            }

            string oldpath     = model.EditingDatabaseData.Definition.Path;
            RrdDb  srcDatabase = null;

            if (!string.IsNullOrEmpty(model.EditingDatabaseData.SourceDatabasePath))
            {
                srcDatabase = new RrdDb(model.EditingDatabaseData.SourceDatabasePath);
            }
            RrdDef rrdDef = model.EditingDatabaseData.Definition;

            rrdDef.setPath(databasePath);
            RrdDb dstDatabase = new RrdDb(rrdDef);

            if (srcDatabase != null)
            {
                srcDatabase.copyStateTo(dstDatabase);
            }

            if (srcDatabase != null)
            {
                srcDatabase.close();
            }
            dstDatabase.close();
            model.DatabaseDirty       = false;
            model.EditingDatabaseData = null;
            DatabaseData databaseData = model.AddDatabase(databasePath);

            rrdDbForm.SetDatabaseDefinition(databaseData);

            TreeForm.RemoveDatabaseDefinition(oldpath);
            TreeForm.SetDatabaseDefinition(databaseData);
            TreeForm.SetEditMode(false);
        }
        /// <summary>
        /// * calculates position of each node based on its level and the no.of nodes that are in its same level
        /// * adds the calculated position point to the (Position) attribute in (Node) class
        /// * creates a graphic object (rectangle or ellipse) for the node and add it to (nodesList) in this classs
        ///
        /// input: nodesLevelsMap (in this class)
        /// output: calculated position & created GObjects
        ///
        /// Note: hab2a an2elha fl private ba3d ma n5allas 34an a3rf a7ottelek btoo3k f region 3 b3daha :D
        /// </summary>
        private void CreateGNodes()
        {
            NumberOfLevel = nodesLevelsMap.Count;

            HeightForm = TreeForm.getInstance().ClientRectangle.Height;
            WidthForm  = TreeForm.getInstance().ClientRectangle.Width;

            foreach (var kvp in nodesLevelsMap)
            {
                value = kvp.Value;
                key3  = kvp.Key;
                foreach (Node v in value)
                {
                    CountN++;
                    v.position.Y = (((key3 * (HeightForm / NumberOfLevel)) / 2) + ((HeightForm / NumberOfLevel) / 2));
                    //v.position.Y = 0;
                    v.position.X = (((WidthForm / value.Count) * CountN) / 2) + CountN;
                    // v.position.Y = 50;
                    AddGnode(v);
                }
                CountN = 0;
            }
        }
Beispiel #17
0
        /// <summary>
        /// Handles the event when the search button is hit
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uxFindAnagrams_Click(object sender, EventArgs e)
        {
            uxListBox.Items.Clear();
            FoundAnagrams = new StringSet();
            uxString.Text = uxString.Text.ToLower();
            GetAnagrams(new ConsList<string>("", null), new StringBuilder(""), BuildQueue(uxString.Text.Trim()));
            FoundAnagrams.AddAll(uxListBox.Items);

            TreeForm form = new TreeForm(FoundAnagrams, 100);
            form.Text = uxString.Text;
            form.Show();

            uxAnagramCount.Text = "" + uxListBox.Items.Count;
        }
Beispiel #18
0
 public void NewDatabase(string databaseName, DateTime startTime, long step)
 {
     TreeForm.SetDatabaseDefinition(model.CreateDatabase(databaseName, startTime, step));
     rrdDbForm.SetDatabaseDefinition(model.CreateDatabase(databaseName, startTime, step));
 }
 public void Done()
 {
     Drawer.getInstance().initAndDraw();
     TreeForm.getInstance().Show();
 }
Beispiel #20
0
 public void DeleteDatabaseDefinition()
 {
     TreeForm.RemoveDatabaseDefinition(model.EditingDatabaseData.Definition.Path);
     model.EditingDatabaseData = null;
     model.DatabaseDirty       = false;
 }