コード例 #1
0
        /// <summary>
        /// Authors: Ameet Toor, Karanbir Toor
        /// Sets the service type for the service being added and changes the current page to the page that should be displayed after the button is clicked.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void nextPage_Click(object sender, RoutedEventArgs e)
        {
            MainWindow mainWindow = Application.Current.MainWindow as MainWindow;

            if ((bool)DriverRadioButton.IsChecked)
            {
                myServiceTypes = ServiceTypes.Drive;
                mainWindow.setServiceType(myServiceTypes);
                IInputElement target = NavigationHelper.FindFrame("ListPage1", this);
                NavigationCommands.GoToPage.Execute("/Informationpage.xaml", target);
            }
            else if ((bool)DonateRadioButton.IsChecked)
            {
                myServiceTypes = ServiceTypes.Donate;
                mainWindow.setServiceType(myServiceTypes);
                IInputElement target = NavigationHelper.FindFrame("ListPage1", this);
                NavigationCommands.GoToPage.Execute("/RequestGoodsPage.xaml", target);
            }
            else if ((bool)EducateRadioButton.IsChecked)
            {
                myServiceTypes = ServiceTypes.Educate;
                mainWindow.setServiceType(myServiceTypes);
                IInputElement target = NavigationHelper.FindFrame("ListPage1", this);
                NavigationCommands.GoToPage.Execute("/EducatePage.xaml", target);
            }
            else if ((bool)RequestGoodsButton.IsChecked)
            {
                myServiceTypes = ServiceTypes.Request;
                mainWindow.setServiceType(myServiceTypes);
                IInputElement target = NavigationHelper.FindFrame("ListPage1", this);
                NavigationCommands.GoToPage.Execute("/RequestGoodsPage.xaml", target);
            }
        }
