Dispose() защищенный Метод

protected Dispose ( bool disposing ) : void
disposing bool
Результат void
Пример #1
0
        static void Main()
        {
            Present.ConsoleDebugging ConsoleControl = new Present.ConsoleDebugging();
            ConsoleControl.ClouseWindow();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            //Экран загрузки с таймером
            StartScreen TimerPage = new StartScreen();
            DateTime    Time      = DateTime.Now + TimeSpan.FromSeconds(3);

            while (Time > DateTime.Now)
            {
                Application.DoEvents();
            }
            TimerPage.Close();
            TimerPage.Dispose();
            //Меню
            OutFirstForm ForFirtsApp = new OutFirstForm {
                DinamicChoiseBool = false,
                FileNameBrain     = null,
                LearningFactor    = 3,
                NumberBotInt      = 50
            };
            MenuForm FirstApp = new MenuForm(ForFirtsApp);

            Application.Run(FirstApp);
            ForFirtsApp = FirstApp.OUT_DATA;
            FirstApp.Dispose();
            //Главная форма
            MainForm SecondApp = new MainForm(ForFirtsApp, ConsoleControl);

            Application.Run(SecondApp);
            SecondApp.Dispose();
        }
Пример #2
0
 public void FixtureTearDown()
 {
     settings = null;
     doc      = null;
     mainForm.Dispose();
     mainForm = null;
 }
Пример #3
0
        private void ThreadProc()
        {
            try
            {
                using (var installer = new PackageInstaller(SetupConfiguration, new Progress(this)))
                {
                    installer.Install();
                }

                BeginInvoke(new Action(() => MainForm.SetStep(1)));
            }
            catch (Exception ex)
            {
                BeginInvoke(new Action(() =>
                {
                    MessageBox.Show(
                        this,
                        String.Format(
                            Labels.UnexpectedSituation,
                            ex.Message
                            ),
                        Program.Configuration.Title,
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );

                    MainForm.Dispose();
                }));
            }
        }
Пример #4
0
 public void FixtureTearDown()
 {
     Settings = null;
     Doc      = null;
     Sci      = null;
     MainForm.Dispose();
     MainForm = null;
 }
Пример #5
0
 private void DisposeForms()
 {
     foreach (var mainForm in Application.OpenForms.OfType <MainForm>())
     {
         mainForm.Invoke((Action)(() => { mainForm.Close(); }));
     }
     GUI?.Dispose();
     GUI = null;
 }
Пример #6
0
    public static int Main(string[] Args)
    {
        MainForm form = new MainForm();

        form.ShowDialog();
        form.Dispose();

        return(0);
    }
Пример #7
0
        private void ShutdownWindows()
        {
            if (MainForm != null)
            {
                MainForm.Dispose();
            }

            MainForm          = null;
            ApplicationHandle = null;
        }
Пример #8
0
        public void QuitUI()
        {
            if (MainForm == null)
            {
                return;
            }

            MainForm.Close();
            MainForm.Dispose();
        }
