Exemple #1
0
        private void SelectNewDB()
        {
            string       db;
            ResponseType result = FileDialog.Show(FileChooserAction.Save,
                                                  this,
                                                  S._("Please enter the name for the new database"),
                                                  out db);

            if (result == ResponseType.Ok && db.Length > 0)
            {
                if (System.IO.Path.GetExtension(db).Length == 0)
                {
                    db += ".vdb";
                }

                bool create = true;
                if (File.Exists(db))
                {
                    create = (MsgDialog.Show(this,
                                             MessageType.Question,
                                             ButtonsType.YesNo,
                                             S._("Database exists"),
                                             S._("Database already exists. Overwrite?")) == ResponseType.Yes);
                }

                if (create)
                {
                    OpenDB(db, true, false, ShowDBProperties);                     // no async list refresh necessary - new database
                    //ShowDBProperties();
                }
            }
        }
Exemple #2
0
 void Current_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
 {
     Logger.Fatal("Application Error", e.Exception);
     MsgDialog.Show("Sorry, some errors occurred, the error message is saved in log");
     Application.Current.Shutdown();
     e.Handled = true;//使用这一行代码告诉运行时,该异常被处理了,不再作为UnhandledException抛出了。
 }
Exemple #3
0
 private void OnImportCompleted(object sender, ImportCompletedEventArgs e)
 {
     try {
         Application.Invoke(delegate {
             if (e.Error != null)
             {
                 if (e.Error is System.IO.FileNotFoundException)
                 {
                     MsgDialog.ShowError(this, S._("Import failed"),
                                         S._("Database not found."));
                 }
                 progress.Text = S._("Import failed!");
             }
             else if (e.Cancelled)
             {
                 progress.Text = S._("Import aborted.");
             }
             else
             {
                 progress.Text = S._("Import completed successfully.");
                 OnVolumesImported();
             }
         });
     } finally {
         Application.Invoke(delegate {
             btnClose.Sensitive   = true;
             fcDatabase.Sensitive = true;
             btnImport.Sensitive  = true;
             btnImport.Label      = LBL_IMPORT;
         });
     }
 }
Exemple #4
0
        public bool LoadMap(string _filepath)
        {
            bool LoadSucess = mapdata.LoadMap(_filepath);

            IsLoad  = LoadSucess;
            IsDirty = false;
            if (LoadSucess == true)
            {
                optionReset();
                //tabitem.Header = mapdata.SafeFileName;
                //tabitem.Content = this;
                InitControl();
                mapDataBinding.PropertyChangeAll();
            }

            return(LoadSucess);

            try
            {
            }
            catch (Exception e)
            {
                Dialog.MsgDialog msgDialog = new MsgDialog(System.IO.Path.GetFileName(_filepath) + "는 열 수 없는 맵입니다.\n" + e.Message, MessageBoxButton.OK, MessageBoxImage.Error);
                msgDialog.ShowDialog();
                return(false);
            }
        }
Exemple #5
0
 private void OnDeleteEvent(object o, Gtk.DeleteEventArgs args)
 {
     if (import != null && import.IsBusy)
     {
         MsgDialog.ShowError(this, S._("Import in progress"),
                             S._("You must stop the import before closing this window."));
         args.RetVal = true;
     }
 }
        public void CaseDetailAddCancelHandler()
        {
            hkCaseDetailMgrModelAdd.Stop();
            MsgDialog.WindowClose(this.caseNo + "号配件明细");
            CaseDetailMgr detailFrm = new CaseDetailMgr(this.caseNumberID, "", this.caseNo);

            this.Close();
            detailFrm.Show();
        }
Exemple #7
0
        private void AddVolume()
        {
            PlatformIO.DriveInfo drive;

            if (App.Settings.ScannerDevice.Length > 0)
            {
                try {
                    drive = PlatformIO.DriveInfo.FromDevice(App.Settings.ScannerDevice);
                } catch (ArgumentException e) {                // e.g. drive not found
                    MsgDialog.ShowError(this,
                                        S._("Error"),
                                        S._("An error occured while accessing drive {0}:\n{1}"),
                                        App.Settings.ScannerDevice,
                                        e.Message);

                    return;
                }
            }
            else
            {
                DriveSelection ds     = new DriveSelection();
                ResponseType   result = (ResponseType)ds.Run();
                ds.Destroy();

                if (result != ResponseType.Ok)
                {
                    return;
                }

                drive = ds.SelectedDrive;
            }

            if (!drive.IsReady)
            {
                MsgDialog.ShowError(this,
                                    S._("Error"),
                                    S._("Drive {0} is not ready."),
                                    drive.Device);                 // e.g. no volume inserted

                return;
            }

            if (!drive.IsMounted && !drive.HasAudioCdVolume)
            {
                MsgDialog.ShowError(this,
                                    S._("Error"),
                                    S._("Drive {0} is neither mounted nor does it contain an audio cd."),
                                    drive.Device);

                return;
            }

            VolumeScanner vs = new VolumeScanner(database, drive);

            AddNewVolumeAddedEventHandler(vs);
        }
