Ejemplo n.º 1
0
        public ExtensionManager(IPluginInterface pluginInterface)
        {
            this.pluginInterface = pluginInterface;

            plugins           = new List <PluginInfo>();
            disposablePlugins = new List <IDisposable>();
        }
Ejemplo n.º 2
0
 public PrintRenderer(IPluginInterface pluginInterface, int route)
 {
     this.pluginInterface = pluginInterface;
     this.tt    = pluginInterface.Timetable;
     this.route = route;
     attrs      = new TimetableStyle(tt);
 }
Ejemplo n.º 3
0
#pragma warning restore CS0649

        public NetworkTrainsEditForm(IPluginInterface pluginInterface) : base(pluginInterface.Timetable)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            this.pluginInterface = pluginInterface;
            tt           = pluginInterface.Timetable;
            backupHandle = pluginInterface.BackupTimetable();

            gridView.AddColumn <ITrain>(t => t.IsLink ? T._("L") : "", "");
            gridView.AddColumn <ITrain>(t => t.TName, T._("Zugnummer"));
            gridView.AddColumn <ITrain>(t => t.Locomotive, T._("Tfz"));
            gridView.AddColumn <ITrain>(t => t.Mbr, T._("Mbr"));
            gridView.AddColumn <ITrain>(t => t.Last, T._("Last"));
            gridView.AddColumn <ITrain>(t => t.Days.DaysToString(false), T._("Verkehrstage"));
            gridView.AddColumn <ITrain>(t => BuildPath(t), T._("Laufweg"));
            gridView.AddColumn <ITrain>(t => t.Comment, T._("Kommentar"));

            gridView.MouseDoubleClick += (s, e) => EditTrain(gridView, TrainDirection.tr, false);

            UpdateListView(gridView, TrainDirection.tr);

            if (Eto.Platform.Instance.IsWpf)
            {
                KeyDown += HandleKeystroke;
            }
            else
            {
                gridView.KeyDown += HandleKeystroke;
            }

            gridView.SelectedItemsChanged += GridViewOnSelectedItemsChanged;

            this.AddCloseHandler();
            this.AddSizeStateHandler();
        }
Ejemplo n.º 4
0
        public RenderSettingsForm(IPluginInterface pluginInterface) : this()
        {
            this.pluginInterface = pluginInterface;

            var designables = pluginInterface.GetRegistered <IAppearanceControl>();

            tabControl.SuspendLayout();
            tabControl.Pages.Clear();

            foreach (var d in designables)
            {
                var c  = d.GetControl(pluginInterface);
                var tp = new TabPage(c)
                {
                    Text = d.DisplayName
                };
                c.BackgroundColor = tp.BackgroundColor;
                tabControl.Pages.Add(tp);

                if (c is IAppearanceHandler sh)
                {
                    handlers.Add(sh);
                }
            }

            tabControl.ResumeLayout();

            expertCheckBox.Checked         = pluginInterface.Settings.Get <bool>("std.expert");
            expertCheckBox.CheckedChanged += ExpertCheckBox_CheckedChanged;
            ExpertCheckBox_CheckedChanged(this, null);
        }
Ejemplo n.º 5
0
        public static IPluginInterface[] GetPlugins(string directory)
        {
            if (String.IsNullOrEmpty(directory))
            {
                return(null);
            }                                                     //sanity check

            DirectoryInfo info = new DirectoryInfo(directory);

            if (!info.Exists)
            {
                return(null);
            }                                  //make sure directory exists

            List <IPluginInterface> plugins = new List <IPluginInterface>();

            foreach (FileInfo file in info.GetFiles("*.dll")) //loop through all dll files in directory
            {
                //using Reflection, load Assembly into memory from disk
                Assembly currentAssembly = Assembly.LoadFile(file.FullName);

                //Type discovery to find the type we're looking for which is IPluginInterface
                foreach (Type type in currentAssembly.GetTypes())
                {
                    //Create instance of class that implements IPluginInterface and cast it to type
                    //IPluginInterface and add it to our list
                    IPluginInterface plugin = (IPluginInterface)Activator.CreateInstance(type);
                    plugins.Add(plugin);
                }
            }

            return(plugins.ToArray());
        }