Пример #9
0
        public static void Main()
        {
            try
            {
                Settings.Configurate();

                //database = new Database();
                felhasználó = null;
                database = new Database();

                LoginForm loginform = new LoginForm();
                Application.Run(loginform);
                database = new Database();
                if (loginform.felhasználó != null)
                {
                    felhasználó = loginform.felhasználó;
                    loginform.Dispose();

                    refresher = new Timer();
                    refresher.Interval = Settings.ui_refresh * 1000;
                    refresher.Tick += Refresher_Elapsed;
                    refresher.Start();

                    MainForm mainform = new MainForm();
                    Application.Run(mainform);

                    refresher.Dispose();
                    mainform.Dispose();
                }
            }
            catch (Exception _e)
            {
                MessageBox.Show("Kezeletlen globális hiba a program futása során!\nKérem jelezze a hibát a rendszergazdának!\nHiba adatai:\n" + _e.Message, "Hiba", MessageBoxButtons.OK, MessageBoxIcon.Error);

                string file_name = string.Format("crash-{0:yyyy-MM-dd_hh-mm-ss}.data", DateTime.Now);

                try
                {
                    StreamWriter file = new StreamWriter(file_name);
                    file.WriteLine("Message:\t" + _e.Message);
                    file.WriteLine("Source:\t" + _e.Source);
                    file.WriteLine("Data:\t" + _e.Data);
                    file.WriteLine("Stack:\t" + _e.StackTrace);
                    file.Close();
                }
                catch (Exception _ex)
                {
                    MessageBox.Show("További hiba a kivétel mentésekor!\n" + _ex.Message, "Hiba", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Environment.Exit(1);
                }

                MessageBox.Show("A hiba adatait a " + file_name + " nevű file tartalmazza!", "Hiba adatainak elérése", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Environment.Exit(0);
            }
        }
Пример #10
0
 public void Dispose()
 {
     if (_mainForm == null)
     {
         return;
     }
     _mainForm.DisposeDirectX();
     _mainForm.Dispose();
     _screenManager = null;
     _mainForm      = null;
 }
        [Test]          // Should not throw AOORE
        public void Bug347669()
        {
            Form main = new MainForm();

            main.Show();
            Form frm = new Childform();

            frm.MdiParent = main;
            frm.Show();
            main.Dispose();
        }
Пример #12
0
        [Test]         // bug 81694
        public void TestNestedControls()
        {
            MainForm f = new MainForm();

            f.ShowInTaskbar = false;

            f.Show();
            Assert.AreEqual(new Rectangle(210, 212, 75, 23), f._userControl._button2.Bounds, "K1");

            f.Dispose();
        }
Пример #13
0
 public void Dispose()
 {
     if (_mainForm == null)
     {
         return;
     }
     _mainForm.DisposeDirectX();
     _mainForm.Dispose();
     _screenManager = null;
     _mainForm      = null;
     _userMessageHandler.Dispose();
 }
Пример #14
0
    static void Main()
    {
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);
        FrmMain = new MainForm();

        Application.Run(FrmMain);

        FrmMain.Dispose();
        FrmMain = null;
        GC.Collect();
    }
Пример #15
0
        /// <summary>
        /// Function to initialize the scratch files area.
        /// </summary>
        private void InitializeScratchArea()
        {
            ScratchArea.ScratchPath = Program.Settings.ScratchPath;

            EditorLogging.Print("Creating scratch area at \"{0}\"", LoggingLevel.Verbose, ScratchArea.ScratchPath);

            _splash.UpdateVersion(Resources.GOREDIT_TEXT_CREATING_SCRATCH);

            // Ensure that we're not being clever and trying to mess up our system.
            if (ScratchArea.CanAccessScratch(Program.Settings.ScratchPath) == ScratchAccessibility.SystemArea)
            {
                GorgonDialogs.ErrorBox(null, Resources.GOREDIT_ERR_CANNOT_USESYS_SCRATCH);
            }
            else
            {
                // Destroy previous scratch area files if possible.
                // Do not do this when we have it set to a system area, this will keep us from
                // destroying anything critical.
                ScratchArea.CleanOldScratchAreas();
            }

            // Ensure we can actually access the scratch area.
            while (ScratchArea.CanAccessScratch(Program.Settings.ScratchPath) != ScratchAccessibility.Accessible)
            {
                EditorLogging.Print("Could not access scratch area at \"{0}\"", LoggingLevel.Verbose, Program.Settings.ScratchPath);

                if (ScratchArea.SetScratchLocation() == ScratchAccessibility.Canceled)
                {
                    // Exit the application if we cancel.
                    MainForm.Dispose();
                    Gorgon.Quit();
                    return;
                }

                EditorLogging.Print("Setting scratch area to \"{0}\".", LoggingLevel.Verbose, Program.Settings.ScratchPath);

                // Update with the new scratch path.
                Program.Settings.Save();
            }

            ScratchArea.InitializeScratch();

            // Get only the providers that are not disabled.
            var plugIns = from plugIn in Gorgon.PlugIns
                          where plugIn is GorgonFileSystemProviderPlugIn &&
                          PlugIns.UserDisabledPlugIns.All(name => !string.Equals(name, plugIn.Name, StringComparison.OrdinalIgnoreCase))
                          select plugIn;

            foreach (GorgonPlugIn plugIn in plugIns)
            {
                ScratchArea.ScratchFiles.Providers.LoadProvider(plugIn.Name);
            }
        }
Пример #16
0
 protected override void Dispose(bool disposing)
 {
     if (_TrayIcon != null)
     {
         _TrayIcon.Dispose();
     }
     if (MainForm != null)
     {
         MainForm.Dispose();
     }
     base.Dispose(disposing);
 }
Пример #17
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing && _mainForm != null)
                {
                    _mainForm.Dispose();
                }

                disposedValue = true;
            }
        }
Пример #18
0
        public static void Main(string[] args)
        {
            // Setup visual styles. Do this first so that any error message boxes
            // displayed get the visual styles to match.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(true);

            // Create the main form and run the app
            _mainForm = new MainForm(); // purposely not using 'using' as, in the event of an exception, we want to access MainForm's state
            Application.Run(_mainForm);
            _mainForm.Dispose();
            _mainForm = null;
        }
Пример #19
0
 void m_cmd_dang_nhap_Click(object sender, EventArgs e)
 {
     try
     {
         Hide();
         MainForm main_form = new MainForm();
         main_form.ShowDialog();
         main_form.Dispose();
     }
     catch (Exception v_e)
     {
         ExceptionHandle.Show(v_e);
     }
 }
Пример #20
0
        void mainForm_FormClosed(object sender, FormClosedEventArgs e)
        {
            MainForm mainForm = sender as MainForm;

            SaveFormSizeNPosition(mainForm);
            mainForm.FormClosed      -= new FormClosedEventHandler(mainForm_FormClosed);
            mainForm.LocationChanged -= new EventHandler(mainForm_LocationChanged);
            mainForm.Dispose();
            mainForms.Remove(mainForm);
            if (mainForms.Count == 0)
            {
                ExitThread();
            }
        }