Exemple #8
0
 private bool SaveAndClose()
 {
     try {
         objEditor.Save();
         this.Destroy();
     } catch (ValidationException e) {
         MsgDialog.ShowError(this, S._("Invalid data"), string.Format(S._("\"{0}\" is {1}.\n\nExpected format: {2}\nPlease correct or remove the data you entered."), e.WidgetName, e.Message, e.ExpectedFormat));
         return(false);
     }
     return(true);
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (_taskList.SelectedItem == null)
            {
                ErrorDialog.Show("Please select a DCP!");
                return;
            }
            var info = (RunningDcpInfo)_taskList.SelectedItem;

            info.CTS.Cancel();
            MsgDialog.Show($"Cancel task success");
            TaskList.Remove(info);
        }
Exemple #10
0
 private void OnDeleteEvent(object o, Gtk.DeleteEventArgs args)
 {
     if (!scanCompleted)
     {
         MsgDialog.ShowError(this, S._("Scan in progress"), S._("You must stop scanning before closing this window."));
         args.RetVal = true;
     }
     else
     {
         bool cancel = !SaveAndClose();
         args.RetVal = cancel;
     }
 }
Exemple #11
0
        private void OnActRecentlyUsedActivated(object sender, System.EventArgs args)
        {
            RecentAction act  = (RecentAction)sender;
            string       path = act.CurrentUri.Replace("file://", string.Empty);

            if (!File.Exists(path))
            {
                MsgDialog.ShowError(this, S._("Error"), S._("Database '{0}' not found."), path);
                return;
            }

            // volumes list will be refreshed asynchronously
            OpenDB(path, false, true, null);
        }
 void delMsgBox_ConfirmSelectionDelegate(int selection)
 {
     if (selection == 1)
     {
         DeleteDetail();
         MsgDialog.WindowClose(this.caseNo + "号配件明细");
         CaseDetailMgr detailFrm = new CaseDetailMgr(this.caseNumberID, "", this.caseNo);
         this.Close();
         detailFrm.Show();
     }
     else
     {
         hkCaseDetailMgrModelAdd.Start();
     }
 }
 public void CaseDetailAddOKHandler()
 {
     if (Convert.ToInt32(lblTotalNum.Text) > Convert.ToInt32(lblsNum.Text))
     {
         msg.ShowMessage("实发数量不能超过应发数量", 1);
     }
     else
     {
         if (!string.IsNullOrEmpty(txtNum.Text) && Convert.ToInt32(txtNum.Text) > 0)
         {
             SaveDetail(Convert.ToInt32(lblTotalNum.Text));
             hkCaseDetailMgrModelAdd.Stop();
             MsgDialog.WindowClose(this.caseNo + "号配件明细");
             CaseDetailMgr detailFrm = new CaseDetailMgr(this.caseNumberID, "", this.caseNo);
             this.Close();
             detailFrm.Show();
         }
     }
 }
Exemple #14
0
        public bool SaveMapCommand()
        {
            if (!MapIsLoad())
            {
                return(false);
            }

            bool result = mapeditor.SaveMap();

            if (result)
            {
            }
            else
            {
                Dialog.MsgDialog msgDialog = new MsgDialog("저장에 실패했습니다.", MessageBoxButton.OK, MessageBoxImage.Error);
                msgDialog.ShowDialog();
            }
            SetWindowName();
            return(result);
        }
        private void Worker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                IsClose = true;
            }
            else
            {
                MsgDialog msgDialog = new MsgDialog("다음과 같은 오류로 그래픽을 불러오지 못했습니다.\n다시 시도하겠습니까?\n" + e.Error.Message, MessageBoxButton.OKCancel, MessageBoxImage.Error);
                msgDialog.ShowDialog();

                if (msgDialog.msgresult == MessageBoxResult.OK)
                {
                    LoadStart();
                    return;
                }
            }

            Close();
        }
