コード例 #1
0
 void Awake()
 {
     if (_control != null)
     {
         _control.Dispose();
         _control = null;
     }
 }
コード例 #2
0
 /// <summary>
 /// Quitar un control de la matriz.
 /// </summary>
 /// <param name="index">El índice del control que se va a quitar.</param>
 protected void Quitar(int index)
 {
     System.Windows.Forms.Control Ctl = this.Controles[index] as System.Windows.Forms.Control;
     this.PanelGrilla.Controls.Remove(Ctl);
     Ctl.Dispose();
     this.Controles.RemoveAt(index);
 }
コード例 #3
0
 private void _CleanNewControl(System.Windows.Forms.Control ctrl)
 {
     if (
         (ctrl != null) &&
         (!ctrl.Disposing)
         )
     {
         ctrl.Dispose();
         ctrl = null;
     }
 }
 public void Dispose()
 {
     if (!IsDisposed)
     {
         IsDisposed = true;
         if (_WPFUIElementAdapter != null)
         {
             System.Windows.Forms.Control wrapper = _WPFUIElementAdapter.Wrap(this);
             wrapper.Dispose();
         }
     }
 }
コード例 #5
0
ファイル: Memory.cs プロジェクト: cyotek/translateclient
        public static void Dispose(System.Windows.Forms.Control.ControlCollection controls)
        {
            if (controls == null)
            {
                return;
            }

            while (controls.Count > 0)
            {
                System.Windows.Forms.Control ctrl = controls[0];
                if (ctrl != null)
                {
                    ctrl.Dispose();
                }
            }
        }
コード例 #6
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         if (components != null)
         {
             components.Dispose();
         }
         if (popedControl != null)
         {
             System.Windows.Forms.Control _content = popedControl;
             popedControl = null;
             _content.Dispose();
         }
     }
     base.Dispose(disposing);
 }
コード例 #7
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                if (_popupContainer != null)
                {
                    System.Windows.Forms.Control _content = _popupContainer;
                    _popupContainer = null;
                    _content.Dispose();
                }
            }

            base.Dispose(disposing);
        }
コード例 #8
0
 /// <summary>
 /// Clean up any resources being used.
 /// </summary>
 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         SetOwnerItem(null);
         if (components != null)
         {
             components.Dispose();
         }
         if (_content != null)
         {
             System.Windows.Forms.Control ctrl = _content;
             _content = null;
             ctrl.Dispose();
         }
         if (_fadingTimer != null)
         {
             _fadingTimer.Dispose();
         }
     }
     base.Dispose(disposing);
 }
コード例 #9
0
        private void AddDataControl(System.Type type)
        {
            if (m_owner == null)
            {
                return;
            }

            System.Windows.Forms.Control control = m_owner.Control;
            if (control != null)
            {
                m_owner.Control = null;
                control.Dispose();
            }

            IDesignerHost           h  = (IDesignerHost)GetService(typeof(IDesignerHost));
            DesignerTransaction     dt = h.CreateTransaction("Add DataControl");
            IComponentChangeService c  = (IComponentChangeService)GetService(typeof(IComponentChangeService));

            control = (System.Windows.Forms.Control)h.CreateComponent(type);
            c.OnComponentChanging(m_owner, null);
            m_owner.Control = control;
            c.OnComponentChanged(m_owner, null, null, null);
            dt.Commit();
        }
コード例 #10
0
 protected virtual void Dispose(bool disposing)
 {
     if (!_isDisposing) // avoid recursion on Dispose
     {
         if (disposing)
         {
             _isDisposing = true;
             if (_presenter != null)
             {
                 _presenter.Dispose();
                 _presenter = null;
             }
             if (_WPFUIElementAdapter != null)
             {
                 System.Windows.Forms.Control host = _WPFUIElementAdapter.Wrap(this);
                 if (!host.Disposing)
                 {
                     host.Dispose();
                 }
                 _WPFUIElementAdapter = null;
             }
         }
     }
 }
コード例 #11
0
ファイル: Plugin.cs プロジェクト: jeffreyclu/case-apps
 /// <summary>
 ///
 /// </summary>
 /// <param name="pane"></param>
 public override void DestroyControlPane(System.Windows.Forms.Control pane)
 {
     pane.Dispose();
 }