Пример #21
0
 void m_cmd_dang_nhap_Click(object sender, EventArgs e)
 {
     try
     {
         Hide();
         MainForm main_form = new MainForm();
         main_form.ShowDialog();
         main_form.Dispose();
     }
     catch(Exception v_e)
     {
         ExceptionHandle.Show(v_e);
     }
 }
Пример #22
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            MainForm form = new MainForm();

            //Note:
            // If turning on break on exception for ArgumentNullException in the debugger:
            // http://connect.microsoft.com/VisualStudio/feedback/details/552261/bindingsource-object-string-constructor-throws-argumentnullexception-when-object-is-a-source-with-data-in-it
            Application.Run(form);

            form.Dispose();
            form = null;
            GC.Collect();
        }
Пример #23
0
 public void Stop()
 {
     try
     {
         if (formMain != null)
         {
             formMain.Dispose();
         }
         _isStarted = false;
         Others.ProductStatusLog(Products.ProductName, 6);
     }
     catch (Exception e)
     {
         Logging.WriteError("Profiles Converters > Main > Stop(): " + e);
     }
 }
Пример #24
0
        static void Main()
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            MainForm frmMain = new MainForm();

            System.Windows.Forms.Application.Run(frmMain);
            if (frmMain != null)
            {
                if (frmMain.IsDisposed == false)
                {
                    frmMain.Dispose();
                }
                frmMain = null;
            }
        }
Пример #25
0
        static void Main()
        {
            System.Windows.Forms.Application.EnableVisualStyles();
            System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);

            MainForm startupForm = new MainForm();

            System.Windows.Forms.Application.Run(startupForm);

            if (startupForm != null)
            {
                if (startupForm.IsDisposed == false)
                {
                    startupForm.Dispose();
                }

                //startupForm = null;
            }
        }
        /// <summary>
        /// Releases all resources used by the <see cref="NotifierApplicationContext"/> class
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (_disposeDone)
            {
                return;
            }

            if (disposing)
            {
                // Free managed resources
                MainForm.Dispose();
                NotifierInstance.Dispose();
                GC.SuppressFinalize(this);
            }

            // Add class finalizer if unmanaged resources are added to the class
            // Free unmanaged resources if there are any
            _disposeDone = true;
        }
        /// <summary>
        /// Executes in two distinct scenarios.
        ///
        /// 1. If disposing is true, the method has been called directly
        /// or indirectly by a user's code via the Dispose method.
        /// Both managed and unmanaged resources can be disposed.
        ///
        /// 2. If disposing is false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference (access)
        /// other managed objects, as they already have been garbage collected.
        /// Only unmanaged resources can be disposed.
        /// </summary>
        /// <remarks>
        /// If any exceptions are thrown, that is fine.
        /// If the method is being done in a finalizer, it will be ignored.
        /// If it is thrown by client code calling Dispose,
        /// it needs to be handled by fixing the issue.
        /// </remarks>
        private void Dispose(bool disposing)
        {
            if (IsDisposed)
            {
                return;
            }

            if (disposing)
            {
                _startupNewView.Startup                -= Startup;
                _existingSystemView.ImportLexicon      -= OnImportLexicon;
                _existingSystemView.ExportLexicon      -= OnExportLexicon;
                _existingSystemView.BasicImportLexicon -= OnBasicImport;

                MainForm.Dispose();
            }

            IsDisposed = true;
        }
Пример #28
0
 static void Main()
 {
     using (AppManager execMgr = new AppManager(AppName)) {
         if (execMgr.IsFirstInstance)
         {
             try
             {
                 MainForm mainFrm = new MainForm();
                 Application.Run(mainFrm);
                 mainFrm.Show();
                 if (mainFrm != null)
                 {
                     mainFrm.Close();
                     mainFrm.Dispose();
                 }
                 return;
             }
             catch (Exception ex)
             {
                 //Log exception //TODO
             }
         }
     }
 }
