Exemplo n.º 1
0
        /**
         * (Attempts to) uninstall sentinel.
         */
        public void Uninstall(object sender, EventArgs args)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure you want to uninstall Mimic Conduit? All files will be deleted.", "Mimic Conduit", MessageBoxButton.YesNo);

            if (result == MessageBoxResult.No)
            {
                return;
            }

            // Step 1: Delete AppData.
            try { Directory.Delete(Persistence.DATA_DIRECTORY, true); } catch { /* ignored */ }

            // Step 2: Unlink launch-on-start if enabled.
            if (Persistence.LaunchesAtStartup())
            {
                Persistence.ToggleLaunchAtStartup();
            }

            // Step 3: Delete Executable.
            Process.Start(new ProcessStartInfo
            {
                Arguments      = "/C choice /C Y /N /D Y /T 3 & Del " + System.Reflection.Assembly.GetExecutingAssembly().Location,
                WindowStyle    = ProcessWindowStyle.Hidden,
                CreateNoWindow = true,
                FileName       = "cmd.exe"
            });

            // Step 4: Stop Program.
            Application.Current.Shutdown();
        }
Exemplo n.º 2
0
        public App()
        {
            codeMenuItem = new MenuItem
            {
                Enabled = false
            };

            icon = new NotifyIcon
            {
                Text        = "Mimic Conduit",
                Icon        = Conduit.Properties.Resources.mimic,
                Visible     = true,
                ContextMenu = new ContextMenu(new []
                {
                    new MenuItem(Program.APP_NAME + " " + Program.VERSION)
                    {
                        Enabled = false
                    },
                    codeMenuItem,
                    new MenuItem("Settings", (sender, ev) =>
                    {
                        new AboutWindow().Show();
                    }),
                    new MenuItem("Quit", (a, b) => Shutdown())
                })
            };

            icon.Click += (a, b) =>
            {
                // Only open about if left mouse is used (otherwise right clicking opens both context menu and about).
                if (b is MouseEventArgs args && args.Button == MouseButtons.Left)
                {
                    new AboutWindow().Show();
                }
            };

            icon.BalloonTipClicked += (a, b) =>
            {
                new AboutWindow().Show();
            };

            manager = new ConnectionManager(this);
            Persistence.OnHubCodeChanged += UpdateCodeMenuItemText;
            UpdateCodeMenuItemText();

            // Unless we automatically launched at startup, display a bubble with info.
            if (!Persistence.LaunchesAtStartup())
            {
                ShowNotification("Mimic will run in the background. Click this notification or the Mimic icon in the system tray for more information and how to connect from your phone.");
            }
        }
Exemplo n.º 3
0
        public AboutWindow()
        {
            InitializeComponent();
            Logo.Source = Imaging.CreateBitmapSourceFromHIcon(Properties.Resources.mimic.Handle, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
            StartOnStartupCheckbox.IsChecked = Persistence.LaunchesAtStartup();

            AboutTitle.Content = "Mimic Conduit v" + Program.VERSION;

            if (Persistence.GetHubCode() != null)
            {
                RenderCode();
            }
            Persistence.OnHubCodeChanged += RenderCode;
        }