コード例 #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            MainWindow mainWindow = new();

            if (e.Args.Length > 0)
            {
                TextArchive textArchive = new TextArchive
                                          (
                    fileName: Path.GetFileName(e.Args[0]),
                    fileSource: e.Args[0],
                    hasSaved: true,
                    text: File.ReadAllText(e.Args[0]),
                    lastModified: File.GetLastWriteTimeUtc(e.Args[0])
                                          );
                mainWindow = new MainWindow(textArchive);
            }
            else if (!string.IsNullOrEmpty(ConfigurationManager.AppSettings["lastTextFile"]))
            {
                string      resumeFilePath = ConfigurationManager.AppSettings["lastTextFile"];
                TextArchive textArchive    = new TextArchive
                                             (
                    fileName: Path.GetFileName(resumeFilePath),
                    fileSource: resumeFilePath,
                    hasSaved: true,
                    text: File.ReadAllText(resumeFilePath),
                    lastModified: File.GetLastWriteTimeUtc(resumeFilePath)
                                             );
                mainWindow = new MainWindow(textArchive);
            }
            mainWindow.Closed += MainWindow_Closed;
            mainWindow.Show();
        }
コード例 #2
0
ファイル: MainWindow.xaml.cs プロジェクト: LuanRoger/Text
        private void BtnAbrirArquivo_Click(object sender, RoutedEventArgs e)
        {
            QueryInvoker <TextArchive> queryInvoker = new(new OpenCommand());

            textArchive = queryInvoker.Invoker();

            LoadInfoText();
        }
コード例 #3
0
ファイル: MainWindow.xaml.cs プロジェクト: LuanRoger/Text
        public MainWindow(TextArchive textArchive = null)
        {
            InitializeComponent();

            this.textArchive = textArchive;
            LoadWindowData();
            LoadConfiguration();
            if (textArchive != null)
            {
                LoadInfoText();
            }
        }
コード例 #4
0
ファイル: OpenCommand.cs プロジェクト: LuanRoger/Text
        public void Execute()
        {
            TextArchive textArchiveNewWindow = TextArchive.OpenFileArchive();

            if (textArchiveNewWindow == null)
            {
                return;
            }

            MainWindow mainWindow = new MainWindow(textArchiveNewWindow);

            mainWindow.Show();
        }
コード例 #5
0
ファイル: MainWindow.xaml.cs プロジェクト: LuanRoger/Text
        private async void BtnSaveWith_Click(object sender, RoutedEventArgs e)
        {
            pgbAsyncTasks.Visibility = Visibility.Visible;

            QueryInvoker <Task <TextArchive> > queryInvoker = new(new SaveWithCommand(textArchive));

            textArchive = await queryInvoker.Invoker();

            if (textArchive != null)
            {
                LoadInfoText();
            }

            pgbAsyncTasks.Visibility = Visibility.Hidden;
        }
コード例 #6
0
ファイル: FileInfo.xaml.cs プロジェクト: LuanRoger/Text
        public FileInfo(TextArchive textArchive)
        {
            InitializeComponent();

            BitmapImage image = new BitmapImage();

            image.BeginInit();
            image.UriSource = new Uri(AppDomain.CurrentDomain.BaseDirectory + @"\assets\imgs\txt_file.png");
            image.EndInit();
            imgFileText.Source = image;

            txtFileName.Text   = textArchive.fileName;
            txtFileSize.Text   = new System.IO.FileInfo(textArchive.fileSource).Length.ToString() + "KB";
            txtFileSource.Text = textArchive.fileSource;
            txtLastUpdate.Text = File.GetLastWriteTimeUtc(textArchive.fileSource).ToString();
            txtLastAccess.Text = File.GetLastAccessTimeUtc(textArchive.fileSource).ToString();
            txtCreateDate.Text = File.GetCreationTimeUtc(textArchive.fileSource).ToString();

            btnFecharInfo.Click += BtnFecharInfo_Click;
        }
コード例 #7
0
 public SaveCommand(TextArchive textArchive)
 {
     this.textArchive = textArchive;
 }
コード例 #8
0
 public ShowFileInfoCommand(TextArchive textFileToOpen)
 {
     this.textFileToOpen = textFileToOpen;
 }