Ejemplo n.º 6
0
#pragma warning restore CS0649

        public StationStyleForm(IPluginInterface pluginInterface)
        {
            this.pluginInterface = pluginInterface;
            var tt    = pluginInterface.Timetable;
            var attrs = new TimetableStyle(tt);

            backupHandle = pluginInterface.BackupTimetable();

            Eto.Serialization.Xaml.XamlReader.Load(this);

            var cc = new ColorCollection(pluginInterface.Settings);
            var ds = new DashStyleHelper();

            var lineWidths = Enumerable.Range(1, 5).Cast <object>().ToArray();

            gridView.AddColumn <StationStyle>(t => t.Station.SName, T._("Name"));
            gridView.AddDropDownColumn <StationStyle>(t => t.HexColor, cc.ColorHexStrings, EtoBindingExtensions.ColorBinding(cc), T._("Farbe"), true);
            gridView.AddDropDownColumn <StationStyle>(t => t.StationWidthInt, lineWidths, Binding.Delegate <int, string>(i => i.ToString()), T._("Linienstärke"), true);
            gridView.AddDropDownColumn <StationStyle>(t => t.LineStyle, ds.Indices.Cast <object>(), Binding.Delegate <int, string>(i => ds.GetDescription(i)), T._("Linientyp"), true);
            gridView.AddCheckColumn <StationStyle>(t => t.Show, T._("Station zeichnen"), true);

            gridView.DataStore = tt.Stations.Select(s => new StationStyle(s, attrs)).ToArray();

            this.AddCloseHandler();
        }
Ejemplo n.º 7
0
        public void Initialize(IPluginInterface pi)
        {
            pluginInterface = pi;

            pluginInterface.FileStateChanged += (s, e) =>
            {
                if (IsDisposed)
                {
                    return;
                }

                ReloadRouteNames(lastFn != e.FileState.FileName);
                lastFn = e.FileState.FileName;
            };

            SelectedIndexChanged += (s, e) =>
            {
                if (SelectedIndex == -1)
                {
                    return;
                }
                selectedRoute = (int)((ListItem)Items[SelectedIndex]).Tag;

                SelectedRouteChanged?.Invoke(this, new EventArgs());
            };

            // Initialisieren der Daten
            ReloadRouteNames(true);
            SelectedIndex = 0;
        }
Ejemplo n.º 8
0
#pragma warning restore CS0649

        public SettingsControl(IPluginInterface pluginInterface)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            var tt = pluginInterface.Timetable;

            settings = pluginInterface.Settings;
            var chooser = Plugin.GetTemplateChooser(pluginInterface);

            templateComboBox.ItemTextBinding = Binding.Property <ITemplate, string>(t => t.TemplateName);
            templateComboBox.DataStore       = chooser.AvailableTemplates;

            var fntComboBox   = new FontComboBox(fontComboBox, exampleLabel);
            var hwfntComboBox = new FontComboBox(hwfontComboBox, hwexampleLabel);

            attrs                  = AfplAttrs.GetAttrs(tt) ?? AfplAttrs.CreateAttrs(tt);
            fontComboBox.Text      = attrs.Font;
            hwfontComboBox.Text    = attrs.HwFont;
            cssTextBox.Text        = attrs.Css ?? "";
            tracksCheckBox.Checked = attrs.ShowTracks;

            var tmpl = chooser.GetTemplate(tt);

            templateComboBox.SelectedValue = tmpl;

            consoleCheckBox.Checked = settings.Get <bool>("afpl.console");

            omitTracksSingleCheckBox.Checked = attrs.OmitTracksWhenSingle;
        }
