private void HideStuff()
        {
            btnLaunch.Show();

            AccountBox.Hide();
            PasswordBox.Hide();
            btnConnect.Hide();
            LabelPassword.Hide();
            LabelAccount.Text = "Logged in as " + account;
        }
Exemple #2
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //this.WindowState = WindowState.Normal;
            //this.WindowStyle = WindowStyle.None;
            //this.ResizeMode = ResizeMode.NoResize;
            //this.Topmost = true;

            this.Left = 0.0;
            this.Top  = 0.0;
            //this.Width = SystemParameters.PrimaryScreenWidth;
            //this.Height = SystemParameters.PrimaryScreenHeight;

            AccountBox.Focus();
            //kbc.Visibility = Visibility.Hidden;
        }
Exemple #3
0
        // main function
        private void SearchButton_Click(object sender, EventArgs e)
        {
            // init variables
            int    start, finish;
            String AccountInput = AccountBox.GetItemText(AccountBox.SelectedItem);
            String ExploreInput = ExploreBox.GetItemText(ExploreBox.SelectedItem);

            System.Text.RegularExpressions.Regex Input2 = new System.Text.RegularExpressions.Regex(@"[A-Z]");

            // scuffed ordinal dictionary
            Dictionary <int, String> ordinal = new Dictionary <int, String>()
            {
                { 0, "th" }, { 1, "st" }, { 2, "nd" }, { 3, "rd" }, { 4, "th" },
                { 5, "th" }, { 6, "th" }, { 7, "th" }, { 8, "th" }, { 9, "th" },
                { 10, "th" }, { 11, "th" }, { 12, "th" }, { 13, "th" }, { 14, "th" },
                { 15, "th" }, { 16, "th" }, { 17, "th" }, { 18, "th" }, { 19, "th" },
                { 20, "th" }, { 21, "th" }, { 22, "th" }, { 23, "th" }, { 24, "th" }
            };

            //Reset Graph Color
            foreach (String v in g.vertices)
            {
                graph.FindNode(v).Attr.FillColor = Microsoft.Msagl.Drawing.Color.White;
            }

            //case no account input
            if (!Input2.IsMatch(AccountInput))
            {
                ResultBox.Text = "Invalid Input 2 . . .";
                return;
            }

            ResultBox.Clear();

            //case same input
            if (AccountInput == ExploreInput)
            {
                ResultBox.AppendText("Please input a different node . . .\n");
            }

            //Explore Friend
            if ((BFSRadio.Checked || DFSRadio.Checked) && Input2.IsMatch(ExploreInput) && AccountInput != ExploreInput)
            {
                // get path from BFS or DFS Algo
                List <String> pathToExplore;
                if (BFSRadio.Checked)
                {
                    pathToExplore = g.ExploreBFS(AccountInput, ExploreInput);
                }
                else
                {
                    pathToExplore = g.ExploreDFS(AccountInput, ExploreInput);
                }

                //Bold first line, it's stupid i know
                start = ResultBox.Text.Length;
                ResultBox.AppendText("Explore Path From " + AccountInput + " To " + ExploreInput + (BFSRadio.Checked ? " (BFS) " : " (DFS) ") + "\n");
                finish = ResultBox.Text.Length - start;
                ResultBox.Select(start, finish);
                ResultBox.SelectionFont = new Font(ResultBox.Font, FontStyle.Bold);

                //case not found
                if (pathToExplore[0] == "-1")
                {
                    ResultBox.AppendText("Tidak ada jalur koneksi yang tersedia.\nAnda harus memulai koneksi baru itu sendiri.\n");
                }
                //case found
                else
                {
                    //print each node and color it
                    foreach (String path in pathToExplore)
                    {
                        if (path == pathToExplore.Last())
                        {
                            ResultBox.AppendText(path + "\n");
                            graph.FindNode(path).Attr.FillColor = Microsoft.Msagl.Drawing.Color.LightPink;
                        }
                        else
                        {
                            ResultBox.AppendText(path + " -> ");
                            graph.FindNode(path).Attr.FillColor = Microsoft.Msagl.Drawing.Color.MistyRose;
                        }
                    }
                    //print degree
                    ResultBox.AppendText((pathToExplore.Count() - 2) + ordinal[pathToExplore.Count() - 2] + " Degree Connection\n");
                }

                ResultBox.AppendText("\n");
            }

            //Friend Recommendation
            List <List <String> > firstDegreeFriend = g.FriendRecBFS(AccountInput);

            //Bold first line, again, it's stupid
            start = ResultBox.Text.Length;
            ResultBox.AppendText("Friend Recommendation For " + AccountInput + " :\n");
            finish = ResultBox.Text.Length - start;
            ResultBox.Select(start, finish);
            ResultBox.SelectionFont = new Font(ResultBox.Font, FontStyle.Bold);
            ResultBox.Select(ResultBox.Text.Length, 0);

            //Print
            foreach (List <String> list in firstDegreeFriend)
            {
                foreach (String v in list)
                {
                    if (v == list.First())
                    {
                        ResultBox.SelectionBullet = true;
                        ResultBox.AppendText("Friend " + v + "\n");
                        ResultBox.SelectionBullet = false;
                        ResultBox.AppendText((list.Count() - 1) + " Mutual Friend : ");
                    }
                    else
                    {
                        ResultBox.AppendText(v + " ");
                    }
                }
                ResultBox.AppendText("\n");
            }

            //Color First Node
            graph.FindNode(AccountInput).Attr.FillColor = Microsoft.Msagl.Drawing.Color.LightCyan;

            //Update Graph
            gViewer1.Graph = graph;
        }