Ejemplo n.º 1
0
        public static void LoadEnvironment(InitialAction act)
        {
            ThemeUtil.Init();

            OptionPreservePlace place = GetOptionPreservePlace();

            _options              = new ContainerOptions();
            _history              = new ConnectionHistory();
            _macroManager         = new MacroManager();
            _container            = new PoderosaContainer();
            _globalCommandTarget  = new ContainerGlobalCommandTarget();
            _interThreadUIService = new ContainerInterThreadUIService();
            _sshKnownHosts        = new SSHKnownHosts();


            //この時点ではOSの言語設定に合ったリソースをロードする。起動直前で必要に応じてリロード
            ReloadStringResource();

            GEnv.Init(_container);
            GEnv.Options              = _options;
            GEnv.GlobalCommandTarget  = _globalCommandTarget;
            GEnv.InterThreadUIService = _interThreadUIService;
            GEnv.SSHKnownHosts        = _sshKnownHosts;
            string dir = GetOptionDirectory(place);

            LoadConfigFiles(dir, act);
            _options.OptionPreservePlace = place;

            //ここまできたら言語設定をチェックし、必要なら読み直し
            if (GUtil.CurrentLanguage != _options.Language)
            {
                System.Threading.Thread.CurrentThread.CurrentUICulture = _options.Language == Language.Japanese? new CultureInfo("ja") : CultureInfo.InvariantCulture;
                ReloadStringResource();
            }
        }
Ejemplo n.º 2
0
        public AboutForm()
        {
            InitializeComponent();
            ThemeUtil.Apply(this);

            lkVersion.Text = @"v" + Application.ProductVersion;
        }
