コード例 #1
0
ファイル: Stylist.cs プロジェクト: rdterner/fcmd
        /// <summary>Apply the specified selector (style) to the specified widget</summary>
        /// <param name="Widget">The widget that should "got" the style</param>
        /// <param name="Pattern">The specified selector with the desired style</param>
        public void ApplyStyle(Widget Widget, string Pattern)
        {
            if (Widget.GetType() == typeof(Label)) { ApplyStyle((Label)Widget, Pattern); return; }
            if (Widget.GetType() == typeof(Box)) { ApplyStyle((Box)Widget, Pattern); return; }

            Selector Selector = CSS[Pattern];

            if (Selector.Declarations["background-color"].Value != "inherit")
            Widget.BackgroundColor =
            Utilities.GetXwtColor(
                Selector.Declarations["background-color"].Value
            );

            if (Selector.Declarations["font-family"].Value != "inherit")
            Widget.Font = Font.FromName(
                Selector.Declarations["font-family"].Value
            );

            Widget.Visible = Selector.Declarations["display"].Value != "none";
        }
コード例 #2
0
ファイル: VEd.cs プロジェクト: Break-Neck/fcmd
        /// <summary>Load the file in the VE</summary>
        /// <param name="URL">The URL of the file</param>
        /// <param name="FS">The filesystem of the file</param>
        /// <param name="plugin">The VE plugin, which will be used to load this file</param>
        /// <param name="AllowEdit">Allow editing the file</param>
        public void LoadFile(string URL, IFSPlugin FS, IVEPlugin plugin, bool AllowEdit)
        {
            //check for external editor
            try{
                if (Settings.Default.UseExternalEditor && AllowEdit || Settings.Default.UseExternalViewer && !AllowEdit && URL.StartsWith("file:")){
                    CanBeShowed = false;
                    if (AllowEdit){
                        ExecuteProgram(Settings.Default.ExternalEditor.Replace("$", "\"" + URL));
                    }
                    else{
                        ExecuteProgram(Settings.Default.ExternalViewer.Replace("$", "\"" + URL));
                    }
                    return;
                }
            }
            catch (Exception ex) { MessageDialog.ShowError(Localizator.GetString("CantRunEXE"), ex.Message); CanBeShowed = false; return; }

            FileNameForTitle = URL.Substring(URL.LastIndexOf(FS.DirSeparator, StringComparison.Ordinal) + 1);
            IsEditor = AllowEdit;

            if(AllowEdit)
                Title = string.Format(Localizator.GetString("FCETitle"), FileNameForTitle);
            else
                Title = string.Format(Localizator.GetString("FCVTitle"), FileNameForTitle);

            FileProcessDialog ProgressDialog = new FileProcessDialog();
            string ProgressInitialText = String.Format(Localizator.GetString("FCVELoadingMsg"),URL);
            ProgressDialog.lblStatus.Text = ProgressInitialText;
            FS.ProgressChanged += d => { ProgressDialog.pbrProgress.Fraction = (d >= 0 && d <= 1) ? d : ProgressDialog.pbrProgress.Fraction; Xwt.Application.MainLoop.DispatchPendingEvents();  };
            FS.StatusChanged += d => { ProgressDialog.lblStatus.Text = ProgressInitialText + "\n" + d; Xwt.Application.MainLoop.DispatchPendingEvents(); };
            ProgressDialog.cmdCancel.Clicked += (o, ea) => { CanBeShowed = false; ProgressDialog.Close(); };
            ProgressDialog.Show();
            Xwt.Application.MainLoop.DispatchPendingEvents();

            if (!CanBeShowed) return;

            try {
                Plugin = plugin;
                Plugin.ReadOnly = !AllowEdit;
                Plugin.OpenFile(URL, FS);
                Plugin.ShowToolbar = Settings.Default.VE_ShowToolbar;
                Plugin.Stylist = s;
                mnuFormat.SubMenu = Plugin.FormatMenu;

                bool Mode = AllowEdit;

                if (!Plugin.CanEdit && AllowEdit)
                {
                    MessageDialog.ShowWarning(String.Format(Localizator.GetString("FCVEpluginro1"), Plugin.Name + " " + Plugin.Version), Localizator.GetString("FCVEpluginro2"));
                    Mode = false;
                }

                FSPlugin = FS;
                PluginBody = Plugin.Body;

            SetVEMode(Mode);
            }
            catch (Exception ex)
            {
                MessageDialog.ShowWarning(ex.Message);
                if(PluginBody.GetType() == typeof(Spinner)) { ProgressDialog.Close(); CanBeShowed = false; return;}
            }
            BuildLayout();
            ProgressDialog.Close();
        }
コード例 #3
0
ファイル: Stylist.cs プロジェクト: rdterner/fcmd
        /// <summary>Enable theming of the widget</summary>
        /// <param name="Widget">The widget that needs to be themized</param>
        /// <param name="Selector">The selector pattern</param>
        public void Stylize(Widget Widget, string Selector = "Widget")
        {
            if (!semaphore) {
                semaphore = true;
                Stylize(Widget, Selector); //apply default style for all widgets
                try {
                    Stylize(Widget, Widget.GetType().ToString().Substring(Widget.GetType().ToString().IndexOf('.') + 1)); //apply default style for the widget type
                }
                catch { Console.WriteLine("NOTICE: No style is set for widgets of type " + Widget.GetType().ToString().Substring(Widget.GetType().ToString().IndexOf('.') + 1)); }
                semaphore = false;
            }

            ApplyStyle(Widget, Selector);

            Widget.MouseEntered+=(o,ea)=> ApplyStyle(Widget, Selector + ":hover");

            Widget.MouseExited+=(o,ea)=>
            {
                ApplyStyle(Widget, Selector);
                if (Widget.HasFocus)
                    ApplyStyle(Widget, Selector + ":focus");
            };

            Widget.ButtonPressed+=(o,ea)=> ApplyStyle(Widget, Selector + ":active");

            Widget.GotFocus+=(o,ea)=> ApplyStyle(Widget, Selector + ":focus");

            Widget.LostFocus += (o, ea) => ApplyStyle(Widget, Selector);

            Widget.ButtonReleased+=(o,ea)=>
            {
                ApplyStyle(Widget, Selector);
                if (Widget.HasFocus)
                    ApplyStyle(Widget, Selector + ":focus");
            };
        }