예제 #1
0
        public MainWindow()
        {
            InitializeComponent();

            for (int i = 0; i < 8; ++i)
            {
                MyGrid.RowDefinitions.Add(new RowDefinition());

                MyDockPanel d = new MyDockPanel(i);
                d.PreviewMouseRightButtonUp += Dock_MouseRightButtonUp;

                Grid.SetRow(d, i);
                MyGrid.Children.Add(d);
            }

            WriteLine("Children: " + MyGrid.Children[7]);
        }
예제 #2
0
        // DockPanel and ContextMenu
        private void Dock_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            MyDockPanel dp = sender as MyDockPanel;

            dp.ContextMenu = new ContextMenu();

            WriteLine("DockPanel_MouseRightButtonUp with ID: " + dp.Identifier());

            // Process[] processes = Process.GetProcessesByName("Dofus");
            Process[] processes = Process.GetProcesses();

            if (processes.Length == 0)
            {
                this.current_id = -1;

                MyMenuItem mi = new MyMenuItem(0, "Error: Unable to find processes");
                // MyMenuItem mi = new MyMenuItem(0, "No such process");

                mi.Click += MenuItem_Click;

                dp.ContextMenu.Items.Add(mi);
            }
            else
            {
                this.current_id = dp.Identifier();

                for (int i = 0; i < processes.Length; ++i)
                {
                    if (processes[i].MainWindowTitle == "")
                    {
                        continue;
                    }

                    // Name = StackPanel Name + Process PID
                    // Header = Process Title
                    MyMenuItem mi = new MyMenuItem(processes[i].Id, processes[i].MainWindowTitle);

                    mi.Click += MenuItem_Click;

                    dp.ContextMenu.Items.Add(mi);
                }
            }
        }
예제 #3
0
        public MainWindow()
        {
            InitializeComponent();

            // Variables
            for (int i = 0; i < pids.Length; ++i)
            {
                pids[i] = 0;
            }
            for (int i = 0; i < titles.Length; ++i)
            {
                titles[i] = String.Empty;
            }

            // UI
            for (int i = 0; i < MAX_ITEM; ++i)
            {
                MyGrid.RowDefinitions.Add(new RowDefinition());

                MyDockPanel d = new MyDockPanel(i);
                d.PreviewMouseRightButtonUp += Dock_MouseRightButtonUp;

                Grid g = d.Children[0] as Grid;
                // Restore Events
                MyButton b = g.Children[BTN_RESTORE] as MyButton;
                b.Click += Restore_Click;
                MyButton c = g.Children[BTN_RESET] as MyButton;
                c.Click += Reset_Click;


                Grid.SetRow(d, i);
                MyGrid.Children.Add(d);
            }

            WriteLine("Permet de restaurer des fenêtres en appuyant sur ALT et un nombre du haut {1-8}");
        }