September discount week
Pouze tento týden sleva až 80 % na e-learning týkající se MS Office
50 % bodů zdarma na online výuku díky naší Slevové akci!
Avatar
froshy
Člen
Avatar
froshy:8.12.2019 10:16

Napisal som tento program aby som umožnil ovladat pocitac pomocou oci. Problem je v tom, že je v WF a chcem prejst na WPF. Ked sa na tom pozerem s hociktoreho uhla je to jedna velka pohroma, lebo nemozem menit ovladanie kvoli ludom co pouzivaju moj program a su trochu mentalne pozadie.
Video ukazka programu:
https://www.youtube.com/watch?…

Program musim prepisat preto lebo pripravujem vlastne zariadenie postavene na Raspberry Pi.

Zkusil jsem: Toto mam pre array.

 private new readonly PictureBox[] Menu = new PictureBox[8];
 private readonly PictureBox[] BuildAPP = new PictureBox[100];
private int Count_util = 0;
private int Count_util2 = 0;

Pridavanie programov do listy ( Lista v WF je Panel )

private void Add_icon_to_desktop()
      {
          try
          {
              string[] dirs = Directory.GetDirectories(@"application");
              foreach (string item2 in dirs)
              {
                  FileInfo f = new FileInfo(item2);
                  if (!(f.Name == "Apps" || f.Name == "Buildapps"))
                  {
                      Count_util++;
                      Menu[Count_util] = new PictureBox();
                      Menu[Count_util].Location = new Point(Count_util * 100, 0);
                      Menu[Count_util].Size = new Size(100, 100);
                      Menu[Count_util].BackColor = Color.Transparent;
                      Menu[Count_util].Name = f.Name;
                      Menu[Count_util].MouseClick += Mouse_selected_icons_click;
                      Menu[Count_util].MouseEnter += Mouse_select_icon;
                      Menu[Count_util].MouseLeave += Leave_select_icons;
                      try
                      {
                          Menu[Count_util].BackgroundImage = Image.FromFile(@"application\" + f.Name + @"\" + f.Name + @".png");
                          Menu[Count_util].BackgroundImageLayout = ImageLayout.Stretch;
                          Menu_panel.Controls.Add(Menu[Count_util]);
                      }
                      catch { Count_util--; }
                  }
              }
          }
          catch { Error_to.file(@"Canot load icon " + Menu[Count_util].Name); }
      }

Pridavanie programou na plochu:

private void Add_dekstop()
        {
            string[] dirs = Directory.GetDirectories(@"application\Apps");
            foreach (string item2 in dirs)
            {
                FileInfo f = new FileInfo(item2);
                if (!(f.Name == "Apps"))
                {
                    Count_util2++;
                    BuildAPP[Count_util2] = new PictureBox(); // Add to array
                    BuildAPP[Count_util2].Size = new Size(100, 100);
                    BuildAPP[Count_util2].Location = new Point(Count_util2 * 110 - 100, 110);
                    BuildAPP[Count_util2].BackColor = Color.Transparent;
                    BuildAPP[Count_util2].Name = f.Name;
                    BuildAPP[Count_util2].MouseClick += Mouse_selected_icons_click;
                    BuildAPP[Count_util2].MouseEnter += Mouse_select_icon;
                    BuildAPP[Count_util2].MouseLeave += Leave_select_icons;
                    try
                    {
                        BuildAPP[Count_util2].BackgroundImage = Image.FromFile(@"application\Apps\" + f.Name + @"\" + f.Name + @".png");
                        BuildAPP[Count_util2].BackgroundImageLayout = ImageLayout.Stretch;
                        this.Controls.Add(BuildAPP[Count_util2]);
                    }
                    catch { Count_util2--; }
                }
            }
        }

Samotny spustac programou ked si vyberete samotnu ikonu:

private void Mouse_select_icon(object sender, EventArgs e)
      {
          PictureBox APP = (PictureBox)sender;
          if (APP.Name == "Emulate_left_click")
          {
              try
              {
                  System.Media.SoundPlayer player = new System.Media.SoundPlayer(@"commons\sounds\beep.wav");
                  player.Play();  // Beep signal;
                  System.Threading.Thread.Sleep(Convert.ToInt32((ls.Delay_left_click)));
                  player.Play();  // Beep signal;
                  Mouse.Left_click(); // click
              }
              catch (Exception Error) { Error_to.file(@"Canot load sound file " + Convert.ToString(Error)); }
          } else
          if (APP.Name == "vkeyboard")
          {
              Exec_files.app("vk");
          } else

          if (APP.Name == "volume_control")
          {
              Exec_files.app("volume");
          } else

          if (APP.Name == "Switch_app")
          {
              Alt_tab.SwithApp();
          }
          else
              // Left click emulation on
              Mouse_click.Start();
      }

Zmena pozadia v programe:

this.BackgroundImage = Image.FromFile(ls.Desktop_wallpaper);
 this.BackgroundImageLayout = ImageLayout.Stretch;

Toto su procedury ktore nedokazem prisposobit do WPF kedze som s tym nikdy nerobil a popisi na internete co som nasiel nie su moc presvedcive. Dakujem za pomoc kazdy kto mi pomoze tak jeho meno zverejnim s jeho suhlasom ako spoluautor.Ako mensie podakovanie.

Chci docílit: Potrebujem hore uvedene procedury prekonvertovat do WPF.

 
Odpovědět
8.12.2019 10:16
Děláme co je v našich silách, aby byly zdejší diskuze co nejkvalitnější. Proto do nich také mohou přispívat pouze registrovaní členové. Pro zapojení do diskuze se přihlas. Pokud ještě nemáš účet, zaregistruj se, je to zdarma.

Zobrazeno 1 zpráv z 1.