Exemple #16
0
        private void RemoveVolume()
        {
            TreeIter iter;

            if (!tvVolumes.GetSelectedIter(out iter))
            {
                return;
            }

            ResponseType result = MsgDialog.Show(this,
                                                 MessageType.Question,
                                                 ButtonsType.YesNo,
                                                 S._("Confirmation"),
                                                 S._("Are you sure you really want to remove the selected volume?"));

            if (result == ResponseType.Yes)
            {
                PurgeVolume(iter);
            }
        }
Exemple #17
0
        private bool SaveAndClose()
        {
            try {
                if (scanner.ScanSucceeded)
                {
                    // SaveTo() may throw a ValidationException.
                    // Note: The volumeditor has either been filled on scanner start manually
                    // (no volume loaded) or an existing volume has been loaded into it
                    // (via the public VolumeEditor property or via volEditor.Load() on scan completion).
                    volEditor.SaveTo(newVolume);
                    SaveLog(newVolume.VolumeID);
                    OnNewVolumeAdded(newVolume);
                }

                this.Destroy();

                if (scanner != null)
                {
                    scanner.Dispose();
                }

                if (mdps != null)
                {
                    foreach (var m in mdps)
                    {
                        m.Dispose();
                    }
                }
            } catch (ValidationException e) {
                MsgDialog.ShowError(this, S._("Invalid data"),
                                    string.Format(S._("\"{0}\" is {1}.\n\nExpected format: {2}\nPlease correct or remove the data you entered."),
                                                  e.WidgetName, e.Message, e.ExpectedFormat));
                return(false);
            }
            return(true);
        }
Exemple #18
0
 private void OpenOrCreateDefaultDB(bool confirmCreation)
 {
     // do not overwrite existing db
     if (File.Exists(App.DefaultDB))
     {
         // opens existing default db and if successful,
         // sets the db path and calls settings.Save()
         OpenDB(App.DefaultDB, false, true, null);
     }
     else
     {
         if (confirmCreation && !(MsgDialog.Show(this,
                                                 MessageType.Question,
                                                 ButtonsType.YesNo,
                                                 S._("Database not found"),
                                                 S._("Default database not found. Create?")) == ResponseType.Yes))
         {
             return;
         }
         // creates default db and if successful,
         // sets the db path and calls settings.Save()
         OpenDB(App.DefaultDB, true, true, null);
     }
 }
Exemple #19
0
        private void SelectExistingDB()
        {
            string       db;
            ResponseType result = FileDialog.Show(FileChooserAction.Open,
                                                  this,
                                                  S._("Please select a database"),
                                                  out db);

            if (result == ResponseType.Ok && db.Length > 0)
            {
                // check if the file existst before calling OpenDB()
                // so the currently loaded db won't be unloaded.
                if (!File.Exists(db))
                {
                    MsgDialog.ShowError(this,
                                        S._("Error"),
                                        S._("Database not found."));
                }
                else
                {
                    OpenDB(db, false, true, null);
                }
            }
        }
Exemple #20
0
 void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     Logger.Fatal("Application Error", (Exception)e.ExceptionObject);
     MsgDialog.Show("Sorry, some errors occurred, the error message is saved in log");
     Application.Current.Shutdown();
 }
Exemple #21
0
        private void Save()
        {
            /*
             * general settings
             */
            if (cmbIconTheme.ActiveText == SYSTEM_ICON_THEME_NAME)
            {
                // prevent non-GNOME users from changing the only custom theme (Tango)
                // into the incomplete and ugly GTK default theme.
                if (Platform.Common.Diagnostics.CurrentPlatform.IsGnome)
                {
                    App.Settings.CustomThemeName = string.Empty;
                }
                else
                {
                    if (iconThemeChanged)
                    {
                        MsgDialog.Show(this, MessageType.Error, ButtonsType.Ok,
                                       S._("Unsupported theme"),
                                       string.Format(S._("The selected icon theme is currently not supported on your system.")));

                        // do not notify that a restart is required
                        iconThemeChanged = false;
                    }
                }
            }
            else
            {
                App.Settings.CustomThemeName = cmbIconTheme.ActiveText;
            }

            App.Settings.OpenMostRecentDB      = chkReopenDB.Active;
            App.Settings.ShowItemInfo          = chkShowItemInfo.Active;
            App.Settings.ShowThumbsInItemLists = chkShowThumbs.Active;
            App.Settings.ShowHiddenItems       = chkShowHiddenFiles.Active;

            /*
             * scanner settings
             */
            string scannerDevice = string.Empty;

            if (cmbScannerDevice.Active > 0)
            {
                TreeIter iter;
                cmbScannerDevice.GetActiveIter(out iter);
                scannerDevice = (string)cmbScannerDevice.Model.GetValue(iter, 1);
            }
            App.Settings.ScannerDevice = scannerDevice;

//			  App.Settings.ScannerBufferSize	  = (int)scaleBufferSize.Value;
            App.Settings.ScannerGenerateThumbnails = chkGenerateThumbnails.Active;
            App.Settings.ScannerExtractMetaData    = chkExtractMetaData.Active;
            App.Settings.ScannerDiscardSymLinks    = chkDiscardSymLinks.Active;
            App.Settings.ScannerComputeHashs       = chkComputeHashs.Active;
            App.Settings.ScannerEnableMusicBrainz  = chkMusicBrainz.Active;

            App.Settings.Save();

            if (iconThemeChanged)
            {
                MsgDialog.Show(this, MessageType.Info, ButtonsType.Ok,
                               S._("Restart required"),
                               string.Format(S._("You must restart {0} for icontheme changes to take effect."), App.Name));
            }
        }
