Ejemplo n.º 1
0
        public DummyForm()
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            //
            // TODO: Add constructor code after the InitializeComponent() call.
            //

            //
            //	Kommandozeilen Parameter abfangen und verarbeiten
            //	-Hostfile="PfadZurListeMitHostAdresse"
            //	-Damware="PfadZurDameWareExe"   --- Wenn abweichend von Standard Installationspfad
            //	-Checkliste="Pfad zur xls Checkliste"
            //
            if (!string.IsNullOrWhiteSpace(Environment.CommandLine))
            {
                Debug.WriteLine(Environment.CommandLine.ToString(), "Programm Start Parameter");
                strSourceFile = ParseCmdLineParam("sourcefile", Environment.CommandLine);
            }

            //
            //	Funktionen der Win7 Taskbar nutzen
            //
            tm = TaskbarManager.Instance;
            tm.ApplicationId = "CSV - SuchTool";
        }
Ejemplo n.º 2
0
        public static void UpdateProgressUI()
        {
            bool   isTasksWorking  = false;
            double averageProgress = 0;

            IEnumerable <WorkerTask> workingTasks = Tasks.Where(x => x != null && x.Status == TaskStatus.Working && x.Info != null);

            if (workingTasks.Count() > 0)
            {
                isTasksWorking = true;

                workingTasks = workingTasks.Where(x => x.Info.Progress != null);

                if (workingTasks.Count() > 0)
                {
                    averageProgress = workingTasks.Average(x => x.Info.Progress.Percentage);
                }
            }

            if (isTasksWorking)
            {
                Program.MainForm.Text = string.Format("{0} - {1:0.0}%", Program.Title, averageProgress);
                UpdateTrayIcon((int)averageProgress);
                TaskbarManager.SetProgressValue(Program.MainForm, (int)averageProgress);
            }
            else
            {
                Program.MainForm.Text = Program.Title;
                UpdateTrayIcon(-1);
                TaskbarManager.SetProgressState(Program.MainForm, TaskbarProgressBarStatus.NoProgress);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Win7"/> class.
 /// </summary>
 public Win7()
 {
     if (IsWindowsSeven)
     {
         windowsTaskbar = TaskbarManager.Instance;
     }
 }
Ejemplo n.º 4
0
        private void InitTaskbar(bool init)
        {
            if (init)
            {
                taskbar = TaskbarManager.Instance;

                taskbarPlayPause = new ThumbnailToolBarButton(Resources.Play, "Play");
                taskbarStop      = new ThumbnailToolBarButton(Resources.Stop, "Stop");
                taskbarClipboard = new ThumbnailToolBarButton(Resources.PlayClipboard, "Play Clipboard");

                taskbarClipboard.Click += buttonPlayClipboard_Click;
                taskbarPlayPause.Click += onTaskbarPlayPause_Click;
                taskbarStop.Click      += buttonStop_Click;

                taskbarButtons = new ThumbnailToolBarButton[]
                {
                    taskbarClipboard,
                    taskbarPlayPause,
                    taskbarStop
                };

                taskbar.ThumbnailToolBars.AddButtons(Handle, taskbarButtons);
            }
            else
            {
                taskbar = null;

                taskbarPlayPause = null;
                taskbarStop      = null;
                taskbarClipboard = null;

                taskbarButtons = null;
            }
        }
Ejemplo n.º 5
0
        public async static Task <bool> RequestPinSecondaryTileToTaskbar(string tileName, string displayname)
        {
            if (ApiInformation.IsMethodPresent("Windows.UI.Shell.TaskbarManager", "RequestPinSecondaryTileAsync"))
            {
                // API present!
                // Unlock the pin to taskbar feature
                var result = LimitedAccessFeatures.TryUnlockFeature(
                    "com.microsoft.windows.secondarytilemanagement",
                    "<tokenFromMicrosoft>",
                    "<publisher> has registered their use of com.microsoft.windows.secondarytilemanagement with Microsoft and agrees to the terms of use.");

                // If unlock succeeded
                if ((result.Status == LimitedAccessFeatureStatus.Available) ||
                    (result.Status == LimitedAccessFeatureStatus.AvailableWithoutToken))
                {
                    if (!SecondaryTile.Exists(tileName))
                    {
                        SecondaryTile tile = new SecondaryTile(SanitizedTileName(displayname).Replace("!", ""));
                        tile.DisplayName = displayname;
                        tile.Arguments   = SanitizedTileName(tileName);
                        tile.VisualElements.Square44x44Logo             = new Uri("ms-appx:///Assets/Square44x44Logo.scale-100.png");
                        tile.VisualElements.Square150x150Logo           = new Uri("ms-appx:///Assets/Square150x150Logo.scale-100.png");
                        tile.VisualElements.ShowNameOnSquare150x150Logo = true;
                        return(await TaskbarManager.GetDefault().RequestPinSecondaryTileAsync(tile));
                    }
                }
            }

            return(true);
        }
Ejemplo n.º 6
0
 private void SetProgress(double multiple = -1)
 {
     Dispatcher.Invoke(() =>
     {
         if (multiple >= 0 && multiple <= 1) // Change
         {
             int percent = Convert.ToInt32(Math.Round(multiple * 100));
             SetTitleSuffix(percent + "%");
             TaskProgressBar.Value = percent;
             TaskbarManager.SetProgressValue(percent, 100);
             TaskbarManager.SetProgressState(TaskbarProgressBarState.Normal);
         }
         else if (multiple == -1) // Reset
         {
             SetTitleSuffix();
             TaskProgressBar.Value = 0;
             TaskbarManager.SetProgressValue(0, 100);
             TaskbarManager.SetProgressState(TaskbarProgressBarState.NoProgress);
         }
         else
         {
             throw new ArgumentException();
         }
     });
 }
Ejemplo n.º 7
0
        private void StartGame()
        {
            this.AddTextToList("Das Spiel wird gestartet.\r\n");

            Process proc = new Process();

            proc.StartInfo.FileName        = Config.BinaryName;
            proc.StartInfo.UseShellExecute = false;
            try
            {
                proc.Start();
            }
            catch
            {
                MessageBox.Show(String.Format("Die Datei {0} existiert nicht.", Config.BinaryName), "Fehler", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            if (this.IsWin7OrHigher())
            {
                TaskbarManager tbmanager = TaskbarManager.Instance;
                tbmanager.SetProgressState(TaskbarProgressBarState.NoProgress);
            }

            BtnPlay.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Background, new System.Windows.Threading.DispatcherOperationCallback(delegate
            {
                BtnPlay.IsEnabled = true;
                return(null);
            }), null);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Creates the recently used ports jumplist
        /// </summary>
        private void CreateJumpList()
        {
            taskBarManager = TaskbarManager.Instance;
            if (TaskbarManager.IsPlatformSupported)
            {
                string currentDir = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location).DirectoryName;

                JumpList list = JumpList.CreateJumpList();

                // Separate by service hosts the recent ports.
                Port.GetUsedPorts().GroupBy(p => p.ServiceHost).ToList().ForEach(group => {
                    JumpListCustomCategory userActionsCategory = new JumpListCustomCategory(group.Key);

                    group.OrderByDescending(p => p.UsedTimes).ToList().ForEach(port =>
                    {
                        JumpListLink userActionLink = new JumpListLink(Assembly.GetEntryAssembly().Location,
                                                                       string.Format("{0} @ {1}", port.Number.ToString(), port.Host))
                        {
                            Arguments     = port.Id.ToString(),
                            IconReference = new IconReference(currentDir + "\\Resources\\tunnel-jump.ico,0")
                        };
                        userActionsCategory.AddJumpListItems(userActionLink);
                    });

                    list.AddCustomCategories(userActionsCategory);
                });

                list.Refresh();
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Show progress on taskbar
        /// </summary>
        /// <param name="i">index</param>
        /// <param name="ii">size</param>
        internal static void Progress(int i, int ii)
        {
            TaskbarManager prog = TaskbarManager.Instance;

            prog.SetProgressState(TaskbarProgressBarState.Normal);
            prog.SetProgressValue(i, ii);
        }
Ejemplo n.º 10
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            appMutex = new Mutex(true, AppName, out bool newMutexCreated);
            if (!newMutexCreated)
            {
                Shutdown();
                return;
            }

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            configurationManager          = new ConfigurationManager();
            configurationManager.Changed += ConfigurationManager_Changed;
            ConfigurationManager_Changed(configurationManager.ConfigFile);

            if (configurationManager.ConfigFile.AutoUpdate)
            {
                var updateManager = new UpdateManager(AppOwner, AppName);
                updateManager.CheckForNewVersion();
            }

            windowManager = new WindowManager(configurationManager);

            shortcutManager = new ShortcutManager(configurationManager, windowManager);

            taskbarManager = new TaskbarManager(configurationManager);

            notifyIcon = (TaskbarIcon)FindResource("NotifyIcon");
        }
Ejemplo n.º 11
0
        public Updater(string Status, int Max, string MapPath)
        {
            InitializeComponent();

            // Set Max
            this.progressBarControl2.Properties.Maximum = Max;
            try
            {
                taskbar = TaskbarManager.Instance;
                taskbar.SetProgressValue(0, Max);
            }
            catch { }
            this.Max = Max;

            // Set Message
            lblStatus.Text   = Status;
            lblInfo.Location = new Point(lblStatus.Location.X + lblStatus.Size.Width + 10, lblInfo.Location.Y);

            // Setup background worker
            this.MapPath      = MapPath;
            backgroundWorker1 = new BackgroundWorker();
            backgroundWorker1.WorkerReportsProgress = true;
            backgroundWorker1.DoWork             += new DoWorkEventHandler(backgroundWorker1_DoWork);
            backgroundWorker1.RunWorkerCompleted += new RunWorkerCompletedEventHandler(backgroundWorker1_RunWorkerCompleted);
            backgroundWorker1.ProgressChanged    += new ProgressChangedEventHandler(backgroundWorker1_ProgressChanged);
        }
Ejemplo n.º 12
0
        public frmMain(bool isGod)
        {
            mGodMode             = isGod;
            mWin7Taskbar         = TaskbarManager.Instance;
            LayoutManager.Layout = Properties.Settings.Default.Layout;

            InitializeComponent();
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Win7"/> class.
 /// </summary>
 public Win7()
 {
     if (this.IsWindowsSeven)
     {
         this.windowsTaskbar = TaskbarManager.Instance;
         this.windowsTaskbar.ApplicationId = "HandBrake";
     }
 }
Ejemplo n.º 14
0
 public static void Init(Form form)
 {
     if (TaskbarManager.IsPlatformSupported)
     {
         WindowsTaskbar = TaskbarManager.Instance;
         WindowsTaskbar.ApplicationId = TaskbarHelper.appId;
         WindowHandle = form.Handle;
     }
 }
 public WindowManagerDecorator(DockIconContainer _container)
 {
     container = _container;
     Application.Current.Exit            += Current_Exit;
     WindowManager.Manager.WindowAdded   += Manager_WindowAdded;
     WindowManager.Manager.WindowRemoved += Manager_WindowRemoved;
     WindowManager.Manager.Start();
     TaskbarManager.SetTaskbarVisibility(false);
 }
Ejemplo n.º 16
0
        public async Task applyUpdate(ProgressBar progressbar, TaskbarManager taskbar)
        {
            taskbar.SetProgressState(TaskbarProgressBarState.Normal);

            double progress       = 0;
            double targetProgress = updateTasks.Count;

            foreach (UpdateTask task in updateTasks)
            {
                progress++;
                string file = task.file;

                try
                {
                    switch (task.operation)
                    {
                    case (UpdateOperations.create_directory):
                        if (!Directory.Exists(file))
                        {
                            await Task.Run(() => Directory.CreateDirectory(file));
                        }
                        break;

                    case UpdateOperations.remove:
                        if (File.Exists(file))
                        {
                            await Task.Run(() => File.Delete(file));
                        }
                        else if (Directory.Exists(file))
                        {
                            await Task.Run(() => Directory.Delete(file, true));
                        }
                        break;

                    case UpdateOperations.update:
                        await Task.Run(() => webClient.DownloadFile(new Uri(host + file), file + ".download"));

                        if (File.Exists(file))
                        {
                            await Task.Run(() => File.Delete(file));
                        }
                        File.Move(file + ".download", file);
                        break;
                    }
                    progressbar.Value = progress / targetProgress * 100;
                    taskbar.SetProgressValue(Convert.ToInt32(progress), Convert.ToInt32(targetProgress));
                    logPrint($"[{task.operation}] {task.file}");
                }
                catch (Exception error)
                {
                    logPrint($"Ошибка при выполнении операции: {error.Message}");
                }
            }
            logPrint($"Применение обновлений завершено");
            return;
        }
Ejemplo n.º 17
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     _manager = TaskbarManager.Instance;
     if (!_noShaders)
     {
         return;
     }
     Resources["DropShadowFx"] = null;
     Resources["BlurEffect"]   = null;
 }
Ejemplo n.º 18
0
 public static async Task <bool?> RequestPinToTaskBar()
 {
     if (IsPinToTaskBarEnabled)
     {
         return(await TaskbarManager.GetDefault().RequestPinCurrentAppAsync());
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 19
0
        /// <summary>
        /// Converter Form. Based on code from nixx's WebMConverter.
        /// </summary>
        /// <param name="inFile">Path to input file</param>
        /// <param name="outFile">Path to output file</param>
        /// <param name="args">ffmpeg arguments without input and output files</param>
        /// <param name="inDuration">Video duration for progress</param>
        public ConverterForm(string inFile, string outFile, string[] args, double inDuration)
        {
            InitializeComponent();

            inputFile  = inFile;
            outputFile = outFile;
            arguments  = args;
            duration   = inDuration;

            taskbarManager = TaskbarManager.Instance;
        }
Ejemplo n.º 20
0
 public async static Task <bool?> IsPinnedToTaskBar()
 {
     if (IsPinToTaskBarEnabled)
     {
         return(await TaskbarManager.GetDefault().IsCurrentAppPinnedAsync());
     }
     else
     {
         return(null);
     }
 }
Ejemplo n.º 21
0
        /// <summary>
        /// Constructs a new Windows 7 taskbar item object.
        /// </summary>
        /// <param name="windowHandle">Window handle.</param>
        /// <exception cref="PlatformNotSupportedException">
        ///     Thrown if the operating system is not Windows 7 or higher.
        /// </exception>
        public Windows7TaskbarItem(IntPtr windowHandle)
        {
            if (!IsPlatformSupported)
            {
                throw new PlatformNotSupportedException("This class requires Windows 7 or higher");
            }

#if !__MonoCS__
            _taskbarManager = TaskbarManager.Instance;
            _windowHandle   = windowHandle;
#endif
        }
Ejemplo n.º 22
0
        public MainWindow()
        {
            InitializeComponent();
            this.IsEnabled = false;

            mWiggleStory = (Storyboard)cmbDisk.FindResource("ComboWiggleStory");

            if (TaskbarManager.IsPlatformSupported)
            {
                mTaskbarManager = TaskbarManager.Instance;
            }
        }
Ejemplo n.º 23
0
        private async Task Authenticate(string code)
        {
            try
            {
                TaskbarManager.SetProgressState(TaskbarProgressBarState.Indeterminate);

                var result = await OAuthFlower.MicrosoftCodeToAccessToken(code, CancelToken);

                var xbox_result = await XboxliveAuther.Authenticate(result, CancelToken);

                var mc_result = await McServices.Authenticate(xbox_result, CancelToken);

                var owner_result = await McServices.CheckHaveGameOwnership(mc_result, CancelToken);

                if (owner_result)
                {
                    MicrosoftUser microsoftUser = await McServices.GetProfile(result, mc_result, CancelToken);

                    LoggedInUser = microsoftUser;
                    islogin      = true;
                    LoginChange();
                }
                else
                {
                    islogin      = false;
                    LoggedInUser = null;
                    var res = await this.ShowMessageAsync(App.GetResourceString("String.OauthLogin.NoMinecraft"),
                                                          App.GetResourceString("String.OauthLogin.NoMinecraft1"),
                                                          MessageDialogStyle.AffirmativeAndNegative,
                                                          new MetroDialogSettings()
                    {
                        AffirmativeButtonText = App.GetResourceString("String.OauthLogin.Back"),
                        NegativeButtonText    = App.GetResourceString("String.OauthLogin.Change"),
                        DefaultButtonFocus    = MessageDialogResult.Negative
                    });

                    if (res == MessageDialogResult.Negative)
                    {
                        LoginOut();
                    }
                }
            }
            catch (Exception ex)
            {
                LoggedInUser = null;
                await this.ShowMessageAsync(App.GetResourceString("String.OauthLogin.LoginError"), ex.ToString());
            }
            finally
            {
                TaskbarManager.SetProgressState(TaskbarProgressBarState.NoProgress);
            }
        }
Ejemplo n.º 24
0
        private async Task TryShowPinTeachingTip()
        {
            var tbmgr    = TaskbarManager.GetDefault();
            var isPinned = await tbmgr.IsCurrentAppPinnedAsync();

            if (SystemInformation.Instance.IsFirstRun &&
                ApiInformation.IsTypePresent("Windows.UI.Shell.TaskbarManager") &&
                tbmgr.IsPinningAllowed &&
                !isPinned)
            {
                PinTeachingTip.IsOpen = true;
                App.Services.GetRequiredService <ITelemetry>().TrackEvent(TelemetryConstants.LaunchMessageShown);
            }
        }
Ejemplo n.º 25
0
 private void Downloader_DownloadProgressChanged(object sender, DownloadProgressChangedArg e)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         progressBar.Maximum = e.TaskCount;
         progressBar.Value   = e.TaskCount - e.LastTaskCount;
         double progress     = (e.TaskCount - e.LastTaskCount) / (double)e.TaskCount;
         if (progress > 0)
         {
             TaskbarManager.SetProgressValue((int)(progress * 100), 100, CriticalHandle);
         }
         progressPerTextBlock.Text = progress.ToString("0%");
         Tasks.Remove(e.DoneTask);
     }));
 }
Ejemplo n.º 26
0
        private async void ShowTaskbarTipIfNeeded()
        {
            try
            {
                // You should  check if you've already shown this tip before,
                // and if so, don't show the tip to the user again.
                if (ApplicationData.Current.LocalSettings.Values.Any(i => i.Key.Equals("ShownTaskbarTip")))
                {
                    // But for purposes of this Quickstart, we'll always show the tip,
                    // so we've commented out the return statement.
                    //return;
                }

                // Store that you've shown this tip, so you don't show it again
                ApplicationData.Current.LocalSettings.Values["ShownTaskbarTip"] = true;

                // If Start screen manager API's aren't present
                if (!ApiInformation.IsTypePresent("Windows.UI.Shell.TaskbarManager"))
                {
                    ShowMessage("TaskbarManager API isn't present on this build.");
                    return;
                }

                // Get the taskbar manager
                var taskbarManager = TaskbarManager.GetDefault();

                // If Taskbar doesn't allow pinning, don't show the tip
                if (!taskbarManager.IsPinningAllowed)
                {
                    ShowMessage("Taskbar doesn't allow pinning (or Taskbar isn't supported on this device family).");
                    return;
                }

                // If already pinned, don't show the tip
                if (await taskbarManager.IsCurrentAppPinnedAsync())
                {
                    ShowMessage("This app is already pinned to Taskbar!");
                    return;
                }

                // Otherwise, show the tip
                FlyoutPinTip.ShowAt(ButtonShowTip);
            }
            catch (Exception ex)
            {
                ShowMessage(ex.ToString());
            }
        }
Ejemplo n.º 27
0
        private async void PinTeachingTip_ActionButtonClick(Microsoft.UI.Xaml.Controls.TeachingTip sender, object args)
        {
            sender.IsOpen = false;

            var tbmgr    = TaskbarManager.GetDefault();
            var isPinned = await tbmgr.IsCurrentAppPinnedAsync();

            if (ApiInformation.IsTypePresent("Windows.UI.Shell.TaskbarManager") &&
                tbmgr.IsPinningAllowed &&
                !isPinned)
            {
                await tbmgr.RequestPinCurrentAppAsync();

                App.Services.GetRequiredService <ITelemetry>().TrackEvent(TelemetryConstants.PinnedToTaskbar);
            }
        }
Ejemplo n.º 28
0
        public Engine()
        {
            CheckForUpdates();
            Core.Initialize();

            this.ConfigManager    = new ConfigManager();
            this.WallpaperManager = new WallpaperManager();
            this._windowManager   = new WindowManager();
            this.TaskbarManager   = new TaskbarManager(ConfigManager);

            this._icon      = new NotifyIcon();
            this._icon.Icon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);

            this._icon.Click             += openSettings;
            this._icon.DoubleClick       += openSettings;
            this._icon.BalloonTipClicked += openSettings;
        }
Ejemplo n.º 29
0
        public FrmExtract(RoGrfFile grf, string rootDir, ArrayList toExtract)
        {
            InitializeComponent();

            mWin7Taskbar = TaskbarManager.Instance;

            mGrfFile   = grf;
            mRootDir   = rootDir;
            mToExtract = toExtract;

            mWorker = new BackgroundWorker();
            mWorker.WorkerReportsProgress      = true;
            mWorker.WorkerSupportsCancellation = true;
            mWorker.RunWorkerCompleted        += new RunWorkerCompletedEventHandler(mWorker_RunWorkerCompleted);
            mWorker.ProgressChanged           += new ProgressChangedEventHandler(mWorker_ProgressChanged);
            mWorker.DoWork += new DoWorkEventHandler(mWorker_DoWork);
        }
Ejemplo n.º 30
0
        private async void PinToTaskBar_Click(object sender, RoutedEventArgs e)
        {
            if (!ApiInformation.IsTypePresent("Windows.UI.Shell.TaskbarManager"))
            {
                await ShowMessageAsync("API requires Windows 10 version 16299 or newer.");

                return;
            }

            var taskbarManager = TaskbarManager.GetDefault();

            if (!taskbarManager.IsSupported)
            {
                await ShowMessageAsync("Taskbar is not supported on this version of Windows 10.");

                return;
            }

            var isPinned = await taskbarManager.IsCurrentAppPinnedAsync();

            if (isPinned)
            {
                await ShowMessageAsync("Application is already pinned.");

                return;
            }

            if (!taskbarManager.IsPinningAllowed)
            {
                await ShowMessageAsync("Pinning to task bar is not allowed on this PC.");

                return;
            }


            var pinned = await taskbarManager.RequestPinCurrentAppAsync();

            if (pinned)
            {
                await ShowMessageAsync("App is successfully pinned!");
            }
            else
            {
                await ShowMessageAsync("App was not pinned!");
            }
        }