コード例 #2
0
        IEnumerable <ModernFrame> GetChildFrames()
        {
            var refs = childFrames.ToArray();

            foreach (var r in refs)
            {
                bool        valid = false;
                ModernFrame frame;
                if (r.TryGetTarget(out frame) && NavigationHelper.FindFrame(null, frame) == this)
                {
                    valid = true;
                    yield return(frame);
                }

                if (frame != null && !valid)
                {
                    //raise NavigatedFrom Event
                    if (frame.Content is IContent content)
                    {
                        content.OnNavigatingFrom(new NavigatingCancelEventArgs());

                        var args = new NavigationEventArgs
                        {
                            Frame          = this,
                            Source         = Source,
                            Content        = Content,
                            NavigationType = NavigationType.Back
                        };
                        content.OnNavigatedFrom(args);
                    }
                    childFrames.Remove(r);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// Direct the user to the next page (Thank you page).
        /// @Author Ameet and Karanbir
        /// Grabs user from mainwindow, adds Drive information and adds service.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void nextPage_Click(object sender, RoutedEventArgs e)
        {
            MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
            User       user       = mainWindow.getUser();

            //Add Drive info to user
            user.addDrive(myVehicleType, myCapacity, myStartTime, myEndTime, myFilePath);

            //Add driving service to user
            Service service = new Service(user.getName(), user.getEmail());

            service.setServiceType(ServiceTypes.Drive);
            service.setDonationRequest(DonationTypes.Goods);
            service.setDescription("Driving goods.");

            user.addService(service);

            UserDatabase.updateDatabase();


            ServiceDatabase serviceDatabase = mainWindow.GetServiceDatabase();

            serviceDatabase.createService(ServiceTypes.Drive, DonationTypes.Goods, user, service);

            IInputElement target = NavigationHelper.FindFrame("ListPage1", this);

            NavigationCommands.GoToPage.Execute("/ThankYou.xaml", target);
        }
コード例 #4
0
        private void updateLoginStatus(bool result, string message)
        {
            lblLoginStatus.Text = message;
            if (result)
            {
                Properties.Settings.Default.Username = txtUserName.Text;

                using (var secureString = txtPassword.Password.ToSecureString())
                {
                    Properties.Settings.Default.Password = secureString.EncryptString();
                }

                MainWindow.SaveAllSettings();

                dialog.Close();

                var uri   = new Uri("/Main/" + Properties.Settings.Default.StartPage + "Page.xaml", UriKind.RelativeOrAbsolute);
                var frame = NavigationHelper.FindFrame(null, this);
                if (frame != null)
                {
                    frame.Source = uri;
                }
            }
            dialog.Close();
        }
コード例 #5
0
        private IEnumerable <ModernFrame> GetChildFrames()
        {
            var refs = childFrames.ToArray();

            foreach (var r in refs)
            {
                var valid = false;

                if (r.IsAlive)
                {
                    var frame = (ModernFrame)r.Target;

                    if (NavigationHelper.FindFrame(null, frame) == this)
                    {
                        valid = true;
                        yield return(frame);
                    }
                }

                if (!valid)
                {
                    childFrames.Remove(r);
                }
            }
        }
コード例 #6
0
        private void nextPage_Click(object sender, RoutedEventArgs e)
        {
            checkWhichButtonChecked();

            MainWindow mainWindow = Application.Current.MainWindow as MainWindow;
            User       user       = mainWindow.getUser();

            Service service = new Service(user.getName(), user.getEmail());

            service.setServiceType(mainWindow.getServiceType());
            service.setDonationRequest(myDonationType);
            if (myDonationType != DonationTypes.Other)
            {
                service.setDescription(myDonationType.ToString());
            }
            else
            {
                service.setDescription(myDescription);
            }

            user.addService(service);

            ServiceDatabase serviceDatabase = mainWindow.GetServiceDatabase();

            serviceDatabase.createService(mainWindow.getServiceType(), myDonationType, user, service);

            IInputElement target = NavigationHelper.FindFrame("ListPage1", this);

            NavigationCommands.GoToPage.Execute("/ThankYou.xaml", target);
        }
コード例 #7
0
        // Click on Listbox Element
        private async void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            // Get menu item name
            string         menuItemName             = ((MenuItem)sender).Name;
            int            selectedMovieViewModelId = Convert.ToInt32(((MenuItem)sender).Tag);
            MovieViewModel selectedMovieViewModel   = MovieMap.MapToMovieViewModel(await movieService.GetMovieByIdAsync(selectedMovieViewModelId));

            switch (menuItemName)
            {
            case "menuItemPlayMovie":
                ((ModernWindow)Application.Current.MainWindow).Hide();

                new PlayerWindow(selectedMovieViewModel).Show();
                break;

            case "menuItemMovieProfile":
                this.Dispatcher.Invoke(() =>
                {
                    IInputElement target = NavigationHelper.FindFrame("_top", this);
                    NavigationCommands.GoToPage.Execute("/Views/Content/MovieProfile.xaml#" + selectedMovieViewModelId, target);
                });
                break;

            default:
                break;
            }
        }
コード例 #8
0
ファイル: ModernFrame.cs プロジェクト: wangGuangXu/mui
        /// <summary>
        /// 获取子框架集合
        /// </summary>
        /// <returns></returns>
        private IEnumerable <ModernFrame> GetChildFrames()
        {
            var refs = this.childFrames.ToArray();

            foreach (var r in refs)
            {
                var         valid = false;
                ModernFrame frame;

#if NET4
                if (r.IsAlive)
                {
                    frame = (ModernFrame)r.Target;
#else
                if (r.TryGetTarget(out frame))
                {
#endif
                    //检查frame是否仍然是一个实际的子级(不是移除子级时的情况,而是尚未进行垃圾回收)
                    // check if frame is still an actual child (not the case when child is removed, but not yet garbage collected)
                    if (NavigationHelper.FindFrame(null, frame) == this)
                    {
                        valid = true;
                        yield return(frame);
                    }
                }

                Debug.Write(string.Format("确定是否要移除子框架", valid.ToString()));

                if (!valid)
                {
                    this.childFrames.Remove(r);
                }
            }
        }
コード例 #9
0
ファイル: personalData.xaml.cs プロジェクト: loviji/CVMan
        private void Delete_Employee(object sender, RoutedEventArgs e)
        {
            var dlg = new ModernDialog
            {
                Title   = "Məlumat silgisi",
                Content = new DropEmployee()
            };

            dlg.Buttons = new Button[] { dlg.OkButton, dlg.CancelButton };

            dlg.ShowDialog();
            if (dlg.DialogResult.HasValue && dlg.DialogResult.Value)
            {
                var employer = dbContext.employee.SingleOrDefault(j => j.ID == selectedPersonID);
                employer.isdeleted = true;
                dbContext.SaveChanges();
                GlobalCache.showdialog = false;
                //   string url = "/Pages/Home.xaml";
                //   NavigationCommands.PreviousPage.Execute(url,this);
                IInputElement target = NavigationHelper.FindFrame("_top", this);
                NavigationCommands.GoToPage.Execute("/Pages/Home.xaml", target);


                // selectedPersonID = 0;
                //fillBasicControls();
            }
        }
コード例 #10
0
ファイル: Home.xaml.cs プロジェクト: w7yuu/CenaPlus
        private void btnStart_Click(object sender, RoutedEventArgs e)
        {
            int port;

            if (!int.TryParse(txtPort.Text, out port))
            {
                ModernDialog.ShowMessage("Port must be an integer", "Error", MessageBoxButton.OK);
                return;
            }

            string serverName = txtName.Text;
            string password   = txtPassword.Password;

            Bll.JudgeNode.Password = password;
            var host = new JudgeNodeHost(port, serverName);

            host.Open();

            var frame = NavigationHelper.FindFrame(null, this);

            if (frame != null)
            {
                frame.Source = new Uri("/JudgeNode/Status.xaml", UriKind.Relative);
            }
        }
コード例 #11
0
ファイル: ModernFrame.cs プロジェクト: bakx/mui
        private IEnumerable <ModernFrame> GetChildFrames()
        {
            var refs = childFrames.ToArray();

            foreach (var r in refs)
            {
                bool        valid = false;
                ModernFrame frame;

#if NET4
                if (r.IsAlive)
                {
                    frame = (ModernFrame)r.Target;
#else
                if (r.TryGetTarget(out frame))
                {
#endif
                    // check if frame is still an actual child (not the case when child is removed, but not yet garbage collected)
                    if (NavigationHelper.FindFrame(null, frame) == this)
                    {
                        valid = true;
                        yield return(frame);
                    }
                }

                if (!valid)
                {
                    childFrames.Remove(r);
                }
            }
        }
コード例 #12
0
ファイル: ModernFrame.cs プロジェクト: Abishai2007/actools
        private IEnumerable <ModernFrame> GetChildFrames()
        {
            var refs = _childFrames.ToArray();

            foreach (var r in refs)
            {
                var         valid = false;
                ModernFrame frame;

                if (r.TryGetTarget(out frame))
                {
                    // check if frame is still an actual child (not the case when child is removed, but not yet garbage collected)
                    if (ReferenceEquals(NavigationHelper.FindFrame(null, frame), this))
                    {
                        valid = true;
                        yield return(frame);
                    }
                }

                if (!valid)
                {
                    _childFrames.Remove(r);
                }
            }
        }
コード例 #13
0
        private void imgSourceDirectory_Drop(object sender, DragEventArgs e)
        {
            imgSourceDirectory.Source = new BitmapImage(new Uri("/CenaPlus.Client;component/Resources/Box.png", UriKind.Relative));
            var files = e.Data.GetData(DataFormats.FileDrop) as string[];

            if (files.Length != 1)
            {
                ModernDialog.ShowMessage("You must select a single file.", "Error", MessageBoxButton.OK);
                return;
            }
            else
            {
                if (!Extension.Contains(System.IO.Path.GetExtension(files[0])))
                {
                    ModernDialog.ShowMessage("The file type is not supported.", "Error", MessageBoxButton.OK);
                    return;
                }
                else
                {
                    Static.SourceFileDirectory = System.IO.Path.GetDirectoryName(files[0]);
                    Static.FileName            = System.IO.Path.GetFileNameWithoutExtension(files[0]);
                    Static.Extension           = System.IO.Path.GetExtension(files[0]);
                    switch (Static.Extension)
                    {
                    case ".c":
                        Static.Language = Entity.ProgrammingLanguage.C;
                        break;

                    case ".cpp":
                        Static.Language = Entity.ProgrammingLanguage.CXX;
                        break;

                    case ".java":
                        Static.Language = Entity.ProgrammingLanguage.Java;
                        break;

                    case ".pas":
                        Static.Language = Entity.ProgrammingLanguage.Pascal;
                        break;

                    case ".py":
                        Static.Language = Entity.ProgrammingLanguage.Python27;
                        break;

                    case ".rb":
                        Static.Language = Entity.ProgrammingLanguage.Ruby;
                        break;

                    default:
                        break;
                    }
                    var frame = NavigationHelper.FindFrame(null, this);
                    if (frame != null)
                    {
                        frame.Source = new Uri("/Local/Configuration.xaml", UriKind.Relative);
                    }
                }
            }
        }
コード例 #14
0
        private void btnProceed_OnClick(object sender, RoutedEventArgs e)
        {
            var frame = NavigationHelper.FindFrame(null, this);

            if (frame != null)
            {
                frame.Source = DataGetter.FirstRun ? new Uri("Pages/Settings.xaml", UriKind.Relative) : new Uri("Pages/Home.xaml", UriKind.Relative);
            }
        }
コード例 #15
0
ファイル: ModernFrame.cs プロジェクト: bakx/mui
        private void OnLoaded(object sender, RoutedEventArgs e)
        {
            ModernFrame parent = NavigationHelper.FindFrame(NavigationHelper.FrameParent, this);

            if (parent != null)
            {
                parent.RegisterChildFrame(this);
            }
        }
コード例 #16
0
ファイル: CreateAUser.xaml.cs プロジェクト: w7yuu/CenaPlus
        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            var frame = NavigationHelper.FindFrame(null, this);

            if (frame != null)
            {
                frame.Source = new Uri("/ServerMode/Users.xaml", UriKind.Relative);
            }
        }
コード例 #17
0
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            var frame = NavigationHelper.FindFrame(null, this);

            if (frame != null)
            {
                frame.Source = new Uri("/Remote/Contest/Submit.xaml#" + problemID, UriKind.Relative);
            }
        }
コード例 #18
0
        private void btnModify_Click(object sender, RoutedEventArgs e)
        {
            var frame = NavigationHelper.FindFrame(null, this);

            if (frame != null)
            {
                frame.Source = new Uri("/ServerMode/Contest/Contest.xaml#" + ContestListBox.SelectedValue, UriKind.Relative);
            }
        }
コード例 #19
0
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            int id    = App.Server.CreateContest("New Contest", "Insert description Here.", DateTime.Now.AddHours(12), null, null, DateTime.Now.AddHours(14), Entity.ContestType.OI, false);
            var frame = NavigationHelper.FindFrame(null, this);

            if (frame != null)
            {
                frame.Source = new Uri("/ServerMode/Contest/Contest.xaml#" + id, UriKind.Relative);
            }
        }
コード例 #20
0
        private void ContestListBox_MouseUp(object sender, MouseButtonEventArgs e)
        {
            var frame = NavigationHelper.FindFrame(null, this);

            if (frame != null)
            {
                frame.Source = new Uri("/Remote/Contest/Contest.xaml#" + ContestListBox.SelectedValue, UriKind.Relative);
            }
            ContestListBox.SelectedIndex = -1;
        }
コード例 #21
0
ファイル: ProblemList.xaml.cs プロジェクト: w7yuu/CenaPlus
        private void btnCreate_Click(object sender, RoutedEventArgs e)
        {
            int id    = App.Server.CreateProblem(contestID, "New Problem", "Insert description here.", 0, 1000, 256 * 1024 * 1024, null, null, null, null, null, null, Enumerable.Empty <ProgrammingLanguage>());
            var frame = NavigationHelper.FindFrame(null, this);

            if (frame != null)
            {
                frame.Source = new Uri("/ServerMode/Contest/Problem/Problem.xaml#" + id, UriKind.Relative);
            }
        }
コード例 #22
0
 private void ProblemListBox_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (ProblemListBox.SelectedItem != null)
     {
         var frame = NavigationHelper.FindFrame(null, this);
         if (frame != null)
         {
             frame.Source = new Uri("/Remote/Contest/Problem.xaml#" + (ProblemListBox.SelectedItem as ProblemListBoxItem).ProblemID, UriKind.Relative);
         }
     }
 }
