Ejemplo n.º 1
0
        public About()
        {
            InitializeComponent();

            mmApp.SetThemeWindowOverride(this);

            VersionLabel.Content     = "Version " + mmApp.GetVersionForDisplay();
            VersionDateLabel.Content = mmApp.GetVersionDate();
            OsLabel.Content          = (Environment.Is64BitProcess ? "64 bit" : "32 bit") + " • " +
                                       ".NET " + WindowsUtils.GetDotnetVersion();
            if (App.IsPortableMode)
            {
                PortableMode.Content = "Portable mode";
            }

            if (UnlockKey.IsRegistered())
            {
                PanelFreeNotice.Visibility = System.Windows.Visibility.Hidden;
            }

            if (mmApp.Configuration.ApplicationUpdates.AccessCount > 20)
            {
                LabelUsingFreeVersion.Text =
                    $"You've used the free version {mmApp.Configuration.ApplicationUpdates.AccessCount:n0} times.";
            }
        }
        private void Register_Click(object sender, RoutedEventArgs routedEventArgs)
        {
            bool registered = UnlockKey.Register(TextRegKey.Password);

            mmApp.Model.Window.SetWindowTitle();
            WindowUtilities.DoEvents();

            if (registered)
            {
                MessageBox.Show("Thank you for your registration.", mmApp.ApplicationName,
                                MessageBoxButton.OK, MessageBoxImage.Information);
                Close();

                UnlockKey.Shutdown();
            }
            else
            {
                MessageBox.Show("Sorry, that's not the right key.\r\nMake sure you entered the value exactly as it\r\n" +
                                "appears in your confirmation.\r\n\r\n", "Software Registration",
                                MessageBoxButton.OK, MessageBoxImage.Exclamation);
                LabelIsRegistered.Text       = "This copy is not registered.";
                LabelIsRegistered.Foreground = new SolidColorBrush(Colors.Red);
                UnlockKey.UnRegister();
            }
        }
