Beispiel #1
0
        /*************************************************************************/
        /* Form Events                                                           */
        /*************************************************************************/

        private void MainForm_Load(object sender, EventArgs e)
        {
            Program.log.Info("Loading application");

            LoadUserSettings();

            CurrentTab      = tabHome;
            CurrentTabTitle = titleHome;

            Directory.CreateDirectory(LocalExtensions.pathRoot);
            Directory.CreateDirectory(LocalExtensions.pathData);

            if (LocalExtensions.CheckForInternetConnection())
            {
                BackGroundWorker.RunWorkAsync(() => Updates.CheckForUpdate());
                LoadTopSearches();
                BackGroundWorker.RunWorkAsync(() => Database.UpdateLocalDatabase(), CompletedChecks);
            }
            else
            {
                Controls.Remove(FrmSplashScreen);
                MessageBox.Show(this, "No Internet connection found. You need to be connected to the Internet to use FileMasta. Please check your connection and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Program.log.Info("Loaded application");
        }
Beispiel #2
0
        public void CheckFileEvents()
        {
            // Shows appropriate Bookmarks button text
            if (!UserBookmarks.IsBookmarked(currentFile.URL))
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Add to Bookmarks");
            }
            else
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Remove from Bookmarks");
            }

            // Shows 'Play Media' button if this file has a supported file extension
            if (videoFileTypes.Contains(currentFile.Type) || audioFileTypes.Contains(currentFile.Type))
            {
                // Support media players installed on users machine
                VLC2ToolStripMenuItem.Visible = true;
                WMPToolStripMenuItem.Visible  = true;
                VLCToolStripMenuItem.Visible  = File.Exists(LocalExtensions.pathVLC);
                MPCToolStripMenuItem.Visible  = File.Exists(LocalExtensions.pathMPCCodec64) || File.Exists(LocalExtensions.pathMPC64) || File.Exists(LocalExtensions.pathMPC86);
            }

            // Support download manangers installed on users machine, shown if this isn't a local file
            IDMToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathIDMAN64) || File.Exists(LocalExtensions.pathIDMAN86) && !currentFile.URL.StartsWith(LocalExtensions.userDownloadsDirectory);

            if (contextOpenFile.Items.Count != 0)
            {
                buttonOpenFile.Visible = true;
            }

            // Shows Request File Size button if size property returns 0
            if (currentFile.Size == 0)
            {
                buttonRequestFileSize.Visible = true;
            }
            else
            {
                buttonRequestFileSize.Visible = false;
            }

            // Add subtitle file to be played when opening external VLC
            if (LocalExtensions.HasExistingSubtitle(currentFile.URL) == true) // If users downloads folder contains a subtitle file matching web file name
            {
                infoFileSubtitles = LocalExtensions.userDownloadsDirectory + Path.GetFileNameWithoutExtension(currentFile.URL) + ".srt";
            }
            else
            {
                infoFileSubtitles = null;
            }

            // Displays appropriate scroll images
            ScrollButtonChecks();
        }
Beispiel #3
0
        public void CheckFileEvents()
        {
            // Shows appropriate Bookmarks button text
            if (!UserBookmarks.IsBookmarked(currentFile.URL))
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Add to Bookmarks");
            }
            else
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Remove from Bookmarks");
            }

            // Support media players installed on users machine
            VLCToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathVLC);
            MPCToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathMPCCodec64) || File.Exists(LocalExtensions.pathMPC64) || File.Exists(LocalExtensions.pathMPC86);

            // Shows 'Play Media' button if is valid file extension
            if (videoFileTypes.Contains(currentFile.Type) || audioFileTypes.Contains(currentFile.Type))
            {
                buttonPlayMedia.Visible = true;
            }
            else
            {
                buttonPlayMedia.Visible = false;
            }

            // Checks if file size isn't default
            if (currentFile.Size == 0)
            {
                buttonRequestFileSize.Visible = true;
            }
            else
            {
                buttonRequestFileSize.Visible = false;
            }

            // Add subtitle file to be played when opening external VLC
            if (LocalExtensions.HasExistingSubtitle(currentFile.URL) == true) // If users downloads folder contains a subtitle file matching web file name
            {
                infoFileSubtitles = LocalExtensions.userDownloadsDirectory + Path.GetFileNameWithoutExtension(currentFile.URL) + ".srt";
            }
            else
            {
                infoFileSubtitles = null;
            }

            // Displays appropriate scroll images
            ScrollButtonChecks();
        }
