Esempio n. 1
0
        private bool __OpenChildWindow(ChildWindow Window, ChildWindowViewModelBase ViewModel)
        {
            var Temp = ChildWindows.FirstOrDefault(c => c.Identifier == Window.Identifier);

            if (Temp != null)
            {
                Temp.Focus();
                return(false);
            }

            Window.DataContext = ViewModel;
            m_ChildViewModels.Add(ViewModel);
            ChildWindows.Add(Window);

            Window.Closed += (sender, e) =>
            {
                ChildWindows.Remove(Window);
                m_ChildViewModels.Remove(ViewModel);
            };

            ViewModel.OpenWindow += (sender, e) =>
            {
                __OpenChildWindow(e.Window, e.ViewModel);
            };

            ViewModel.StatusBarTextChanged += (sender, text) => StatusBarText = text;

            return(true);
        }
 public MainWindow()
 {
     InitializeComponent();
     Vars         = new Model();
     childWindows = new ChildWindows();
     //this is the event subscriber.
     childWindows.ParentUpdated += ChildWindows_ParentUpdated;
 }
Esempio n. 3
0
        private void __CleanUp()
        {
            if (m_RefreshingThread != null)
            {
                m_CancellationTokenSource.Cancel();
                m_CancellationTokenSource = null;
            }

            if (m_CurrentArea != null)
            {
                m_CurrentArea.LiveTrains.Clear();
            }

            ChildWindows.Clear();
            Runtime.VisibleStations.Clear();
        }
Esempio n. 4
0
        /// <summary>
        /// Devuelve el handler de la ventana asociada al proceso
        /// </summary>
        /// <param name="pid" />Id del proceso
        /// <returns>handler de la ventana</returns>
        public static IntPtr GetProcessWindowHandler(IntPtr hWndParent, int pid)
        {
            //Delegado con el proceso auxiliar de búsqueda
            ChildWindows getHandlerVentana = new ChildWindows(_GetProcessWindowHandler);
            //Informacion auxiliar
            AuxInfo informacion = new AuxInfo();

            informacion.processID = pid;

            /*Repetir bucle hasta que este presente la ventana del proceso
             *(puede que la enumeracion se realice y windows  aún no haya creado
             * la primera ventana del proceso o bien no la haya hecho visible,
             * por lo cual se debe repetir el bucle hasta encontrala)*/
            do
            {
                /*Enumerar las ventanas buscando la que coincida con
                 * el id de proceso contenido en informacion */
                EnumChildWindows(hWndParent, getHandlerVentana, informacion);
            } while (informacion.handler == IntPtr.Zero || !IsWindowVisible(informacion.handler));

            return(informacion.handler);
        }
Esempio n. 5
0
 private static extern bool EnumChildWindows(IntPtr hWndParent, ChildWindows lpEnumFunc, AuxInfo lParam);
