Ejemplo n.º 1
0
        bool ReloadBounds()
        {
            bool changed = false;

            Prefs pref = Abnaki.Windows.Software.Wpf.Profile.Preference.ReadClassPrefs <MainWindow, Prefs>();

            if (pref != null)
            {
                if (WpfScreenHelper.Screen.AllScreens.Any(sc => sc.WorkingArea.IntersectsWith(pref.Bounds)))
                {
                    this.Hide(); // show later
                    Top    = pref.Bounds.Top;
                    Left   = pref.Bounds.Left;
                    Width  = pref.Bounds.Width;
                    Height = pref.Bounds.Height;

                    this.WindowState = pref.State;
                    changed          = true;
                }
                else
                {
                    AbnakiLog.Comment(GetType().Name + " disregarded undisplayable bounds " + pref.Bounds);
                }
            }

            return(changed);
        }
Ejemplo n.º 2
0
        static void CompleteSetup(Abnaki.Windows.GUI.IWindow mainWindow, IDockSystem ds)
        {
            if (ds == null)
            {
                AbnakiLog.Comment("IDockSystem null");
            }
            else
            {
                ds.Defaults();

                mainWindow.SavingPanelLayout    += fi => ds.SerializeLayout(fi);
                mainWindow.RestoringPanelLayout += fi => ds.DeserializeLayout(fi);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Starts Application having Twindow as first thing user sees.
        /// </summary>
        /// <typeparam name="Tapp">System.Windows.Application, or subclass if necessary</typeparam>
        /// <typeparam name="Twindow">class of window</typeparam>
        /// <example>
        /// <code>
        /// [STAThread]
        /// public static int Main(string[] args)
        /// {  return Starter.Start &lt; YourApp,YourWin &gt;(args); }
        /// </code>
        /// </example>
        public static int Start <Twindow, Tapp>(string[] args, Func <Twindow> initWindow = null)
            where Tapp : System.Windows.Application, new()
            where Twindow : System.Windows.Window, new()
        {
            //Process proc = System.Diagnostics.Process.GetCurrentProcess();
            //ProcessStartInfo pistart = proc.StartInfo; // no use
            try
            {
                var starta = System.Reflection.Assembly.GetEntryAssembly();
                AbnakiLog.Comment("Start", starta.Location);
                AbnakiLog.Comment("Version", starta.GetName().Version);
                AbnakiLog.Comment("Operating System", Environment.OSVersion);
                AbnakiLog.Comment("Culture", System.Globalization.CultureInfo.CurrentCulture);

                // reconcile FrameworkElement Language with CurrentCulture, which is independent by default
                FrameworkElement.LanguageProperty.OverrideMetadata(
                    typeof(FrameworkElement),
                    new FrameworkPropertyMetadata(
                        System.Windows.Markup.XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

                System.AppDomain.CurrentDomain.AssemblyLoad += CurrentDomain_AssemblyLoad;

                Tapp app = new Tapp();

                app.DispatcherUnhandledException += Current_DispatcherUnhandledException;

                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                Twindow mw;
                if (initWindow == null)
                {
                    mw = new Twindow();
                }
                else
                {
                    mw = initWindow();
                }

                return(app.Run(mw));
            }
            catch (Exception ex)
            {
                Diplomat.Notifier.Error(ex);
                Diplomat.Troubleshooter.DialogSaveLog();
            }
            return(1); // failed
        }
Ejemplo n.º 4
0
        public void TestEntryOfEntries()
        {
            string f1 = "log1.xml";

            AbnakiLog.Comment("Vote Labour");
            AbnakiLog.Comment("Vote Tory");
            AbnakiLog.Write(f1);

            AbnakiLog.Comment("Should be followed by EntryOfEntries");
            AbnakiLog.Incorporate(f1);

            string f2 = "log2.xml";

            AbnakiLog.Write(f2);

            Debug.WriteLine("Wrote logs in " + Environment.CurrentDirectory);
        }