Example #1
0
        private void AssignTHC()
        {
            IHistoryCursor uctgfound = FindTHC();

            if ((uctgfound != null && !Object.ReferenceEquals(uctgfound, ucursor_inuse)) ||    // if got one but its not the one currently in use
                (uctgfound == null && !Object.ReferenceEquals(ucursor_history, ucursor_inuse)) // or not found, but we are not on the history one
                )
            {
                ucursor_inuse = (uctgfound != null) ? uctgfound : ucursor_history;    // select
                //System.Diagnostics.Debug.WriteLine("Children of " + this.GetHashCode() + " Change to " + ucursor_inuse.GetHashCode());

                (panelPlayfield.Controls[0] as SplitContainer).RunActionOnSplitterTree((p, c) =>        // runs on each split panel node exactly..
                {
                    UserControlCommonBase uccb = ((c is ExtendedControls.TabStrip) ? ((c as ExtendedControls.TabStrip).CurrentControl) : c) as UserControlCommonBase;
                    if (uccb != null)     // tab strip may not have a control set..
                    {
                        uccb.ChangeCursorType(ucursor_inuse);
                        //System.Diagnostics.Debug.WriteLine("Change cursor call to " + c.Name + " " + uccb.Name);
                    }
                });

                ucursor_inuse.FireChangeSelection();       // let the uctg tell the children a change event, so they can refresh
            }
            else
            {
                //System.Diagnostics.Debug.WriteLine("Children of " + this.GetHashCode() + " Stay on " + ucursor_inuse.GetHashCode());
            }

            UserControlTravelGrid tg = GetTravelGrid;       // this is called whenever deployment changes.. so see if TG is there..

            if (tg != null)
            {
                tg.OnKeyDownInCell -= Tg_OnKeyDownInCell;
                tg.OnKeyDownInCell += Tg_OnKeyDownInCell;
            }
        }
Example #2
0
        public override void LoadLayout()                   // cursor now set up, initial setup complete..
        {
            ucursor_history = uctg;                         // record base one
            ucursor_inuse   = FindTHC() ?? ucursor_history; // if we have a THC, use it, else use the history one
            string splitctrl = SQLiteConnectionUser.GetSettingString(DbWindows, "");

            //System.Diagnostics.Debug.WriteLine("--------------------" + splitctrl);
            //panelPlayfield.Controls[0].DumpTree(0);

            (panelPlayfield.Controls[0] as SplitContainer).RunActionOnSplitterTree((p, c) =>        // runs on each split panel node exactly..
            {
                UserControlCommonBase uccb = ((c is ExtendedControls.TabStrip) ? ((c as ExtendedControls.TabStrip).CurrentControl) : c) as UserControlCommonBase;
                if (uccb != null)     // tab strip may not have a control set..
                {
                    int tagid         = (int)c.Tag;
                    int displaynumber = DisplayNumberOfSplitter(tagid);                         // tab strip - use tag to remember display id which helps us save context.
                    System.Diagnostics.Trace.WriteLine("SP:Make UCCB " + uccb.GetType().Name + " tag " + tagid + " dno " + displaynumber);

                    uccb.Init(discoveryform, displaynumber);
                    uccb.SetCursor(ucursor_inuse);
                    uccb.LoadLayout();
                    discoveryform.theme.ApplyToControls(uccb);
                    uccb.InitialDisplay();
                }
            });

            Invalidate(true);
            Update();                                 // need this to FORCE a full refresh in case there are lots of windows

            UserControlTravelGrid tg = GetTravelGrid; // if travel grid, link up

            if (tg != null)
            {
                tg.OnKeyDownInCell += Tg_OnKeyDownInCell;
            }
        }