Esempio n. 6
0
        void DoIt(Point startpt, Point endpt,
                  int startnox, int startnoy,
                  int pointsx, int pointsy,
                  int pointdelay,
                  string outfile,
                  int startdelay,
                  string keys4init,
                  string childprog, string childargs)
        {
            //WindowState = FormWindowState.Minimized;

            StartProg(childprog, childargs, startdelay);

            if (childargs.Length == 0)
            {
                childargs = "Unbenannt";
            }
            else
            {
                childargs = childargs.Substring(0, childargs.Length - 4);  // Dateiname ohne '.gpx'
            }
            ApiWindow progwin = new ApiWindow("{7A96B96B-E756-4e42-8274-54CBF24F7944}",
                                              childargs + " - MapSource");

            if (progwin == null || progwin.hWnd.ToInt32() == 0)
            {
                MessageBox.Show("Programm nicht gefunden!", "Fehler");
                Close();
                return;
            }

            ChildWindows childwin  = new ChildWindows(progwin.hWnd, "msctls_statusbar32");
            ApiWindow    statuswin = childwin.WindowList.Count > 0 ? childwin.WindowList[0] : null;

            if (statuswin == null)
            {
                MessageBox.Show("Statusbar nicht gefunden!", "Fehler");
                Close();
                return;
            }

            childwin = new ChildWindows(progwin.hWnd, "GarminMapWindow");
            ApiWindow clientwin = null;

            foreach (ApiWindow win in childwin.WindowList)
            {
                if (win.GetText().Trim() == "")
                {
                    clientwin = win;
                    break;
                }
            }

            progwin.SetForeground();
            Helper.Wait4Idle();

            // Regex zum Höhe ermitteln: z.B. "N54.53305 E13.41344, 17 ft"
            Regex r = new Regex(@"N\d+\.\d+\s+E\d+\.\d+,\s+(\d+)");

            StreamWriter wr = null;

            if (outfile.Length > 0)
            {
                try {
                    if (File.Exists(outfile))
                    {
                        File.Delete(outfile);
                    }
                    wr = new StreamWriter(outfile);
                } catch (Exception ex) {
                    MessageBox.Show(string.Format("Fehler beim Erzeugen der Datei '{0}'!", outfile) + System.Environment.NewLine + ex.Message, "Fehler");
                    Close();
                }
            }

            if (keys4init.Length > 0)
            {
                Helper.SendKeys(keys4init);
                Helper.Wait4Idle();
            }

            Helper.MousePosition = startpt;
            Helper.Wait(500);

            if (outfile.Length > 0)
            {
                wr.WriteLine(outfile);
            }

            // Spaltenüberschriften
            for (int stepx = 0; stepx < pointsx; stepx++)
            {
                if (wr != null)
                {
                    wr.Write("\t");
                    wr.Write(startnox + stepx);
                }
                else
                {
                    Debug.Write("\t");
                    Debug.Write(startnox + stepx);
                }
            }
            if (wr != null)
            {
                wr.WriteLine();
            }
            else
            {
                Debug.WriteLine("");
            }

            for (int stepy = 0; stepy < pointsy; stepy++)
            {
                for (int stepx = 0; stepx < pointsx; stepx++)
                {
                    // Maus-Position setzen (Rundung halbiert den max. möglichen Fehler)
                    Point newpos = new Point(startpt.X + (pointsx <= 1 ? 0 : (int)Math.Round(((double)stepx * (endpt.X - startpt.X)) / (pointsx - 1))),
                                             startpt.Y + (pointsy <= 1 ? 0 : (int)Math.Round(((double)stepy * (endpt.Y - startpt.Y)) / (pointsy - 1))));
                    Helper.MousePosition = newpos;
                    //Helper.MouseLeftClick();
                    Helper.Wait4Idle(progwin);
                    //Helper.Wait(1);
                    Helper.WaitExt(pointdelay);

                    // Höhe ermitteln: z.B. "N54.53305 E13.41344, 17 ft"
                    string txt = Helper.GetPanelText(statuswin.hWnd, 2);   // 3. Panel
                    Match  m   = r.Match(txt);
                    if (m.Success)
                    {
                        int    h = Convert.ToInt32(m.Groups[1].Value);
                        string v = h > 0 ? h.ToString() : ".";

                        if (wr != null)
                        {
                            if (stepx == 0)
                            {
                                wr.Write(startnoy + stepy);
                            }
                            wr.Write("\t");

                            //wr.Write(newpos.X);
                            //wr.Write(";");

                            wr.Write(v);
                        }
                        else
                        {
                            if (stepx == 0)
                            {
                                Debug.Write(startnoy + stepy);
                            }
                            Debug.Write("\t");
                            Debug.Write(v);
                        }
                    }
                    else
                    {
                        stepx = pointsx;
                        stepy = pointsy;
                        if (wr != null)
                        {
                            wr.Close();
                            wr = null;
                            if (File.Exists(outfile))
                            {
                                File.Delete(outfile);
                            }
                        }
                    }
                }
                if (wr != null)
                {
                    wr.WriteLine();
                }
                else
                {
                    Debug.WriteLine("");
                }
            }

            if (wr != null)
            {
                wr.Close();
            }

            // Programm beenden
            Helper.SendKeys("%{F4}");

            Close();
        }
Esempio n. 7
0
 private void __ClearChildWindows()
 {
     ChildWindows.Clear();
 }