Пример #29
0
        static void Main(string[] args)
        {
            // This startup sequence is based on the "Circuit editor" sample in the Sony ATF repo
            // We want to take advantage of the ATF implementations whereever they exist, but we'll
            // remove the parts that are specific to that circuit editor sample app.

            // It's important to call these before starting the app; otherwise theming and bitmaps
            //  may not render correctly.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());

            // early engine initialization
            var engineDevice = new GUILayer.EngineDevice();

            GC.KeepAlive(engineDevice);

            var attach0 = new ShaderPatcherLayer.LibraryAttachMarker(engineDevice);

            GC.KeepAlive(attach0);

            XLEBridgeUtils.Utils.AttachLibrary(engineDevice);
            var logRedirect = new XLEBridgeUtils.LoggingRedirect();

            // Enable metadata driven property editing for the DOM
            DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator <CustomTypeDescriptorNodeAdapter>());

            // Create a type catalog with the types of components we want in the application
            var catalog = new TypeCatalog(

                typeof(SettingsService),                // persistent settings and user preferences dialog
                // typeof(StatusService),                  // status bar at bottom of main Form
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(WindowLayoutService),            // multiple window layout support
                typeof(WindowLayoutServiceCommands),    // window layout commands
                // typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                // typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                // typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(FileDialogService),              // standard Windows file dialogs

                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(TabbedControlSelector),          // enable ctrl-tab selection of documents and controls within the app
                typeof(HelpAboutCommand),               // Help -> About command

                typeof(ContextRegistry),                // central context registry with change notification
                typeof(StandardFileExitCommand),        // standard File exit menu command
                // typeof(StandardEditCommands),           // standard Edit menu commands for copy/paste
                // typeof(StandardEditHistoryCommands),    // standard Edit menu commands for undo/redo
                typeof(StandardSelectionCommands),      // standard Edit menu selection commands
                typeof(StandardLayoutCommands),         // standard Format menu layout commands
                typeof(StandardViewCommands),           // standard View menu commands

                // typeof(PaletteService),                 // global palette, for drag/drop instancing

                typeof(PropertyEditor),                 // property grid for editing selected objects
                typeof(GridPropertyEditor),             // grid control for editing selected objects
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor, like Reset,
                                                        // Reset All, Copy Value, Paste Value, Copy All, Paste All

                typeof(HistoryLister),                  // visual list of undo/redo stack
                typeof(PrototypeLister),                // editable palette of instantiable item groups
                typeof(LayerLister),                    // editable tree view of layers

                typeof(Outputs),                        // passes messages to all log writers
                // typeof(ErrorDialogService),             // displays errors to the user in a message box
                typeof(OutputService),                  // rich text box for displaying error and warning messages. Implements IOutputWriter.
                typeof(DomRecorder),                    // records and displays changes to the DOM for diagnostic purposes

                typeof(Editor),                         // editor which manages circuit documents and controls
                // typeof(SchemaLoader),                   // loads circuit schema and extends types
                // typeof(GroupingCommands),               // circuit group/ungroup commands
                typeof(DiagramControlRegistry),         // circuit controls management
                // typeof(LayeringCommands),               // "Add Layer" command
                // typeof(GraphViewCommands),              // zooming with presets
                typeof(PerformanceMonitor),             // displays the frame rate and memory usage
                typeof(DefaultTabCommands),             // provides the default commands related to document tab Controls
                // typeof(ModulePlugin),                   // component that defines circuit module types
                // typeof(TemplateLister),                 // template library for subgraph referencing or instancing
                // typeof(TemplatingCommands),             // commands for promoting/demoting graph elements to/from template library
                //typeof(TemplatingSupervisor),         // templated instances copy-on-edit support(optionally)

                typeof(AnnotatingCommands),             // annotating commands
                // typeof(CircuitTestCommands),            // circuit tester commands

                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService),              // provides facilities to run an automated script using the .NET remoting service

                typeof(SkinService),

                typeof(ShaderPatcherLayer.Manager),
                typeof(ShaderFragmentArchive.Archive),

                typeof(Controls.DiagramControl),
                typeof(Controls.ShaderFragmentArchiveControl),
                typeof(Controls.DiagramLister),

                typeof(NodeEditorCore.ShaderFragmentArchiveModel),
                typeof(NodeEditorCore.ModelConversion),
                typeof(NodeEditorCore.ShaderFragmentNodeCreator),
                typeof(NodeEditorCore.DiagramDocument),

                typeof(ControlsLibraryExt.Commands.CommonCommands),
                typeof(ControlsLibraryExt.Material.MaterialInspector),
                typeof(ControlsLibraryExt.Material.MaterialSchemaLoader),
                typeof(ControlsLibraryExt.ModelView.ActiveModelView),

                typeof(ActiveMaterialContext),
                typeof(DiagramCommands)
                );

            // enable use of the system clipboard
            StandardEditCommands.UseSystemClipboard = true;

            // Set up the MEF container with these components
            var container = new CompositionContainer(catalog);

            // This is bit wierd, but we're going to add the container to itself.
            // This will create a tight circular dependency, of course
            // It's also not ideal by the core DI pattern.
            // But it's useful for us, because we want to use the same container to construct
            // objects (and also to retrieve global instances).
            container.ComposeExportedValue <ExportProvider>(container);
            container.ComposeExportedValue <CompositionContainer>(container);

            // Configure the main Form
            var batch    = new CompositionBatch();
            var mainForm = new MainForm(new ToolStripContainer())
            {
                Text = Application.ProductName     //,
                       // Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
            };

            // Sce.Atf.Direct2D.D2dFactory.EnableResourceSharing(mainForm.Handle);

            // Add the main Form instance, etc., to the container
            batch.AddPart(mainForm);
            // batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Circuit-Editor-Sample".Localize()));
            container.Compose(batch);

            // We need to attach compilers for models, etc
            engineDevice.AttachDefaultCompilers();

            container.InitializeAll();

            // if there is a model filename on the command line, we will load it into our viewer
            if (args != null && args.Length > 0)
            {
                var a = args[0];
                if (string.Equals(System.IO.Path.GetExtension(a), ".dae", StringComparison.OrdinalIgnoreCase))
                {
                    // Insert a delegate to be executed after the AutoDocumentService has run. That is attached
                    // to the "Loaded" event in the main form, also -- so this should occur afterwards
                    // This way we can pop our window to the top, after the auto load documents appear
                    mainForm.Loaded += delegate(object o, EventArgs eventArgs)
                    {
                        var modelView = container.GetExport <ControlsLibraryExt.ModelView.ActiveModelView>().Value;
                        if (modelView != null)
                        {
                            modelView.LoadFromCommandLine(a);

                            var hostService = container.GetExport <IControlHostService>().Value;
                            if (hostService != null)
                            {
                                hostService.Show(modelView.Control);
                            }

                            // unfortunately we can't suppress the autoload documents stuff from here!
                        }
                    };
                }
            }

            Application.Run(mainForm);
            container.Dispose();
            mainForm.Dispose();

            logRedirect.Dispose();
            engineDevice.PrepareForShutdown();
            XLEBridgeUtils.Utils.DetachLibrary();
            attach0.Dispose();
            engineDevice.Dispose();
        }