Ejemplo n.º 9
0
#pragma warning restore CS0649

        public SettingsControl(IPluginInterface pluginInterface)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            var tt = pluginInterface.Timetable;

            settings = pluginInterface.Settings;
            var chooser = Plugin.GetTemplateChooser(pluginInterface);

            templateComboBox.ItemTextBinding = Binding.Delegate <ITemplate, string>(t => t.TemplateName);
            templateComboBox.DataStore       = chooser.AvailableTemplates;

            var fntComboBox = new FontComboBox(fontComboBox, exampleLabel);

            attrs                   = BfplAttrs.GetAttrs(tt) ?? BfplAttrs.CreateAttrs(tt);
            fontComboBox.Text       = attrs.Font ?? "";
            cssTextBox.Text         = attrs.Css ?? "";
            commentCheckBox.Checked = attrs.ShowComments;
            daysCheckBox.Checked    = attrs.ShowDays;

            var tmpl = chooser.GetTemplate(tt);

            templateComboBox.SelectedValue = tmpl;

            consoleCheckBox.Checked = settings.Get <bool>("bfpl.console");
        }
Ejemplo n.º 10
0
        public void Init(IPluginInterface pi, IComponentRegistry componentRegistry)
        {
            pluginInterface = pi;
            pluginInterface.FileStateChanged += PluginInterface_FileStateChanged;

#pragma warning disable CA2000
            var item = ((MenuBar)pluginInterface.Menu).CreateItem(T._("&jTrainGraph"));
#pragma warning restore CA2000

            startItem        = item.CreateItem(T._("jTrain&Graph starten"), enabled: false);
            startItem.Click += (s, e) =>
            {
                if (pluginInterface.Timetable.Type == TimetableType.Linear)
                {
                    StartLinear();
                }
                else
                {
                    StartNetwork(pluginInterface.FileState.SelectedRoute);
                }
            };

#pragma warning disable CA2000
            item.CreateItem(T._("Einstell&ungen"), clickHandler: (s, e) => (new SettingsForm(pluginInterface.Settings)).ShowModal(pluginInterface.RootForm));
#pragma warning restore CA2000
        }
Ejemplo n.º 11
0
        public LineEditForm(IPluginInterface pluginInterface, int route)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            this.pluginInterface = pluginInterface;
            this.route           = route;

            gridView.AddColumn <Station>(s => s.SName, T._("Bahnhof"));
            gridView.AddColumn <Station>(s => s.Positions.GetPosition(route).ToString(), T._("abs. Kilometr."));
            gridView.AddColumn <Station>(s => s.StationCode, T._("Abk."));
            gridView.AddColumn <Station>(s => s.StationType, T._("Typ"));
            gridView.AddColumn <Station>(s => s.Tracks.Count.ToString(), T._("Anzahl Gleise"));
            gridView.AddCheckColumn <Station>(s => s.RequestStop, T._("Bedarfshalt"));

            gridView.MouseDoubleClick += (s, e) => EditStation(false);

            if (Eto.Platform.Instance.IsWpf)
            {
                KeyDown += HandleKeystroke;
            }
            else
            {
                gridView.KeyDown += HandleKeystroke;
            }

            pluginInterface.FileStateChanged += OnFileStateChanged;
            Closing += (s, e) => pluginInterface.FileStateChanged -= OnFileStateChanged;

            InitializeGrid();

            this.AddCloseHandler();
            this.AddSizeStateHandler();
        }
Ejemplo n.º 12
0
        public SettingsControl(IPluginInterface pluginInterface)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            var tt = pluginInterface.Timetable;

            settings = pluginInterface.Settings;
            var chooser = Plugin.GetTemplateChooser(pluginInterface);

            templateComboBox.ItemTextBinding = Binding.Delegate <ITemplate, string>(t => t.TemplateName);
            templateComboBox.DataStore       = chooser.AvailableTemplates;

            var fntComboBox   = new FontComboBox(fontComboBox, exampleLabel);
            var hefntComboBox = new FontComboBox(hefontComboBox, heexampleLabel);

            attrs               = KfplAttrs.GetAttrs(tt) ?? KfplAttrs.CreateAttrs(tt);
            fontComboBox.Text   = attrs.Font;
            hefontComboBox.Text = attrs.HeFont;
            cssTextBox.Text     = attrs.Css ?? "";

            setRouteNumbers = new Dictionary <int, string>();
