コード例 #1
0
 private void con_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Left)
     {
         con.FindForm().Left += e.X - p.X;
         con.FindForm().Top  += e.Y - p.Y;
     }
 }
コード例 #2
0
ファイル: Parent.cs プロジェクト: perryiv/cadkit
        /// <summary>
        /// Find the parent mdi form.
        /// </summary>
        public static System.Windows.Forms.Form findMdiParent(System.Windows.Forms.Control child)
        {
            lock ("CadKit.Tools.Parent.findMdiParent")
            {
                if (null == child)
                {
                    return(null);
                }

                System.Windows.Forms.Form parent = child.FindForm();
                System.Windows.Forms.Form last   = null;
                while (null != parent && last != parent)
                {
                    last   = parent;
                    parent = parent.FindForm();
                }
                if (null != parent.MdiParent)
                {
                    return(parent.MdiParent);
                }
                else
                {
                    return(null);
                }
            }
        }
コード例 #3
0
        public void RunMacro_Click(object sender, RoutedEventArgs e)
        {
            HumanMacroData.Separator separator = HumanMacroData.Separator.Sentence;
            if (separatorBox.SelectedItem == item2)
            {
                separator = HumanMacroData.Separator.Sentence;
            }
            else if (separatorBox.SelectedItem == item1)
            {
                separator = HumanMacroData.Separator.Paragraph;
            }

            double reward; int redundancy; string localtitle; string localsubtitle; string localinstructions;

            /*
             * if (Soylent.DEBUG == true)
             * {
             *  reward = 0.05;
             *  redundancy = 2;
             *  localtitle = "\"Make my novel present tense\"";
             *  localsubtitle = "\"I need to change some prose from past to present tense\"";
             *  localinstructions = "'I am changing this section of my novel from the past tense to the present tense. Please read and fix to make everything present tense, e.g., \"Susan swerved and aimed the gun at her assailant. The man recoiled, realizing that his prey had now caught on to the scheme.\" becomes \"Susan swerves and aims the gun at her assailant. The man recoils, realizing that his prey had now caught on to the scheme.\"'";
             * }
             * else
             * {
             */
            reward            = payment;
            redundancy        = numRepetitions;
            localtitle        = title;
            localsubtitle     = subtitle;
            localinstructions = instructions;
            //}

            HumanMacroData.ReturnType type = HumanMacroData.ReturnType.Comment;
            if (returnTypeBox.SelectedItem == returnAsComments)
            {
                type = HumanMacroData.ReturnType.Comment;
            }
            else if (returnTypeBox.SelectedItem == returnAsInline)
            {
                type = HumanMacroData.ReturnType.SmartTag;
            }


            //Debug.WriteLine("########################");
            //Debug.WriteLine("Reward: " + reward + " || Redundancy: "+redundancy+" || Title: "+localtitle+" || Subtitle: "+localsubtitle+" || Instructions: "+localinstructions);
            //Debug.WriteLine(separatorBox.SelectedValue.ToString() + " 1 " + (item2 == separatorBox.SelectedValue) + " 2 " + (item2 == separatorBox.SelectionBoxItem) + " 3 " + (item2 == separatorBox.SelectedItem) + " 4 " + (item2.Content == separatorBox.SelectedValuePath));

            //HumanMacroData data = new HumanMacroData(text, jobNumber, separator, reward, redundancy, localtitle, localsubtitle, localinstructions, type, HumanMacroData.TestOrReal.Real);

            //HumanMacroJob job = new HumanMacroJob(data, jobNumber);
            HumanMacroJob job = new HumanMacroJob(text, jobNumber, separator, reward, redundancy, localtitle, localsubtitle, localinstructions, type, HumanMacroData.TestOrReal.Real);

            HwndSource source = (HwndSource)PresentationSource.FromVisual(sender as Button);

            System.Windows.Forms.Control ctl = System.Windows.Forms.Control.FromChildHandle(source.Handle);
            ctl.FindForm().Close();
        }