Пример #30
0
		[Test] // bug 81695
		public void TestNestedControls2 ()
		{
			MainForm f = new MainForm ();
			f.ShowInTaskbar = false;

			f.Show ();
			
			Size s = f.Size;
			f.Size = new Size (10, 10);
			f.Size = s;
			
			Assert.AreEqual (new Rectangle (210, 212, 75, 23), f._userControl._button2.Bounds, "K1");

			f.Dispose ();
		}
Пример #31
0
        /*
         * /// <summary>
         * /// (Deprecated) Método invocado pelo Thread Runner para atualizar o AD.
         * /// </summary>
         * /// <param name="o">Identifica se o método é chamado por um serviço ou não.</param>
         * public void run_old(object o)
         * {
         *  bool service = (bool)o;
         *  bool runforever = true;
         *  while (runforever)
         *  {
         *      Int32 sleepinterval;
         *      List<String> fields = new List<string>();
         *      Setup setup = new Setup();
         *      DataGridView dataGridView = new DataGridView();
         *      dataGridView.Columns.Add("CampoOrigem", "CampoOrigem");
         *      dataGridView.Columns.Add("CampoDestino", "CampoDestino");
         *      try
         *      {
         *          FileInfo file = new FileInfo(Path.Combine(Application.StartupPath, "DePara.xml"));
         *          if (file.Exists)
         *          {
         *              Dictionary<Int32, Dictionary<String, String>> data =
         *                  new Dictionary<int, Dictionary<string, string>>();
         *              XmlReader xr = XmlReader.Create(file.FullName);
         *              xr.MoveToContent();
         *              while (xr.Read())
         *              {
         *                  Dictionary<String, String> attributes = new Dictionary<string, string>();
         *                  while (xr.MoveToNextAttribute())
         *                  {
         *                      if (xr.Name != "CampoOrigem" && xr.Name != "CampoDestino")
         *                          continue;
         *                      attributes.Add(xr.Name, xr.Value);
         *                  }
         *                  if (attributes.Count > 0)
         *                      data.Add(data.Count, attributes);
         *              }
         *              xr.Close();
         *              foreach (KeyValuePair<Int32, Dictionary<String, String>> kp in data)
         *              {
         *                  dataGridView.Rows.Add(kp.Value["CampoOrigem"], kp.Value["CampoDestino"]);
         *              }
         *
         *              ADWork adw = new ADWork(setup.dataGridViewLdapStrings, setup.textBoxLdapUsername.Text,
         *                  setup.textBoxLdapPassword.Text);
         *              Dictionary<String, Userdata> usuarios = new Dictionary<string, Userdata>();
         *              String keyfield = "USRRED";
         *              OracleConnection conn = new OracleConnection(setup.ConnectionStringOracle);
         *              conn.Open();
         *              OracleCommand cmd = new OracleCommand();
         *              cmd.Connection = conn;
         *              cmd.CommandText = "SELECT * from " + setup.textBoxOraView.Text;
         *              cmd.CommandType = CommandType.Text;
         *              OracleDataReader dr = cmd.ExecuteReader();
         *
         *              if (dr.HasRows)
         *              {
         *                  while (dr.Read())
         *                  {
         *                      Userdata us = new Userdata(dr, fields);
         *                      try
         *                      {
         *                          usuarios.Add(us.Attribute[keyfield], us);
         *                      }
         *                      catch
         *                      {
         *                      }
         *                  }
         *              }
         *
         *              dr.Close();
         *              conn.Dispose();
         *
         *              foreach (KeyValuePair<String, Userdata> user in usuarios)
         *              {
         *                  foreach (DataGridViewRow row in dataGridView.Rows)
         *                  {
         *                      if (!row.IsNewRow)
         *                      {
         *                          if (
         *                              user.Value.Attribute.ContainsKey(
         *                                  row.Cells["CampoOrigem"].Value.ToString().ToUpper()))
         *                          {
         *                              adw.SetAdInfo(user.Key, row.Cells["CampoDestino"].Value.ToString(),
         *                                  user.Value.Attribute[row.Cells["CampoOrigem"].Value.ToString().ToUpper()],
         *                                  setup.textBoxLdapDomain.Text);
         *                          }
         *                      }
         *                  }
         *              }
         *          }
         *      }
         *      catch
         *      {
         *      }
         *      if (Int32.TryParse(setup.textBoxUpdateInterval.Text, out sleepinterval))
         *      {
         *          Thread.Sleep(sleepinterval);
         *      }
         *      else
         *      {
         *          if (service)
         *          {
         *              Thread.Sleep(720000);
         *          }
         *          else
         *          {
         *              runforever = false;
         *          }
         *      }
         *  }
         * }
         */

        /// <summary>
        /// Método invocado pelo Thread Runner para atualizar o AD.
        /// </summary>
        /// <param name="o">Identifica se o método é chamado por um serviço ou não.</param>
        public void run(object o)
        {
            bool service    = (bool)o;
            bool runforever = true;

            //ServiceName = setup.textBoxWinServiceName.Text;
            ((ISupportInitialize)(this.EventLog)).BeginInit();

            if (!EventLog.SourceExists(this.EventLog.Source))
            {
                EventLog.CreateEventSource(this.EventLog.Source, this.EventLog.Log);
            }
            ((ISupportInitialize)(this.EventLog)).EndInit();


            while (runforever)
            {
                try
                {
                    Setup setup = new Setup();
                    if (DateTime.Now.TimeOfDay < setup.dateTimePickerInicioUpdate.Value.TimeOfDay ||
                        DateTime.Now.TimeOfDay > setup.dateTimePickerFimUpdate.Value.TimeOfDay)
                    {
                        DateTime tomorrow  = DateTime.Now.AddDays(1);
                        DateTime nextstart = new DateTime(tomorrow.Year, tomorrow.Month, tomorrow.Day,
                                                          setup.dateTimePickerInicioUpdate.Value.TimeOfDay.Hours,
                                                          setup.dateTimePickerInicioUpdate.Value.TimeOfDay.Minutes,
                                                          setup.dateTimePickerInicioUpdate.Value.TimeOfDay.Seconds);

                        Thread.Sleep(nextstart - DateTime.Now);
                    }
                    setup.Dispose();
                    MainForm mainform = new MainForm(false);
                    DateTime start    = DateTime.Now;
                    mainform.buttonRunQuery_Click(this, new EventArgs());
                    //mainform.buttonUpdateAD_Click(this, new EventArgs());
                    mainform.adUpdate(service);
                    TimeSpan totaltime = DateTime.Now - start;
                    mainform.Dispose();
                    setup = new Setup();
                    Int32 sleep = Int32.Parse(setup.textBoxUpdateInterval.Text);
                    EventLog.WriteEntry("Atualização AD completa em " + totaltime.TotalMilliseconds + "ms.");
                    setup.Dispose();

                    DateTime temp = DateTime.Now.AddMilliseconds(sleep);
                    if (temp.Day != DateTime.Now.Day)
                    {
                        Int32 sleeptime =
                            (int)
                            ((new DateTime(temp.Year, temp.Month, temp.Day, 0, 0, 0) - DateTime.Now)
                             .TotalMilliseconds);
                        if (sleep > sleeptime)
                        {
                            Thread.Sleep(sleep);
                        }
                        else
                        {
                            Thread.Sleep(sleeptime);
                        }
                    }
                    else
                    {
                        Thread.Sleep(sleep);
                    }
                }
                catch (Exception e)
                {
                    EventLog.WriteEntry("Erro no processo de atualização: " + e.Message + "\nExceção: " + e.InnerException + "\nStack Trace: " + e.StackTrace);
                    runforever = false;
                }
            }
        }
		[Test]  // Should not throw AOORE
		public void Bug347669 ()
		{
			Form main = new MainForm ();
			main.Show ();
			Form frm = new Childform ();
			frm.MdiParent = main;
			frm.Show ();
			main.Dispose ();
		}