コード例 #23
0
ファイル: ProblemList.xaml.cs プロジェクト: w7yuu/CenaPlus
 private void ProblemListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     if (ProblemListView.SelectedIndex != -1)
     {
         var frame = NavigationHelper.FindFrame(null, this);
         if (frame != null)
         {
             frame.Source = new Uri("/ServerMode/Contest/Problem/Problem.xaml#" + ProblemListView.SelectedValue, UriKind.Relative);
         }
     }
 }
コード例 #24
0
        /// <summary>
        /// Navigate to specific page.
        /// </summary>
        /// <param name="page">source page</param>
        /// <param name="url">target url</param>
        /// <returns></returns>
        public static bool NavigateTo(Page page, string url)
        {
            var uri   = new Uri(url, UriKind.RelativeOrAbsolute);
            var frame = NavigationHelper.FindFrame(null, page);

            if (frame != null)
            {
                frame.Source = uri;
            }

            return(true);
        }
コード例 #25
0
ファイル: Submit.xaml.cs プロジェクト: w7yuu/CenaPlus
        private void btnSubmit_Click(object sender, RoutedEventArgs e)
        {
            int recordID = App.Server.Submit(problemID, new TextRange(txtCode.Document.ContentStart, txtCode.Document.ContentEnd).Text, (ProgrammingLanguage)Enum.Parse(typeof(ProgrammingLanguage), (string)lstLanguage.SelectedItem));
            var problem  = App.Server.GetProblem(problemID);
            var frame    = NavigationHelper.FindFrame(null, this);

            if (frame != null)
            {
                Thread.Sleep(200);
                frame.Source = new Uri("/Remote/Contest/ProblemGeneral.xaml#" + problem.ContestID, UriKind.Relative);
            }
        }