Exemple #22
0
        // SDK location: /utility/psputility_msgdialog.h:50
        // SDK declaration: int sceUtilityMsgDialogInitStart(SceUtilityMsgDialogParams *params);
        public unsafe int sceUtilityMsgDialogInitStart(int msgParams)
        {
            uint *p = ( uint * )_memorySystem.Translate(( uint )msgParams);

            // Size... we don't care
            p++;

            MsgDialog dialog = new MsgDialog();

            dialog.Language    = ( Language )(*(p++));
            dialog.SwapButtons = (*(p++) == 1);

            // unknowns
            p += 4;

            // We save the address so we can write to it later
            dialog.ReturnValue = p;
            p++;

            // unknowns
            p += 4;
            p++;

            dialog.Type = ( MessageType )(*p++);

            if (dialog.Type == MessageType.Internal)
            {
                dialog.MessageID = *(p++);
            }
            else
            {
                p++;
                dialog.Message = _kernel.ReadString(( byte * )p, Encoding.UTF8).Trim();
            }
            p += (512 / 4);

            dialog.Flags = ( MessageFlags )(*p++);

            // Save address for later
            dialog.ReturnButton = p;
            p++;

            dialog.Status = UtilityStatus.Running;

            _currentDialog = dialog;

            Log.WriteLine(Verbosity.Normal, Feature.Bios, "MsgDialog: {0}", dialog.Message);

            // Fake the result!
            // Not sure exactly how right this is
            if ((dialog.Flags & MessageFlags.YesNo) == MessageFlags.YesNo)
            {
                if ((dialog.Flags & MessageFlags.DefaultNo) == MessageFlags.DefaultNo)
                {
                    *dialog.ReturnValue  = unchecked (( uint )-1);
                    *dialog.ReturnButton = ( uint )MessageButton.No;
                }
                else
                {
                    *dialog.ReturnValue  = 0;
                    *dialog.ReturnButton = ( uint )MessageButton.Yes;
                }
            }
            else
            {
                *dialog.ReturnValue  = 0;
                *dialog.ReturnButton = ( uint )MessageButton.Yes;
            }

            return(0);
        }
Exemple #23
0
        private void OpenDB(string path, bool createNew, bool loadAsync, System.Action onsuccess)
        {
            EnableGui(false);             // will be re-enabled after opening AND loading has been completed successfully
            SetWindowTitle(null);

            // clear views
            tvVolumes.Clear();
            tvItems.Clear();
            itemInfo.Clear();
            itemInfo.Hide();

            if (database != null)
            {
                database.Close();
            }

            lastSuccessfulSearchCriteria = null;

            try {
                database = new VolumeDatabase(path, createNew);
                database.SearchItemResultsLimit = App.SEARCH_RESULTS_LIMIT;
            } catch (UnsupportedDbVersionException) {
                MsgDialog.ShowError(this,
                                    S._("Unsupported database version"),
                                    S._("This database version is not supported."));
                return;
            }

            // load volumes

            Action <Volume[]> updateGui = (Volume[] volumes) => {
                tvVolumes.Fill(volumes);

                // select first volume

                /*
                 * // this clearly harms startup time.
                 * TreeIter iter;
                 * if (tvVolumes.Model.GetIterFirst(out iter))
                 *      tvVolumes.Selection.SelectIter(iter);
                 */

                EnableGui(true);
                SetWindowTitle(path);
                SetTempStatus(string.Format(S._("{0} volumes loaded."), volumes.Length));

                recentManager.AddFull("file://" + path, recentData);

                App.Settings.MostRecentDBPath = path;
                App.Settings.Save();

                if (onsuccess != null)
                {
                    onsuccess();                      // must be called on the gui thread
                }
            };

            if (loadAsync)
            {
                // delegate that will be called
                // when asynchronous volume loading (searching) has been finished.
                AsyncCallback cb = (IAsyncResult ar) => {
                    Volume[] volumes;

                    try {
                        volumes = database.EndSearchVolume(ar);
                    } catch (Exception ex) {
                        Application.Invoke(delegate {
                            SetStatus(string.Format(S._("An error occured while loading the volume list: {0}"),
                                                    ex.Message));
                        });
                        return;
                    }

                    Application.Invoke(delegate {
                        updateGui(volumes);
                    });
                };

                database.BeginSearchVolume(cb, null);                 // returns immediately
            }
            else
            {
                Volume[] volumes = database.SearchVolume();
                updateGui(volumes);
            }
        }
