void ExifFormActivated(object sender, EventArgs e) { int wX = this.Left; int wY = this.Top; int wW = this.Width; int wH = this.Height; bool visible; Rectangle screenRectangle = RectangleToScreen(this.ClientRectangle); int titleHeight = screenRectangle.Top - this.Top; Multi.FormShowVisible(out visible, ref wX, ref wY, wW, titleHeight); if (!visible) { this.Left = wX; this.Top = wY; } else { Multi.FormShowVisible(out visible, ref wX, ref wY, wW, wH); if (!visible) { this.Left = wX; this.Top = wY; } } }
//-------------------------- form ---------------------------// void FrmMainLoad(object sender, EventArgs e) { Debug.WriteLine("Main start: "); listener = new XDListener(); listener.MessageReceived += new XDListener.XDMessageHandler(listener_MessageReceived); listener.RegisterChannel("NVMessage"); bool kShift = (Control.ModifierKeys == Keys.Shift); bool created; s_event = new EventWaitHandle(false, EventResetMode.ManualReset, "Next-View", out created); // instead of mutex if (created || kShift) // 1st instance or shift key { if (Properties.Settings.Default.UpgradeRequired) { Settings.Default.Upgrade(); Settings.Default.UpgradeRequired = false; Settings.Default.Save( ); } int wX; int wY; int wW = Settings.Default.MainW; int wH = Settings.Default.MainH; Multi.MainLoad(out wX, out wY); //Debug.WriteLine("open main 1 y: {0} ", wY); bool visible; // menu bar visible Rectangle screenRectangle = RectangleToScreen(this.ClientRectangle); int titleHeight = screenRectangle.Top - this.Top; Multi.FormShowVisible(out visible, ref wX, ref wY, wW, titleHeight); if (!visible) { this.Left = wX; this.Top = wY; //Debug.WriteLine("open main 2 y: {0} ", wY); } else { Multi.FormShowVisible(out visible, ref wX, ref wY, wW, wH); this.Left = wX; this.Top = wY; //Debug.WriteLine("open main 3 y: {0} ", wY); } this.Width = wW; this.Height = wH; string curDir = Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location); string moPath = curDir + @"\language\"; string cultureStr = Settings.Default.Language; if (cultureStr == "") { cultureStr = CultureInfo.InstalledUICulture.ToString(); Settings.Default.Language = cultureStr; } //Debug.WriteLine("Culture: " + cultureStr); T.SetCatalog(moPath, cultureStr); TranslateMainForm(); tbNoGif(); string recentPath = Settings.Default.RecentImgs; this.recentItem1.LoadList(recentPath); this.recentItem1.UpdateList(); this.recentItem1.MaxItems = 5; this.recentItem1.ItemClick += new System.EventHandler(recentItem_Click); this.recentItem1.UpdateList(); //Debug.WriteLine("open main y: {0} ", Settings.Default.MainY); } else // 2nd instance, give image path to 1st instance and end this 2nd { string[] args = Environment.GetCommandLineArgs(); string commandLine = "S"; if (args.Length > 1) { commandLine = args[1]; } //Debug.WriteLine("send message:"); XDBroadcast.SendToChannel("NVMessage", commandLine); // receive: listener_MessageReceived // send is to itself as well, before exit // NvSendMsg(); does not work for strings, ExitApp(); } }
void FrmImageLoad(object sender, EventArgs e) { if (_wType == WinType.normal){ _ndRunning = false; _fullRunning = false; _scWidth = Screen.FromControl(this).Bounds.Width; _scHeight = Screen.FromControl(this).Bounds.Height; picBox.BackColor = SystemColors.Control; } if (_wType == WinType.full){ _ndRunning = false; _fullRunning = true; _scWidth = Screen.FromControl(this).Bounds.Width; _scHeight = Screen.FromControl(this).Bounds.Height; //Debug.WriteLine("Full Image W / H: {0}/{1}", _scWidth, _scHeight); ScollbarVis(false); //this.Width = _scWidth; //this.Height = _scHeight; //this.Top = 0; //this.Left = 0; picBox.BackColor = Color.Black; this.FormBorderStyle = FormBorderStyle.None; this.WindowState = FormWindowState.Maximized; } TranslateImageForm(); if (_wType == WinType.second){ popClose.Text = T._("Close"); // not Exit int wX; int wY; int wW = Settings.Default.SecondW; int wH = Settings.Default.SecondH; Multi.SecondLoad(out wX, out wY); bool visible; // menu bar visible Rectangle screenRectangle = RectangleToScreen(this.ClientRectangle); int titleHeight = screenRectangle.Top - this.Top; Multi.FormShowVisible(out visible, ref wX, ref wY, wW, titleHeight); if (!visible){ this.Left = wX; this.Top = wY; } else { Multi.FormShowVisible(out visible, ref wX, ref wY, wW, wH); this.Left = wX; this.Top = wY; } this.Width = wW; this.Height = wH; this.Icon = Icon1.Icon; //Debug.WriteLine("open 2nd y: {0} ", Settings.Default.SecondY); _ndRunning = true; _fullRunning = false; _mainWidth = picBox.Width; _mainHeight = picBox.Height; _scWidth = this.Width; _scHeight = this.Height; picBox.BackColor = SystemColors.Control; } // end 2nd }