示例#1
0
        private void AddHotKeys()
        {
            try
            {
                RoutedCommand firstSettings = new RoutedCommand();
                firstSettings.InputGestures.Add(new KeyGesture(Key.Enter));
                CommandBindings.Add(new CommandBinding(firstSettings, Dugme_Login_Click));

                RoutedCommand secondSettings = new RoutedCommand();
                secondSettings.InputGestures.Add(new KeyGesture(Key.Escape));
                CommandBindings.Add(new CommandBinding(secondSettings, Dugme_Otkazi_Click));
            }
            catch (Exception err)
            {
                MessageBox.Show(err.Message);
            }
        }
示例#2
0
 /* Edit canvas methods */
 public void DeleteAll()
 {
     /* Check if there are lines */
     if (Lines.Count > 0)
     {
         /* Clear ListBox, list of lines and update canvas */
         List.Items.Clear();
         List.Items.Refresh();
         Lines.Clear();
         DrawingSheet.Children.Clear();
         MessageBox.Show("All lines deleted", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("No line drawn!", "WARNING!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
示例#3
0
        private void btnDeleteEntry_Click(object sender, RoutedEventArgs e)
        {
            if (MessageBox.Show("Are you sure you wish to delete the selected entrees?", "Delete Entries?",
                                MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            List <Entry> selItems = dgEntryList.SelectedItems.OfType <Entry>().ToList();

            if (!selItems.Any())
            {
                return;
            }

            m_entryList.DeleteEntries(selItems);
        }
示例#4
0
 private void OnTemplate(DPFP.Template template)
 {
     this.Dispatcher.Invoke(new Function(delegate()
     {
         Template = template;
         //VerifyButton.Enabled = SaveButton.Enabled = (Template != null);
         if (Template != null)
         {
             MessageBox.Show("La huella ha sido capturada correctamente", "Capturar huella.");
             imgVerHuella.Visibility = Visibility.Visible;
         }
         else
         {
             MessageBox.Show("The fingerprint template is not valid. Repeat fingerprint enrollment.", "Fingerprint Enrollment");
         }
     }));
 }
 public static void OpenDirectory(string subDirectory)
 {
     try
     {
         var fullPath = Path.Combine(GameRootDirectory, subDirectory ?? "");
         fullPath = Path.GetFullPath(fullPath);
         if (!Directory.Exists(fullPath))
         {
             throw new DirectoryNotFoundException("Could not find directory");
         }
         Process.Start("explorer.exe", fullPath);
     }
     catch (Exception ex)
     {
         MessageBox.Show($"Could not open the folder: {subDirectory}\n\n{ex.Message}", "Warning!");
     }
 }
示例#6
0
        public static void ExportWorkSheetDatas(List <WorkSheetData> sheet_Infos)
        {
            // 数据导出到 Excel
            string errMsg;
            var    succ = ExportDataToExcel(sheet_Infos, out errMsg);

            if (!succ)
            {
                var res = MessageBox.Show($"将数据导出到Excel中时出错:{errMsg},\r\n是否将其以文本的形式导出?", @"提示",
                                          MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                if (res == DialogResult.OK)
                {
                    // 数据导出到 Txt
                    ExportAllDataToDirectory(sheet_Infos);
                }
            }
        }
示例#7
0
 private void FormMain_FormClosing(object sender, FormClosingEventArgs e)
 {
     if (e.CloseReason == CloseReason.UserClosing && viewers.Items.Count > 0)
     {
         var dr = MBOX.Show(
             this,
             LanguageData.Current.FormMain_FormClosing,
             this.Text,
             MessageBoxButtons.YesNo,
             MessageBoxIcon.Question
             );
         if (dr == DialogResult.No)
         {
             e.Cancel = true;
         }
     }
 }
示例#8
0
        private async Task BackupTask(FolderBrowserDialog folderBrowserDialog1)
        {
            string folderName = folderBrowserDialog1.SelectedPath;

            try
            {
                using (new CursorWait(true, this))
                {
                    var   client        = StaticUtils.GetClient();
                    var   getsinnertask = client.AdminGetSINnersWithHttpMessagesAsync();
                    await getsinnertask;
                    using (new CursorWait(true, this))
                    {
                        foreach (var sinner in getsinnertask.Result.Body)
                        {
                            try
                            {
                                if (!sinner.SiNnerMetaData.Tags.Any())
                                {
                                    Log.Error("Sinner " + sinner.Id + " has no Tags!");
                                    continue;
                                }
                                string jsonsinner = Newtonsoft.Json.JsonConvert.SerializeObject(sinner);
                                string filePath   = Path.Combine(folderName, sinner.Id.ToString() + ".chum5json");
                                if (File.Exists(filePath))
                                {
                                    File.Delete(filePath);
                                }
                                File.WriteAllText(filePath, jsonsinner);
                                Log.Info("Sinner " + sinner.Id + " saved to " + filePath);
                            }
                            catch (Exception e2)
                            {
                                Log.Error(e2);
                                Invoke(new Action(() => MessageBox.Show(e2.Message)));
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                Invoke(new Action(() => MessageBox.Show(ex.Message)));
            }
        }
        private async void Button_GenerateRadioStation_Click(object sender, RoutedEventArgs e)
        {
            var trackAux = (Track)datagrid_Track.SelectedItem;

            if (trackAux != null)
            {
                int idGender  = (int)Enum.Parse(typeof(MusicGender), trackAux.Gender.ToString());
                var trackList = await Session.serverConnection.trackService.GenerateRadioStationAsync((short)idGender);

                StreamingPlayer.AddListTracksToQueue(trackList);
                MessageBox.Show("Radio station has been generated: " + trackAux.Gender);
            }
            else
            {
                textBlock_Message.Text = "*Select a track";
            }
        }
示例#10
0
        /// <summary>
        /// Create the Preview.
        /// </summary>
        /// <param name="state">
        /// The state.
        /// </param>
        private void CreatePreview(object state)
        {
            // Make sure we are not already encoding and if we are then display an error.
            if (encodeQueue.IsEncoding)
            {
                MessageBox.Show(
                    this,
                    "Handbrake is already encoding a video!",
                    "Warning",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Warning);

                return;
            }

            encodeQueue.Start((QueueTask)state, false);
        }
示例#11
0
        private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            string filePath = "";

            using (OpenFileDialog fbd = new OpenFileDialog()
            {
                Filter = "Excel 97-2003|*.xls|Excel Workbook|*.xlsx"
            })
            {
                if (fbd.ShowDialog() == DialogResult.OK)
                {
                    filePath = fbd.FileName;
                    try
                    {
                        using (var stream = File.Open(fbd.FileName, FileMode.Open, FileAccess.Read))
                        {
                            using (IExcelDataReader reader = ExcelReaderFactory.CreateReader(stream))
                            {
                                DataSet result = reader.AsDataSet(new ExcelDataSetConfiguration()
                                {
                                    ConfigureDataTable = (_) => new ExcelDataTableConfiguration()
                                    {
                                        UseHeaderRow = true
                                    }
                                });
                                tableCollection = result.Tables;
                                cboSheet.Items.Clear();
                                foreach (DataTable table in tableCollection)
                                {
                                    cboSheet.Items.Add(table.TableName);//add sheet to combobox
                                }
                            }
                        }
                    }
                    catch (System.IO.IOException ex)
                    {
                        MessageBox.Show("Сонгосон файлыг өөр процесс ашиглаж байна файлаа хадгалаад хаана уу \n" + ex.ToString());
                        return;
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
        }
示例#12
0
 /// <summary>
 /// 检查MD5算法有没有开启支持
 /// </summary>
 public void CheckFIPSRegistValue()
 {
     try
     {
         reg = Registry.ClassesRoot;
         string value = GetFIPSRegistData("Enabled");
         if (value != "0")
         {
             //MessageBox.Show("Enabled" + value);
             SetRegistData("Enabled", "0");
         }
     }
     catch (Exception e)
     {
         MessageBox.Show("CheckRegistValue error:" + e.Message);
     }
 }
示例#13
0
        void Model_GetFilePath(object sender, Ozeki.VoIP.VoIPEventArgs <string> e)
        {
            InvokeGuiThread(() =>
            {
                if (SendCapturedFileEmailCheckBox.IsChecked != null && (bool)SendCapturedFileEmailCheckBox.IsChecked)
                {
                    Task.Factory.StartNew(SendEmailThread(e.Item));
                }

                if (UploadCapturedFileFtpCheckBox.IsChecked != null && (bool)UploadCapturedFileFtpCheckBox.IsChecked)
                {
                    Task.Factory.StartNew(UploadFtpThread(e.Item));
                }

                MessageBox.Show("Snapshot saved to " + e.Item, "Snapshot");
            });
        }
 private void OnBackgroundWorker_ProgressChanged_Complete(object sender, RunWorkerCompletedEventArgs e)
 {
     if (e.Cancelled)
     {
         MessageBox.Show("Learning has been canceled");
     }
     else if (e.Error != null)
     {
         MessageBox.Show(e.Error.Message);
     }
     else
     {
         MessageBox.Show("Learning has ended");
         _dataContext.Stopwatch.Stop();
         _dispatcherTimer.Stop();
     }
 }
示例#15
0
 private void PopulateImageList()
 {
     Items.Clear();
     try
     {
         var images = CameraDevice.GetObjects(null, true);
         foreach (DeviceObject deviceObject in images)
         {
             Items.Add(new FileItem(deviceObject, CameraDevice));
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show(TranslationStrings.LabelErrorLoadingFileList);
         Log.Error("Error loading file list", exception);
     }
 }
        public static bool CheckForUpdate(bool notify)
        {
            try
            {
                string tempfile = System.IO.Path.GetTempFileName();
                using (WebClient client = new WebClient())
                {
                    client.DownloadFile("http://digicamcontrol.com/updates/versioninfo.xml", tempfile);
                }

                XmlDocument document = new XmlDocument();
                document.Load(tempfile);
                string ver              = document.SelectSingleNode("application/version").InnerText;
                string url              = "http://digicamcontrol.com/download";
                string logurl           = "";
                var    selectSingleNode = document.SelectSingleNode("application/url");
                if (selectSingleNode != null)
                {
                    url = selectSingleNode.InnerText;
                }
                var logNode = document.SelectSingleNode("application/logurl");
                if (logNode != null)
                {
                    logurl = logNode.InnerText;
                }
                Version v_ver = new Version(ver);
                if (v_ver > Assembly.GetExecutingAssembly().GetName().Version)
                {
                    var wnd = new NewVersionWnd(logurl, url);
                    wnd.ShowDialog();
                }
                else
                {
                    if (notify)
                    {
                        MessageBox.Show(TranslationStrings.MsgApplicationUpToDate);
                    }
                }
                File.Delete(tempfile);
            }
            catch (Exception exception)
            {
                Log.Error("Error download update information", exception);
            }
            return(false);
        }
示例#17
0
        private bool OstrzeżenieOUtracie()
        {
            DialogResult wybór = MessageBox.Show(@"Czy chcesz wcześniej zapisać zmiany?", string.Empty, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);

            switch (wybór)
            {
            case System.Windows.Forms.DialogResult.Cancel:
                return(false);

            case System.Windows.Forms.DialogResult.Yes:
                Zapisz_OnClick(null, null);

                break;
            }

            return(true);
        }
 private void Window_Closing(object sender, CancelEventArgs e)
 {
     if (_backgroundWorker.IsBusy)
     {
         if (MessageBox.Show("A task is running !\n Do you want to cancel it ?", "", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No)
         {
             e.Cancel = true;
         }
         else
         {
             if (_backgroundWorker.IsBusy)
             {
                 _backgroundWorker.CancelAsync();
             }
         }
     }
 }
示例#19
0
        private async void btnLogin_Click(object sender, RoutedEventArgs e)
        {
            Dispatcher.Invoke(() =>
            {
                btnLogin.IsEnabled  = false;
                spnLogin.Visibility = Visibility.Visible;
            });

            var user     = txtUserName.Text.Trim();
            var password = txtPassword.Password.Trim();

            var token = await Task.Run(() => GetToken(user, password));

            if (token?.Length > 0)
            {
                if (_rememberCreds)
                {
                    CreateOrUpdateStoredCreds(user, password);
                }

                if (rdoPlayer.IsChecked != null && (bool)rdoPlayer.IsChecked)
                {
                    var playerView = new PlayerSelectView(Logger, token);
                    Close();
                    playerView.Show();
                }
                else
                {
                    MessageBox.Show("This mode is currently under construction!", "Sorry");
                    btnLogin.IsEnabled = true;

                    //var consumableView = new ConsumableSelectView(Logger, token);
                    //Close();
                    //consumableView.Show();
                }
            }
            else
            {
                _messageBoxActive = true;
                MessageBox.Show("Invalid User or Password", "Authentication Error");
                btnLogin.IsEnabled    = true;
                chkRemember.IsChecked = false;
            }

            spnLogin.Visibility = Visibility.Hidden;
        }
示例#20
0
        private void cmdCleanReinstall_Click(object sender, EventArgs e)
        {
            Log.Info("cmdCleanReinstall_Click");
            if (MessageBox.Show(LanguageManager.GetString("Message_Updater_CleanReinstallPrompt", GlobalOptions.Language),
                                LanguageManager.GetString("MessageTitle_Updater_CleanReinstallPrompt", GlobalOptions.Language), MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
            {
                return;
            }
            if (Directory.Exists(_strAppPath) && File.Exists(_strTempPath))
            {
                Cursor                    = Cursors.WaitCursor;
                cmdUpdate.Enabled         = false;
                cmdRestart.Enabled        = false;
                cmdCleanReinstall.Enabled = false;
                if (!CreateBackupZip())
                {
                    Cursor = Cursors.Default;
                    return;
                }

                HashSet <string> lstFilesToDelete    = new HashSet <string>(Directory.GetFiles(_strAppPath, "*", SearchOption.AllDirectories));
                HashSet <string> lstFilesToNotDelete = new HashSet <string>();
                foreach (string strFileToDelete in lstFilesToDelete)
                {
                    string strFileName       = Path.GetFileName(strFileToDelete);
                    string strFilePath       = Path.GetDirectoryName(strFileToDelete).TrimStart(_strAppPath);
                    int    intSeparatorIndex = strFilePath.LastIndexOf(Path.DirectorySeparatorChar);
                    string strTopLevelFolder = intSeparatorIndex != -1 ? strFilePath.Substring(intSeparatorIndex + 1) : string.Empty;
                    if ((!strFilePath.StartsWith("customdata") &&
                         !strFilePath.StartsWith("data") &&
                         !strFilePath.StartsWith("export") &&
                         !strFilePath.StartsWith("lang") &&
                         !strFilePath.StartsWith("settings") &&
                         !strFilePath.StartsWith("sheets") &&
                         !strFilePath.StartsWith("Utils") &&
                         !string.IsNullOrEmpty(strFilePath.TrimEnd(strFileName))) ||
                        strFileName.EndsWith(".old"))
                    {
                        lstFilesToNotDelete.Add(strFileToDelete);
                    }
                }
                lstFilesToDelete.RemoveWhere(x => lstFilesToNotDelete.Contains(x));

                InstallUpdateFromZip(_strTempPath, lstFilesToDelete);
            }
        }
        public bool Delete(UserbLL u)
        {
            //create a boolean variable and set its default value to false
            bool isSuccess = false;

            //create an object of sql connection to connect database
            SqlConnection conn = new SqlConnection(myconstn);

            try
            {
                //create the string variable to hold the sql query to delete data
                string SQL = "DELETE userTbl WHERE userId=@userId ";

                //create a sql command to pass the value in query
                SqlCommand cmd = new SqlCommand(SQL, conn);

                //now pass the vale to sql query
                cmd.Parameters.AddWithValue("@userId", u.UserId);

                //create a variable to hold the value after query executed
                int rows = cmd.ExecuteNonQuery();

                if (rows > 0)
                {
                    //query executed successfully
                    isSuccess = true;
                }
                else
                {
                    //failed to execute query
                    isSuccess = false;
                }
            }
            catch (Exception Ex)
            {
                //dispose error message if there is any exceptional error
                MessageBox.Show(Ex.Message);
            }
            finally
            {
                //close database connection
                conn.Close();
            }
            return(isSuccess);
        }
示例#22
0
        private void ManageLicense()
        {
            try
            {
                var stopAdvertisementLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "McTools.StopAdvertisement.dll");

                if (File.Exists(stopAdvertisementLocation))
                {
                    var type = Assembly.LoadFile(stopAdvertisementLocation).GetType("McTools.StopAdvertisement.LicenseManager");
                    if (type == null)
                    {
                        return;
                    }

                    var methodInfo = type.GetMethod("IsValid");
                    if (methodInfo == null) { return; }

                    object classInstance = Activator.CreateInstance(type, null);

                    if ((bool)methodInfo.Invoke(classInstance, null))
                    {
                        var userNameInfo = type.GetProperty("UserName");
                        var orgNameInfo = type.GetProperty("OrganizationName");

                        var userName = userNameInfo.GetValue(classInstance, null).ToString();
                        var orgName = orgNameInfo.GetValue(classInstance, null).ToString();

                        lblSupport.Text = string.Format(lblSupport.Text,
                            userName,
                            orgName.Length > 0 && orgName != userName ? string.Format(" ({0})", orgName) : "");

                        pnlSupport.Visible = true;
                    }
                }
            }
            catch (FileNotFoundException)
            {
                // Nothing to do as if the file is missing, it's not big deal
            }
            catch (NotSupportedException)
            {
                MessageBox.Show(this,
                    "It seems you maybe forgot to unblock XrmToolBox.zip before extracting it. XrmToolBox can't work as expected until you unblocked all files. To do so, display XrmToolBox.zip properties and unblock the file before extracting it", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#23
0
        private static void UnhandledExceptionHandler(Exception e)
        {
            if (e is InvalidOperationException && e.Message.Contains("Visibility") && e.Message.Contains("WindowInteropHelper.EnsureHandle"))
            {
                Logging.Error(e.ToString());
                return;
            }

            var text = e?.ToString() ?? @"?";

            if (!_initialized)
            {
                try {
                    MessageBox.Show(text, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                } catch (Exception) {
                    // ignored
                }
                Environment.Exit(1);
            }

            if (!LogError(text))
            {
                try {
                    var logFilename = $"{AppDomain.CurrentDomain.BaseDirectory}/content_manager_crash_{DateTime.Now.Ticks}.txt";
                    File.WriteAllText(logFilename, text);
                } catch (Exception) {
                    // ignored
                }
            }

            try {
                UnhandledExceptionFancyHandler(e);
                return;
            } catch (Exception ex) {
                LogError(ex.Message);

                try {
                    MessageBox.Show(text, "Fatal Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                } catch (Exception) {
                    // ignored
                }
            }

            Environment.Exit(1);
        }
示例#24
0
 public LoginViewModel()
 {
     WhenLogin = ReactiveCommand.CreateFromTask(async v =>
     {
         Visibility = Visibility.Hidden;
         var auth   = new OldAuthenticator(UserName, Password, App.Config.ClientToken);
         try
         {
             var result  = await auth.Authenticate();
             var account = new MinecraftAccount
             {
                 Name        = result["auth_player_name"],
                 AccessToken = result["auth_access_token"],
                 AccountGuid = Guid.Parse(result["auth_uuid"]),
                 Type        = result["user_type"]
             };
             App.Config.Accounts[account.Name] = account;
             App.Config.DefaultAccount         = account.Name;
             App.Config  = App.Config;
             var version = Directory.CreateDirectory("versions").FullName;
             var asset   = Directory.CreateDirectory("assets").FullName;
             var lib     = Directory.CreateDirectory("libraries").FullName;
             var games   = Directory.CreateDirectory("games").FullName;
             //Start game
             var defaultGame = App.Config.Instances[App.Config.DefaultGame];
             var game        = await defaultGame
                               .GetMinecraftGame(version, Array.Empty <string>());
             var assetList = JsonConvert.DeserializeObject <MinecraftAssetCollection>(
                 await File.ReadAllTextAsync(Path.Combine(asset, "indexes", $"{game.AssetIndex}.json")));
             var launcher = new Launcher(auth, game, assetList, asset, lib,
                                         Path.Combine(games, App.Config.DefaultGame), defaultGame.CustomJava ?? App.Config.DefaultJava);
             launcher.ArgBuilder.Append(new JvmArgProvider(o =>
             {
                 o.MaxMemoryInMegaBytes = defaultGame.Ram;
             }));
             await launcher.Run();
             Environment.Exit(0);
         }
         catch (AuthenticationException e)
         {
             MessageBox.Show(e.Message, "错误", MessageBoxButtons.OKCancel);
             Visibility = Visibility.Visible;
         }
     });
 }
示例#25
0
        public Result OnStartup(UIControlledApplication application)
        {
            try
            {
                ControlledApplication = application.ControlledApplication;

                RevThread.IdlePromise.RegisterIdle(application);
                TransactionManager.SetupManager(new AutomaticTransactionStrategy());
                ElementBinder.IsEnabled = true;

                //TAF load english_us TODO add a way to localize
                res = Resource_en_us.ResourceManager;
                // Create new ribbon panel
                RibbonPanel ribbonPanel = application.CreateRibbonPanel(res.GetString("App_Description"));

                dynamoButton =
                    (PushButton)ribbonPanel.AddItem(
                        new PushButtonData(
                            "Dynamo 0.7 Alpha",
                            res.GetString("App_Name"),
                            assemblyName,
                            "Dynamo.Applications.DynamoRevit"));


                Bitmap dynamoIcon = Resources.logo_square_32x32;

                BitmapSource bitmapSource = Imaging.CreateBitmapSourceFromHBitmap(
                    dynamoIcon.GetHbitmap(),
                    IntPtr.Zero,
                    Int32Rect.Empty,
                    BitmapSizeOptions.FromEmptyOptions());

                dynamoButton.LargeImage = bitmapSource;
                dynamoButton.Image      = bitmapSource;

                RegisterAdditionalUpdaters(application);

                return(Result.Succeeded);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return(Result.Failed);
            }
        }
        private void BtnExportNow_Click(object sender, RoutedEventArgs e)
        {
            Custome custome = new Custome(this.pathExport, "Chọn đường dẫn để xuất File");

            if (custome.ShowDialog() == false)
            {
                return;
            }
            if (listData.Items.Count == 0)
            {
                MessageBox.Show("Không có gì để xuất cả");
                return;
            }
            this.running.Show();
            Splash.Visibility = Visibility.Visible;
            this.pathExport   = custome.Answer;
            int    num  = 0;
            string path = this.pathExport + @"\export.xlsx";

            try
            {
                while (true)
                {
                    bool isExists = File.Exists(path);
                    if (!isExists)
                    {
                        break;
                    }
                    path = this.pathExport + @"\export-" + num + ".xlsx";
                    num++;
                }
                ExcelHelper.GenerateExcel(this.ConvertToDataTable(this.listItems), path);
                this.running.Hide();
                System.Windows.MessageBox.Show(System.Windows.Application.Current.MainWindow, "Xuất file thành công!" + Environment.NewLine + path, "Thông báo !", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Exclamation);
            }
            catch
            {
                this.running.Hide();
                System.Windows.MessageBox.Show(System.Windows.Application.Current.MainWindow, "Xuất file thất bại", "Thông báo !", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning);
            }
            finally
            {
                Splash.Visibility = Visibility.Collapsed;
            }
        }
示例#27
0
        private void TeamNameSet(object sender, RoutedEventArgs e)
        {
            try
            {
                MotoGPDB4 objCourse = db.MotoGPDB4s.Single(course => course.TeamName == TeamsNameMod.Text);

                string name   = objCourse.TeamName;
                int    yearof = objCourse.YearOfFound;
                int    wonch  = objCourse.WonChamps;
                bool   a      = objCourse.Fee;
                db.MotoGPDB4s.DeleteOnSubmit(objCourse);
                try
                {
                    db.SubmitChanges();
                    MaxNum.Text        = MaxWonCham();
                    MaxNumYear.Text    = MaxYear();
                    BeginningNum1.Text = MinYear();
                }

                catch (Exception)
                {
                    MessageBox.Show("Something is wrong in submitting.", "Error", 0);
                }
                MotoGPDB4 datab    = new MotoGPDB4();
                int       maxPrice = db.MotoGPDB4s.Max(s => s.Id) + 1;
                datab.Id          = maxPrice;
                datab.TeamName    = TeamNameModTo.Text;
                datab.WonChamps   = wonch;
                datab.YearOfFound = yearof;
                datab.Fee         = a;
                try
                {
                    db.MotoGPDB4s.InsertOnSubmit(datab);
                    db.SubmitChanges();
                }
                catch
                {
                    MessageBox.Show("Something is wrong in the insertion.", "Error", 0);
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Only existing teams can be deleted.", "Error", 0, MessageBoxIcon.Warning);
            }
        }
示例#28
0
        private void searchPasswordToolStripMenuItem_Click(object sender, EventArgs e)
        {
            char[] zeichen = { ' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };


            myConn = new PLCConnection((string)lstConnections.SelectedItem);
            myConn.Connect();

            Int64 anz = 0;

            bool   pwdCorr = false;
            string pwd     = "12345678";

            int[] cnt = new int[8];
            while (!pwdCorr)
            {
                cnt[0]++;
                for (int n = 0; n < 7; n++)
                {
                    if (cnt[n] >= zeichen.Length)
                    {
                        cnt[n + 1]++;
                        cnt[n] = 0;
                    }
                }

                if (cnt[7] >= zeichen.Length)
                {
                    MessageBox.Show("Password not found!");
                    return;
                }


                pwd = "";
                for (int n = 0; n < 8; n++)
                {
                    pwd += zeichen[cnt[n]];
                }

                anz++;
                pwdCorr = myConn.PLCSendPassword(pwd.Trim());
            }

            MessageBox.Show("Passwort:" + pwd + "\n" + "Anzahl geprüfter Kennwörter:" + anz.ToString());
        }
示例#29
0
        private void AddStepImagesButton_Click(object sender, RoutedEventArgs e)
        {
            var fileDialog = new OpenFileDialog();

            fileDialog.Filter = "Images (*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|" +
                                "All files (*.*)|*.*";

            fileDialog.Multiselect = true;
            fileDialog.Title       = "My Image Browser";

            DialogResult dr = fileDialog.ShowDialog();

            if (dr == System.Windows.Forms.DialogResult.OK)
            {
                List <string> result = new List <string>();
                foreach (string file in fileDialog.FileNames)
                {
                    try
                    {
                        result.Add(file);
                    }
                    catch (SecurityException ex)
                    {
                        System.Windows.MessageBox.Show("Security error. Please contact your administrator for details.\n\n" +
                                                       "Error message: " + ex.Message + "\n\n" +
                                                       "Details (send to Support):\n\n" + ex.StackTrace
                                                       );
                    }
                    catch (Exception ex)
                    {
                        System.Windows.MessageBox.Show("Cannot display the image: " + file.Substring(file.LastIndexOf('\\'))
                                                       + ". You may not have permission to read the file, or " +
                                                       "it may be corrupt.\n\nReported error: " + ex.Message);
                    }
                }
                if (result != null)
                {
                    ImageListView.ItemsSource = result;
                }
                else
                {
                    MessageBox.Show("Bạn chưa chọn ảnh");
                }
            }
        }
 private void BtnLoaDanhSach_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         this.basePath = txtFoderInput.Text;
         this.listItems.Clear();
         listData.ClearValue(ItemsControl.ItemsSourceProperty);
         string[] path = new string[0];
         if (chkFile.IsChecked == true)
         {
             if (chkFillTer.IsChecked == true)
             {
                 string[] fillter = txtFillter.Text.Split('|');
                 foreach (string fill in fillter)
                 {
                     path = path.Union(System.IO.Directory.GetFiles(this.basePath, fill)).ToArray();
                 }
             }
             else
             {
                 path = System.IO.Directory.GetFiles(this.basePath);
             }
         }
         else
         {
             path = System.IO.Directory.GetDirectories(this.basePath);
         }
         foreach (string fileName in path)
         {
             DateTime dateTime  = System.IO.File.GetLastWriteTime(fileName);
             string[] pathSplit = fileName.Split('\\');
             this.listItems.Add(new ListLoad()
             {
                 Select = true, Path = fileName, FileName = pathSplit.Last(), DateModified = dateTime
             });
         }
         listData.ItemsSource = this.listItems;
         lblSoLuong.Text      = this.stringSoLuong(listItems.Count);
         MessageBox.Show("Thành Công " + this.stringSoLuong(listItems.Count) + "!");
     }
     catch
     {
         MessageBox.Show("Không có gì để load cả");
     }
 }