コード例 #12
0
ファイル: EditorService.cs プロジェクト: gleibson/phobos3d
 public static void Stop()
 {
     m_invokeControl.Dispose();
     m_invokeControl = null;
 }
        // Event handlers for addons
        #region MgaEventSink members
        public void GlobalEvent(globalevent_enum @event)
        {
            if (GMEConsole == null || GMEConsole.gme == null)
            {
                GMEConsole = GMEConsole.CreateFromProject(this.project);
            }

            if (@event == globalevent_enum.GLOBALEVENT_SAVE_PROJECT)
            {
                // update the list of models to be re-opened
                modelsToReOpen = new List <string>(openModels);

#if (DEBUG)
                // notify open models on console
                GMEConsole.Info.Write(String.Format("Models Open: {0}", openModels.Count));
                foreach (string model in openModels)
                {
                    GMEConsole.Out.Write(model);
                }
#endif
            }

            if (@event == globalevent_enum.GLOBALEVENT_CLOSE_PROJECT)
            {
#if (DEBUG)
                // notify close project
                if (GMEConsole != null)
                {
                    GMEConsole.Info.WriteLine("Closed project: {0}", project.ProjectConnStr.Split('\\').Last());
                }
#endif
                //if (GMEConsole != null)
                //{
                //    if (GMEConsole.gme != null)
                //    {
                //        Marshal.FinalReleaseComObject(GMEConsole.gme);
                //    }
                //    GMEConsole = null;
                //}
                addon.Destroy();
                Marshal.FinalReleaseComObject(addon);
                addon = null;
                hiddenWindow.BeginInvoke((System.Action) delegate
                {
                    hiddenWindow.Dispose();
                    hiddenWindow = null;
                });
            }

            if (@event == globalevent_enum.GLOBALEVENT_OPEN_PROJECT_FINISHED)
            {
                if (hiddenWindow == null)
                {
                    hiddenWindow = new System.Windows.Forms.Control();
                    IntPtr handle = hiddenWindow.Handle; // If the handle has not yet been created, referencing this property will force the handle to be created.
                }
#if (DEBUG)
                // notify open project
                if (getGMEConsole())
                {
                    GMEConsole.Info.WriteLine("Opened project: {0}", project.ProjectConnStr.Split('\\').Last());
                }
#endif
                // Re-opening a project, re-open the previously open models
                if (project != null && mgaFile == project.ProjectConnStr)
                {
                    var modelsToReOpenFcos = modelsToReOpen.Select(path => project.ObjectByPath[path]).Where(fco => fco != null).ToList();
                    if (modelsToReOpenFcos.Count > 0)
                    {
                        hiddenWindow.BeginInvoke((System.Action) delegate
                        {
                            foreach (MgaObject obj in modelsToReOpenFcos)
                            {
                                try
                                {
                                    GMEConsole.gme.ShowFCO((MgaFCO)obj, false);
                                }
                                catch (Exception e)
                                {
                                    //throw e;
                                    GMEConsole.Error.Write(e.ToString());
                                }
                            }
                        });
                    }
                }
                modelsToReOpen.Clear();

                // update the open mga file name
                mgaFile = GMEConsole.gme.MgaProject.ProjectConnStr;

                if (thread != null)
                {
                    if ((bool)abortOK)
                    {
                        thread.Abort();
                    }
                    if (namedPipeServer != null)
                    {
                        namedPipeClient = new NamedPipeClientStream(".", pipeFile, PipeDirection.InOut);
                        namedPipeClient.Connect();
                        namedPipeClient.Close();
                        namedPipeClient = null;
                    }
                    //if (namedPipeServer != null)
                    //{
                    //    if (namedPipeServer.IsConnected)
                    //    {
                    //        namedPipeServer.Disconnect();
                    //    }
                    //    namedPipeServer.Close();
                    //    namedPipeServer = null;
                    //}

                    Thread.Sleep(2000);
                    thread.Join();
                }
                thread = new Thread(() =>
                {
                    try
                    {
                        abortOK         = true;
                        pipeFile        = String.Format("\\{0}\\{1}", Process.GetCurrentProcess().Id, mgaFile.Split('\\').Last());
                        PipeSecurity ps = new PipeSecurity();
                        ps.AddAccessRule(new PipeAccessRule(@"NT AUTHORITY\Everyone", PipeAccessRights.ReadWrite, System.Security.AccessControl.AccessControlType.Allow));
                        namedPipeServer = new NamedPipeServerStream(pipeFile, PipeDirection.InOut, 1, PipeTransmissionMode.Message, PipeOptions.None, BUFFER_SIZE, BUFFER_SIZE, ps);

#if (DEBUG)
                        GMEConsole.Info.Write(String.Format("Opened Pipe File: {0}", pipeFile));
#endif
                        namedPipeServer.WaitForConnection();
                        byte[] buffer = new byte[BUFFER_SIZE];
                        int nread     = namedPipeServer.Read(buffer, 0, BUFFER_SIZE);
                        string line   = Encoding.UTF8.GetString(buffer, 0, nread);
                        Actions act   = (Actions)Enum.Parse(typeof(Actions), line, true);
                        if (act != Actions.CLOSE)
                        {
                            throw new Exception(String.Format("Expected action: CLOSE, received action: {0}", act));
                        }

                        GMEConsole.gme.SaveProject();
                        GMEConsole.gme.CloseProject(false);
                        using (BinaryWriter writer = new BinaryWriter(new MemoryStream()))
                        {
                            writer.Write("closed");
                            namedPipeServer.Write(((MemoryStream)writer.BaseStream).ToArray(), 0, ((MemoryStream)writer.BaseStream).ToArray().Length);
                        }

                        nread = namedPipeServer.Read(buffer, 0, BUFFER_SIZE);
                        line  = Encoding.UTF8.GetString(buffer, 0, nread);
                        act   = (Actions)Enum.Parse(typeof(Actions), line, true);
                        if (act != Actions.OPEN)
                        {
                            throw new Exception(String.Format("Expected action: OPEN, received action: {0}", act));
                        }

                        namedPipeServer.Disconnect();
                        namedPipeServer.Close();
                        namedPipeServer = null;

                        abortOK = false;
                        new Thread(() => GMEConsole.gme.OpenProject(mgaFile)).Start();
                    }
                    catch (ThreadAbortException e)
                    {
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine(String.Format("Inner Exception: {0}\nMessage: {1}\nSource: {2}\nStack Trace: {3}", e.InnerException, e.Message, e.Source, e.StackTrace));
                        GMEConsole.Error.WriteLine(String.Format("Inner Exception: {0}\nMessage: {1}\nSource: {2}\nStack Trace: {3}", e.InnerException, e.Message, e.Source, e.StackTrace));
                    }
                    finally
                    {
                        if (namedPipeServer != null)
                        {
                            if (namedPipeServer.IsConnected)
                            {
                                namedPipeServer.Disconnect();
                            }
                            namedPipeServer.Close();
                            namedPipeServer = null;
                        }
                        abortOK = true;
                    }
                });
                thread.Start();
            }

            #region Other EventHandlers
            if (@event == globalevent_enum.APPEVENT_XML_IMPORT_BEGIN)
            {
                handleEvents    = false;
                addon.EventMask = 0;
            }
            else if (@event == globalevent_enum.APPEVENT_XML_IMPORT_END)
            {
                unchecked { addon.EventMask = (uint)ComponentConfig.eventMask; }
                handleEvents = true;
            }
            else if (@event == globalevent_enum.APPEVENT_LIB_ATTACH_BEGIN)
            {
                addon.EventMask = 0;
                handleEvents    = false;
            }
            else if (@event == globalevent_enum.APPEVENT_LIB_ATTACH_END)
            {
                unchecked { addon.EventMask = (uint)ComponentConfig.eventMask; }
                handleEvents = true;
            }
            #endregion

            if (!componentEnabled)
            {
                return;
            }

            // TODO: Handle global events
            // MessageBox.Show(@event.ToString());
        }