Ejemplo n.º 3
0
        void ApplyMinTrackTintColor(string propertyName)
        {
            if (propertyName == null || propertyName == SliderGloss.MinTrackTintColorProperty.PropertyName)
            {
                var minTrackTintColor = (Color)Element.GetValue(SliderGloss.MinTrackTintColorProperty);
                // Skip assigning anything if all properties are being applied and the color is set to the default value
                if (propertyName != null || minTrackTintColor != Color.Default)
                {
                    var aMinTrackTintColor = (minTrackTintColor == Color.Default) ?
                                             ThemeUtil.IntToColor(ThemeUtil.ColorAccent(Control.Context,
                                                                                        ThemeUtil.DefaultColorControlTrackActivated)) :
                                             minTrackTintColor.ToAndroid();

                    if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
                    {
                        // FYI: Lollipop (API 21) has a broken implementation for the ProgressTintList property.
                        // Assigning a value to the property causes the entire track to be colored with the assigned
                        // value, instead of just the track to the left of the thumb. It works as expected on API 22+.
                        Control.ProgressTintList = ColorStateList.ValueOf(aMinTrackTintColor);
                    }
                    else if (XFGloss.Droid.Library.UsingAppCompat)
                    {
                        DrawableCompat.SetTint(DrawableCompat.Wrap(Control.ProgressDrawable), aMinTrackTintColor);
                        // We also have to explicitly set the MaxTrackTintColor to either the specified custom color or
                        // the default color. Otherwise, setting the MinTrackTintColor tints both the left and right
                        // sides of the track
                        ApplyMaxTrackTintColor(null, true);
                    }
                    else
                    {
                        Console.WriteLine(XFGloss.Droid.Library.appCompatWarning);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        void ApplyThumbTintColor(string propertyName)
        {
            if (propertyName == null || propertyName == SliderGloss.ThumbTintColorProperty.PropertyName)
            {
                var thumbTintColor = (Color)Element.GetValue(SliderGloss.ThumbTintColorProperty);
                // Skip assigning anything if all properties are being applied and the color is set to the default value
                if (propertyName != null || thumbTintColor != Color.Default)
                {
                    var aThumbTintColor = (thumbTintColor == Color.Default) ?
                                          ThemeUtil.IntToColor(ThemeUtil.ColorAccent(Control.Context,
                                                                                     ThemeUtil.DefaultColorControlThumb)) :
                                          thumbTintColor.ToAndroid();

                    if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
                    {
                        Control.ThumbTintList = ColorStateList.ValueOf(aThumbTintColor);
                    }
                    else if (XFGloss.Droid.Library.UsingAppCompat)
                    {
                        DrawableCompat.SetTint(DrawableCompat.Wrap(Control.Thumb), aThumbTintColor);
                    }
                    else
                    {
                        Console.WriteLine(XFGloss.Droid.Library.appCompatWarning);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public AboutForm()
        {
            componentsLayout();
            ThemeUtil.Apply(this);


            lkVersion.Text = @"v" + Application.ProductVersion;
        }
Ejemplo n.º 6
0
        private UpdateForm()
        {
            InitializeComponent();
            ThemeUtil.Apply(this);
            var screen = Screen.PrimaryScreen.WorkingArea;

            Location = new Point(screen.Width - Width, screen.Height - Height);
        }
Ejemplo n.º 7
0
        private UpdateForm()
        {
            componentsLayout();
            ThemeUtil.Apply(this);

            var screen = Util.GetScreenSize(true);

            Location = new Point(screen.Width - Width, screen.Height - Height);
        }
Ejemplo n.º 8
0
        void ApplyMaxTrackTintColor(string propertyName, bool forceApply = false)
        {
            // We always want to force the application of the MaxTrackTintColor if we're running an API that is older
            // than Marshmallow and we're also using the AppCompat library so the track color will be appropriately
            // clamped.
            forceApply = forceApply ||
                         (Android.OS.Build.VERSION.SdkInt < Android.OS.BuildVersionCodes.M &&
                          XFGloss.Droid.Library.UsingAppCompat);

            if (propertyName == null ||
                propertyName == SliderGloss.MaxTrackTintColorProperty.PropertyName ||
                forceApply)
            {
                var maxTrackTintColor = (Color)Element.GetValue(SliderGloss.MaxTrackTintColorProperty);
                // Skip assigning anything if all properties are being applied and the color is set to the default value
                if (propertyName != null || maxTrackTintColor != Color.Default || forceApply)
                {
                    if (maxTrackTintColor != Color.Default)
                    {
                        maxTrackTintColor = new Color(maxTrackTintColor.R, maxTrackTintColor.G, maxTrackTintColor.B, 0.3);
                    }

                    var aMaxTrackTintColor =
                        (maxTrackTintColor == Color.Default) ?
                        ThemeUtil.IntToColor(ThemeUtil.ColorControlNormal(Control.Context,
                                                                          ThemeUtil.DefaultColorControlTrack)) :
                        maxTrackTintColor.ToAndroid();

                    if (!XFGloss.Droid.Library.UsingAppCompat || XFGloss.Droid.Library.UsingAppCompatAlpha)
                    {
                        // Clamp the track tint colors to 30% opacity - API 24 automatically does this. AppCompat doesn't.
                        aMaxTrackTintColor = new AColor(aMaxTrackTintColor.R,
                                                        aMaxTrackTintColor.G,
                                                        aMaxTrackTintColor.B,
                                                        (byte)77);
                    }

                    if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
                    {
                        // FYI: Lollipop (API 21) has the ProgressBackgroundTintList implemented but it is broken.
                        // Assigning a value to the property has no effect on API 21. It works as expected on API 22+.
                        Control.ProgressBackgroundTintList = ColorStateList.ValueOf(aMaxTrackTintColor);
                    }
                    else if (XFGloss.Droid.Library.UsingAppCompat)
                    {
                        ThemeUtil.SetLayerTint(Control.ProgressDrawable as LayerDrawable, 0, aMaxTrackTintColor);
                    }
                    else
                    {
                        Console.WriteLine(XFGloss.Droid.Library.appCompatWarning);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ThemeUtil.Apply(this);
            MainForm_ForeColorChanged(null, null);

            // 干掉按钮边框
            btnScreenshot.NoBorder();

            Height = 20;
            Width  = 88;
            Init();

            // 初始化截图窗口
            ScreenShot.Init();
        }
Ejemplo n.º 10
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            ThemeUtil.Apply(this);
            UpdateShotButton(ForeColor);

            // 干掉按钮边框
            btnScreenshot.NoBorder();

            Height = Util.ScaleY(20);
            Width  = Util.ScaleX(88);
            Init();

            // 初始化截图窗口
            ScreenShot.Init();
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Internal method used to do the work on behalf of the UpdateColorProperty extension method for both
        /// XFGlossSwitchExtensions and XFGlossSwitchCompatExtensions
        /// </summary>
        /// <param name="control">Control.</param>
        /// <param name="properties">Properties.</param>
        /// <param name="propertyName">Property name.</param>
        /// <typeparam name="TControl">The 1st type parameter.</typeparam>
        static void ApplyColorProperty <TControl>(TControl control, ISwitchGloss properties, string propertyName)
        {
            // We have to create a multiple state color list to set both the "off" and "on" (checked/unchecked)
            // states of the switch control.

            bool isSwitch = Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.M &&
                            control is ASwitch;

            bool isSwitchCompat = !isSwitch &&
                                  XFGloss.Droid.Library.UsingAppCompat &&
                                  control is ASwitchCompat;

            Android.Content.Context controlContext = (isSwitch) ? (control as ASwitch).Context :
                                                     (isSwitchCompat) ? (control as ASwitchCompat).Context :
                                                     null;

            int[][] states = new int[2][];
            int[]   colors = new int[2];

            if (propertyName == null ||
                propertyName == SwitchGloss.TintColorProperty.PropertyName ||
                propertyName == SwitchGloss.OnTintColorProperty.PropertyName)
            {
                var tintColor   = properties.TintColor;
                var onTintColor = properties.OnTintColor;

                // Skip assigning anything if all properties are being applied and the color is set to the default value
                if (isSwitchCompat || propertyName != null || tintColor != Color.Default || onTintColor != Color.Default)
                {
                    var aTintColor = (tintColor != Color.Default) ?
                                     tintColor.ToAndroid() :
                                     new AColor(ThemeUtil.ColorControlNormal(controlContext,
                                                                             ThemeUtil.DefaultColorControlTrack));

                    var aOnTintColor = (onTintColor != Color.Default) ?
                                       onTintColor.ToAndroid() :
                                       new AColor(ThemeUtil.ColorControlActivated(controlContext,
                                                                                  ThemeUtil.DefaultColorControlTrackActivated));

                    // Clamp the track tint colors to 30% opacity - API 24 automatically does this. AppCompat doesn't.
                    if (isSwitchCompat && XFGloss.Droid.Library.UsingAppCompatAlpha)
                    {
                        aTintColor   = new AColor(aTintColor.R, aTintColor.G, aTintColor.B, (byte)77);
                        aOnTintColor = new AColor(aOnTintColor.R, aOnTintColor.G, aOnTintColor.B, (byte)77);
                    }

                    states[0] = new int[] { -Android.Resource.Attribute.StateChecked };
                    colors[0] = aTintColor;

                    states[1] = new int[] { Android.Resource.Attribute.StateChecked };
                    colors[1] = aOnTintColor;

                    var colorList = new ColorStateList(states, colors);

                    if (isSwitch)
                    {
                        (control as ASwitch).TrackTintList = colorList;
                    }
                    else if (isSwitchCompat)
                    {
                        DrawableCompat.SetTintList((control as ASwitchCompat).TrackDrawable, colorList);
                    }
                    else
                    {
                        Console.WriteLine(XFGloss.Droid.Library.appCompatWarning);
                    }
                }
            }

            if (propertyName == null ||
                propertyName == SwitchGloss.ThumbTintColorProperty.PropertyName ||
                propertyName == SwitchGloss.ThumbOnTintColorProperty.PropertyName)
            {
                var thumbTintColor   = properties.ThumbTintColor;
                var thumbOnTintColor = properties.ThumbOnTintColor;

                // Skip assigning anything if all properties are being applied and the color is set to the default value
                if (propertyName != null || thumbTintColor != Color.Default || thumbOnTintColor != Color.Default)
                {
                    states[0] = new int[] { -Android.Resource.Attribute.StateChecked };
                    colors[0] = (thumbTintColor != Color.Default) ?
                                thumbTintColor.ToAndroid() :
                                ThemeUtil.DefaultColorControlThumb;

                    states[1] = new int[] { Android.Resource.Attribute.StateChecked };
                    colors[1] = (thumbOnTintColor != Color.Default) ?
                                thumbOnTintColor.ToAndroid() :
                                new AColor(ThemeUtil.ColorControlActivated(controlContext,
                                                                           ThemeUtil.DefaultColorControlThumbActivated));

                    var colorList = new ColorStateList(states, colors);

                    if (isSwitch)
                    {
                        (control as ASwitch).ThumbTintList = colorList;
                    }
                    else if (isSwitchCompat)
                    {
                        DrawableCompat.SetTintList((control as ASwitchCompat).ThumbDrawable, colorList);
                    }
                    else
                    {
                        Console.WriteLine(XFGloss.Droid.Library.appCompatWarning);
                    }
                }
            }
        }
Ejemplo n.º 12
0
 public MainForm()
 {
     InitializeComponent();
     ThemeUtil.Apply(this);
 }
Ejemplo n.º 13
0
 protected void Button_Enter(object sender, EventArgs e)
 {
     ThemeUtil.UpdateFocus(((Button)sender).Handle);
 }
Ejemplo n.º 14
0
 // GET
 public IActionResult Index()
 {
     ViewBag.themes = ThemeUtil.ListThemes("./Views");
     return(View());
 }
Ejemplo n.º 15
0
 public HotkeyForm()
 {
     InitializeComponent();
     ThemeUtil.Apply(this);
 }
Ejemplo n.º 16
0
 public HistoryForm()
 {
     componentsLayout();
     ThemeUtil.Apply(this);
 }
Ejemplo n.º 17
0
 public BugReportForm()
 {
     componentsLayout();
     ThemeUtil.Apply(this);
 }
Ejemplo n.º 18
0
 public MainForm()
 {
     componentsLayout();
     ThemeUtil.Apply(this);
 }
Ejemplo n.º 19
0
 protected void TrackBar_Capture(object sender, EventArgs e)
 {
     ThemeUtil.UpdateFocus(((TrackBar)sender).Handle);
 }
Ejemplo n.º 20
0
 public BugReportForm()
 {
     InitializeComponent();
     ThemeUtil.Apply(this);
 }