Esempio n. 1
0
        private void Current_Startup(object sender, StartupEventArgs e)
        {
            Rect        positionAndSize = PlotManager.UI.Properties.Settings.Default.MainWindowPosition;
            WindowState wState          = PlotManager.UI.Properties.Settings.Default.MainWindowState;

            wnd             = new wndMain();
            vmm             = new ViewModelMain();
            wnd.DataContext = vmm;

            wnd.Closing += Wnd_Closing;

            if ((positionAndSize.IsEmpty) ||
                (SystemParameters.VirtualScreenWidth < positionAndSize.Left) ||
                (SystemParameters.VirtualScreenHeight < positionAndSize.Top))
            {
                positionAndSize = new Rect(10, 10, 800, 600);
            }

            wnd.Left        = positionAndSize.Left;
            wnd.Top         = positionAndSize.Top;
            wnd.Width       = positionAndSize.Width;
            wnd.Height      = positionAndSize.Height;
            wnd.WindowState = wState;

            wnd.Show();
        }
Esempio n. 2
0
        /// <summary>
        /// Called when BtnSelect is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BtnSelect_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if ((DataRowView)DGInvoices.SelectedValue != null)
                {
                    //System.Windows.MessageBox.Show(((DataRowView)DGInvoices.SelectedValue).Row[0].ToString());
                    sSelectedInvoiceNum = ((DataRowView)DGInvoices.SelectedValue).Row[0].ToString();

                    Start();
                    this.Hide();
                    mainWindow.Show();
                }
                else
                {
                    MessageBox.Show("Please select an invoice");
                }
            }
            catch (System.Exception ex)
            {
                HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                            MethodInfo.GetCurrentMethod().Name, ex.Message);
            }
        }
 /// <summary>
 /// Shows main window when closes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     try
     {
         if (mainWindow != null)
         {
             mainWindow.itemWindow = null;
             mainWindow.Show();
         }
     }
     catch (Exception ex)
     {
         HandleError(MethodInfo.GetCurrentMethod().DeclaringType.Name,
                     MethodInfo.GetCurrentMethod().Name, ex.Message);
     }
 }
    private static void Wnd_Closed(object sender, EventArgs e)
    {
        wndMain wnd = sender as wndMain;

        if (!string.IsNullOrEmpty(wnd.LangSwitch))
        {
            string lang = wnd.LangSwitch;
            wnd.Closed -= Wnd_Closed;
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
            wnd         = new wndMain();
            wnd.Closed += Wnd_Closed;
            wnd.Show();
        }
        else
        {
            App.Current.Shutdown();
        }
    }