/// <summary>
            /// Initializes a new instance of the WindowLocation class.
            /// </summary>
            /// <param name="input">The input string.</param>
            public WindowLocation(string input)
            {
                Param.AssertValidString(input, "input");

                string[] sections = input.Split(',');
                if (sections.Length < 5)
                {
                    throw new ArgumentException(string.Format(
                        CultureInfo.CurrentCulture, Strings.InvalidWindowLocationInputString, input));
                }

                this.location.X = Convert.ToInt32(sections[0], null);
                this.location.Y = Convert.ToInt32(sections[1], null);
                this.size.Height = Convert.ToInt32(sections[2], null);
                this.size.Width = Convert.ToInt32(sections[3], null);

                int state = Convert.ToInt32(sections[4], null);
                if (state < 0)
                {
                    this.state = FormWindowState.Minimized;
                }
                else if (state > 0)
                {
                    this.state = FormWindowState.Maximized;
                }
                else if (state == 0)
                {
                    this.state = FormWindowState.Normal;
                }
            }
Exemple #2
0
 internal FormLayout(DlgBase form)
 {
     if (Program.IsClosing || ((!form.Disposing && !form.IsDisposed) && (form.WindowState != FormWindowState.Minimized)))
     {
         this.mBounds = form.Bounds;
         if (this.mBounds.X == -32000)
         {
             this.mBounds.X = 0;
         }
         if (this.mBounds.Y == -32000)
         {
             this.mBounds.Y = 0;
         }
         if (form.WindowState == FormWindowState.Minimized)
         {
             this.mWindowState = FormWindowState.Normal;
         }
         else
         {
             this.mWindowState = form.WindowState;
         }
         this.mSaveLoadData = form.LayoutData;
         this.mWasOpenOnExit = (Program.IsClosing && form.AllowRestoreWindow) && form.Visible;
         this.mFormType = form.GetType();
     }
 }