コード例 #4
0
        private void btn_Login_Click(object sender, RoutedEventArgs e)
        {
            String salida = SettingsSistema.saveParametros(txtServer.Text, txtDatabase.Text, txtUser.Text, pswPassword.Password);

            MessageBox.Show(salida, "Mensaje", MessageBoxButton.OK, MessageBoxImage.Exclamation);
            HwndSource source = (HwndSource)PresentationSource.FromVisual(sender as Button);

            System.Windows.Forms.Control ctl = System.Windows.Forms.Control.FromChildHandle(source.Handle);
            ctl.FindForm().Close();
            System.Windows.Forms.Application.Restart();
        }
コード例 #5
0
        private static string GetNomForRegistre(System.Windows.Forms.Control liste, string strName)
        {
            string strPath = "Preferences\\Panel_Listes\\";

            if (liste.FindForm() != null)
            {
                strPath += liste.FindForm().GetType().Name + "_";
            }
            else
            {
                System.Windows.Forms.Control ctrl = liste;
                while (ctrl.Parent != null)
                {
                    ctrl = ctrl.Parent;
                }
                strPath += ctrl.GetType().Name + "_";
            }
            strPath += strName;
            return(strPath);
        }
コード例 #6
0
        /// <summary>
        /// Starts game in a borderless window at display resolution.
        /// </summary>
        private void StartBorderlessWindowed(GraphicsDeviceInformation graphicsDeviceInformation)
        {
            // Set borderless window style
            System.Windows.Forms.Control control = System.Windows.Forms.Form.FromHandle(this.Window.Handle);
            System.Windows.Forms.Form    form    = control.FindForm();
            form.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;

            // Set borderless window resolution to match display resolution
            graphicsDeviceInformation.PresentationParameters.BackBufferFormat = displayMode.Format;
            graphicsDeviceInformation.PresentationParameters.BackBufferWidth  = displayMode.Width;
            graphicsDeviceInformation.PresentationParameters.BackBufferHeight = displayMode.Height;
        }
コード例 #7
0
        public LibVlc11xDynamic MakeSecondMediaPlayer(System.Windows.Forms.Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded)
        {
            LibVlc11xDynamic newVlc = new LibVlc11xDynamic();

            newVlc._libVlc       = this._libVlc;
            newVlc._libVlcDLL    = this._libVlcDLL;
            newVlc._ownerControl = ownerControl;
            if (ownerControl != null)
            {
                newVlc._parentForm = ownerControl.FindForm();
            }

            newVlc.LoadLibVlcDynamic();

            newVlc.OnVideoLoaded = onVideoLoaded;
            newVlc.OnVideoEnded  = onVideoEnded;

            if (!string.IsNullOrEmpty(videoFileName))
            {
                IntPtr media = _libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0"));
                newVlc._mediaPlayer = _libvlc_media_player_new_from_media(media);
                _libvlc_media_release(media);

                //  Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable);
                //  Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view);
                _libvlc_media_player_set_hwnd(newVlc._mediaPlayer, ownerControl.Handle); // windows

                if (onVideoEnded != null)
                {
                    newVlc._videoEndTimer = new System.Windows.Forms.Timer {
                        Interval = 500
                    };
                    newVlc._videoEndTimer.Tick += VideoEndTimerTick;
                    newVlc._videoEndTimer.Start();
                }

                _libvlc_media_player_play(newVlc._mediaPlayer);
                newVlc._videoLoadedTimer = new System.Windows.Forms.Timer {
                    Interval = 500
                };
                newVlc._videoLoadedTimer.Tick += new EventHandler(newVlc.VideoLoadedTimer_Tick);
                newVlc._videoLoadedTimer.Start();

                newVlc._mouseTimer = new System.Windows.Forms.Timer {
                    Interval = 25
                };
                newVlc._mouseTimer.Tick += newVlc.MouseTimerTick;
                newVlc._mouseTimer.Start();
            }
            return(newVlc);
        }
