示例#1
0
        /// <summary>
        ///
        /// </summary>
        public void SetViewCommand()
        {
            ButtonCommand = new DelegateCommand(() => {
                if (WindowType != null)
                {
                    Window window            = null;
                    WindowCollection windows = App.Current.Windows;
                    for (int i = 0; i < windows.Count; i++)
                    {
                        if (windows[i].GetType() == WindowType)
                        {
                            window = windows[i];
                            break;
                        }
                    }
                    if (window != null)
                    {
                        window.Close();
                    }

                    window = (Window)Activator.CreateInstance(WindowType, WindowParameters);
                    window.ShowDialog();
                }
                if (Callback != null)
                {
                    Callback();
                }
            });
        }
        private void openNewView(OpenNewViewMessage obj)
        {
            Window wnd = null;

            string name = "CorsoWpf.DigitalManager.WpfApp." + obj.WindowName + "Window";
            Type   t    = Type.GetType(name);

            if (t != null)
            {
                WindowCollection windows = Application.Current.Windows;

                wnd = Activator.CreateInstance(t) as Window;
            }

            if (wnd != null)
            {
                if (wnd.Resources.Contains("viewmodel"))
                {
                    var vm = wnd.Resources["viewmodel"] as ApplicationViewModelBase;
                }

                wnd.Closed += Wnd_Closed;

                if (obj.Modal)
                {
                    wnd.ShowDialog();
                }
                else
                {
                    wnd.Show();
                }
            }
        }
示例#3
0
        private void ComboBoxAdv_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            ComboBoxItemAdv  item;
            WindowCollection windows = Application.Current.Windows;

            if (windows.Count > 0)
            {
                Window      samplewindow = windows[0];
                ComboBoxAdv combo        = sender as ComboBoxAdv;
                if (combo != null)
                {
                    if (combo.SelectedItem != null)
                    {
                        item = combo.SelectedItem as ComboBoxItemAdv;
                        if (this.viewer != null)
                        {
#if !SyncfusionFramework3_5
                            Syncfusion.SfSkinManager.SfSkinManager.SetVisualStyle(this.viewer, (VisualStyles)Enum.Parse(typeof(VisualStyles), item.Content.ToString()));
#endif
                            Syncfusion.Samples.ViewModel.ReportViewModel viewModel = new ReportViewModel();
                            viewModel.Loaded(samplewindow as object, e);
                        }
                    }
                }
            }
        }
示例#4
0
        /// <summary>
        /// Enumerates the windows on a desktop.
        /// </summary>
        /// <returns>A window collection if successful, otherwise null.</returns>
        public WindowCollection GetWindows()
        {
            // make sure object isn't disposed.
            ThrowIfDisposed();

            // make sure a desktop is open.
            if (!IsOpen)
            {
                return(null);
            }

            // init the array list.
            _windows.Clear();

            // get windows.
            bool result = Win32.EnumDesktopWindows(_desktop, DesktopWindowsProc, IntPtr.Zero);

            // check for error.
            if (!result)
            {
                return(null);
            }

            // get window names.
            WindowCollection windows = new WindowCollection();
            StringBuilder    sb      = new StringBuilder(Win32.MAX_WINDOW_NAME_LENGTH);

            foreach (IntPtr wnd in _windows)
            {
                Win32.GetWindowText(wnd, sb, sb.Capacity);
                windows.Add(new Window(wnd, sb.ToString()));
            }

            return(windows);
        }