#pragma warning disable CA2000
            kbsnListView.AddColumn(new TextBoxCell
            {
                Binding = Binding.Delegate <Route, string>(r =>
                {
                    setRouteNumbers.TryGetValue(r.Index, out string val);
                    return(val ?? attrs.KBSn.GetValue(r.Index) ?? NO_KBS_TEXT);
                },
                                                           (r, n) => setRouteNumbers[r.Index] = n)
            }, "Name", editable: true
Ejemplo n.º 13
0
 public void LoadDLL(string file)
 {
     if (file.Contains(".dll"))
     {
         AssemblyName an       = AssemblyName.GetAssemblyName(file);
         Assembly     assembly = Assembly.Load(an);
         if (assembly != null)
         {
             Type[] types = assembly.GetTypes();
             foreach (Type type in types)
             {
                 if (type.IsInterface || type.IsAbstract)
                 {
                     continue;
                 }
                 else
                 {
                     if (type.GetInterface(pluginType.FullName) != null)
                     {
                         IPluginInterface plugin = (IPluginInterface)Activator.CreateInstance(type);
                         CConsole.PRINT(plugin.Name + " " + plugin.Version + " loaded successfully.");
                         FileInfo info = new FileInfo(file);
                         plugins.Add(info.Name.Replace(".dll", ""), plugin);
                         return;
                     }
                 }
             }
         }
         CConsole.WARN("It was unable to load '" + file + "'");
     }
     else
     {
         CConsole.WARN("'" + file + "' is not a .dll file");
     }
 }
Ejemplo n.º 14
0
        public LinearTrainsEditForm(IPluginInterface pluginInterface) : base(pluginInterface.Timetable)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);
            this.pluginInterface = pluginInterface;
            tt           = pluginInterface.Timetable;
            backupHandle = pluginInterface.BackupTimetable();

            InitListView(topGridView, new [] { topEditButton, topDeleteButton, topCopyButton });
            InitListView(bottomGridView, new [] { bottomEditButton, bottomDeleteButton, bottomCopyButton });

            topLineLabel.Text    = T._("Züge {0}", tt.GetLinearLineName(TOP_DIRECTION));
            bottomLineLabel.Text = T._("Züge {0}", tt.GetLinearLineName(BOTTOM_DIRECTION));
            UpdateListView(topGridView, TOP_DIRECTION);
            UpdateListView(bottomGridView, BOTTOM_DIRECTION);

            bottomGridView.MouseDoubleClick += (s, e) => EditTrain(bottomGridView, BOTTOM_DIRECTION, false);
            topGridView.MouseDoubleClick    += (s, e) => EditTrain(topGridView, TOP_DIRECTION, false);

            if (Eto.Platform.Instance.IsWpf)
            {
                KeyDown += HandleKeystroke;
            }

            this.AddCloseHandler();
            this.AddSizeStateHandler();
        }
Ejemplo n.º 15
0
        public void Init(IPluginInterface pluginInterface, IComponentRegistry componentRegistry)
        {
            this.pluginInterface  = pluginInterface;
            Style.pluginInterface = pluginInterface;

            dpf = new DynamicPreview();
            componentRegistry.Register <IPreviewAction>(dpf);
            pluginInterface.AppClosing += (s, e) => dpf.Close();

#if !DEBUG
            if (pluginInterface.Settings.Get <bool>("feature.enable-full-graph-editor"))
            {
#endif
            componentRegistry.Register <IExport>(new BitmapExport());

            pluginInterface.FileStateChanged += PluginInterface_FileStateChanged;

            var graphItem = ((MenuBar)pluginInterface.Menu).CreateItem("B&ildfahrplan");

            showItem         = graphItem.CreateItem("&Anzeigen", enabled: false, clickHandler: ShowItem_Click);
            configItem       = graphItem.CreateItem("Darste&llung ändern", enabled: false, clickHandler: (s, ev) => ShowForm(new ConfigForm(pluginInterface.Timetable, pluginInterface)));
            printItem        = graphItem.CreateItem("&Drucken", enabled: false, clickHandler: PrintItem_Click);
            trainColorItem   = graphItem.CreateItem("&Zugdarstellung ändern", enabled: false, clickHandler: (s, ev) => ShowForm(new TrainStyleForm(pluginInterface)));
            stationStyleItem = graphItem.CreateItem("&Stationsdarstellung ändern", enabled: false, clickHandler: (s, ev) => ShowForm(new StationStyleForm(pluginInterface)));
            overrideItem     = graphItem.CreateCheckItem("Verwende nur &Plandarstellung", isChecked: pluginInterface.Settings.Get <bool>("bifpl.override-entity-styles"),
                                                         changeHandler: OverrideItem_CheckedChanged);
#if !DEBUG
        }
#endif
        }