コード例 #8
0
        public override void Initialize(System.Windows.Forms.Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded)
        {
            _ownerControl = ownerControl;
            if (ownerControl != null)
            {
                _parentForm = ownerControl.FindForm();
            }

            OnVideoLoaded = onVideoLoaded;
            OnVideoEnded  = onVideoEnded;

            if (!string.IsNullOrEmpty(videoFileName))
            {
                string[] initParameters = new string[] { "--no-sub-autodetect-file" }; //, "--no-video-title-show" }; //TODO: Put in options/config file
                _libVlc = libvlc_new(initParameters.Length, initParameters);
                IntPtr media = libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0"));
                _mediaPlayer = libvlc_media_player_new_from_media(media);
                libvlc_media_release(media);

                //  Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable);
                //  Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view);
                libvlc_media_player_set_hwnd(_mediaPlayer, ownerControl.Handle); // windows

                if (onVideoEnded != null)
                {
                    _videoEndTimer = new System.Windows.Forms.Timer {
                        Interval = 500
                    };
                    _videoEndTimer.Tick += VideoEndTimerTick;
                    _videoEndTimer.Start();
                }

                libvlc_media_player_play(_mediaPlayer);
                _videoLoadedTimer = new System.Windows.Forms.Timer {
                    Interval = 500
                };
                _videoLoadedTimer.Tick += new EventHandler(VideoLoadedTimer_Tick);
                _videoLoadedTimer.Start();
            }
        }
コード例 #9
0
        private System.Windows.Forms.Form _stMessageBoxGetForm(System.Windows.Forms.Control ctrl)
        {
            this.pForm = null;

            if (ctrl == null)
            {
                if (this.Parent != null)
                {
                    ctrl = this.Parent;
                }
            }
            if (ctrl is System.Windows.Forms.Form)
            {
                this.pForm = (System.Windows.Forms.Form)ctrl as System.Windows.Forms.Form;
            }
            else if (ctrl != null)
            {
                this.pForm = (System.Windows.Forms.Form)ctrl.FindForm();
            }
            this.pForm = ((this.pForm is System.Windows.Forms.Form) ? this.pForm : null);
            return(this.pForm);
        }
コード例 #10
0
        /// <summary>
        /// 在窗口控件中启动应用程序
        /// </summary>
        /// <param name="containerControl">容器控件</param>
        internal void StartNormalApp(System.Windows.Forms.Control containerControl)
        {
            //启动进程
            this._process.Start();

            // Wait for process to be created and enter idle condition
            this._process.WaitForInputIdle();

            //启用的应用程序要等待这么久,否则不会被嵌套到指定的容器控件中,具体原因为毛以后再研究
            System.Threading.Thread.Sleep(190);

            // Remove border and whatnot
            NativeMethods.SetWindowLong(this._process.MainWindowHandle, NestProcess.GWL_STYLE, NestProcess.WS_VISIBLE);

            // Put it into this form
            NativeMethods.SetParent(this._process.MainWindowHandle, containerControl.Handle);

            // Move the window to overlay it on this window
            NativeMethods.MoveWindow(this._process.MainWindowHandle, 0, 0, containerControl.Width, containerControl.Height, true);

            //注册窗口控件大小改变及窗口控件所在窗口关闭事件
            containerControl.Resize += containerControl_Resize;
            containerControl.FindForm().FormClosing += form_FormClosing;
        }
コード例 #11
0
ファイル: Game1.cs プロジェクト: SayakaIsBaka/Furret2
        public Game1()
        {
            _graphics             = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
            IsMouseVisible        = true;
            Window.IsBorderless   = true;
            IntPtr hWnd = Window.Handle;

            _ctrl = System.Windows.Forms.Control.FromHandle(hWnd);
            _form = _ctrl.FindForm();
            _form.TransparencyKey = System.Drawing.Color.Beige;
            _form.TopMost         = true;

            uint initialStyle = GetWindowLong(hWnd, -20);

            SetWindowLong(hWnd, -20, initialStyle | 0x80000 | 0x20);

            SetScreenBounds();

            _graphics.PreferredBackBufferWidth  = 500;
            _graphics.PreferredBackBufferHeight = 500;
            Window.Position = new Point((GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Width / 2) - (_graphics.PreferredBackBufferWidth / 2), (GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / 2) - (_graphics.PreferredBackBufferHeight / 2));
            _graphics.ApplyChanges();
        }