示例#5
0
        public inRoom(bool _isAdmin, int _questionsNum, int _time, int _playersNum, string _roomName)
        {
            windows = WPFclient.App.Current.Windows; //for waitForMsg
            isAdmin = _isAdmin;
            cl      = (ClientBody)WPFclient.App.Current.Properties["client"];
            InitializeComponent();
            questionNum.Content = questionNum.Content.ToString() + _questionsNum;
            time.Content        = time.Content.ToString() + _time;
            players.Content     = players.Content.ToString() + _playersNum;
            room.Content        = room.Content.ToString() + _roomName;
            UserName.Content    = cl._username;

            ListBoxItem user = new ListBoxItem();

            user.Content = cl._username;
            usersList.Items.Add(user);
            if (!isAdmin)
            {//hide the start game and close game buttons, as they aren't allowed for a non admin, and show the leave game button, and instructions
                //instead of the number of players, that is intended only for admins.
                players.Content             = "Please wait for the admin to start the game";
                adminExitButton.Visibility  = Visibility.Collapsed;
                adminStartButton.Visibility = Visibility.Collapsed;
                joinerExit.Visibility       = Visibility.Visible;
            }
            WindowStartupLocation = WindowStartupLocation.CenterScreen;

            background_worker.WorkerSupportsCancellation = true;
            background_worker.WorkerReportsProgress      = true;
            background_worker.DoWork          += background_worker_DoWork;
            background_worker.ProgressChanged += background_worker_ProgressChanged;

            background_worker.RunWorkerAsync(this);
        }
示例#6
0
        public static void ShouldShutDown()
        {
            WindowCollection allWindows = System.Windows.Application.Current.Windows;

            bool shouldShutDown = false;

            if (Settings.Default.RunInTheBackground == true)
            {
                if (App.Current is App app)
                {
                    if (app.NumberOfRunningInstances > 1 &&
                        app.TextGrabIcon == null &&
                        allWindows.Count < 1)
                    {
                        shouldShutDown = true;
                    }
                }
            }
            else
            {
                if (allWindows.Count < 1)
                {
                    shouldShutDown = true;
                }
            }

            if (shouldShutDown == true)
            {
                System.Windows.Application.Current.Shutdown();
            }
        }
示例#7
0
        private void ComboBoxAdv_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBoxItemAdv  item;
            WindowCollection windows = Application.Current.Windows;

            if (windows.Count > 0)
            {
                Window      samplewindow = windows[0];
                ComboBoxAdv combo        = sender as ComboBoxAdv;
                if (combo != null)
                {
                    if (combo.SelectedItem != null)
                    {
                        item = combo.SelectedItem as ComboBoxItemAdv;
                        VisualStyles selectedStyle = (VisualStyles)Enum.Parse(typeof(VisualStyles), item.Content.ToString());
                        SfSkinManager.SetVisualStyle(BulletGraph, selectedStyle);
                        SfSkinManager.SetVisualStyle(this.combo, selectedStyle);
                        SfSkinManager.SetVisualStyle(this.HeaderText, selectedStyle);
                        SfSkinManager.SetVisualStyle(this.VisiualStyleTextBlock, selectedStyle);

                        if (selectedStyle == VisualStyles.MaterialDark)
                        {
                            this.grid.Background = Brushes.Black;
                        }
                        else
                        {
                            this.grid.Background = Brushes.White;
                        }
                    }
                }
            }
        }
        public static List <Window> ToList(this WindowCollection wc)
        {
            var ret = new Window[wc.Count];

            wc.CopyTo(ret, 0);
            return(ret.ToList());
        }
示例#9
0
        Window GetActiveWindow()
        {
            try {
                Application app = Application.Current;
                if (app == null)
                {
                    return(null);
                }

                WindowCollection windows = app.Windows;
                if (windows == null || windows.Count <= 0)
                {
                    return(null);
                }

                int count = windows.Count;
                for (int i = 0; i < count; i++)
                {
                    if (windows[i].IsActive)
                    {
                        return(windows[i]);
                    }
                }
            }
            catch {
            }
            return(null);
        }
示例#10
0
        protected override Window CreateShell()
        {
            coreModule.OnInitialized(Container);
            base.InitializeModules();

            // now we should have a shell, load settings and show if we can.
            IShell shell = Container.Resolve <IShell>();

            coreModule.LoadSettings();

            // Assign main window object and show window.
            Window main = shell as Window;

            main.DataContext = Container.Resolve <IWorkspace>();

            // make sure we are the only one.
            WindowCollection windows = Application.Current.Windows;

            foreach (Object item in windows)
            {
                Window window = item as Window;
                if (window != main)
                {
                    window.Close();
                }
            }
            return(main);
        }