Пример #33
0
        static void Main()
        {
            // This startup sequence is based on the "Circuit editor" sample in the Sony ATF repo
            // We want to take advantage of the ATF implementations whereever they exist, but we'll
            // remove the parts that are specific to that circuit editor sample app.

            // It's important to call these before starting the app; otherwise theming and bitmaps
            //  may not render correctly.
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.DoEvents(); // see http://www.codeproject.com/buglist/EnableVisualStylesBug.asp?df=100&forumid=25268&exp=0&select=984714

            // Set up localization support early on, so that user-readable strings will be localized
            //  during the initialization phase below. Use XML files that are embedded resources.
            Thread.CurrentThread.CurrentUICulture = System.Globalization.CultureInfo.CurrentCulture;
            Localizer.SetStringLocalizer(new EmbeddedResourceStringLocalizer());
            
            // early engine initialization
            var engineDevice = new GUILayer.EngineDevice();
            GC.KeepAlive(engineDevice);

            var attach0 = new ShaderPatcherLayer.LibraryAttachMarker(engineDevice);
            GC.KeepAlive(attach0);

            XLEBridgeUtils.Utils.AttachLibrary(engineDevice);
            var logRedirect = new XLEBridgeUtils.LoggingRedirect();

            // Enable metadata driven property editing for the DOM
            DomNodeType.BaseOfAllTypes.AddAdapterCreator(new AdapterCreator<CustomTypeDescriptorNodeAdapter>());

            // Create a type catalog with the types of components we want in the application
            var catalog = new TypeCatalog(

                typeof(SettingsService),                // persistent settings and user preferences dialog
                // typeof(StatusService),                  // status bar at bottom of main Form
                typeof(CommandService),                 // handles commands in menus and toolbars
                typeof(ControlHostService),             // docking control host
                typeof(WindowLayoutService),            // multiple window layout support
                typeof(WindowLayoutServiceCommands),    // window layout commands
                // typeof(AtfUsageLogger),                 // logs computer info to an ATF server
                // typeof(CrashLogger),                    // logs unhandled exceptions to an ATF server
                // typeof(UnhandledExceptionService),      // catches unhandled exceptions, displays info, and gives user a chance to save
                typeof(FileDialogService),              // standard Windows file dialogs

                typeof(DocumentRegistry),               // central document registry with change notification
                typeof(AutoDocumentService),            // opens documents from last session, or creates a new document, on startup
                typeof(RecentDocumentCommands),         // standard recent document commands in File menu
                typeof(StandardFileCommands),           // standard File menu commands for New, Open, Save, SaveAs, Close
                typeof(MainWindowTitleService),         // tracks document changes and updates main form title
                typeof(TabbedControlSelector),          // enable ctrl-tab selection of documents and controls within the app
                typeof(HelpAboutCommand),               // Help -> About command

                typeof(ContextRegistry),                // central context registry with change notification
                typeof(StandardFileExitCommand),        // standard File exit menu command
                // typeof(StandardEditCommands),           // standard Edit menu commands for copy/paste
                // typeof(StandardEditHistoryCommands),    // standard Edit menu commands for undo/redo
                typeof(StandardSelectionCommands),      // standard Edit menu selection commands
                typeof(StandardLayoutCommands),         // standard Format menu layout commands
                typeof(StandardViewCommands),           // standard View menu commands

                // typeof(PaletteService),                 // global palette, for drag/drop instancing

                typeof(PropertyEditor),                 // property grid for editing selected objects
                typeof(GridPropertyEditor),             // grid control for editing selected objects
                typeof(PropertyEditingCommands),        // commands for PropertyEditor and GridPropertyEditor, like Reset,
                                                        // Reset All, Copy Value, Paste Value, Copy All, Paste All

                typeof(HistoryLister),                  // visual list of undo/redo stack
                typeof(PrototypeLister),                // editable palette of instantiable item groups
                typeof(LayerLister),                    // editable tree view of layers

                typeof(Outputs),                        // passes messages to all log writers
                // typeof(ErrorDialogService),             // displays errors to the user in a message box
                typeof(OutputService),                  // rich text box for displaying error and warning messages. Implements IOutputWriter.
                typeof(DomRecorder),                    // records and displays changes to the DOM for diagnostic purposes

                typeof(Editor),                         // editor which manages circuit documents and controls
                // typeof(SchemaLoader),                   // loads circuit schema and extends types
                // typeof(GroupingCommands),               // circuit group/ungroup commands
                typeof(DiagramControlRegistry),         // circuit controls management
                // typeof(LayeringCommands),               // "Add Layer" command
                // typeof(GraphViewCommands),              // zooming with presets
                typeof(PerformanceMonitor),             // displays the frame rate and memory usage
                typeof(DefaultTabCommands),             // provides the default commands related to document tab Controls
                // typeof(ModulePlugin),                   // component that defines circuit module types
                // typeof(TemplateLister),                 // template library for subgraph referencing or instancing 
                // typeof(TemplatingCommands),             // commands for promoting/demoting graph elements to/from template library 
                //typeof(TemplatingSupervisor),         // templated instances copy-on-edit support(optionally)

                typeof(AnnotatingCommands),             // annotating commands
                // typeof(CircuitTestCommands),            // circuit tester commands

                typeof(PythonService),                  // scripting service for automated tests
                typeof(ScriptConsole),                  // provides a dockable command console for entering Python commands
                typeof(AtfScriptVariables),             // exposes common ATF services as script variables
                typeof(AutomationService),              // provides facilities to run an automated script using the .NET remoting service

                typeof(SkinService),

                typeof(ShaderPatcherLayer.Manager),
                typeof(ShaderFragmentArchive.Archive),
               
                typeof(Controls.DiagramControl),
                typeof(Controls.ShaderFragmentArchiveControl),
                typeof(Controls.DiagramLister),

                typeof(NodeEditorCore.ShaderFragmentArchiveModel),
                typeof(NodeEditorCore.ModelConversion),
                typeof(NodeEditorCore.ShaderFragmentNodeCreator),
                typeof(NodeEditorCore.DiagramDocument),

                typeof(ControlsLibraryExt.Commands.CommonCommands),
                typeof(ControlsLibraryExt.Material.MaterialInspector),
                typeof(ControlsLibraryExt.Material.MaterialSchemaLoader),
                typeof(ControlsLibraryExt.ModelView.ActiveModelView),

                typeof(ActiveMaterialContext),
                typeof(DiagramCommands)
            );

            // enable use of the system clipboard
            StandardEditCommands.UseSystemClipboard = true;

            // Set up the MEF container with these components
            var container = new CompositionContainer(catalog);

            // This is bit wierd, but we're going to add the container to itself.
            // This will create a tight circular dependency, of course
            // It's also not ideal by the core DI pattern. 
            // But it's useful for us, because we want to use the same container to construct
            // objects (and also to retrieve global instances).
            container.ComposeExportedValue<ExportProvider>(container);
            container.ComposeExportedValue<CompositionContainer>(container);

            // Configure the main Form
            var batch = new CompositionBatch();
            var mainForm = new MainForm(new ToolStripContainer())
                {
                    Text = Application.ProductName //,
                    // Icon = GdiUtil.CreateIcon(ResourceUtil.GetImage(Sce.Atf.Resources.AtfIconImage))
                };
            // Sce.Atf.Direct2D.D2dFactory.EnableResourceSharing(mainForm.Handle);

            // Add the main Form instance, etc., to the container
            batch.AddPart(mainForm);
            // batch.AddPart(new WebHelpCommands("https://github.com/SonyWWS/ATF/wiki/ATF-Circuit-Editor-Sample".Localize()));
            container.Compose(batch);

            // We need to attach compilers for models, etc
            engineDevice.AttachDefaultCompilers();

            container.InitializeAll();
            Application.Run(mainForm);
            container.Dispose();
            mainForm.Dispose();

            logRedirect.Dispose();
            engineDevice.PrepareForShutdown();
            XLEBridgeUtils.Utils.DetachLibrary();
            attach0.Dispose();
            engineDevice.Dispose();
        }
