示例#1
0
        private async void ImportButton_Click(object sender, RoutedEventArgs e)
        {
            CanShowDeviceUpdateDialog = false;

            var inputFile = await ShowFileOpenPickerAsync();

            if (inputFile == null)
            {
                return;
            }

            ContentDialogResult result = ContentDialogResult.Secondary;

            if (NeedSave)
            {
                YesNoCancelDialog dialog = new YesNoCancelDialog
                {
                    DialogTitle               = resourceLoader.GetString("YesNoCancelDialog_SaveFile"),
                    DialogContent             = resourceLoader.GetString("YesNoCancelDialog_SaveHint"),
                    DialogYesButtonContent    = resourceLoader.GetString("YesNoCancelDialog_Save"),
                    DialogCancelButtonContent = resourceLoader.GetString("YesNoCancelDialog_Discard")
                };
                await dialog.ShowAsync();

                result = dialog.Result;
            }

            if (result != ContentDialogResult.None)
            {
                if (result == ContentDialogResult.Primary)
                {
                    bool successful = await SaveCurrentUserFile();

                    if (!successful)
                    {
                        return;
                    }

                    savedUndoCommand = ReUndoManager.CurUndoCommand;
                }

                StorageFile copyfile = await inputFile.CopyAsync(m_LocalUserFileFolder, inputFile.Name, NameCollisionOption.ReplaceExisting);

                await inputFile.CopyAsync(m_LocalUserFileFolder, inputFile.Name, NameCollisionOption.ReplaceExisting);

                Log.Debug("[ImportButton] CopyAsync " + inputFile.Path + " to " + m_LocalUserFileFolder + "\\" + inputFile.Name);

                CurrentUserFilename = copyfile.Name.Replace(".xml", "");
                await LoadUserFile(CurrentUserFilename);
                await SaveCurrentUserFile();

                ReUndoManager.Clear();
                SetLayerCounter = 1;
            }
        }
示例#2
0
        private async void FileItem_Click(object sender, RoutedEventArgs e)
        {
            CanShowDeviceUpdateDialog = false;

            var    item         = sender as MenuFlyoutItem;
            string selectedName = item.Text;

            if (selectedName == CurrentUserFilename)
            {
                return;
            }

            ContentDialogResult result = ContentDialogResult.Secondary;

            if (NeedSave)
            {
                YesNoCancelDialog dialog = new YesNoCancelDialog
                {
                    DialogTitle               = resourceLoader.GetString("YesNoCancelDialog_SaveFile"),
                    DialogContent             = resourceLoader.GetString("YesNoCancelDialog_SaveHint"),
                    DialogYesButtonContent    = resourceLoader.GetString("YesNoCancelDialog_Save"),
                    DialogCancelButtonContent = resourceLoader.GetString("YesNoCancelDialog_Discard")
                };
                await dialog.ShowAsync();

                result = dialog.Result;
            }

            if (result != ContentDialogResult.None)
            {
                if (result == ContentDialogResult.Primary)
                {
                    bool successful = await SaveCurrentUserFile();

                    if (!successful)
                    {
                        return;
                    }

                    savedUndoCommand = ReUndoManager.CurUndoCommand;
                }

                Log.Debug("[FileItem_Click] Selected file name : " + selectedName);
                await LoadUserFile(selectedName);

                CurrentUserFilename = selectedName;

                ReUndoManager.Clear();
                SetLayerCounter = 1;
            }
        }