示例#11
0
        private void RunNormalMultipleWindows()
        {
            //List<Window> windows = new List<Window>();
            ArrayList windows = new ArrayList();

            Form primary = new Form();

            primary.StartPosition = FormStartPosition.Manual;
            primary.Location      = Screen.PrimaryScreen.Bounds.Location;
            primary.Size          = Screen.PrimaryScreen.Bounds.Size;
            primary.BackColor     = Color.Black;
#if !DEBUG
            primary.TopMost = true;
#endif
            primary.FormBorderStyle = FormBorderStyle.None;
            primary.Text            = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            primary.Icon            = InvisbleLockScreen.Properties.Resources.icon;

            foreach (Screen screen in Screen.AllScreens)
            {
                if (screen == Screen.PrimaryScreen)
                {
                    continue;
                }

                Form form = new Form();
                form.Owner     = primary;
                form.BackColor = Color.Black;
#if !DEBUG
                form.TopMost = true;
#endif
                form.StartPosition   = FormStartPosition.Manual;
                form.Location        = screen.Bounds.Location;
                form.Size            = screen.Bounds.Size;
                form.FormBorderStyle = FormBorderStyle.None;
                form.Text            = primary.Text;
                form.Icon            = InvisbleLockScreen.Properties.Resources.icon;

                windows.Add(new Window(this, form));
            }

            windows.Insert(0, new Window(this, primary));

            primary.Load += delegate(object sender, EventArgs e)
            {
                foreach (Window window in this.windows)
                {
                    if (window.Form.Owner == null)
                    {
                        continue;
                    }
                    window.Form.Show();
                }
            };

            this.windows = new WindowCollection(windows.ToArray(typeof(Window)) as Window[]);

            primary.Show();
            InitializeAndStart();
        }
示例#12
0
        protected void InternalConstruct(DockingManager manager, State state)
        {
            // Must provide a valid manager instance
            if (manager == null)
            {
                throw new ArgumentNullException("DockingManager");
            }

            // Remember initial state
            _state       = state;
            _manager     = manager;
            _autoDispose = true;

            // Get correct starting state from manager
            this.BackColor = _manager.BackColor;
            this.ForeColor = _manager.InactiveTextColor;

            // Create collection of windows
            _windows = new WindowCollection();

            // We want notification when contents are added/removed/cleared
            _windows.Clearing += new CollectionClear(OnWindowsClearing);
            _windows.Inserted += new CollectionChange(OnWindowInserted);
            _windows.Removing += new CollectionChange(OnWindowRemoving);
            _windows.Removed  += new CollectionChange(OnWindowRemoved);
        }
示例#13
0
        /// <summary>
        /// Creates a proxy instance to the bridged client service.
        /// </summary>
        /// <param name="windowCollection">The window collection.</param>
        /// <returns>The created proxy instance.</returns>
        public static T Create(WindowCollection windowCollection)
        {
            var proxy         = Create <T, BridgeClientService <T> >();
            var clientService = (BridgeClientService <T>)(object) proxy;

            clientService !.Init(windowCollection);
            return(proxy);
        }
        protected override void OnClick()
        {
            WindowCollection windows = Application.Current.Windows;

            foreach (Window window in windows)
            {
                window.WindowState = WindowState.Minimized;
            }
        }
示例#15
0
        /// <summary>
        /// インスタンスを生成します。
        /// </summary>
        /// <param name="screen">Screen。</param>
        internal Root(Screen screen)
            : base(screen)
        {
            Desktop = new Desktop(screen);
            // Desktop を子として関連付けます。
            AddChild(Desktop);

            Windows = new WindowCollection(this);
        }