Пример #34
0
        /// <summary>
        /// Function to begin the execution of the application context.
        /// </summary>
        public void RunMe()
        {
            string annoyUser = "******";
            int    counter   = 0;

            try
            {
                _timer.Reset();
                _splashScreen.Show();
                _splashScreen.UpdateText("This is the splash screen.");

                // Fade in the splash screen about 10% every 7 milliseconds.
                while (_splashScreen.Opacity < 1)
                {
                    if (!(_timer.Milliseconds > 7))
                    {
                        continue;
                    }

                    _timer.Reset();
                    _splashScreen.Opacity += 0.01;
                }

                // Annoy the user.  They're asking for it.
                while (counter < 5)
                {
                    while (_timer.Seconds > 1)
                    {
                        if (annoyUser.Length < 50)
                        {
                            annoyUser += ".";
                        }
                        else
                        {
                            annoyUser = "******";
                        }

                        _splashScreen.UpdateText(annoyUser);
                        _timer.Reset();
                        counter++;
                    }
                }

                // Fade it out.
                while (_splashScreen.Opacity > 0.02)
                {
                    if (!(_timer.Milliseconds > 5))
                    {
                        continue;
                    }

                    _timer.Reset();
                    _splashScreen.Opacity -= 0.01;
                }

                // Resize the main form to 640 x 480.
                MainForm.KeyDown    += MainForm_KeyDown;
                MainForm.Deactivate += (sender, args) => GorgonApplication.Log.Print("Application is deactivated. Loops will pause.", LoggingLevel.All);
                MainForm.Activated  += (sender, args) => GorgonApplication.Log.Print("Application is activated. Loops will run.", LoggingLevel.All);
                MainForm.ClientSize  = new Size(640, 480);
                MainForm.Show();
            }
            catch (Exception ex)
            {
                // If we get an error, then leave the application.
                GorgonDialogs.ErrorBox(MainForm, ex);

                MainForm?.Dispose();
                MainForm = null;
            }
            finally
            {
                // We don't need this any more.
                _splashScreen?.Dispose();
                _splashScreen = null;
            }
        }
Пример #35
0
 protected override void Dispose(bool disposing)
 {
     MainForm = _mainForm;
     _mainForm.Dispose();
     base.Dispose(disposing);
 }
Пример #36
0
 private void _acceptButton_Click(object sender, EventArgs e)
 {
     MainForm.Dispose();
 }