Ejemplo n.º 16
0
        public ConfigForm(Timetable tt, IPluginInterface pluginInterface)
        {
            Eto.Serialization.Xaml.XamlReader.Load(this);

            backupHandle = pluginInterface.BackupTimetable();

            this.tt = tt;
            this.pluginInterface = pluginInterface;

            heightPerHourValidator = new NumberValidator(heightPerHourTextBox, false, false, errorMessage: "Bitte eine Zahl als Höhe pro Stunde angeben!");
            startTimeValidator     = new TimeValidator(startTimeTextBox, false, errorMessage: "Bitte eine gültige Uhrzeit im Format hh:mm angeben!");
            endTimeValidator       = new TimeValidator(endTimeTextBox, false, errorMessage: "Bitte eine gültige Uhrzeit im Format hh:mm angeben!", maximum: new TimeEntry(48, 0));
            validators             = new ValidatorCollection(heightPerHourValidator, startTimeValidator, endTimeValidator);

            DropDownBind.Color <TimetableStyle>(pluginInterface.Settings, bgColorComboBox, "BgColor");
            DropDownBind.Color <TimetableStyle>(pluginInterface.Settings, stationColorComboBox, "StationColor");
            DropDownBind.Color <TimetableStyle>(pluginInterface.Settings, timeColorComboBox, "TimeColor");
            DropDownBind.Color <TimetableStyle>(pluginInterface.Settings, trainColorComboBox, "TrainColor");

            DropDownBind.Font <TimetableStyle>(stationFontComboBox, stationFontSizeComboBox, "StationFont");
            DropDownBind.Font <TimetableStyle>(timeFontComboBox, timeFontSizeComboBox, "TimeFont");
            DropDownBind.Font <TimetableStyle>(trainFontComboBox, trainFontSizeComboBox, "TrainFont");

            DropDownBind.Width <TimetableStyle>(hourTimeWidthComboBox, "HourTimeWidth");
            DropDownBind.Width <TimetableStyle>(minuteTimeWidthComboBox, "MinuteTimeWidth");
            DropDownBind.Width <TimetableStyle>(stationWidthComboBox, "StationWidth");
            DropDownBind.Width <TimetableStyle>(trainWidthComboBox, "TrainWidth");

            var styles = new Dictionary <StationLineStyle, string>()
            {
                [StationLineStyle.None]   = "Keine",
                [StationLineStyle.Normal] = "Gerade Linien",
                [StationLineStyle.Cubic]  = "Kubische Linien",
            };

            if (tt.Version == TimetableVersion.JTG2_x)
            {
                styles.Remove(StationLineStyle.Cubic);
            }
            DropDownBind.Enum <TimetableStyle, StationLineStyle>(stationLinesDropDown, "StationLines", styles);

            heightPerHourTextBox.TextBinding.AddFloatConvBinding <TimetableStyle, TextControl>(s => s.HeightPerHour);

            startTimeTextBox.TextBinding.AddTimeEntryConvBinding <TimetableStyle, TextControl>(s => s.StartTime);
            endTimeTextBox.TextBinding.AddTimeEntryConvBinding <TimetableStyle, TextControl>(s => s.EndTime);

            includeKilometreCheckBox.CheckedBinding.BindDataContext <TimetableStyle>(s => s.DisplayKilometre);
            drawStationNamesCheckBox.CheckedBinding.BindDataContext <TimetableStyle>(s => s.DrawHeader);
            stationVerticalCheckBox.CheckedBinding.BindDataContext <TimetableStyle>(s => s.StationVertical);
            multitrackCheckBox.CheckedBinding.BindDataContext <TimetableStyle>(s => s.MultiTrack);
            networkTrainsCheckBox.CheckedBinding.BindDataContext <TimetableStyle>(s => s.DrawNetworkTrains);

            networkTrainsCheckBox.Enabled = tt.Type == TimetableType.Network;

            attrs       = new TimetableStyle(tt);
            DataContext = attrs;

            this.AddCloseHandler();
        }