示例#3
0
        private async void OnCloseRequest(object sender, SystemNavigationCloseRequestedPreviewEventArgs e)
        {
            ContentDialog cDialog = GetCurrentContentDialog();

            e.Handled = true;

            if (cDialog != null)
            {
                cDialog.Hide();
                return;
            }

            CanShowDeviceUpdateDialog = false;

            e.Handled = true;
            ContentDialogResult result = ContentDialogResult.Secondary;

            if (NeedSave)
            {
                YesNoCancelDialog dialog = new YesNoCancelDialog
                {
                    DialogTitle               = resourceLoader.GetString("YesNoCancelDialog_SaveFile"),
                    DialogContent             = resourceLoader.GetString("YesNoCancelDialog_SaveHint"),
                    DialogYesButtonContent    = resourceLoader.GetString("YesNoCancelDialog_Save"),
                    DialogCancelButtonContent = resourceLoader.GetString("YesNoCancelDialog_Discard")
                };

                await dialog.ShowAsync();

                result = dialog.Result;
            }

            if (result != ContentDialogResult.None)
            {
                if (result == ContentDialogResult.Primary)
                {
                    bool successful = await SaveCurrentUserFile();

                    if (!successful)
                    {
                        return;
                    }
                }

                SaveSettings();
                Log.Debug("[OnCloseRequest] Exit ...");
                CoreApplication.Exit();
            }
        }
示例#4
0
        private async void DeleteItem_Click(object sender, RoutedEventArgs e)
        {
            if (CurrentUserFilename == "")
            {
                return;
            }

            YesNoCancelDialog dialog = new YesNoCancelDialog
            {
                DialogTitle               = resourceLoader.GetString("YesNoCancelDialog_DeleteNow"),
                DialogContent             = resourceLoader.GetString("YesNoCancelDialog_DeleteHint"),
                DialogYesButtonContent    = resourceLoader.GetString("YesNoCancelDialog_Delete"),
                DialogCancelButtonContent = resourceLoader.GetString("YesNoCancelDialog_Cancel")
            };

            await dialog.ShowAsync();

            ContentDialogResult result = dialog.Result;

            if (result != ContentDialogResult.Primary)
            {
                return;
            }

            Log.Debug("[DeleteFile] Delete file : " + CurrentUserFilename);
            StorageFile localscript = await m_LocalUserScriptFolder.GetFileAsync(CurrentUserFilename + ".xml");

            await localscript.DeleteAsync(StorageDeleteOption.PermanentDelete);

            StorageFile localfile = await m_LocalUserFileFolder.GetFileAsync(CurrentUserFilename + ".xml");

            await localfile.DeleteAsync(StorageDeleteOption.PermanentDelete);

            Log.Debug("[DeleteFile] Delete successfully !");

            foreach (var item in FileListMenuFlyout.Items)
            {
                MenuFlyoutItem mfi = item as MenuFlyoutItem;
                if (mfi.Text == CurrentUserFilename)
                {
                    FileListMenuFlyout.Items.Remove(mfi);
                    break;
                }
                ;
            }

            ResetToDefault();
            SendMessageToServer("[XML] Change");
        }
示例#5
0
        private async void NewFileButton_Click(object sender, RoutedEventArgs e)
        {
            CanShowDeviceUpdateDialog = false;

            Log.Debug("[NewFile] New File");
            ContentDialogResult result = ContentDialogResult.Secondary;

            if (NeedSave)
            {
                YesNoCancelDialog dialog = new YesNoCancelDialog
                {
                    DialogTitle               = resourceLoader.GetString("YesNoCancelDialog_SaveFile"),
                    DialogContent             = resourceLoader.GetString("YesNoCancelDialog_SaveHint"),
                    DialogYesButtonContent    = resourceLoader.GetString("YesNoCancelDialog_Save"),
                    DialogCancelButtonContent = resourceLoader.GetString("YesNoCancelDialog_Discard")
                };
                await dialog.ShowAsync();

                result = dialog.Result;
            }

            if (result != ContentDialogResult.None)
            {
                if (result == ContentDialogResult.Primary)
                {
                    bool successful = await SaveCurrentUserFile();

                    if (!successful)
                    {
                        return;
                    }

                    savedUndoCommand = ReUndoManager.CurUndoCommand;
                }

                ResetToDefault();
            }
            ForHotkeyFocus.Focus(FocusState.Programmatic);
        }