示例#16
0
        private void RunPreview()
        {
#if DEBUG
            System.Diagnostics.Debugger.Launch();
#endif
            windows = new WindowCollection(new Window[] { new Window(this, windowHandle) });
            InitializeAndStart();
            previewShutdownEvent.WaitOne();
        }
        /// <summary>Handles the <c>Closed</c> event of this (<see cref="MahApps.Metro.Controls.MetroWindow"/>) control.
        /// <para/>Closes all active <see cref="Window"/>s within the current <see cref="Application"/>.</summary>
        /// <param name="Sender">The source of the event.</param>
        /// <param name="E">The <see cref="EventArgs"/> instance containing the event data.</param>
        void MetroWindow_Closed(object Sender, EventArgs E)
        {
            WindowCollection Windows = Application.Current.Windows;

            foreach (Window W in from Window W in Windows where W != this select W)
            {
                W.Close();
            }
        }
示例#18
0
        public IEnumerable <Window> GetWindowEnumerable(WindowCollection windows)
        {
            var enumerator = windows.GetEnumerator();

            while (enumerator.MoveNext())
            {
                yield return((Window)enumerator.Current);
            }
        }
示例#19
0
        /// <summary>
        /// Initializes a new instance of the Translator class. Translates all existing windows.
        /// </summary>
        public Translator()
        {
            LoadAssembly();
            WindowCollection windows = Application.Current.Windows;

            for (int i = 0; i < windows.Count; i++)
            {
                TranslateWindow(windows[i]);
            }
        }
示例#20
0
 /// <summary>
 /// (Расширение) Метод закрытия окна
 /// </summary>
 /// <param name="windows"></param>
 /// <param name="name"></param>
 public static void CloseWindow(this WindowCollection windows, string name)
 {
     foreach (Window t in windows)
     {
         if (t.Name == name)
         {
             t.Close();
         }
     }
 }
示例#21
0
        public static void SetWindowPosition(Window passedWindow)
        {
            string storedPostionString = "";

            if (passedWindow is EditTextWindow)
            {
                storedPostionString = Properties.Settings.Default.EditTextWindowSizeAndPosition;
            }

            if (passedWindow is GrabFrame)
            {
                storedPostionString = Properties.Settings.Default.GrabFrameWindowSizeAndPosition;
            }

            List <string> storedPostion = new(storedPostionString.Split(','));

            bool isStoredRectWithinScreen = false;

            if (storedPostion != null &&
                storedPostion.Count == 4)
            {
                bool couldParseAll = false;
                couldParseAll = double.TryParse(storedPostion[0], out double parsedX);
                couldParseAll = double.TryParse(storedPostion[1], out double parsedY);
                couldParseAll = double.TryParse(storedPostion[2], out double parsedWid);
                couldParseAll = double.TryParse(storedPostion[3], out double parsedHei);
                Rectangle        storedSize = new Rectangle((int)parsedX, (int)parsedY, (int)parsedWid, (int)parsedHei);
                Screen[]         allScreens = Screen.AllScreens;
                WindowCollection allWindows = System.Windows.Application.Current.Windows;

                if (parsedHei < 10 || parsedWid < 10)
                {
                    return;
                }

                foreach (Screen screen in allScreens)
                {
                    if (screen.WorkingArea.IntersectsWith(storedSize))
                    {
                        isStoredRectWithinScreen = true;
                    }
                }

                if (isStoredRectWithinScreen == true && couldParseAll == true)
                {
                    passedWindow.Left   = storedSize.X;
                    passedWindow.Top    = storedSize.Y;
                    passedWindow.Width  = storedSize.Width;
                    passedWindow.Height = storedSize.Height;

                    return;
                }
            }
        }
示例#22
0
        private Plugin()
        {
            Icons = new Dictionary<string, Image>();
            ItemTemplates = new List<ItemTemplate>();
            ProjectTemplates = new List<ProjectTemplate>();

            Dependencies = new List<Library>();

            Events = new EventStorage();
            Windows = new WindowCollection();
        }
