示例#1
0
 public /* Interface KGuiControl */ void GuiSaveInput()
 {
     try {
         string path = WinControls.CreateKaemikaDataDirectory() + "\\save.txt";
         File.WriteAllText(path, this.GuiInputGetText());
     } catch (Exception) { }
 }
示例#2
0
        // ====  KGuiControl INTERFACE =====

        public /* Interface KGuiControl */ void GuiInputSetEditable(bool editable)
        {
            if (!this.InvokeRequired)
            {
                WinControls.SetEditable(editable);
            }
            else
            {
                this.Invoke((Action) delegate { GuiInputSetEditable(editable); });
            }
        }
示例#3
0
 public TightButton(bool hover, bool multiline) : base()
 {
     this.hover                   = hover;
     this.multiline               = multiline;
     mouseEntered                 = false;
     ownText                      = "";
     this.ownFormat               = new StringFormat();
     this.ownFormat.Alignment     = StringAlignment.Near;
     this.ownFormat.LineAlignment = StringAlignment.Near;
     WinControls.AutoSizeButton(this); // but autosize only until a Text is assigned, or if multiline
 }
示例#4
0
 public /* Interface KGuiControl */ void GuiRestoreInput()
 {
     try {
         string path = WinControls.CreateKaemikaDataDirectory() + "\\save.txt";
         if (File.Exists(path))
         {
             this.GuiInputSetText(File.ReadAllText(path));
         }
         else
         {
             this.GuiInputSetText(SharedAssets.TextAsset("StartHere.txt"));
         }
     } catch (Exception) { }
 }
示例#5
0
        // ON LOAD

        private void GuiToWin_Load(object sender, EventArgs e)
        {
            this.texter = new PlatformTexter();
            fonts       = new Dictionary <float, Font>();
            fontsFixed  = new Dictionary <float, Font>();

            // Register this Gui for platform-independent access via interface KGuiControl
            KGui.Register(this);

            // Register this Gui for platform-independent access via interface KControls
            winControls = new WinControls();             // set up platform-specific gui controls
            KGui.Register(new KControls(winControls));   // bind actions to them (non-platform specific) and register them throug KGui

            txtInput.MouseClick     += (object ms, MouseEventArgs me) => { KGui.kControls.CloseOpenMenu(); };
            txtOutput.MouseClick    += (object ms, MouseEventArgs me) => { KGui.kControls.CloseOpenMenu(); };
            panel1.MouseDown        += (object ms, MouseEventArgs me) => { Title_MouseDown(ms, me); KGui.kControls.CloseOpenMenu(); };
            panel1.MouseUp          += (object ms, MouseEventArgs me) => { Title_MouseUp(ms, me); };
            panel1.MouseMove        += (object ms, MouseEventArgs me) => { Title_MouseMove(ms, me); };
            panel2.MouseDown        += (object ms, MouseEventArgs me) => { Title_MouseDown(ms, me); KGui.kControls.CloseOpenMenu(); };
            panel2.MouseUp          += (object ms, MouseEventArgs me) => { Title_MouseUp(ms, me); };
            panel2.MouseMove        += (object ms, MouseEventArgs me) => { Title_MouseMove(ms, me); };
            panel_Splash.MouseClick += (object ms, MouseEventArgs me) => { KGui.kControls.CloseOpenMenu(); };

            this.KeyPreview = true; // used to detect shift key down

            //AutoScaleMode and AutoScaleDimensions are set in the GUI editor
            this.Width  = Math.Min(this.Width, Screen.PrimaryScreen.Bounds.Size.Width);
            this.Height = Math.Min(this.Height, Screen.PrimaryScreen.Bounds.Size.Height);
            this.CenterToScreen();

            this.BackColor        = WinControls.cMainButtonDeselected;
            this.panel1.BackColor = WinControls.cMainButtonDeselected;
            this.panel2.BackColor = WinControls.cMainButtonDeselected;
            this.splitContainer_Columns.BackColor = WinControls.cMainButtonDeselected;

            // Splash screen

            this.panel_Splash.Location = this.panel_KChart.Location;
            this.panel_Splash.Size     = this.panel_KChart.Size;
            this.panel_Splash.BringToFront();
            this.panel_Splash.Visible = true;

            // Text

            WinControls.SetTextFont(WinControls.currentFontSize, true);
            WinControls.SetEditable(true);

            // Device

            this.panel_Microfluidics.Controls.Add(new DeviceSKControl());
            this.panel_Microfluidics.BackColor = Extensions.ToDrawingColor(KDeviceHandler.deviceBackColor);

            // KChart

            this.panel_KChart.Controls.Add(new KChartSKControl());
            this.panel_KChart.BackColor = Color.White;

            // KScore

            this.panel_KScore.Controls.Add(new KScoreSKControl());
            this.panel_KScore.BackColor = Color.White;

            // Saved state

            winControls.RestorePreferences();            // needs winControls initialized
            GuiRestoreInput();
        }