Ejemplo n.º 3
0
        public About()
        {
            InitializeComponent();

            mmApp.SetThemeWindowOverride(this);

            VersionLabel.Content = mmApp.GetVersion() + " • " +
                                   (Environment.Is64BitProcess ? "64 bit" : "32 bit");

            if (UnlockKey.IsRegistered())
            {
                PanelFreeNotice.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Ejemplo n.º 4
0
        public About()
        {
            InitializeComponent();

            mmApp.SetThemeWindowOverride(this);

            string bitNess = Environment.Is64BitProcess ? "64 bit" : "32 bit";
            var    v       = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location);

            VersionLabel.Content = "Version " + v.FileMajorPart + "." + v.FileMinorPart + " • " + bitNess;

            if (UnlockKey.IsRegistered())
            {
                PanelFreeNotice.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Ejemplo n.º 5
0
        public override void OnExecute(object sender)
        {
            if (snippetsWindow == null || !snippetsWindow.IsLoaded)
            {
                if (!UnlockKey.IsUnlockedPremium)
                {
                    UnlockKey.ShowPremiumDialog("Snippet Template Expansion",
                                                "https://github.com/RickStrahl/Snippets-MarkdownMonster-Addin");
                    return;
                }

                snippetsWindow = new SnippetsWindow(this);
            }
            snippetsWindow.Show();
            snippetsWindow.Activate();
        }
Ejemplo n.º 6
0
        public void RaiseOnApplicationShutdown()
        {
            foreach (var addin in AddIns)
            {
                try
                {
                    addin?.OnApplicationShutdown();
                }
                catch (Exception ex)
                {
                    mmApp.Log(addin.Id + "::AddIn::OnApplicationShutdown Error: " + ex.GetBaseException().Message);
                }
            }

            UnlockKey.Shutdown();
        }
Ejemplo n.º 7
0
        public void RaiseOnWindowLoaded()
        {
            foreach (var addin in AddIns)
            {
                try
                {
                    addin?.OnWindowLoaded();
                }
                catch (Exception ex)
                {
                    mmApp.Log(addin.Id + "::AddIn::OnWindowLoaded Error: " + ex.GetBaseException().Message);
                }
            }

            UnlockKey.Startup();
        }
        public RegistrationForm()
        {
            InitializeComponent();

            DataContext = this;

            if (UnlockKey.IsRegistered())
            {
                LabelIsRegistered.Text       = "This copy is registered.";
                LabelIsRegistered.Foreground = new SolidColorBrush(Colors.LightGreen);
            }
            else
            {
                LabelIsRegistered.Text = "This copy is not registered.";
            }
        }
Ejemplo n.º 9
0
        public About()
        {
            InitializeComponent();

            mmApp.SetThemeWindowOverride(this);

            VersionLabel.Content     = "Version " + mmApp.GetVersionForDisplay();
            VersionDateLabel.Content = mmApp.GetVersionDate();
            OsLabel.Content          = (Environment.Is64BitProcess ? "64 bit" : "32 bit") + " • " +
                                       ".NET " + ComputerInfo.GetDotnetVersion();


            if (UnlockKey.IsRegistered())
            {
                PanelFreeNotice.Visibility = System.Windows.Visibility.Hidden;
            }
        }
Ejemplo n.º 10
0
        public override void OnExecute(object sender)
        {
            if (snippetsWindow == null || !snippetsWindow.IsLoaded)
            {
                if (!UnlockKey.UnlockedPremium)
                {
                    UnlockKey.ShowPremiumDialog("Snippet Template Expansion",
                                                "https://github.com/RickStrahl/Snippets-MarkdownMonster-Addin");
                    return;
                }

                snippetsWindow = new SnippetsWindow(this);

                snippetsWindow.Top  = Model.Window.Top;
                snippetsWindow.Left = Model.Window.Left + Model.Window.Width -
                                      Model.Configuration.WindowPosition.SplitterPosition;
            }
            snippetsWindow.Show();
            snippetsWindow.Activate();
        }
        public RegistrationForm()
        {
            InitializeComponent();

            DataContext = this;

            if (UnlockKey.IsRegistered())
            {
                LabelIsRegistered.Text       = "This copy is already registered. Only enter key to clear or reset.";
                LabelIsRegistered.FontWeight = FontWeights.DemiBold;
                LabelIsRegistered.Foreground = new SolidColorBrush(Colors.LightGreen);
            }
            else
            {
                LabelIsRegistered.Text       = "This copy is not registered.";
                LabelIsRegistered.FontWeight = FontWeights.Normal;
            }

            Loaded += (s, e) =>
            {
                TextRegKey.Focus();
            };
        }
Ejemplo n.º 12
0
        public About()
        {
            InitializeComponent();

            mmApp.SetThemeWindowOverride(this);

            VersionLabel.Content     = "Version " + mmApp.GetVersionForDisplay();
            VersionDateLabel.Content = mmApp.GetVersionDate();

#if NETFULL
            OsLabel.Content = (Environment.Is64BitProcess ? "64 bit" : "32 bit") + " • " +
                              ".NET " + MarkdownMonster.Utilities.mmWindowsUtils.GetDotnetVersion();
#else
            OsLabel.Content = (Environment.Is64BitProcess ? "64 bit" : "32 bit") + " • " +
                              System.Runtime.InteropServices.RuntimeInformation.FrameworkDescription;
#endif



            if (App.IsPortableMode)
            {
                PortableMode.Content = "Portable mode";
            }

            if (UnlockKey.IsRegistered())
            {
                PanelFreeNotice.Visibility = System.Windows.Visibility.Hidden;
                LabelRegistered.Visibility = System.Windows.Visibility.Visible;
            }


            if (mmApp.Configuration.ApplicationUpdates.AccessCount > 20)
            {
                LabelUsingFreeVersion.Text =
                    $"You've used the free version {mmApp.Configuration.ApplicationUpdates.AccessCount:n0} times.";
            }
        }
Ejemplo n.º 13
0
        public void HandleCommandLineArguments()
        {
            var arg0 = CommandArgs[0].ToLower().TrimStart('-');

            if (CommandArgs[0] == "-")
            {
                arg0 = "-";
            }


            HtmltoMarkdownProcessor converter;

            switch (arg0)
            {
            case "version":
                // just display the header
                ConsoleHeader();
                ConsoleFooter();
                break;

            case "uninstall":
                UninstallSettings();

                ConsoleHeader();
                ConsoleHelper.WriteLine("Markdown Monster Machine Wide Settings uninstalled.", ConsoleColor.Green);
                ConsoleFooter();

                break;

            case "reset":
                // load old config and backup
                mmApp.Configuration.Backup();
                mmApp.Configuration.Reset();     // forces exit

                ConsoleHeader();
                ConsoleHelper.WriteLine("Markdown Monster Settings reset to defaults.", ConsoleColor.Green);
                ConsoleFooter();

                break;

            case "setportable":
                ConsoleHeader();

                // Note: Startup logic to handle portable startup is in AppConfiguration::FindCommonFolder
                try
                {
                    string portableSettingsFolder = Path.Combine(App.InitialStartDirectory, "PortableSettings");
                    bool   exists          = Directory.Exists(portableSettingsFolder);
                    string oldCommonFolder = mmApp.Configuration.CommonFolder;

                    File.WriteAllText("_IsPortable",
                                      @"forces the settings to be read from .\PortableSettings rather than %appdata%");

                    if (!exists &&
                        Directory.Exists(oldCommonFolder) &&
                        MessageBox.Show(
                            "Portable mode set. Do you want to copy settings from:\r\n\r\n" +
                            oldCommonFolder + "\r\n\r\nto the PortableSettings folder?",
                            "Markdown MonsterPortable Mode",
                            MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
                    {
                        FileUtils.CopyDirectory(oldCommonFolder,
                                                portableSettingsFolder, deepCopy: true);

                        mmApp.Configuration.CommonFolder = portableSettingsFolder;
                        mmApp.Configuration.Read();
                    }


                    mmApp.Configuration.CommonFolder = portableSettingsFolder;
                    mmApp.Configuration.Write();
                }
                catch (Exception ex)
                {
                    ConsoleHelper.WriteLine("Unable to set portable mode: " + ex.Message, ConsoleColor.Red);
                }

                ConsoleFooter();
                break;

            case "unsetportable":
                ConsoleHeader();
                try
                {
                    File.Delete("_IsPortable");
                    var internalFolder = Path.Combine(
                        Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Markdown Monster");
                    ReflectionUtils.SetProperty(mmApp.Configuration, "InternalCommonFolder", internalFolder);
                    mmApp.Configuration.CommonFolder = internalFolder;
                    mmApp.Configuration.Write();

                    ConsoleHelper.WriteLine("Removed Portable settings for this installation. Use `mm SetPortable` to reenable.", ConsoleColor.Green);
                }
                catch (Exception ex)
                {
                    ConsoleHelper.WriteLine($"Unable to delete portable settings switch file\r\n_IsPortable\r\n\r\n{ex.Message}", ConsoleColor.Red);
                }

                break;

            case "register":
                ConsoleHeader();
                if (CommandArgs.Length < 2)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Missing registration code. Please pass a registration code.");
                }
                else
                {
                    if (!UnlockKey.Register(CommandArgs[1]))
                    {
                        ConsoleHelper.WriteLine("Invalid registration code. Please pass a valid registration code.", ConsoleColor.Red);
                    }
                    else
                    {
                        ConsoleHelper.WriteLine("Markdown Monster Registration successful.", ConsoleColor.Green);
                        ConsoleHelper.WriteLine("Thank you for playing fair!", ConsoleColor.Green);
                    }
                }

                ConsoleFooter();
                break;

            case "markdowntohtml":
            {
                int    parmCount  = CommandArgs.Length;
                string inputFile  = parmCount > 1 ? CommandArgs[1] : null;
                string outputFile = parmCount > 2 ? CommandArgs[2] : null;
                string renderMode = parmCount > 3 ? CommandArgs[3] : null;       // html,packagedhtml,zip

                if (outputFile.StartsWith("-"))
                {
                    outputFile = null;
                }
                if (inputFile.StartsWith("-"))
                {
                    inputFile = null;
                }
                if (renderMode.StartsWith("-"))
                {
                    renderMode = null;
                }

                bool openOutputFile =
                    Environment.CommandLine.Contains("-open", StringComparison.OrdinalIgnoreCase) ||
                    string.IsNullOrEmpty(outputFile);

                converter = new HtmltoMarkdownProcessor(this);
                converter.MarkdownToHtml();
                break;
            }

            case "htmltomarkdown":
            {
                converter = new HtmltoMarkdownProcessor(this);

                int    parmCount  = CommandArgs.Length;
                string inputFile  = parmCount > 0 ? CommandArgs[1] : null;
                string outputFile = parmCount > 1 ? CommandArgs[2] : null;
                if (outputFile.StartsWith("-"))
                {
                    outputFile = null;
                }
                if (inputFile.StartsWith("-"))
                {
                    inputFile = null;
                }

                bool openOutputFile =
                    Environment.CommandLine.Contains("-open", StringComparison.OrdinalIgnoreCase) ||
                    string.IsNullOrEmpty(outputFile);

                converter.HtmlToMarkdown();
                break;
            }

            case "markdowntopdf":
            {
                MarkdownToPdfProcessor pdfProcessor = new MarkdownToPdfProcessor(this);
                pdfProcessor.MarkdownToPdf();
                break;
            }
            }
        }