Example #3
0
        //EDDiscovery Init calls this
        public void CreateTabs(EDDiscoveryForm edf)
        {
            eddiscovery = edf;

            string majortabs = SQLiteConnectionUser.GetSettingString("MajorTabControlList", "");

            string[] majortabnames = null;
            int[]    tabctrl;

            if (!majortabs.RestoreArrayFromString(out tabctrl) || tabctrl.Length == 0 || (tabctrl.Length % 2) != 1) // need it odd as we have an index tab as first
            {
                tabctrl = new int[] { 0, -1, 0,                                                                     // reset..
                                      (int)PanelInformation.PanelIDs.Route, 0,
                                      (int)PanelInformation.PanelIDs.Expedition, 0,
                                      (int)PanelInformation.PanelIDs.Settings, 0,
                                      (int)PanelInformation.PanelIDs.PanelSelector, 0 };
            }
            else
            {
                majortabnames = SQLiteConnectionUser.GetSettingString("MajorTabControlName", "").Replace("!error!", "+").Split(';'); // if its okay, load the name list
            }
            TabPage history = TabPages[0];                                                                                           // remember history page, remove

            TabPages.Clear();

            UserControls.UserControlHistory uch = history.Controls[0] as UserControls.UserControlHistory;
            travelgrid = uch.GetTravelGrid;     // remember travel grid globally for later

            bool donehistory = false;

            for (int i = 1; i < tabctrl.Length; i += 2)
            {
                int    nameindex = (i - 1) / 2;
                string name      = majortabnames != null && nameindex < majortabnames.Length && majortabnames[nameindex].Length > 0 ? majortabnames[nameindex] : null;

                if (tabctrl[i] != -1)       // this means UserControlHistory, which is a special one
                {
                    try
                    {
                        PanelInformation.PanelIDs p = (PanelInformation.PanelIDs)tabctrl[i];
                        CreateTab(p, name, tabctrl[i + 1], TabPages.Count, false); // no need the theme, will be themed as part of overall load
                                                                                   // may fail if p is crap, then just ignore
                    }
                    catch { }                                                      // paranoia in case tabctrl number is crappy.
                }
                else if (!donehistory)                                             // just double check for repeats
                {
                    if (name != null)                                              // set name. if set.
                    {
                        history.Text = name;
                    }
                    TabPages.Add(history); // add back in right place
                    donehistory = true;
                }
            }

            if (!donehistory)                                                                         // just in case its missing.. be something up if it is.
            {
                TabPages.Add(history);                                                                // add back in right place
            }
            uch.Dock     = System.Windows.Forms.DockStyle.Fill;                                       // Crucial ! uccb has to be fill, even though the VS designer does not indicate you need to set it.. copied from designer code
            uch.Location = new System.Drawing.Point(3, 3);
            uch.Init(eddiscovery, null, UserControls.UserControlCommonBase.DisplayNumberHistoryGrid); // and init at this point with 0 as dn

            EnsureMajorTabIsPresent(PanelInformation.PanelIDs.PanelSelector, true);                   // just in case it disappears due to weirdness or debugging

            if (tabctrl.Length > 0 && tabctrl[0] >= 0 && tabctrl[0] < TabPages.Count)                 // make sure external data does not crash us
            {
                SelectedIndex = tabctrl[0];
            }
        }
        public void PopOut(PopOuts selected)
        {
            UserControlForm tcf = usercontrolsforms.NewForm(_discoveryForm.option_nowindowreposition);
            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EDDiscovery.EDDiscoveryForm));
            tcf.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));

            if (selected == PopOuts.Log)
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlLog)) + 1;

                UserControlLog uclog = new UserControlLog(); // Add a log
                tcf.Init(uclog, "Log " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame, "Log" + numopened, _discoveryForm.TopMost);
                uclog.Init(_discoveryForm, numopened);
                uclog.AppendText(_discoveryForm.LogText, _discoveryForm.theme.TextBackColor);
            }
            else if (selected == PopOuts.NS)
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlStarDistance)) + 1;

                UserControlStarDistance ucsd = new UserControlStarDistance(); // Add a closest distance tab
                tcf.Init(ucsd, "Nearest Stars " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame,  "StarDistance" + numopened, _discoveryForm.TopMost);

                ucsd.Init(_discoveryForm, numopened);
                if (lastclosestsystems != null)           // if we have some, fill in this grid
                    ucsd.FillGrid(lastclosestname, lastclosestsystems);
            }
            else if (selected == PopOuts.Materials)
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlMaterials)) + 1;

                UserControlMaterials ucmc = new UserControlMaterials(); // Add a closest distance tab
                tcf.Init(ucmc, "Materials " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame, "Materials" + numopened, _discoveryForm.TopMost);

                ucmc.Init(_discoveryForm, numopened);
                HistoryEntry curpos = userControlTravelGrid.GetCurrentHistoryEntry;
                if (curpos != null)
                    ucmc.Display(curpos.MaterialCommodity.Sort(false));
            }
            else if (selected == PopOuts.Commodities)
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlCommodities)) + 1;

                UserControlCommodities ucmc = new UserControlCommodities(); // Add a closest distance tab
                tcf.Init(ucmc, "Commodities " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame, "Commodities" + numopened, _discoveryForm.TopMost);

                ucmc.Init(_discoveryForm, numopened);
                HistoryEntry curpos = userControlTravelGrid.GetCurrentHistoryEntry;
                if (curpos != null)
                    ucmc.Display(curpos.MaterialCommodity.Sort(true));
            }
            else if (selected == PopOuts.Ledger)
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlLedger)) + 1;

                UserControlLedger ucmc = new UserControlLedger(); // Add a closest distance tab
                tcf.Init(ucmc, "Ledger " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame, "Ledger" + numopened, _discoveryForm.TopMost);

                ucmc.Init(_discoveryForm, numopened);
                ucmc.Display(_discoveryForm.history.materialcommodititiesledger);
                ucmc.OnGotoJID += GotoJID;
            }
            else if (selected == PopOuts.Journal)
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlJournalGrid)) + 1;  // used to determine name and also key for DB
                UserControlJournalGrid uctg = new UserControlJournalGrid();
                tcf.Init(uctg, "Journal History " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame, "JournalHistory" + numopened, _discoveryForm.TopMost);
                uctg.Init(_discoveryForm, numopened);
                uctg.Display(_discoveryForm.history);
                uctg.NoPopOutIcon();
                uctg.NoHistoryIcon();
            }
            else if (selected == PopOuts.TravelGrid)    // match order in bitmap mp and comboBoxCustomPopOut
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlTravelGrid)) + 1;  // used to determine name and also key for DB
                UserControlTravelGrid uctg = new UserControlTravelGrid();
                tcf.Init(uctg,"Travel History " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame, "TravelHistory" + numopened, _discoveryForm.TopMost);
                uctg.Init(_discoveryForm, numopened);
                uctg.Display(_discoveryForm.history);
                uctg.NoPopOutIcon();
                uctg.NoHistoryIcon();
            }
            else if (selected == PopOuts.ScreenShot)    // match order in bitmap mp and comboBoxCustomPopOut
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlScreenshot)) + 1;  // used to determine name and also key for DB
                UserControlScreenshot ucm = new UserControlScreenshot();
                tcf.Init(ucm, "ScreenShot " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame, "ScreenShot" + numopened, _discoveryForm.TopMost);
                ucm.Init(_discoveryForm, numopened);
            }
            else if (selected == PopOuts.Statistics)    // match order in bitmap mp and comboBoxCustomPopOut
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlStats)) + 1;  // used to determine name and also key for DB
                UserControlStats ucm = new UserControlStats();
                tcf.Init(ucm,"Statistics " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame, "Stats" + numopened, _discoveryForm.TopMost);
                ucm.Init(_discoveryForm, numopened);
                ucm.SelectionChanged(userControlTravelGrid.GetCurrentHistoryEntry, _discoveryForm.history);
            }
            else if (selected == PopOuts.Scan)
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlScan)) + 1;  // used to determine name and also key for DB
                UserControlScan ucm = new UserControlScan();
                tcf.Init(ucm, "Scan " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame, "Scan" + numopened, _discoveryForm.TopMost);
                tcf.InitForTransparency(false, _discoveryForm.theme.LabelColor, _discoveryForm.theme.SPanelColor);
                ucm.Init(_discoveryForm, numopened);
            }
            else if (selected == PopOuts.Spanel2)
            {
                int numopened = usercontrolsforms.CountOf(typeof(UserControlSpanel)) + 1;  // used to determine name and also key for DB
                UserControlSpanel ucm = new UserControlSpanel();
                tcf.Init(ucm, "Summary Panel " + ((numopened > 1) ? numopened.ToString() : ""), _discoveryForm.theme.WindowsFrame, "Spanel" + numopened, true);
                tcf.InitForTransparency(true, _discoveryForm.theme.LabelColor, _discoveryForm.theme.SPanelColor);
                ucm.Init(_discoveryForm, numopened);
            }

            tcf.Show();

            if ( tcf.UserControl != null )
                tcf.UserControl.Font = _discoveryForm.theme.GetFont;        // Important. Apply font autoscaling to the user control
                                                                        // ApplyToForm does not apply the font to the actual UC, only
                                                                        // specific children controls.  The TabControl in the discoveryform ends up autoscaling most stuff
                                                                        // the children directly attached to the discoveryform are not autoscaled

            _discoveryForm.theme.ApplyToForm(tcf);

            if (selected == PopOuts.Spanel2)                            // need to theme, before draw, as it needs the theme colours set up
                ((UserControlSpanel)tcf.UserControl).Display(_discoveryForm.history);
            if (selected == PopOuts.Scan)                            // need to theme, before draw, as it needs the theme colours set up
                ((UserControlScan)tcf.UserControl).Display(userControlTravelGrid.GetCurrentHistoryEntry, _discoveryForm.history);
        }