Ejemplo n.º 17
0
        public void Initialize(IPluginInterface pluginInterface)
        {
            this.pluginInterface = pluginInterface;
            Enabled   = pluginInterface.Settings.Get("files.save-last", true);
            lastFiles = pluginInterface.Settings.Get("files.last", "").Split(';').Where(s => s != "").Reverse().ToList();

            LastFilesUpdates?.Invoke(this, null);
        }
Ejemplo n.º 18
0
        public TemplateManager(RegisterStore store, IPluginInterface pluginInterface, string templatePath)
        {
            this.TemplatePath    = templatePath;
            this.store           = store;
            this.pluginInterface = pluginInterface;

            enabledTemplates = pluginInterface.Settings.Get("tmpl.enabled", "").Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
        }
Ejemplo n.º 19
0
        public Control GetControl(IPluginInterface pluginInterface)
        {
            var mg = new UpdateManager(pluginInterface.Settings);

#pragma warning disable CA2000
            var cb = new CheckBox {
                Text = T._("Automatische Überprüfung auf Updates beim Programmstart aktivieren.")
            };
            var privacyTitle = new Label {
                Text = T._("Datenschutz:"), Font = SystemFonts.Bold()
            };
            var label = new Label {
                Text = T._("Dabei wird Ihre IP-Adresse und der verwendete Betriebssystemtyp an den Server übermittelt; Die IP-Adresse wird nur anonymisiert in Log-Dateien gespeichert; ein Rückschluss auf einzelne Benutzer ist daher nicht möglich.")
            };
            var checkButton = new Button {
                Text = T._("Auf neue Version prüfen")
            };
#pragma warning restore CA2000
            var stack = new StackLayout(cb, privacyTitle, label, checkButton)
            {
                Padding     = new Padding(10),
                Orientation = Orientation.Vertical,
                Spacing     = 5
            };
            cb.CheckedBinding.Bind(() => mg.AutoUpdateEnabled, (b) => mg.AutoUpdateEnabled = b ?? false);

            checkButton.Click += (s, e) =>
            {
                mg.CheckResult = (newAvail, vi) =>
                {
                    if (newAvail)
                    {
                        DialogResult res = MessageBox.Show(T._("Eine neue Programmversion ({0}) ist verfügbar!\n{1}\nJetzt zur Download-Seite wechseln, um die neue Version herunterzuladen?", vi.NewVersion, vi.Description ?? ""),
                                                           T._("Neue FPLedit-Version verfügbar"), MessageBoxButtons.YesNo);

                        if (res == DialogResult.Yes)
                        {
                            OpenHelper.Open(vi.DownloadUrl);
                        }
                    }
                    else
                    {
                        MessageBox.Show(T._("Sie benutzen bereits die aktuelle Version!"),
                                        T._("Auf neue Version prüfen"));
                    }
                };
                mg.CheckError = ex =>
                {
                    MessageBox.Show(T._("Verbindung mit dem Server fehlgeschlagen!"),
                                    T._("Auf neue Version prüfen"));
                };

                mg.CheckAsync();
                checkButton.Enabled = false;
            };

            return(stack);
        }
Ejemplo n.º 20
0
 public void Invoke(IPluginInterface pluginInterface, Route route)
 {
     pluginInterface.StageUndoStep();
     using (var svf = new VelocityForm(pluginInterface, route))
         if (svf.ShowModal() == DialogResult.Ok)
         {
             pluginInterface.SetUnsaved();
         }
 }
Ejemplo n.º 21
0
 public void Invoke(IPluginInterface pluginInterface, Route route)
 {
     pluginInterface.StageUndoStep();
     using (var lef = new LineEditForm(pluginInterface, route.Index))
         if (lef.ShowModal(pluginInterface.RootForm) == DialogResult.Ok)
         {
             pluginInterface.SetUnsaved();
         }
 }