Beispiel #4
0
        /*************************************************************************/
        /* Form / Startup Events                                                 */
        /*************************************************************************/

        private void MainForm_Load(object sender, EventArgs e)
        {
            Program.log.Info("Starting load events");

            Directory.CreateDirectory(LocalExtensions.pathRoot);
            Directory.CreateDirectory(LocalExtensions.pathData);

            if (LocalExtensions.IsConnectionEnabled())
            {
                Updates.CheckForUpdate();
                LoadTopSearches();
                BackGroundWorker.RunWorkAsync(() => Database.UpdateLocalDatabase(), InitializeFinished);
            }
            else
            {
                Controls.Remove(FrmSplashScreen);
                MessageBox.Show(this, "No Internet connection found. You need to be connected to the Internet to use FileMasta. Please check your connection and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            Program.log.Info("Completed all load events");
        }
Beispiel #5
0
        public async Task Timezone(
            [Summary("The time to convert")] string time,
            [Summary("The timezone of the original timezone")] string origzone,
            [Remainder][Summary("Other timezones, separated by commas")] string zones)
        {
            //try
            zones = zones.ToUpper();
            {
                DateTime result;
                if (!DateTime.TryParse(time, out result))
                {
                    await this.Context.Channel.SendMessageAsync("???");
                }

                //static: run all timezones
                if (zones.Equals("REZ"))
                {
                    zones = "";
                    foreach (KeyValuePair <string, string> timePair in LookupData.TimeAbs)
                    {
                        zones += timePair.Key + ",";
                    }
                    zones = zones.Replace(origzone + ",", "");
                    zones = zones.TrimEnd(',');
                }
                Console.WriteLine(zones);

                string[]            aZones = zones.Split(',');
                List <TimeZoneInfo> tzis   = new List <TimeZoneInfo>();
                TimeZoneInfo        otzi   = null;
                //UNIX system requires an IANA conversion
                if (Environment.OSVersion.Platform != PlatformID.Win32NT)
                {
                    string stz = LocalExtensions.WindowsToIana(LookupData.TimeAbs[origzone]);
                    otzi = TimeZoneInfo.FindSystemTimeZoneById(stz);
                }
                //Windows system uses the dotNET/Windows internal table
                else
                {
                    otzi = TimeZoneInfo.FindSystemTimeZoneById(LookupData.TimeAbs[origzone]);
                }

                foreach (var zone in aZones)
                {
                    string tz = LookupData.TimeAbs[zone];
                    if (Environment.OSVersion.Platform != PlatformID.Win32NT)
                    {
                        tz = LocalExtensions.WindowsToIana(tz);
                        TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(tz);
                        tzis.Add(tzi);
                    }
                    else
                    {
                        TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById(tz);
                        tzis.Add(tzi);
                    }
                }

                DateTime utcTime = TimeZoneInfo.ConvertTime(result, otzi, TimeZoneInfo.Utc);

                var ebh = new EmbedBuilder();
                ebh.WithTitle(result.ToString("h:mm tt") + " in " + otzi.StandardName + " conversions\n");

                int i = 0;
                foreach (TimeZoneInfo tzi in tzis)
                {
                    DateTime newTime = TimeZoneInfo.ConvertTime(utcTime, TimeZoneInfo.Utc, tzi);
                    string   head    = "**" + aZones[i] + "** (" + LookupData.TimeAbs[aZones[i]] + ")";
                    string   body    = "__" + newTime.ToString("h: mm tt") + "__";

                    if ((newTime.Date - result.Date).Days >= 0.99)
                    {
                        body += " [next day]";
                    }
                    if ((newTime.Date - result.Date).Days <= -0.99)
                    {
                        body += " [previous day]";
                    }
                    body += "\n\n";
                    i++;

                    ebh.AddField(head, body);
                }

                await this.Context.Channel.SendMessageAsync("", false, ebh);
            }
        }
Beispiel #6
0
        public void CheckFileEvents()
        {
            // Hides all open file items
            foreach (ToolStripMenuItem item in contextOpenFile.Items)
            {
                item.Visible = false;
            }

            // Shows appropriate Bookmarks button text
            if (!UserBookmarks.IsBookmarked(CurrentFile.URL))
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Add to Bookmarks");
            }
            else
            {
                ControlExtensions.SetControlText(buttonBookmarkFile, "Remove from Bookmarks");
            }

            // Shows supported pdf readers installed on users machine
            if (BookFileTypes.Contains(CurrentFile.Type))
            {
                NitroReaderToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathNitroReader);
            }

            // Shows supported pdf readers installed on users machine
            if (TextFileTypes.Contains(CurrentFile.Type))
            {
            }

            // Shows supported media players installed on users machine
            if (VideoFileTypes.Contains(CurrentFile.Type) || AudioFileTypes.Contains(CurrentFile.Type))
            {
                VLC2ToolStripMenuItem.Visible      = true;
                WMPToolStripMenuItem.Visible       = true;
                VLCToolStripMenuItem.Visible       = File.Exists(LocalExtensions.pathVLC);
                MPCToolStripMenuItem.Visible       = File.Exists(LocalExtensions.pathMPCCodec64) || File.Exists(LocalExtensions.pathMPC64) || File.Exists(LocalExtensions.pathMPC86);
                KMPlayerToolStripMenuItem.Visible  = File.Exists(LocalExtensions.pathKMPlayer);
                PotPlayerToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathPotPlayer);
            }

            // Support download manangers installed on users machine, only shown if this isn't a local file
            if (!IsLocalFile)
            {
                IDMToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathIDM64) || File.Exists(LocalExtensions.pathIDM86) && !CurrentFile.URL.StartsWith(LocalExtensions.pathDownloadsDirectory);
                FDMToolStripMenuItem.Visible = File.Exists(LocalExtensions.pathFDM) && !CurrentFile.URL.StartsWith(LocalExtensions.pathDownloadsDirectory);
            }

            // Shows Open File button if context menu has items
            if (contextOpenFile.Items.Count > 0)
            {
                buttonOpenWith.Visible = true;
            }

            // Shows Request File Size button if size property returns 0
            if (CurrentFile.Size == 0)
            {
                buttonRequestFileSize.Visible = true;
            }
            else
            {
                buttonRequestFileSize.Visible = false;
            }

            // Hides features that aren't needed for local files (Bookmark, Share & Report)
            if (IsLocalFile)
            {
                buttonBookmarkFile.Visible = false;
                panelShare.Visible         = false;
                panelReport.Visible        = false;
            }

            // Add subtitle file to be played when opening external VLC
            if (LocalExtensions.IsSubtitlesAvailable(CurrentFile.URL)) // If users downloads folder contains a subtitle file matching web file name
            {
                FileSubtitles = LocalExtensions.pathDownloadsDirectory + Path.GetFileNameWithoutExtension(CurrentFile.URL) + ".srt";
            }
            else
            {
                FileSubtitles = null;
            }

            // Displays appropriate scroll images
            ScrollButtonChecks();
        }
Beispiel #7
0
 private void buttonFilesLocal_ClickButtonArea(object Sender, MouseEventArgs e)
 {
     SelectedFilesType = Types.All; ControlExtensions.SelectFilesTab(buttonFilesLocal); SelectedFiles = LocalExtensions.GetLocalFiles(); ShowFiles(SelectedFiles);
 }