Exemple #3
0
        public void load()
        {
            using (RegistryKey r = Registry.CurrentUser.OpenSubKey(@"Software\" + CompanyId() + @"\" + AppId() + @"\Window State\" + form.Name))
            {
                if (r != null)
                {
                    try
                    {
                        string _location = (string)r.GetValue("location"), _size = (string)r.GetValue("size");
                        state = (FormWindowState)r.GetValue("state");
                        location = (Point)TypeDescriptor.GetConverter(typeof(Point)).ConvertFromInvariantString(_location);
                        size = (Size)TypeDescriptor.GetConverter(typeof(Size)).ConvertFromInvariantString(_size);

                        // Don't do anything if the screen config has since changed (otherwise windows vanish off the side)
                        if (screenconfig() == new MD5Sum((string) r.GetValue("screenconfig")))
                        {
                            form.Location = location;
                            form.Size = size;
                            // Don't restore if miminised (it's unhelpful as the user misses the fact it's opened)
                            if (state != FormWindowState.Minimized)
                                form.WindowState = state;
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            }
        }
 public FormRobneLokacije(Terminal _terminal, Katalog _katalog, Point _koordinate, int _širina, int _visina, FormWindowState _stanje)
     : base(_terminal, _katalog, _koordinate, _širina, _visina, _stanje)
 {
     InitializeComponent();
     dgvRobneLokacije.AutoGenerateColumns = false;
     CoreScannerProxy.Instance.BarcodeEvent += new BarcodeEventHandler(OnBarcode); // Događaj za očitanje barkoda.
     txtŠifraIliBarkod.Select();
     ddlSkladište.DataSource = this.katalog.skladišta;
     try
     {
         zadanoSkladište = ConfigurationManager.AppSettings["ZadanoSkladište"];
         if (String.IsNullOrEmpty(zadanoSkladište))
         {
             return;
         }
         for (int i = 0; i < ddlSkladište.Items.Count; i++)
         {
             if (((KSkladiste)ddlSkladište.Items[i]).oznaka == ConfigurationManager.AppSettings["ZadanoSkladište"])
             {
                 ddlSkladište.SelectedIndex = i;
                 break;
             }
         }
     }
     catch (ConfigurationErrorsException)
     {
         // Pojeo vuk magare iliti On error resume next.
     }
 }
Exemple #5
0
        private AdminTool(string formName)
        {
            InitializeComponent();

            DBUser.DesignMode = true;

            //Помещаем окно редактора контролов справа на экране
            var screenBound = Screen.FromControl(FormControls.MainForm).WorkingArea;
            Size = new Size(Width, screenBound.Height);
            Location = new Point(screenBound.Location.X + screenBound.Width - Size.Width, 0);

            //Запоминаем старые данные для главной формы
            parentBound = new Rectangle(FormControls.MainForm.Location, FormControls.MainForm.Size);
            parentState = FormControls.MainForm.WindowState;

            //Загружаем список всех запущенных форм в выпадающий список
            bsForms.DataSource = Application.OpenForms
                .OfType<CommonChildForm>()
                .Where(form => form.SaveState && form != this)
                .Cast<Form>()
                .Union(new[]
                {
                    FormControls.MainForm
                })
                .Select(f => new KeyValuePair<string, string>(f.Name, f.Text))
                .ToList();
            lueForms.EditValue = formName;
        }
Exemple #6
0
        private void BindGrid(DbConnection conn)
        {
            conn.Open();
                _schema = new DataSet();
                var schema = conn.GetSchema();

                foreach (DataRow dataRow in schema.Rows)
                {
                    var tableName = dataRow["CollectionName"].ToString();
                    if(!_schema.Tables.Contains(tableName))
                    {
                        var dt = conn.GetSchema(tableName);
                        dt.TableName = tableName;
                        _schema.Tables.Add(dt);
                    }
                }
                conn.Close();
                dgSchema.DataSource = _schema.Tables[0];

                cbTable.DataSource = _schema.Tables[0];
                cbTable.DisplayMember = "CollectionName";
                cbTable.ValueMember = "CollectionName";
                _previousWidth = dgSchema.Width;
                _previousState = WindowState;
        }
Exemple #7
0
 public static FormWindowState «агрузить(string путь, string секци¤, string им¤, FormWindowState значениеѕо”молчанию)
 {
     int число = «агрузить(путь, секци¤, им¤, (int)значениеѕо”молчанию);
     if (число < 0 || число > 2)
         return значениеѕо”молчанию;
     return (FormWindowState)число;
 }
        private const int SettingsLocation = 0; // 0 - registry, 1 - ini-file

        #endregion Fields

        #region Methods

        public static void LoadApplicationSettings()
        {
            RegistryKey regKey = Registry.CurrentUser.OpenSubKey(SettingsAndConstants.RegistryLocation);

            LastProjectFileName = HiddenObjectStudio.Core.Tools.GetParameterFromReg(regKey, "LastProjectFile", string.Empty);
            DisplaySpriteActiveArea = HiddenObjectStudio.Core.Tools.GetParameterFromReg(regKey, "DisplaySpriteActiveArea", true);

            LastProjectBrowsePath = HiddenObjectStudio.Core.Tools.GetParameterFromReg(regKey, "LastProjectBrowsePath", string.Empty);
            LastSpriteBrowsePath = HiddenObjectStudio.Core.Tools.GetParameterFromReg(regKey, "LastSpriteBrowsePath", string.Empty);
            LastBackgroundBrowsePath = HiddenObjectStudio.Core.Tools.GetParameterFromReg(regKey, "LastBackgroundBrowsePath", string.Empty);

            if (HiddenObjectStudio.Core.Tools.GetParameterFromReg(regKey, "Maximized", false))
            {
                MainFormState = FormWindowState.Maximized;
            }
            else
            {
                MainFormPosition.Location = new Point(
                    HiddenObjectStudio.Core.Tools.GetParameterFromReg(regKey, "WindowLeft", 0),
                    HiddenObjectStudio.Core.Tools.GetParameterFromReg(regKey, "WindowTop", 0)
                    );
                MainFormPosition.Width = HiddenObjectStudio.Core.Tools.GetParameterFromReg(regKey, "WindowWidth", 0);
                MainFormPosition.Height = HiddenObjectStudio.Core.Tools.GetParameterFromReg(regKey, "WindowHeight", 0);
                MainFormState = FormWindowState.Normal;
            }

            LoadPreferences();

            if (regKey != null) regKey.Close();
        }
		private void OnMove(object sender, System.EventArgs e)
		{			
			if (form.WindowState == FormWindowState.Normal)
				dimensions.Location = form.Location;
			
			windowState = form.WindowState;
		}
Exemple #10
0
        /*
         * Create a wrapper form around the chromium web browser.
         */
        public WrapperForm() {
            InitializeComponent();

            // Initializes a new instance of the chromium web browser
            chromium = new ChromiumWebBrowser(AboutBlankPage) {
                Dock = DockStyle.Fill,
                LifeSpanHandler = new BrowserLifeSpanHandler(),
                MenuHandler = new BrowserMenuHandler(),
                RequestHandler = new BrowserRequestHandler(),
                ResourceHandler = new BrowserResourceHandler()
            };

            // Subscribe to multiple chromium web browser events
            chromium.FrameLoadEnd += chromium_FrameLoadEnd;
            chromium.NavStateChanged += chromium_NavStateChanged;

            // Immediately load the initial page (force handle to be created)
            chromium.CreateControl();

            // Add the chromium web browser to the browser panel
            browserPanel.Controls.Add(chromium);

            // Save the current window state as the previous one
            previousWindowState = WindowState;
        }
Exemple #11
0
        private void Launcher_Load(object sender, EventArgs e)
        {
            this.Icon = DnDCS.Win.Libs.Assets.AssetsLoader.LauncherIcon;

            initialFormTopMost = this.TopMost;
            initialFormBorderStyle = this.FormBorderStyle;
            initialFormWindowState = this.WindowState;

            if (this.runMode.HasValue)
            {
                switch (this.runMode.Value)
                {
                    case Constants.RunMode.Client:
                        this.btnClient.PerformClick();
                        break;

                    case Constants.RunMode.Server:
                        this.btnServer.PerformClick();
                        break;

                    default:
                        break;
                }
            }
        }
Exemple #12
0
        public void Run()
        {
            _current_form_window_state = WindowState;

            bool is_form_closed = false;
            bool is_form_resizing = false;

            Resize += (o, args) =>
            {
                if(WindowState != _current_form_window_state)
                    HandleResize();

                _current_form_window_state = WindowState;
            };

            ResizeBegin += (o, args) => { is_form_resizing = true; };
            ResizeEnd += (o, args) =>
            {
                is_form_resizing = false;
                HandleResize();
            };

            Closed += (o, args) => { is_form_closed = true; };

            MessagePump.Run(this, () =>
            {
                if (is_form_closed) return;

                if (!is_form_resizing)
                    _engine.FrameTick();
            });
        }
Exemple #13
0
		protected override void OnLocationChanged(EventArgs e)
		{
			base.OnLocationChanged(e);

			if (WindowState != FormWindowState.Minimized)
				LastNonMinimizedState = WindowState;
		}
 private void SaveFormState(Form a_form)
 {
     if (a_form.WindowState == FormWindowState.Normal)
         m_bounds = a_form.Bounds;
     if (a_form.WindowState != FormWindowState.Minimized)
         m_window_state = a_form.WindowState;
 }
Exemple #15
0
        public void activateForm(Form f, FormWindowState ws, FormStartPosition fs)
        {
            demandBackup = true;
            foreach (Form each in MdiChildren)
            {
                if ((string)each.Tag != "1")
                {
                    each.Close();
                }
            }

            if (fs == FormStartPosition.Manual)
            {
                f.StartPosition = FormStartPosition.Manual;
                int w = this.Width;
                int h = this.Height;
                f.Left = (w - f.Width) / 4;
                f.Top = (h - f.Height) / 6;
            }
            else
            {
                f.StartPosition = fs;
            }
            f.WindowState = ws;
            f.MdiParent = this;
            f.ControlBox = false;
            f.Show();
        }
Exemple #16
0
 public FormNalog(Terminal _terminal, Katalog _katalog, Point _koordinate, int _širina, int _visina, FormWindowState _stanje, KNalog _nalog)
     : base(_terminal, _katalog, _koordinate, _širina, _visina, _stanje)
 {
     InitializeComponent();
     dgvNalog.AutoGenerateColumns = false;
     dgvNalog.Columns["colPromet"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
     dgvNalog.Columns["colSken"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight;
     this.nalog = _nalog;
     txtDok.Focus();
     CoreScannerProxy.Instance.BarcodeEvent += new BarcodeEventHandler(OnBarcode); // Događaj za očitanje barkoda.
     if (nalog != null)
     {
         txtDok.Text =
             this.nalog.dokVrsta +
             this.nalog.sklaOznaka +
             (this.nalog.dokVrsta == "PSS" ? this.nalog.sklaOznakaPSS : String.Empty) +
             this.nalog.dokBr +
             ((from r in this.katalog.dokumenti where r.vrsta == this.nalog.dokVrsta select r).Single().oznaka);
         PrikažiNalog(
             this.nalog.sklaOznaka,
             this.nalog.sklaOznakaPSS,
             this.nalog.dokVrsta,
             this.nalog.dokBr,
             this.nalog.smjer);
     }
 }
Exemple #17
0
		public void Initialize(Rectangle position, FormWindowState state, bool detailView, bool loggerTree)
		{
			WindowPosition = position;
			WindowState = state;
			ShowLogDetailView = detailView;
			ShowLoggerTree = loggerTree;
		}
Exemple #18
0
 public void Save(Form targetForm)
 {
     winState = targetForm.WindowState;
     brdStyle = targetForm.FormBorderStyle;
     topMost = targetForm.TopMost;
     bounds = targetForm.Bounds;
 }
Exemple #19
0
 public FormInvUpisnik(Terminal _terminal, Katalog _katalog, Point _koordinate, int _širina, int _visina, FormWindowState _stanje, KInventura _inventura)
     : base(_terminal, _katalog, _koordinate, _širina, _visina, _stanje)
 {
     InitializeComponent();
     this.inventura = _inventura;
     txtLokacija.Focus();
     CoreScannerProxy.Instance.BarcodeEvent += new BarcodeEventHandler(OnBarcode); // Događaj za očitanje barkoda.
 }
		public void WriteChangesAndRelease()
		{
			// when it closes, update the state
			_state = _form.WindowState;

			// and then write the changes
			this.WriteWindowData();
		}
 public WindowSizeSaver(Form form)
 {
     location = form.Location;
     size = form.Size;
     state = form.WindowState;
     form.Resize += new EventHandler(form_Event);
     form.Move += new EventHandler(form_Event);
 }
Exemple #22
0
 public FormOtprema(Terminal _terminal, Katalog _katalog, Point _koordinate, int _širina, int _visina, FormWindowState _stanje)
     : base(_terminal, _katalog, _koordinate, _širina, _visina, _stanje)
 {
     InitializeComponent();
     dgvDok.AutoGenerateColumns = false;
     dgvLok.AutoGenerateColumns = false;
     CoreScannerProxy.Instance.BarcodeEvent += new BarcodeEventHandler(OnBarcode); // Događaj za očitanje barkoda.
 }
Exemple #23
0
 public MainWindowArgument(Rectangle location, FormWindowState state, string split, string toolbar, int tabrowcount)
 {
     _location = location;
     _windowState = state;
     _splitInfo = split;
     _toolBarInfo = toolbar;
     _tabRowCount = tabrowcount;
 }
Exemple #24
0
 protected override void OnResize(EventArgs e)
 {
     if (WindowState != FormWindowState.Minimized)
     {
         lastFormState = WindowState;
     }
     base.OnResize(e);
 }
Exemple #25
0
 private void frmGlavna_Resize(object sender, EventArgs e)
 {
     if (WindowState != LastWindowState)
     {
         LastWindowState = WindowState;
         this.Refresh();
     }
 }
Exemple #26
0
 public FormRobniIzlaz(Terminal _terminal, Katalog _katalog, Point _koordinate, int _širina, int _visina, FormWindowState _stanje, KNalog _nalog, KStavkaNaloga _stavka)
     : base(_terminal, _katalog, _koordinate, _širina, _visina, _stanje)
 {
     InitializeComponent();
     dgvLok.AutoGenerateColumns = false;
     this.nalog = _nalog;
     this.stavka = _stavka;
     lblRoba.Text =
         stavka.roba.sifra + Environment.NewLine +
         stavka.roba.naziv + Environment.NewLine +
         "količina: " + stavka.zadaniPromet.ToString() + Environment.NewLine +
         "za sken: " + (stavka.zadaniPromet - stavka.skeniraniPromet).ToString();
     CoreScannerProxy.Instance.BarcodeEvent += new BarcodeEventHandler(OnBarcode); // Događaj za očitanje barkoda.
     MTrenisClient c = new MTrenisClient();
     try
     {
         RobnaLokacija[] polje = c.DohvatiRobneLokacije(nalog.sklaOznaka, null, stavka.roba.sifra);
         List<KRobnaLokacija> lista = new List<KRobnaLokacija>();
         foreach (var r in polje)
         {
             lista.Add(
                 new KRobnaLokacija(
                     new KRoba(r.roba.sifra, r.roba.naziv, r.roba.dobavljac),
                     r.lokOznaka,
                     r.zonOznaka,
                     r.stanje,
                     r.kapacitet));
         }
         dgvLok.DataSource = lista;
         foreach (DataGridViewRow row in dgvLok.Rows)
         {
             if (row.Cells["colLokacija"].Value.ToString() == stavka.optiLok && row.Cells["colZona"].Value.ToString() == stavka.optiZon)
             {
                 //dgvLok.FirstDisplayedScrollingRowIndex = dgvLok.Rows[row.Index].Index;
                 dgvLok.ClearSelection();
                 dgvLok.Rows[row.Index].Selected = true;
                 dgvLok.CurrentCell = dgvLok.Rows[row.Index].Cells[0];
                 break;
             }
         }
     }
     catch (FaultException<MTrenisKvar> ex)
     {
         MessageBox.Show(ex.Detail.opis, ex.Detail.oznaka.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, P.MSGBOX_ERR_TITLE, MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     finally
     {
         if (c != null && c.State != CommunicationState.Closed)
         {
             c.Close();
         }
     }
     txtKol.Select(); // NE .Focus()!!!
 }
Exemple #27
0
        public WindowData()
        {
            Position.X          = -1;
            Position.Y          = -1;
            Position.Width      = -1;
            Position.Height     = -1;

            State = FormWindowState.Normal;
        }
Exemple #28
0
 public void Set(Rectangle position, FormWindowState state, Control detailView, Control loggerTree)
 {
     WindowPosition = position;
     WindowState = state;
     ShowLogDetailView = detailView.Visible;
     LogDetailViewSize = detailView.Size;
     ShowLoggerTree = loggerTree.Visible;
     LoggerTreeSize = loggerTree.Size;
 }
Exemple #29
0
        private void OnClosed(object sender, EventArgs e)
        {
            if (windowState == FormWindowState.Minimized)
                windowState = FormWindowState.Normal;

            IsolatedStorageFormState item = new IsolatedStorageFormState(store, storageArea);
            item.Store(new FormState(dimensions, windowState));
            store.Dispose();
        }
Exemple #30
0
 private void Form1_SizeChanged(object sender, EventArgs e)
 {
     if ((this.WindowState == FormWindowState.Maximized && _CurrentWindowState != FormWindowState.Maximized)
         || (this.WindowState != FormWindowState.Maximized && _CurrentWindowState == FormWindowState.Maximized))
     {
         FireFormMaximized();
     }
     _CurrentWindowState = this.WindowState;
 }
Exemple #31
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            UpdateTimer.Enabled = true;


            if (Settings.GetObject("Auto Update", true))
            {
                GitHub.CheckVersion(false);
            }

            SuspendLayout();
            //restore last size and position
            Object[]        msp   = Settings.GetObject <Object[]>("Mainform Size and Position", null);
            FormWindowState state = msp == null ? FormWindowState.Maximized : (FormWindowState)msp[2] != FormWindowState.Minimized ? (FormWindowState)msp[2] : FormWindowState.Maximized;

            if (state == FormWindowState.Normal)
            {
                WindowState = state; Size = (Size)msp[0]; Location = (Point)msp[1];
            }
            ResumeLayout();
        }
        /// <summary>
        /// Parent form is closing.
        /// Keep last state in Registry.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnClosing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // save position, size and state
            RegistryKey key = MkaDefine.RootKey.CreateSubKey(MkaDefine.WindowStateKey);

            key.SetValue("Left", normalLeft);
            key.SetValue("Top", normalTop);
            key.SetValue("Width", normalWidth);
            key.SetValue("Height", normalHeight);

            // check if we are allowed to save the state as minimized (not normally)
            if (!allowSaveMinimized)
            {
                if (windowState == FormWindowState.Minimized)
                {
                    windowState = FormWindowState.Normal;
                }
            }

            key.SetValue("WindowState", (int)windowState);
        }
Exemple #33
0
        protected override void OnSizeChanged(EventArgs e)
        {
            base.OnSizeChanged(e);
            if (previouseState != WindowState)
            {
                previouseState = WindowState;

                if (WindowState.ToString() == "Minimized")
                {
                    this.ShowInTaskbar       = false;
                    this.Visible             = false;
                    this.notifyIcon1.Visible = true;
                }
                else if (WindowState.ToString() == "Normal")
                {
                    this.ShowInTaskbar       = true;
                    this.Visible             = true;
                    this.notifyIcon1.Visible = false;
                }
            }
        }
Exemple #34
0
        protected void StoreClientBounds()
        {
            if (_mode == ScreenMode.FullScreen)
            {
                return;
            }
            // We must store the window state to be able to correctly restore the clients bounds if the user was in maximized mode
            // when switching to fullscreen
            _previousWindowState = WindowState;
            if (WindowState != FormWindowState.Normal)
            {
                return;
            }
            // Only store size and position if we are in windowed mode and not maximized. The size for all other modes/states
            // is obvious, only those two values are interesting to be restored on a mode switch from fullscreen to windowed.
            AppSettings appSettings = ServiceRegistration.Get <ISettingsManager>().Load <AppSettings>();

            appSettings.WindowPosition = _previousWindowLocation = Location;
            appSettings.WindowSize     = _previousWindowClientSize = ClientSize;
            ServiceRegistration.Get <ISettingsManager>().Save(appSettings);
        }
Exemple #35
0
 private void SetWindowState(FormWindowState state, bool setSize)
 {
     if (state == FormWindowState.Maximized)
     {
         this.IsMaximized = true;
         if (setSize)
         {
             this.previousPosition.Size = this.Size;
         }
         this.WindowState     = FormWindowState.Normal;
         this.FormBorderStyle = FormBorderStyle.None;
         this.Location        = Point.Empty;
         this.Size            = Screen.FromHandle(this.Handle).Bounds.Size;
     }
     else
     {
         this.FormBorderStyle = FormBorderStyle.Sizable;
         this.Bounds          = this.previousPosition;
         this.IsMaximized     = false;
     }
 }
Exemple #36
0
        public static void SaveFormPosition(Form theForm)
        {
            // Get current location, size, and state
            Point           myLoc   = theForm.Location;
            Size            mySize  = theForm.Size;
            FormWindowState myState = theForm.WindowState;

            // if minimized or maximized
            if (myState != FormWindowState.Normal)
            {
                // override with the restore location and size
                myLoc  = new Point(theForm.RestoreBounds.X, theForm.RestoreBounds.Y);
                mySize = new Size(theForm.RestoreBounds.Width, theForm.RestoreBounds.Height);
            }

            // Save it for later!
            Properties.Settings.Default.Location    = myLoc;
            Properties.Settings.Default.Size        = mySize;
            Properties.Settings.Default.WindowState = (int)myState;
            Properties.Settings.Default.Save();
        }         // End SaveFormPostion
Exemple #37
0
        /// <summary>
        /// 設定視窗位置
        /// </summary>
        /// <param name="form"></param>
        /// <param name="size"></param>
        /// <param name="state"></param>
        /// <param name="location"></param>
        internal static void Set(Form form, Size size, FormWindowState state, Point location)
        {
            if (size.Width == 0 || size.Height == 0)
            {
                // first start
                // optional: add default values
            }
            else
            {
                form.WindowState = state;

                // we don't want a minimized window at startup
                if (form.WindowState == FormWindowState.Minimized)
                {
                    form.WindowState = FormWindowState.Normal;
                }

                form.Location = location;
                form.Size     = size;
            }
        }
Exemple #38
0
        internal void ChildFormClosed(Form form)
        {
            FormWindowState closed_form_windowstate = form.WindowState;

            form.Visible = false;
            Controls.Remove(form);

            if (Controls.Count == 0)
            {
                ((MdiWindowManager)form.window_manager).RaiseDeactivate();
            }
            else if (closed_form_windowstate == FormWindowState.Maximized)
            {
                Form current = (Form)Controls [0];
                current.WindowState = FormWindowState.Maximized;
                ActivateChild(current);
            }

            if (Controls.Count == 0)
            {
                XplatUI.RequestNCRecalc(Parent.Handle);
                ParentForm.PerformLayout();

                // If we closed the last child, unmerge the menus.
                // If it's not the last child, the menu will be unmerged
                // when another child takes focus.
                MenuStrip parent_menu = form.MdiParent.MainMenuStrip;

                if (parent_menu != null)
                {
                    if (parent_menu.IsCurrentlyMerged)
                    {
                        ToolStripManager.RevertMerge(parent_menu);
                    }
                }
            }
            SizeScrollBars();
            SetParentText(false);
            form.Dispose();
        }
Exemple #39
0
        internal void SetWindowState(FormWindowState state)
        {
            if (formState == FormWindowState.Minimized && state != FormWindowState.Minimized)
            {
                Visible = true;
            }

            formState = state;

            switch (state)
            {
            case FormWindowState.Normal:
                FormBorderStyle = minimizedBorderStyle;
                uwfMovable      = minimizedMovable;

                SetBounds(minimizedLocation.X, minimizedLocation.Y, minimizedSize.Width, minimizedSize.Height);
                break;

            case FormWindowState.Maximized:
                minimizedBorderStyle = FormBorderStyle;
                minimizedLocation    = Location;
                minimizedMovable     = uwfMovable;
                minimizedSize        = Size;

                FormBorderStyle = FormBorderStyle.FixedSingle;
                uwfMovable      = false;

                var nx = 0;
                var ny = 0;
                var nw = Screen.width;
                var nh = Screen.height;

                SetBounds(nx, ny, nw, nh);
                break;

            case FormWindowState.Minimized:
                Visible = false;     // ?
                break;
            }
        }
Exemple #40
0
        //窗口从正常到最大、从最大到正常时触发,修改size和state
        //全屏时,该事件的有效主体Reset将永远不会执行
        private void Game_Resize(object sender, EventArgs e)
        {
#if FULL_SCREEN
            client_size = new Size(1024, 768);             //全屏模式下,size永远等于1024*768
            if (WindowState == FormWindowState.Minimized)  //要么最大、要么最小
            {
                window_state = FormWindowState.Minimized;
            }
            else
            {
                window_state = FormWindowState.Maximized;
            }
#else
            //最大化、最小化、或者恢复的情况
            if (ClientSize != client_size && WindowState != window_state)
            {
                //非<最小化或者是从最小化恢复>,即<最大化或者是从最大化恢复>
                if (WindowState != FormWindowState.Minimized && window_state != FormWindowState.Minimized)
                {
                    CreatePresentParameters();
                    try
                    {
                        device.Reset(present_params);
                    }
                    catch (DeviceLostException)
                    {
                        device_lost = true;
                        Debug.WriteLine("Device was lost during Resize");
                    }
                }
                client_size  = ClientSize;
                window_state = WindowState;
            }
            else
            {
                //拉动窗口边框的情况
                onpaint_enabled = false;                 //不希望在此时触发OnPaint事件
            }
#endif
        }
Exemple #41
0
        public static void RestoreFormRect(Form form, ExtRect rt, FormWindowState winState)
        {
            // check for new and empty struct
            if (form == null || rt.IsEmpty())
            {
                return;
            }

            if (winState != FormWindowState.Minimized)
            {
                form.Left   = rt.Left;
                form.Top    = rt.Top;
                form.Width  = rt.GetWidth();
                form.Height = rt.GetHeight();

                form.WindowState = winState;
            }
            else
            {
                form.WindowState = FormWindowState.Maximized;
            }
        }
Exemple #42
0
        private void MyListForm_Load(object sender, EventArgs e)
        {
            try
            {
                //DataGridViewButtonColumnの作成
                DataGridViewButtonColumn column = new DataGridViewButtonColumn();
                //列の名前を設定
                column.Name = "Button";
                //全てのボタンに"詳細閲覧"と表示する
                column.UseColumnTextForButtonValue = true;
                column.Text = "表示";
                //DataGridViewに追加する
                myListdataGridView.Columns.Add(column);
                Settings.LoadFromXmlFile();


                NicoNico niconico = new NicoNico(Settings.Instance.Email, Settings.Instance.RowPassword);

                // 削除されていないリストを取得
                foreach (var m in niconico.GetMyList().Where(x => x.deleted == "0"))
                {
                    this.myListDataSet1.MyList.AddMyListRow(m.title, m.video_id);
                }

                //初期化
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.preWindowState = FormWindowState.Normal;
                }
                else
                {
                    this.preWindowState = this.WindowState;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("マイリストの取得に失敗しました。");
            }
        }
Exemple #43
0
        /// <summary>
        /// Show or Hide your WinForm in full screen mode.
        /// </summary>
        private void ScreenMode()
        {
            // set full screen
            if (!fullScreen)
            {
                // Get the WinForm properties
                borderStyle = form.FormBorderStyle;
                bounds      = form.Bounds;
                windowState = form.WindowState;

                // set to false to avoid site effect
                form.Visible = false;

                HandleTaskBar.hideTaskBar();

                // set new properties
                form.FormBorderStyle = FormBorderStyle.None;
                form.WindowState     = FormWindowState.Maximized;

                form.Visible = true;
                fullScreen   = true;
            }
            else  // reset full screen
            {
                // reset the normal WinForm properties
                // always set WinForm.Visible to false to avoid site effect
                form.Visible         = false;
                form.WindowState     = windowState;
                form.FormBorderStyle = borderStyle;
                form.Bounds          = bounds;

                HandleTaskBar.showTaskBar();

                form.Visible = true;

                // Not in full screen mode
                fullScreen = false;
            }
        }
Exemple #44
0
        private void ToggleFullscreen(object sender = null, EventArgs e = null)
        {
            if (_isFullscreen)
            {
                FormBorderStyle = _previousBorderStyle;
                WindowState     = _previousWindowState;

                _isFullscreen      = false;
                fullscreenbtn.Text = Resources.FullScreen;
            }

            else
            {
                _previousBorderStyle = FormBorderStyle;
                _previousWindowState = WindowState;

                FormBorderStyle    = FormBorderStyle.None;
                WindowState        = FormWindowState.Maximized;
                _isFullscreen      = true;
                fullscreenbtn.Text = Resources.Restore;
            }
        }
Exemple #45
0
        /// <summary>
        /// 处理鼠标离开
        /// </summary>
        /// <param name="p">The Point.</param>
        /// User:Ryan  CreateTime:2011-07-28 10:44.
        protected virtual void ProcessMouseUp(Point p)
        {
            Rectangle closeRect = this.CloseBoxRect;
            Rectangle maxRect   = this.MaximizeBoxRect;
            Rectangle minRect   = this.MinimizeBoxRect;

            if (!closeRect.IsEmpty && closeRect.Contains(p))
            {
                base.Close();
                this.CloseBoxState = EnumControlState.Default;
            }

            if (!maxRect.IsEmpty && maxRect.Contains(p))
            {
                FormWindowState fs = FormWindowState.Normal;
                switch (base.WindowState)
                {
                case FormWindowState.Maximized:
                    fs = FormWindowState.Normal;
                    break;

                case FormWindowState.Normal:
                default:
                    fs = FormWindowState.Maximized;
                    break;
                }

                base.WindowState = fs;
                this.MaxBoxState = EnumControlState.Default;
            }

            if (!minRect.IsEmpty && minRect.Contains(p))
            {
                base.WindowState = FormWindowState.Minimized;
                this.MinBoxState = EnumControlState.Default;
            }

            this.Invalidate(this.CaptionRect);
        }
Exemple #46
0
        public void LastWindowClosedIsPersisted()
        {
            // Open two forms with different sizes/positions
            Rectangle rectCompare;

            using (var form1 = new DummyPersistedFormWinDef())
            {
                form1.Show();
                form1.SetDesktopBounds(205, 106, 407, 308);

                using (var form2 = new DummyPersistedFormWinDef())
                {
                    form2.Show();
                    form2.SetDesktopBounds(101, 52, 301, 401);
                    rectCompare       = form2.DesktopBounds;
                    form2.WindowState = FormWindowState.Maximized;
                    form1.Close();
                    form2.Close();
                }
            }

            // Test that restored window has size/pos of Last Window Closed
            using (var form = new DummyPersistedFormWinDef())
            {
                form.Show();
#if !__MonoCS__
                FormWindowState state = form.WindowState;
#endif
                form.WindowState = FormWindowState.Normal;
                Rectangle rcForm = form.DesktopBounds;
                form.Close();
#if !__MonoCS__
                Assert.AreEqual(FormWindowState.Maximized, state);
#else
                // TODO-Linux: proberbly fails because of this bug https://bugzilla.novell.com/show_bug.cgi?id=495562 renable this when this has been fixed
#endif
                Assert.AreEqual(rectCompare, rcForm);
            }
        }
Exemple #47
0
        public void MinimizedRestoresAsNormal()
        {
            // Establish Baseline - create registry entries
            DummyPersistedFormWinDef form = new DummyPersistedFormWinDef();

            form.Show();
            Rectangle rectOrig = form.DesktopBounds;

            form.WindowState = FormWindowState.Minimized;
            form.Close();

            // Test that Minimized Window Comes Back As Normal
            form = new DummyPersistedFormWinDef();
            form.Show();
            FormWindowState state  = form.WindowState;
            Rectangle       rcForm = form.DesktopBounds;

            form.Close();

            Assert.AreEqual(FormWindowState.Normal, state);
            Assert.AreEqual(rectOrig, rcForm);
        }
Exemple #48
0
        public static void SetWindowPlacement(IntPtr windowHandle, FormWindowState windowState, Rectangle position)
        {
            var wp = new WINDOWPLACEMENT();

            wp.length = Marshal.SizeOf(wp);

            var retVal = GetWindowPlacement(windowHandle, ref wp);

            if (!retVal)
            {
                throw new Win32Exception("Call to GetWindowPlacement failed");
            }

            wp.showCmd          = WindowStateToShowCmd(windowState);
            wp.rcNormalPosition = position;

            retVal = SetWindowPlacement(windowHandle, ref wp);
            if (!retVal)
            {
                throw new Win32Exception("Call to SetWindowPlacement failed");
            }
        }
Exemple #49
0
 private void ChangeWindowState(bool fullscreen)
 {
     if (fullscreen)
     {
         preFullscreenState  = WindowState;
         WindowState         = FormWindowState.Normal;
         TopMost             = true;
         FormBorderStyle     = FormBorderStyle.None;
         WindowState         = FormWindowState.Maximized;
         ControlBox          = false;
         buttonPanel.Visible = false;
         Focus();
     }
     else
     {
         TopMost             = false;
         ControlBox          = true;
         FormBorderStyle     = FormBorderStyle.Sizable;
         WindowState         = preFullscreenState;
         buttonPanel.Visible = true;
     }
 }
Exemple #50
0
        private void ToggleScreenMode()
        {
            if (this.FormBorderStyle != FormBorderStyle.None)
            {
                // Go full screen
                this.FormBorderStyle     = FormBorderStyle.None;
                this.previousWindowState = this.WindowState;
                this.WindowState         = FormWindowState.Maximized;

                // HACK: Toggle form visibility to make it cover the task bar.
                // On Windows XP: if the form was already maximized, the task bar wouldn't be covered.
                // If the form wasn't maximized, it would be covered but not repainted right away.
                this.Visible = false;
                this.Visible = true;
            }
            else
            {
                // Go back to windowed mode
                this.FormBorderStyle = FormBorderStyle.Sizable;
                this.WindowState     = this.previousWindowState;
            }
        }
Exemple #51
0
        public DefaultWorkbench()
        {
            Text = "我的SD插件框架";
            Icon = ResourceService.GetIcon("htc_sense_footprint_icon");
            //Icon = ResourceService.GetIcon("Icons.SharpDevelopIcon");

            StartPosition = FormStartPosition.Manual;
            _NormalBounds = PropertyService.Get <Rectangle>(_BoundProperty, new Rectangle(60, 80, 640, 480));
            Bounds        = _NormalBounds;
            bool bMax = PropertyService.Get <bool>(_WindowIsMaximized, false);

            if (bMax)
            {
                _WindowState = FormWindowState.Maximized;
                WindowState  = FormWindowState.Maximized;
            }
            _FullScreen = PropertyService.Get <bool>(_WindowIsFullScreen, false);
            if (_FullScreen)
            {
                FormBorderStyle = FormBorderStyle.None;
                WindowState     = FormWindowState.Maximized;
            }

            AllowDrop = true;

            PadDescriptor.BringPadToFrontEvent += delegate(PadDescriptor padDesc)
            {
                foreach (PadDescriptor pd in PadContentCollection)
                {
                    if (pd.Equals(padDesc))
                    {
                        layout.ShowPad(padDesc, true);
                        return;
                    }
                    // ShowPad(padDesc);--2013.2.4调整位置
                }
                ShowPad(padDesc);
            };
        }
Exemple #52
0
 private void GlobalHookKeyCtrlF1Press()
 {
     if (this.WindowState == FormWindowState.Minimized)
     {
         this.WindowState     = FormWindowState.Normal;
         this.FormBorderStyle = FormBorderStyle.None;
         Show();
         resizeForm();
         fixSize();
         this.Focus();
         notifyIcon.Visible = false;
         this.lastState     = this.WindowState;
     }
     else
     {
         this.FormBorderStyle = FormBorderStyle.Sizable;
         Hide();
         this.WindowState   = FormWindowState.Minimized;
         this.lastState     = this.WindowState;
         notifyIcon.Visible = true;
     }
 }
        /// <summary>
        /// Show or Hide your WinForm in full screen mode.
        /// </summary>
        private void ScreenMode()
        {
            // set full screen
            if (!_FullScreen)
            {
                // Get the WinForm properties
                _cBorderStyle = _Form.FormBorderStyle;
                _cBounds      = _Form.Bounds;
                _cWindowState = _Form.WindowState;

                // set to false to avoid site effect
                _Form.Visible = false;

                //HandleTaskBar.hideTaskBar();

                // set new properties
                _Form.FormBorderStyle = FormBorderStyle.None;
                _Form.WindowState     = FormWindowState.Maximized;

                _Form.Visible = true;
                _FullScreen   = true;
            }
            else  // reset full screen
            {
                // reset the normal WinForm properties
                // always set WinForm.Visible to false to avoid site effect
                _Form.Visible         = false;
                _Form.WindowState     = _cWindowState;
                _Form.FormBorderStyle = _cBorderStyle;
                _Form.Bounds          = _cBounds;

                //HandleTaskBar.showTaskBar();

                _Form.Visible = true;

                // Not in full screen mode
                _FullScreen = false;
            }
        }
Exemple #54
0
        public Dish(Point Location, FormWindowState state, object Role)
        {
            InitializeComponent();
            this.Location    = Location;
            this.WindowState = state;
            this.Role        = Role;
            switch (Role)
            {
            case "A":
                linkMenu.Enabled        = true;
                linkIngredients.Enabled = false;
                linkChildren.Enabled    = true;
                break;

            case "T":
                linkMenu.Enabled        = false;
                linkIngredients.Enabled = false;
                linkChildren.Enabled    = true;
                break;

            case "M":
                linkMenu.Enabled        = true;
                linkIngredients.Enabled = false;
                linkChildren.Enabled    = false;
                break;
            }
            if (DataBase.Connect())
            {
                Table dinnerType = new Table();
                InvokeDtDinnerType();
                DataBase.Close();
            }
            else
            {
                MessageBox.Show("Проверте подключение к базе данных", "Ошибка Подключения", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            splitContainer2.Panel2Collapsed = true;
            open = true;
        }
Exemple #55
0
        public Window(IntPtr HWnd,
                      Point Location,
                      Size Size,
                      WindowStyleFlags Style,
                      WindowExStyleFlags ExStyle,
                      FormWindowState State,
                      string ClassName)
        {
            _sysWin = new SystemWindow(HWnd);
            IsValid = false; // until proven otherwise

            // SystemWindow.IsValid only checks that the HWnd != IntPtr.Zero, so we perform our own checks
            try
            {
                // if the ClassNames don't match, it's probably not the same window
                IsValid = (ClassName == _sysWin.ClassName);
                if (!IsValid)
                {
                    return;
                }
            }
            catch (System.ComponentModel.Win32Exception ex)
            {
                // this might not really be an error...
                if (ex.HResult == 0)
                {
                    IsValid = true;
                }
                // ... but usually it is.  attempting to access an invalid window throws a Win32Exception whose
                // NativeErrorCode is 0x0 ("operation completed successfully"), but whose HResult is not S_OK =
                // 0x0 (it's usually E_FAIL, "Unspecified failure", 0x80004005).
            }

            this.Location = Location;
            this.Size     = Size;
            this.Style    = Style;
            this.ExStyle  = ExStyle;
            this.State    = State;
        }
Exemple #56
0
        // need finish
        public void SetWindowState(FormWindowState state)
        {
            WinAPI.Message msg = 0;
            switch (state)
            {
            case FormWindowState.Normal:
                msg = WinAPI.Message.SC_RESTORE;
                break;

            case FormWindowState.Minimized:
                msg = WinAPI.Message.SC_MINIMIZE;
                break;

            case FormWindowState.Maximized:
                msg = WinAPI.Message.SC_MAXIMIZE;
                break;

            default:
                throw new Exception(((uint)state).ToString());
            }
            WinAPI.SendMessage(Handle, (uint)WinAPI.Message.WM_SYSCOMMAND, (IntPtr)(uint)msg, NULL);
        }
Exemple #57
0
        private void TitlebarButton_Click(object sender, MouseEventArgs e)
        {
            switch (action)
            {
            case TitlebarAction.Minimize:
                parent.WindowState = FormWindowState.Minimized;
                break;

            case TitlebarAction.Maximize:
                FormWindowState finalWindowState = FormWindowState.Normal;
                if (parent.WindowState == FormWindowState.Normal)
                {
                    finalWindowState = FormWindowState.Maximized;
                }
                parent.WindowState = finalWindowState;
                break;

            case TitlebarAction.Close:
                parent.Close();
                break;
            }
        }
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == Keys.F11)
            {
                IsFullScreenLikeBrowser = !IsFullScreenLikeBrowser;

                if (IsFullScreenLikeBrowser)
                {
                    OldWinState = this.WindowState;

                    this.WindowState     = FormWindowState.Maximized;
                    this.FormBorderStyle = FormBorderStyle.None;
                }
                else
                {
                    this.WindowState     = OldWinState;
                    this.FormBorderStyle = FormBorderStyle.Sizable;
                }
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Exemple #59
0
        private void GameForm_RestoredActions(SDL.SDL_WindowEvent e)
        {
            if (previousWindowState == FormWindowState.Minimized)
            {
                ResumeRendering?.Invoke(this, EventArgs.Empty);
            }

            var newSize = Size;

            if (!isUserResizing && (!newSize.Equals(cachedSize) || previousWindowState == FormWindowState.Maximized))
            {
                previousWindowState = FormWindowState.Normal;

                // Only update when cachedSize is != 0
                if (cachedSize != Size2.Empty)
                {
                    isSizeChangedWithoutResizeBegin = true;
                }
            }

            previousWindowState = FormWindowState.Normal;
        }
Exemple #60
0
 public static void MiniMaxi(Form form, FormWindowState state)
 {
     // InvokeRequired required compares the thread ID of the
     // calling thread to the thread ID of the creating thread.
     // If these threads are different, it returns true.
     if (form.InvokeRequired)
     {
         SetFormstateCallback d = MiniMaxi;
         try
         {
             form.Invoke(d, form, state);
         }
         catch (Exception)
         {
             // ignored
         }
     }
     else
     {
         form.WindowState = state;
     }
 }