Ejemplo n.º 22
0
        /// <summary>
        /// Form to create a new station with a given route index.
        /// </summary>
        public EditStationForm(IPluginInterface pluginInterface, Timetable tt, int route) : this(tt, pluginInterface)
        {
            Title           = T._("Neue Station erstellen");
            this.route      = route;
            existingStation = false;
            Station         = new Station(tt);

            stationRenderer.InitializeWithStation(route, Station);
        }
Ejemplo n.º 23
0
        public void Init(IPluginInterface pluginInterface, IComponentRegistry componentRegistry)
        {
            this.pluginInterface              = pluginInterface;
            pluginInterface.ExtensionsLoaded += PluginInterface_ExtensionsLoaded;
            pluginInterface.FileStateChanged += PluginInterface_FileStateChanged;

            editRoot    = (ButtonMenuItem)((MenuBar)pluginInterface.Menu).GetItem(MainForm.LocEditMenu);
            previewRoot = (ButtonMenuItem)((MenuBar)pluginInterface.Menu).GetItem(MainForm.LocPreviewMenu);
        }
Ejemplo n.º 24
0
        public Control GetControl(IPluginInterface pluginInterface)
        {
            var linVersions = GetAvailableVersions(TimetableType.Linear);
            var netVersions = GetAvailableVersions(TimetableType.Network);

#pragma warning disable CA2000
            var linLabel = new Label {
                Text = T._("Lineare Fahrpläne")
            };
            var netLabel = new Label {
                Text = T._("Netzwerk-Fahrpläne")
            };

            var descriptionLabel = new Label
            {
                Text = T._("Hier kann die Dateiformatversion ausgewählt werden, mit der standardmäßig neue Dateien erstellt werden." +
                           "\n\nDie Auwahl der höchsten Dateiversion ist meist die richtige Lösung. Nur in Ausnahmefällen ist eine Anpassung " +
                           "sinnvoll, beispielsweise wenn eine ältere Version von jTrainGraph verwendet werden soll.\n" +
                           "Ein Öffnen von neueren Dateien in älteren Programmversionen ist oft nicht möglich.")
            };

            var linearDropDown = new DropDown {
                DataStore = linVersions.Cast <object>(), SelectedValue = Timetable.DefaultLinearVersion
            };
            linearDropDown.SelectedValueChanged += (s, e) =>
            {
                var linVersion = (TimetableVersion)linearDropDown.SelectedValue;
                Timetable.DefaultLinearVersion = linVersion;
                pluginInterface.Settings.SetEnum("core.default-file-format", linVersion);
            };

            var networkDropDown = new DropDown {
                DataStore = netVersions.Cast <object>(), SelectedValue = Timetable.DefaultNetworkVersion
            };
            networkDropDown.SelectedValueChanged += (s, e) =>
            {
                var netVersion = (TimetableVersion)networkDropDown.SelectedValue;
                Timetable.DefaultNetworkVersion = netVersion;
                pluginInterface.Settings.SetEnum("core.default-network-file-format", netVersion);
            };
#pragma warning restore CA2000

            var table = new TableLayout(new TableRow(new TableCell(), descriptionLabel),
                                        new TableRow(linLabel, linearDropDown),
                                        new TableRow(netLabel, networkDropDown),
                                        new TableRow()
            {
                ScaleHeight = true
            })
            {
                Spacing = new Size(5, 5)
            };

            return(table);
        }
        public static void LoadRunPlugin()
        {
            string pluginName = "TrendsPlugin.PluginDemo, TrendsPlugin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null";

            Type             pluginType     = Type.GetType(pluginName);
            object           pluginInstance = Activator.CreateInstance(pluginType);
            IPluginInterface plugin         = pluginInstance as IPluginInterface;

            string[] l = plugin.NavigateToSite("http://google.com");
            Console.WriteLine("Lines fetched: " + l.Length.ToString());
        }
Ejemplo n.º 26
0
 public void TryInit(IPluginInterface pluginInterface, IComponentRegistry componentRegistry)
 {
     try
     {
         plugin.Init(pluginInterface, componentRegistry);
     }
     catch (Exception ex)
     {
         pluginInterface.Logger.Error(T._("Fehler beim Initialisieren einer Erweiterung: {0}: + {1}", plugin.GetType().FullName, ex.Message));
     }
 }
