예제 #1
0
파일: AToolbar.cs 프로젝트: alexfordc/Au
        /// <param name="name">
        /// Toolbar name. Must be valid filename.
        /// Used for the toolbar's settings file name. Also it is the initial <b>Name</b> and <b>Text</b> of <see cref="Control"/>, and used with <see cref="Find"/>.
        /// </param>
        /// <param name="f"><see cref="CallerFilePathAttribute"/></param>
        /// <param name="l"><see cref="CallerLineNumberAttribute"/></param>
        /// <exception cref="ArgumentException">Empty or invalid name.</exception>
        /// <remarks>
        /// Reads the settings file if exists, ie if settings changed in the past. See <see cref="GetSettingsFilePath"/>. If fails, writes warning to the output and uses default settings.
        ///
        /// Creates <see cref="Control"/> object. Does not create its window handle; will do it in <see cref="Show"/>.
        ///
        /// Sets properties:
        /// - <see cref="MTBase.ItemThread"/> = <see cref="MTThread.StaThread"/>.
        /// - <see cref="MTBase.ExtractIconPathFromCode"/> = true.
        /// - <see cref="MTBase.DefaultIcon"/> = <see cref="MTBase.CommonIcon"/>.
        /// - <see cref="MTBase.DefaultSubmenuIcon"/> = <see cref="MTBase.CommonSubmenuIcon"/>.
        /// </remarks>
        public AToolbar(string name, [CallerFilePath] string f = null, [CallerLineNumber] int l = 0)
            : base(f, l)
        {
            int tid = Thread.CurrentThread.ManagedThreadId;

            if (s_treadId == 0)
            {
                s_treadId = tid;
            }
            else if (tid != s_treadId)
            {
                AWarning.Write("All toolbars should be in single thread. Multiple threads use more CPU. If using triggers, insert this code before adding toolbar triggers: <code>Triggers.Options.RunActionInMainThread();</code>");
            }

            //rejected: [CallerMemberName] string name = null. Problem: if local func or lambda, it is parent method's name. And can be eg ".ctor" if directly in script.
            _name = name;
            _sett = _Settings.Load(GetSettingsFilePath(name));

            _c = new _ToolStrip(this)
            {
                Name = _name,
                Text = _name,
                Size = _sett.size,
            };

            _anchor = _sett.anchor;
            _xy     = _sett.location;
            Border  = _sett.border;            //default Sizable2

            ExtractIconPathFromCode = true;
            DefaultIcon             = CommonIcon;
            DefaultSubmenuIcon      = CommonSubmenuIcon;
            ItemThread = MTThread.StaThread;

            _constructed = true;
        }
예제 #2
0
 internal _ToolStripOverflow(_ToolStrip ts, ToolStripItem parentItem) : base(parentItem)
 {
     _ts = ts;
 }