示例#23
0
        private Plugin()
        {
            Icons            = new Dictionary <string, Image>();
            ItemTemplates    = new List <ItemTemplate>();
            ProjectTemplates = new List <ProjectTemplate>();

            Dependencies = new List <Library>();

            Events  = new EventStorage();
            Windows = new WindowCollection();
        }
示例#24
0
 public static bool All(this WindowCollection source, Func <Window, bool> predicate)
 {
     foreach (Window item in source)
     {
         if (!predicate(item))
         {
             return(false);
         }
     }
     return(true);
 }
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Получение коллекции всех окон приложения
            WindowCollection windows = App.Current.Windows;

            foreach (Window win in windows)
            {
                // Применение стиля ко  всем окнам!
                win.WindowStyle = WindowStyle.ToolWindow;
            }
        }
        private static bool ContainsWindow(WindowCollection windows, Window myWindow)
        {
            foreach (Window w in windows)
            {
                if (w == myWindow)
                {
                    return(true);
                }
            }

            return(false);
        }
        public static bool ContainsWindow <TWindow>(this WindowCollection collection)
        {
            foreach (Window item in collection)
            {
                if (item is TWindow)
                {
                    return(true);
                }
            }

            return(false);
        }
示例#28
0
        public static void AddTextToOpenWindow(string textToAdd)
        {
            WindowCollection allWindows = System.Windows.Application.Current.Windows;

            foreach (Window window in allWindows)
            {
                if (window is EditTextWindow mtw)
                {
                    mtw.AddThisText(textToAdd);
                }
            }
        }
示例#29
0
        void setParent(Boolean mainWindowAsParent = false)
        {
            WindowCollection windows = Application.Current.Windows;
            Window           parent  = null;

            if (windows.Count > 0)
            {
                parent = mainWindowAsParent
                    ? windows[0]
                    : windows[windows.Count - 2];
            }
            hwnd.Owner = parent;
        }
示例#30
0
        public static MessageBoxResult MsgBox(String header, String message, MessageBoxImage image = MessageBoxImage.Error, MessageBoxButton button = MessageBoxButton.OK)
        {
            WindowCollection windows = Application.Current.Windows;
            Window           hwnd    = null;

            if (windows.Count > 0)
            {
                hwnd = windows[windows.Count - 1];
            }
            return(hwnd == null
                ? MessageBox.Show(message, header, button, image)
                : MessageBox.Show(hwnd, message, header, button, image));
        }
示例#31
0
        /// <summary>
        /// This method activates last child window
        /// </summary>
        /// <returns></returns>
        public bool ActivateChildWindow()
        {
            WindowCollection wc  = Windows;
            Window           wnd = wc[wc.Count - 1];

            if (wnd != wc[0])
            {
                wnd.Activate();
                return(true);
            }

            return(false);
        }
        private void Button_DisplayHelp(object sender, RoutedEventArgs e)
        {
            WindowCollection CBAWindows = Application.Current.Windows;

            foreach (var win in CBAWindows)
            {
                if (win.ToString() == "CANBUS.HelpWindow")
                {
                    return;
                }
            }
            new HelpWindow().Show();
        }
示例#33
0
        /// <summary>
        ///     Enumerates the windows on a desktop.
        /// </summary>
        /// <param name="windows">Array of Desktop.Window objects to recieve windows.</param>
        /// <returns>A window colleciton if successful, otherwise null.</returns>
        public WindowCollection GetWindows()
        {
            // make sure object isnt disposed.
            CheckDisposed();

            // make sure a desktop is open.
            if (!IsOpen) return null;

            // init the arraylist.
            m_windows.Clear();
            var windows = new WindowCollection();

            // get windows.
            var result = EnumDesktopWindows(DesktopHandle, DesktopWindowsProc, IntPtr.Zero);

            // check for error.
            if (!result) return null;

            // get window names.
            windows = new WindowCollection();

            var ptr = Marshal.AllocHGlobal(MaxWindowNameLength);

            foreach (IntPtr wnd in m_windows)
            {
                GetWindowText(wnd, ptr, MaxWindowNameLength);
                windows.Add(new Window(wnd, Marshal.PtrToStringAnsi(ptr)));
            }

            Marshal.FreeHGlobal(ptr);

            return windows;
        }