Ejemplo n.º 27
0
        public TimetableCheckRunner(IPluginInterface pluginInterface)
        {
            var checks = pluginInterface.GetRegistered <ITimetableCheck>();

            pluginInterface.FileStateChanged += (s, e) =>
            {
                if (pluginInterface.Timetable == null)
                {
                    return;
                }

                var clone = pluginInterface.Timetable.Clone();

                if (lastTask != null && cancelTokenSource != null && !lastTask.IsCompleted && !cancelTokenSource.IsCancellationRequested)
                {
                    cancelTokenSource.Cancel();
                }

                cancelTokenSource = new CancellationTokenSource();

                lastTask = new Task(tk =>
                {
                    var token = (CancellationToken)tk;

                    var list = new List <string>();

                    foreach (var check in checks)
                    {
                        token.ThrowIfCancellationRequested();
                        list.AddRange(check.Check(clone));
                    }

                    token.ThrowIfCancellationRequested();

                    Application.Instance.Invoke(() =>
                    {
                        lock (uiLock)
                        {
                            if (list.Any() && form == null)
                            {
                                GetForm().Show();
                            }
                            if (gridView != null && gridView.Visible)
                            {
                                gridView.DataStore = list.ToArray();
                            }
                        }
                    });
                }, cancelTokenSource.Token, cancelTokenSource.Token);

                lastTask.Start();
            };
            pluginInterface.AppClosing += (s, e) => form?.Close();
        }
Ejemplo n.º 28
0
        public Window1()
        {
            InitializeComponent();
            show_log_window();
            debug("FFXIAI");
            debug("  author: framerate");
            debug("  version: 0.0.0.1");
            debug("  Starting...");

            ArrayList a = Processes.get_ffxi_processes();

            process_list_cb.Items.Clear();
            foreach (Process obj in a)
            {
                process_list_cb.Items.Add(obj.MainWindowTitle + " - " + obj.Id);
                debug("found PID: " + obj.MainWindowTitle + " - " + obj.Id);
            }

            if (process_list_cb.Items.Count == 1)
            {
                debug("Only one FFXI process found!");
                string polID = process_list_cb.Text;
                debug("Word: " + polID);
                int polIDPosition = polID.IndexOf(" - ");
                polID = polID.Remove(0, polIDPosition + 3);
                int pid = (int)Convert.ToUInt32(polID);
                debug("Attached to Process");
                //Processes.attach_process(pid);
            }

            debug(System.AppDomain.CurrentDomain.BaseDirectory);
            //System.IO.Path.Combine(System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath), @"settings/nav");
            //system.reflection.assembly.getexecutingassembly().location

            foreach (string Filename in Directory.GetFiles(Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "Plugins"), "*.dll"))
            {
                Assembly Asm = Assembly.LoadFile(Filename);
                foreach (Type AsmType in Asm.GetTypes())
                {
                    if (AsmType.GetInterface("IPluginInterface") != null)
                    {
                        IPluginInterface Plugin = (IPluginInterface)Activator.CreateInstance(AsmType);
                        Plugins.Add(Plugin);
                        debug("Plugin Loaded!");
                    }
                }
            }
            if (Plugins.Count == 0)
            {
                debug("No plugins found!");
            }
        }
        public MultipleTimetableEditForm(IPluginInterface pluginInterface) : this()
        {
            this.pluginInterface = pluginInterface;
            backupHandle         = pluginInterface.BackupTimetable();

            //editor.Initialize(info.Timetable, t);
            //Title = Title.Replace("{train}", t.TName);

            trainDropDown.ItemTextBinding       = Binding.Delegate <ITrain, string>(tr => tr.TName);
            trainDropDown.DataStore             = pluginInterface.Timetable.Trains;
            trainDropDown.SelectedIndexChanged += TrainDropDown_SelectedIndexChanged;
            trainDropDown.SelectedIndex         = 0;
        }
Ejemplo n.º 30
0
        public TempLogger(IPluginInterface pluginInterface)
        {
            filename = pluginInterface.GetTemp("fpledit_log.txt");

            var fi = new FileInfo(filename);

            if (fi.Exists && fi.Length > 10240) // > 10KB
            {
                fi.Delete();
            }

            Info("Started FPLedit");
        }