コード例 #26
0
 private void adicionar_button_Click(object sender, RoutedEventArgs e)
 {
     if (!id_textbox.Text.Equals("") && !nome_textbox.Text.Equals("") && !nome_textbox.Text.Equals("") && !cinema_textbox.Text.Equals("") && !salario_textbox.Text.Equals("") && !nif_textbox.Text.Equals(""))
     {
         ModernDialog.ShowMessage("Empregado adicionado com sucesso!", "Sucesso!", MessageBoxButton.OK);
         IInputElement target = NavigationHelper.FindFrame("_top", this);
         NavigationCommands.GoToPage.Execute("/Pages/Adicionar.xaml", target);
     }
     else
     {
         ModernDialog.ShowMessage("Dados inválidos!", "Sem Sucesso!", MessageBoxButton.OK);
     }
 }
コード例 #27
0
 private void editar_button_Click(object sender, RoutedEventArgs e)
 {
     if (!adulto_textbox.Text.Equals("") || !criança_textbox.Text.Equals("") || !senior_textbox.Text.Equals("") || !segunda_feira_textbox.Text.Equals("") || !cartao_textbox.Text.Equals(""))
     {
         ModernDialog.ShowMessage("Preço alterado com sucesso!", "Sucesso!", MessageBoxButton.OK);
         IInputElement target = NavigationHelper.FindFrame("_top", this);
         NavigationCommands.GoToPage.Execute("/Pages/Alterar.xaml", target);
     }
     else
     {
         ModernDialog.ShowMessage("Dados inválidos!", "Sem Sucesso!", MessageBoxButton.OK);
     }
 }