示例#34
0
        private void RunWindowed()
        {
            Form form = new Form();
            form.FormBorderStyle = FormBorderStyle.FixedSingle;
            form.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            form.StartPosition = FormStartPosition.CenterScreen;
            form.BackColor = Color.Black;
            #if !DEBUG
            form.TopMost = true;
            #endif
            form.MaximizeBox = false;
            form.ClientSize = new Size((int)(Screen.PrimaryScreen.WorkingArea.Width * 0.9), (int)(Screen.PrimaryScreen.WorkingArea.Height * 0.9));

            windows = new WindowCollection(new Window[] { new Window(this, form) });

            form.Show();
            InitializeAndStart();
        }
示例#35
0
 private void RunPreview()
 {
     #if DEBUG
     System.Diagnostics.Debugger.Launch();
     #endif
     windows = new WindowCollection(new Window[] { new Window(this, windowHandle) });
     InitializeAndStart();
     previewShutdownEvent.WaitOne();
 }
示例#36
0
        private void RunNormalSingleWindow()
        {
            Form form = new Form();
            Rectangle rect = GetVirtualScreenRect();
            form.Location = rect.Location;
            form.Size = rect.Size;
            form.BackColor = Color.Black;
            form.TopMost = true;
            form.FormBorderStyle = FormBorderStyle.None;
            form.StartPosition = FormStartPosition.Manual;
            form.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

            PictureBox p = new PictureBox();
            p.Image = GetScreen(rect);
            p.Dock = DockStyle.Fill;
            form.Controls.Add(p);

            windows = new WindowCollection(new Window[] { new Window(this, form) });

            form.Show();
            InitializeAndStart();
        }
示例#37
0
        private void RunNormalSingleWindow()
        {
            Form form = new Form();
            Rectangle rect = GetVirtualScreenRect();
            form.Location = rect.Location;
            form.Size = rect.Size;
            form.BackColor = Color.Black;
            #if !DEBUG
            form.TopMost = true;
            #endif
            form.FormBorderStyle = FormBorderStyle.None;
            form.StartPosition = FormStartPosition.Manual;
            form.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

            windows = new WindowCollection(new Window[] { new Window(this, form) });

            form.Show();
            InitializeAndStart();
        }
示例#38
0
        private void RunNormalMultipleWindows()
        {
            //List<Window> windows = new List<Window>();
            ArrayList windows = new ArrayList();

            Form primary = new Form();
            primary.StartPosition = FormStartPosition.Manual;
            primary.Location = Screen.PrimaryScreen.Bounds.Location;
            primary.Size = Screen.PrimaryScreen.Bounds.Size;
            primary.BackColor = Color.Black;
            #if !DEBUG
            primary.TopMost = true;
            #endif
            primary.FormBorderStyle = FormBorderStyle.None;
            primary.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;

            foreach (Screen screen in Screen.AllScreens)
            {
                if (screen == Screen.PrimaryScreen)
                    continue;

                Form form = new Form();
                form.Owner = primary;
                form.BackColor = Color.Black;
            #if !DEBUG
                form.TopMost = true;
            #endif
                form.StartPosition = FormStartPosition.Manual;
                form.Location = screen.Bounds.Location;
                form.Size = screen.Bounds.Size;
                form.FormBorderStyle = FormBorderStyle.None;
                form.Text = primary.Text;

                windows.Add(new Window(this, form));
            }

            windows.Insert(0, new Window(this, primary));

            primary.Load += delegate(object sender, EventArgs e)
            {
                foreach (Window window in this.windows)
                {
                    if (window.Form.Owner == null)
                        continue;
                    window.Form.Show();
                }
            };

            this.windows = new WindowCollection(windows.ToArray(typeof(Window)) as Window[]);

            primary.Show();
            InitializeAndStart();
        }