Example #1
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.Reset();
            Properties.Settings.Default.apps = new List<string>();

            Program.savedApps = new Dictionary<string, PosWindow.Rect>();
            //Program.savedContainers = new Dictionary<string, IContainerControl>();

            //List<string> appList = new List<string>();
            foreach (Control control in tableUpper.Controls.OfType<AppPanel>())
            {
                GetControl(control, getValues);
                if (!String.IsNullOrEmpty(tmpName))
                {
                    PosWindow.Rect position = new PosWindow.Rect()
                    {
                        Left = tmpValues[1],
                        Top = tmpValues[0]
                    };
                    Program.savedApps[tmpName] = position;
                    Properties.Settings.Default.apps.Add(tmpName + ";" + position.Left + ";" + position.Top);
                }

                tmpName = null;
                tmpValues = new List<int>();
            }

            Properties.Settings.Default.Save(); 
        }
Example #2
0
        private void buttonSet_Click(object sender, EventArgs e)
        {
            if (comboApp.SelectedIndex > -1)
            {
                try
                {
                    PosWindow.Rect position = new PosWindow.Rect
                    {
                        Left = Int32.Parse(textPosLeft.Text),
                        Top  = Int32.Parse(textPosTop.Text) //Int32.Parse(textPosRight.Text), Int32.Parse(textPosBottom.Text) };
                    };

                    String app = comboApp.SelectedItem.ToString();
                    if (Program.savedApps.ContainsKey(app))
                    {
                        Program.savedApps[app] = position;
                    }
                    else
                    {
                        Program.savedApps.Add(app, position);
                    }

                    IntPtr hWnd = PosWindow.FindWindow(null, comboApp.SelectedItem.ToString());
                    if (hWnd != IntPtr.Zero)
                    {
                        PosWindow.SetWindowPos(hWnd, IntPtr.Zero, position.Left, position.Top, 500, 500, PosWindow.SWP_NOSIZE | PosWindow.SWP_NOZORDER);
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Please enter valid values");
                    return;
                }
            }
        }
Example #3
0
        public AppPanel(string appName, PosWindow.Rect position)
        {
            InitializeComponent();
            getApps();

            comboApp.SelectedItem = appName;
            textPosLeft.Text      = position.Left.ToString();
            textPosTop.Text       = position.Top.ToString();
        }
Example #4
0
        private void buttonImportAll_Click(object sender, EventArgs e)
        {
            foreach (Control panel in tableUpper.Controls.OfType<AppPanel>())
            {

                GetControl(panel, putValues);
                tmpName = null;
                tmpPosition = new PosWindow.Rect();
            }
        }
Example #5
0
 public static void importFromSettings()
 {
     foreach (String savedData in Properties.Settings.Default.apps)
     {
         string appName = savedData.Split(';')[0];
         PosWindow.Rect position = new PosWindow.Rect()
         {
             Left = Int32.Parse(savedData.Split(';')[1]),
             Top = Int32.Parse(savedData.Split(';')[2])
         };
         Program.savedApps.Add(appName, position);
     }
 }
Example #6
0
 private void buttonLoad_Click(object sender, EventArgs e)
 {
     //IntPtr hWnd = PosWindow.FindWindow(comboApp.SelectedItem.ToString(),null);
     if (comboApp.SelectedIndex > -1)
     {
         IntPtr hWnd = PosWindow.FindWindow(null, comboApp.SelectedItem.ToString());
         if (hWnd != IntPtr.Zero)
         {
             //PosWindow.SetWindowPos(hWnd, IntPtr.Zero, 0, 0, 0, 0, PosWindow.SWP_NOSIZE | PosWindow.SWP_NOZORDER);
             PosWindow.Rect position = new PosWindow.Rect();
             PosWindow.GetWindowRect(hWnd, ref position);
             textPosLeft.Text   = position.Left.ToString();
             textPosTop.Text    = position.Top.ToString();
             textPosRight.Text  = position.Right.ToString();
             textPosBottom.Text = position.Bottom.ToString();
         }
     }
     else
     {
         MessageBox.Show("Please select an application");
     }
 }