コード例 #12
0
        /// <summary>
        /// Reubicar los controles hijos, en caso de que se hayan agregado o quitado algunos.
        /// </summary>
        protected virtual void ReubicarControles()
        {
            if (this.Controles != null && this.Controles.Count > 0)
            {
                this.SuspendLayout();
                int ControlNumber = 0, AlturaActual = 0;
                foreach (T Control in this.Controles)
                {
                    Control.Location = new Point(Control.Location.X, AlturaActual + this.PanelGrilla.AutoScrollPosition.Y);
                    AlturaActual    += Control.Size.Height + Control.Margin.Vertical;
                    Control.TabIndex = ControlNumber;
                    Control.Size     = new Size(this.Width - 20, Control.Size.Height);
                    ControlNumber++;

                    if (this.AutoSize)
                    {
                        System.Windows.Forms.Control WinCtrl = Control as System.Windows.Forms.Control;
                        Point LocationOnForm = WinCtrl.FindForm().PointToClient(Control.Parent.PointToScreen(Control.Location));
                        this.Height = Control.Size.Height + LocationOnForm.Y;
                    }
                }
                this.ResumeLayout();
            }
        }
コード例 #13
0
 /// <summary>
 /// Create a new FormGame.
 /// </summary>
 /// <param name="targetControl">A control which the game will draw onto.</param>
 public WpfGame(Control targetControl)
     : this((targetControl != null) ? targetControl.FindForm() : null)
 {
     TargetControl = targetControl;
 }
コード例 #14
0
        public override void Initialize(System.Windows.Forms.Control ownerControl, string videoFileName, EventHandler onVideoLoaded, EventHandler onVideoEnded)
        {
            _ownerControl = ownerControl;
            if (ownerControl != null)
            {
                _parentForm = ownerControl.FindForm();
            }
            string dllFile = GetVlcPath("libvlc.dll");

            if (File.Exists(dllFile))
            {
                Directory.SetCurrentDirectory(Path.GetDirectoryName(dllFile));
                _libVlcDLL = LoadLibrary(dllFile);
                LoadLibVlcDynamic();
            }
            else if (!Directory.Exists(videoFileName))
            {
                return;
            }

            OnVideoLoaded = onVideoLoaded;
            OnVideoEnded  = onVideoEnded;

            if (!string.IsNullOrEmpty(videoFileName))
            {
                string[] initParameters = new string[] { "--no-sub-autodetect-file" }; //, "--no-video-title-show" }; //TODO: Put in options/config file
                _libVlc = _libvlc_new(initParameters.Length, initParameters);
                IntPtr media = _libvlc_media_new_path(_libVlc, Encoding.UTF8.GetBytes(videoFileName + "\0"));
                _mediaPlayer = _libvlc_media_player_new_from_media(media);
                _libvlc_media_release(media);


                //  Linux: libvlc_media_player_set_xdrawable (_mediaPlayer, xdrawable);
                //  Mac: libvlc_media_player_set_nsobject (_mediaPlayer, view);

                if (ownerControl != null)
                {
                    _libvlc_media_player_set_hwnd(_mediaPlayer, ownerControl.Handle); // windows

                    //hack: sometimes vlc opens in it's own windows - this code seems to prevent this
                    for (int j = 0; j < 50; j++)
                    {
                        System.Threading.Thread.Sleep(10);
                        System.Windows.Forms.Application.DoEvents();
                    }
                    _libvlc_media_player_set_hwnd(_mediaPlayer, ownerControl.Handle); // windows
                }

                if (onVideoEnded != null)
                {
                    _videoEndTimer = new System.Windows.Forms.Timer {
                        Interval = 500
                    };
                    _videoEndTimer.Tick += VideoEndTimerTick;
                    _videoEndTimer.Start();
                }

                _libvlc_media_player_play(_mediaPlayer);
                _videoLoadedTimer = new System.Windows.Forms.Timer {
                    Interval = 500
                };
                _videoLoadedTimer.Tick += new EventHandler(VideoLoadedTimer_Tick);
                _videoLoadedTimer.Start();

                _mouseTimer = new System.Windows.Forms.Timer {
                    Interval = 25
                };
                _mouseTimer.Tick += MouseTimerTick;
                _mouseTimer.Start();
            }
        }
コード例 #15
0
 public static System.Drawing.Point GetControlLocation(System.Windows.Forms.Control control)
 {
     return(control.FindForm().PointToClient(control.Parent.PointToScreen(control.Location)));
 }