コード例 #28
0
        private void remover_button_Click(object sender, RoutedEventArgs e)
        {
            /*            if (Carregar num item)
             *          {  */
            ModernDialog.ShowMessage("Sala removida com sucesso!", "Sucesso!", MessageBoxButton.OK);
            IInputElement target = NavigationHelper.FindFrame("_top", this);

            NavigationCommands.GoToPage.Execute("/Pages/Remover.xaml", target);

            /*            }
             *          else
             *              ModernDialog.ShowMessage("Dados inválidos!", "Sem Sucesso!", MessageBoxButton.OK);*/
        }
コード例 #29
0
 private void editar_button_Click(object sender, RoutedEventArgs e)
 {
     if (!salas_textbox.Text.Equals(""))
     {
         ModernDialog.ShowMessage("Tecnologia alterada com sucesso!", "Sucesso!", MessageBoxButton.OK);
         IInputElement target = NavigationHelper.FindFrame("_top", this);
         NavigationCommands.GoToPage.Execute("/Pages/Alterar.xaml", target);
     }
     else
     {
         ModernDialog.ShowMessage("Dados inválidos!", "Sem Sucesso!", MessageBoxButton.OK);
     }
 }
コード例 #30
0
 private void adicionar_button_Click(object sender, RoutedEventArgs e)
 {
     if (!id_textbox.Text.Equals("") && !titulo_textbox.Text.Equals("") && !idade_textbox.Text.Equals("") && !duracao_textbox.Text.Equals("") && !estreia_textbox.Text.Equals("") && !tecnologia_textbox.Text.Equals("") && !distribuidora_textbox.Text.Equals("") && !cinemas_textbox.Text.Equals(""))
     {
         ModernDialog.ShowMessage("Filme adicionado com sucesso!", "Sucesso!", MessageBoxButton.OK);
         IInputElement target = NavigationHelper.FindFrame("_top", this);
         NavigationCommands.GoToPage.Execute("/Pages/Adicionar.xaml", target);
     }
     else
     {
         ModernDialog.ShowMessage("Dados inválidos!", "Sem Sucesso!", MessageBoxButton.OK);
     }
 }