Exemple #24
0
        public unsafe int sceUtilityMsgDialogInitStart( int msgParams )
        {
            uint* p = ( uint* )_memorySystem.Translate( ( uint )msgParams );

            // Size... we don't care
            p++;

            MsgDialog dialog = new MsgDialog();
            dialog.Language = ( Language )( *( p++ ) );
            dialog.SwapButtons = ( *( p++ ) == 1 );

            // unknowns
            p += 4;

            // We save the address so we can write to it later
            dialog.ReturnValue = p;
            p++;

            // unknowns
            p += 4;
            p++;

            dialog.Type = ( MessageType )( *p++ );

            if( dialog.Type == MessageType.Internal )
            {
                dialog.MessageID = *( p++ );
            }
            else
            {
                p++;
                dialog.Message = _kernel.ReadString( ( byte* )p, Encoding.UTF8 ).Trim();
            }
            p += ( 512 / 4 );

            dialog.Flags = ( MessageFlags )( *p++ );

            // Save address for later
            dialog.ReturnButton = p;
            p++;

            dialog.Status = UtilityStatus.Running;

            _currentDialog = dialog;

            Log.WriteLine( Verbosity.Normal, Feature.Bios, "MsgDialog: {0}", dialog.Message );

            // Fake the result!
            // Not sure exactly how right this is
            if( ( dialog.Flags & MessageFlags.YesNo ) == MessageFlags.YesNo )
            {
                if( ( dialog.Flags & MessageFlags.DefaultNo ) == MessageFlags.DefaultNo )
                {
                    *dialog.ReturnValue = unchecked( ( uint )-1 );
                    *dialog.ReturnButton = ( uint )MessageButton.No;
                }
                else
                {
                    *dialog.ReturnValue = 0;
                    *dialog.ReturnButton = ( uint )MessageButton.Yes;
                }
            }
            else
            {
                *dialog.ReturnValue = 0;
                *dialog.ReturnButton = ( uint )MessageButton.Yes;
            }

            return 0;
        }
Exemple #25
0
        public MainWindow(string dbPath)
        {
            recentManager = RecentManager.Default;

            // retrieve the sort property from settings
            // (from default settings if the settings file does not exist yet)
            Widgets.VolumeSortProperty sp;
            bool desc;

            GetVolumeSortProperty(out sp, out desc);

            BuildGui();

            windowDeleted = false;
            lastSuccessfulSearchCriteria = null;

            SetWindowTitle(null);
            EnableGui(false);

            // set the volumeview's sort property
            // (before filling it with volumes)
            tvVolumes.SetSortProperty(sp, desc);

            // create default db on first startup
            if (!App.Settings.SettingsFileExists())
            {
                // creates (or opens existing) default db and if successful,
                // sets the db path and calls settings.Save()
                OpenOrCreateDefaultDB(false);
                return;
            }

            if (dbPath != null)
            {
                if (!File.Exists(dbPath))
                {
                    MsgDialog.ShowError(this,
                                        S._("Error"),
                                        S._("Database '{0}' not found."),
                                        dbPath);
                }
                else
                {
                    // volumes list will be refreshed asynchronously
                    OpenDB(dbPath, false, true, null);
                }

                return;
            }

            // reopen recent database
            dbPath = App.Settings.MostRecentDBPath;
            if (App.Settings.OpenMostRecentDB && dbPath.Length > 0)
            {
                if (!File.Exists(dbPath))
                {
                    MsgDialog.ShowError(this,
                                        S._("Error"),
                                        S._("Database '{0}' not found."),
                                        dbPath);

                    // clear path so the error won't occur again on next startup
                    App.Settings.MostRecentDBPath = string.Empty;
                    App.Settings.Save();
                }
                else
                {
                    // volumes list will be refreshed asynchronously
                    OpenDB(dbPath, false, true, null);
                }
            }
        }