Exemplo n.º 1
0
        // }}}
        //}}}

        // LOG //{{{
        public string get_status() //{{{
        {
            string reader_status
                = ((connected)
                ? " === " + Settings.APP_NAME + " IS CONNECTED"
                : " *** " + Settings.APP_NAME + " NOT CONNECTED")
                  + "\n";

            string timestamp = "missing timestamp";

            if (Settings.PRODATE > 0)
            {
                System.DateTime dt = new System.DateTime(1970, 1, 1, 0, 0, 0);
                dt        = dt.AddSeconds(Settings.PRODATE).ToLocalTime();
                timestamp = dt.ToString("yyyy-MMM-dd HH:mm:ss");
            }
            string profile         = " @@@ [" + Settings.PROFILE + "] [" + Settings.PRODATE + "] [" + timestamp + "]\n";
            string tabs_status     = " === x" + MainFormInstance.tabsCollection.tabs_Dictionary.Count + " Tabs\n";
            string palettes_status = " === x" + NotePane.GetColorPaletteCount() + " Color palettes\n";

            string msg = ""
                         + reader_status
                         + profile
                         + tabs_status
                         + palettes_status
            ;

            return(msg);
        }
Exemplo n.º 2
0
        //}}}
        // DESIGNER LIFE-CYCLE {{{
        public void ClientServerButtons(MainForm mainForm) // {{{
        {
            MainFormInstance = mainForm;


            control_start = MainFormInstance.tabsCollection.update_control(NotePane.CONTROL_NAME_START, NotePane.CONTROL_LABEL_START);
            control_start.TT
                = "Open DESIGNER-SERVER connection"
                ;
            control_stop = MainFormInstance.tabsCollection.update_control(NotePane.CONTROL_NAME_STOP, NotePane.CONTROL_LABEL_STOP);
            control_stop.TT
                = "Close DESIGNER-SERVER connection"
                ;
            control_hide = MainFormInstance.tabsCollection.update_control("Hide");
            control_hide.TT
                = "Minimize application window"
                ;
            control_stop_server = MainFormInstance.tabsCollection.update_control("Stop Server");
            control_stop_server.TT
                = "Send the stop-service request to the server (not really useful btw)"
                ;
            control_ADB = MainFormInstance.tabsCollection.update_control(NotePane.CONTROL_NAME_ADB, NotePane.CONTROL_LABEL_ADB);
            control_ADB.TT
                = NotePane.CONTROL_LABEL_ADB
                ;

/*
 *          control_send_tabs       = MainFormInstance.tabsCollection.update_control("SEND TABS"                );
 *          control_get_tabs        = MainFormInstance.tabsCollection.update_control("GET TABS"                 );
 *          control_send_palettes   = MainFormInstance.tabsCollection.update_control("SEND PALETTES"            );
 *          control_get_palettes    = MainFormInstance.tabsCollection.update_control("GET PALETTES"             );
 */
        }
Exemplo n.º 3
0
        //}}}
        // SERVER LIFE-CYCLE {{{
        public void ClientServerButtons(MainForm mainForm) // {{{
        {
            MainFormInstance        = mainForm;
            Server.MainFormInstance = MainFormInstance;

            control_start = MainFormInstance.tabsCollection.update_control(NotePane.CONTROL_NAME_START, NotePane.CONTROL_LABEL_START);
            control_start.TT
                = "Open server connection"
                ;
            control_stop = MainFormInstance.tabsCollection.update_control(NotePane.CONTROL_NAME_STOP, NotePane.CONTROL_LABEL_STOP);
            control_stop.TT
                = "Close server connection"
                ;
            control_hide = MainFormInstance.tabsCollection.update_control("Hide");
            control_hide.TT
                = "Minimize application Window into the System Tray"
                ;
            control_autostart    = MainFormInstance.tabsCollection.update_control("Auto-Start");
            control_autostart.TT = "Sends the START WITH WINDOWS\nrequest to the Task Scheduler";


            control_ADB = MainFormInstance.tabsCollection.update_control(NotePane.CONTROL_NAME_ADB, NotePane.CONTROL_LABEL_ADB);
            control_ADB.TT
                = NotePane.CONTROL_LABEL_ADB
                ;
        }
Exemplo n.º 4
0
        // http://stackoverflow.com/questions/18017044/insert-image-at-cursor-position-in-rich-text-box {{{

        // public methods
        public static string embedImage(NotePane np, string fileName)// {{{
        {
            var img = Image.FromFile(fileName);

            var sb = new StringBuilder();

            sb.Append(@"{\rtf1\ansi\ansicpg1252\deff0\deflang1033");    // header
            sb.Append(getFontTable(np.Font));                           // font table
            sb.Append(@"\fs" + NotePane.CONTROL_NAME_FONT_SIZE + @"\b \bullet  " + np.Name + @"\b0  (" + fileName.Substring(fileName.LastIndexOf("\\") + 1) + @")\line ");
            sb.Append(getImagePrefix(img, np));                         // image control
            sb.Append(getRtfImage(img, np));                            // metafile bytes in HEX format
            sb.Append(@"}");                                            // close image control

            return(sb.ToString());
        }
Exemplo n.º 5
0
        //}}}


        private void control_autostart_Click()// {{{
        {
            log("EVENTS", "control_autostart_Click");

            // DONE ALREADY
            panel_autostart = MainFormInstance.tabsCollection.get_tab_NP(NotePane.PANEL_NAME_AUTOSTART);
            if ((panel_autostart != null) && panel_autostart.Visible)
            {
                panel_autostart.Hide();
                return;
            }

            // PERFORM TASK
            if (ServerHelper.IsUserAdministrator())
            {
                // CLEAR PREVIOUS LOG
                if (panel_autostart != null)
                {
                    panel_autostart.Text = "";
                }

                if (ScheduleTask.AddNewTask(Settings.APP_NAME, Settings.APP_NAME + " auto-start"))
                {
                    MessageBox.Show(
                        "Schedule task added for " + Settings.APP_NAME + " auto-start"
                        , Settings.APP_NAME
                        , MessageBoxButtons.OK
                        , MessageBoxIcon.Information
                        );
                }

                // SHOW LAST LOG
                panel_autostart = MainFormInstance.tabsCollection.get_tab_NP(NotePane.PANEL_NAME_AUTOSTART);
                if ((panel_autostart != null) && !panel_autostart.Visible)
                {
                    panel_autostart.Show();
                }
            }
            else
            {
                MessageBox.Show(
                    "*** " + Settings.APP_TITLE + " must be \"Run as Administrator\" in order to add a Schedule task"
                    , Settings.APP_NAME
                    , MessageBoxButtons.OK
                    , MessageBoxIcon.Error
                    );
            }
        }
Exemplo n.º 6
0
        // }}}
        // CONSTRUCT {{{
        public HelpForm(string title)// {{{
        {
            InitializeComponent();
            tabsCollection = new Util.TabsCollection(this, tabs_container);
            closed         = false;
            this.title     = title;

            // BUILTIN BUTTONS
            control_close = tabsCollection.update_control("Close");
            //tton_close        .MouseClick += new System.Windows.Forms.MouseEventHandler(this.control_close_Click);

            control_close.Left   = 0;
            control_close.Top    = 0;
            control_close.Width  = Width - 10;
            control_close.Height = 80;
            control_close.Anchor = ((System.Windows.Forms.AnchorStyles)
                                        (((System.Windows.Forms.AnchorStyles.Top
                                           | System.Windows.Forms.AnchorStyles.Left)
                                          | System.Windows.Forms.AnchorStyles.Right)));
            control_close.Padding = new System.Windows.Forms.Padding(10, 10, 10, 10);
            //  control_close.Rtf = @"{\rtf1\ansi\fs32\b Close Help\b0}";
            control_close.LabelPrefix = @"\fs32\b";

            // BUILTIN PANELS
            panel_help        = tabsCollection.update_panel("panel_help", "panel_help");
            panel_help.Left   = 0;
            panel_help.Top    = control_close.Height + 10;
            panel_help.Width  = Width - 10;
            panel_help.Height = panel_help.Parent.Height - control_close.Height - 10;;
            panel_help.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                                                                       | System.Windows.Forms.AnchorStyles.Left)
                                                                      | System.Windows.Forms.AnchorStyles.Right)));
            panel_help.Location = new System.Drawing.Point(0, control_close.Height + 5);
            panel_help.Padding  = new System.Windows.Forms.Padding(10, 10, 50, 10);

            panel_help.BackColor    = Color.Yellow;
            panel_help.TextBox.Font = new System.Drawing.Font("Comic sans ms", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            panel_help.Width        = Width - 10;

            //  panel_help.Rtf          = @"{\rtf1\ansi\fs20\b " + panel_help.Name +@"\b0:\line}";
            control_close.LabelPrefix = @"\fs20\b";
        }
Exemplo n.º 7
0
        // }}}
        public void ClientServer_callback(System.Object caller, string detail)// {{{
        {
            log("EVENTS", "DesignerForm.ClientServer_callback:\n.caller=[" + caller + "]\n.detail=[" + detail + "]");

            // UI BUTTONS (connect disconnect server_stop win_start_menu task_mgr)
            if (caller == control_hide)
            {
                control_hide_Click();
            }
            else if (caller == control_start)
            {
                control_start_Click();
            }
            else if (caller == control_stop)
            {
                control_stop_Click();
            }
            else if (caller == control_stop_server)
            {
                control_stop_server_Click();
            }
            else if (caller == control_ADB)
            {
                MainFormInstance.control_ADB_Click((NotePane)caller);
            }

            // TYPE_SHORTCUT {{{
            else
            {
                NotePane np = (NotePane)caller;
                if (np.Type == NotePane.TYPE_SHORTCUT)
                {
                    try {
                        // parse
                        string cmdLine = np.Tag.ToString();
                        cmdLine = parse_cmdLine("ClientServer_callback", cmdLine);

                        // send
                        if (cmdLine != "")
                        {
                            // URL
                            if (cmdLine.StartsWith("http:") ||
                                cmdLine.StartsWith("https:") ||
                                cmdLine.StartsWith("file:")
                                )
                            {
                                cmdLine = "SHELL " + cmdLine;
                                //cmdLine = cmdLine.Replace(Settings.PROFILES_DIR, Settings.PROFILES_DIR_PATH); // server responsibility
                                log("COMM", "Bare URL cmdLine set to [" + cmdLine + "]");
                            }
                            if (Settings.IsABuiltinCmdLine(cmdLine))
                            {
                                send_cmd(cmdLine);
                            }
                            else if (Settings.can_parse_KEY_VAL(cmdLine))
                            {
                                send_cmd("SendKeys", cmdLine);
                            }
                            else if ("" != (cmdLine))
                            {
                                send_cmd("SendKeys", cmdLine);
                            }
                            else if (Settings.IsADashCmdLine(cmdLine))
                            {
                                send_cmd("SendDash", cmdLine + " " + np.Text);
                            }
                        }
                    }
                    catch (Exception) { }
                }
            }
            //}}}
        }
Exemplo n.º 8
0
 // }}}
 public string ClientServer_get_BOM() //{{{
 {
     return(NotePane.get_BOM());      // color palettes
 }
Exemplo n.º 9
0
        //}}}


        // LoadXMLProfile {{{
        public static List <NotePane> LoadXMLProfile(string profileName)
        {
            log("ProfileManager.LoadXMLProfile(" + profileName + "):");

            List <NotePane> np_list = new List <NotePane>();

            // access file
            string filePath = Settings.UserProfileFolder + profileName + XML_EXTENSION;

            if (!System.IO.File.Exists(filePath))
            {
                log("***file not found:\n" + filePath);
                return(np_list);
            }

            // load file
            XmlTextReader reader = null;

            try {
                NotePane np           = null;
                bool     reading_node = false;
                reader = new XmlTextReader(filePath);
                while (reader.Read())
                {
                    // TAB {{{
                    if (reader.Name == XMLTAG_TAB)
                    {
                        if (reader.NodeType == XmlNodeType.Element)
                        {
                            np           = new NotePane();
                            reading_node = true;
                        }
                        else if (reader.NodeType == XmlNodeType.EndElement)
                        {
                            if (np.Type != 0)
                            {
                                np_list.Add(np);
                            }
                            reading_node = false;
                        }
                    }
                    //}}}
                    AutoPlacePoint_INCR;// TAB elements {{{
                    else if (reading_node)
                    {
                        if (reader.Name == XMLTAG_TYPE)
                        {
                            np.Type = ((string)reader.ReadElementContentAs(typeof(string), "")).Trim();
                        }
                        else if (reader.Name == XMLTAG_TAG)
                        {
                            np.Tag = ((string)reader.ReadElementContentAs(typeof(string), "")).Trim();
                        }
                        else if (reader.Name == XMLTAG_ZOOM)
                        {
                            np.zoom = ((string)reader.ReadElementContentAs(typeof(string), "")).Trim();
                        }
                        else if (reader.Name == XMLTAG_XY_WH)
                        {
                            np.xy_wh = ((string)reader.ReadElementContentAs(typeof(string), "")).Trim();
                        }
                        else if (reader.Name == XMLTAG_TEXT)
                        {
                            np.text = ((string)reader.ReadElementContentAs(typeof(string), "")).Trim();
                        }
                        else if (reader.Name == XMLTAG_TT)
                        {
                            np.tt = ((string)reader.ReadElementContentAs(typeof(string), "")).Trim();
                        }
                    }
                    //}}}
                }
Exemplo n.º 10
0
 // }}}
 public void notify(NotePane np, string detail)// {{{
 {
 }
Exemplo n.º 11
0
        public static DialogResult ShowDialog(NotePane np, string tag_old, out string tag_new)
        {
            // SINGLETON -  {{{
            int x, y, w, h;

            if (ttf == null)
            {
                ttf = new TabTagForm();

                // START POSITION .. parent middle
                x = Settings.MainFormInstance.Location.X;
                y = Settings.MainFormInstance.Location.Y
                    + Settings.MainFormInstance.ClientSize.Height / 2
                    - ttf.ClientSize.Height / 2
                ;
                ttf.Location = new Point(x, y);

                // Start Dimension .. fit parent width
                w = Settings.MainFormInstance.ClientSize.Width;
                h = ttf.ClientSize.Height;
                ttf.ClientSize = new Size(w, h);

                ToolTip toolTip = new System.Windows.Forms.ToolTip();
                toolTip.BackColor = Settings.MainFormInstance.BackColor;
                toolTip.ForeColor = Settings.MainFormInstance.ForeColor;

                toolTip.SetToolTip(ttf.btn_ok, "EDIT: apply changes");
                toolTip.SetToolTip(ttf.btn_activate, "EDIT: activate / desactivate");
                toolTip.SetToolTip(ttf.btn_cancel, "EDIT: ignore changes");

                toolTip.SetToolTip(ttf.btn_RUN, "SERVER: RUN EXECUTABLE\n ...as a new process");
                toolTip.SetToolTip(ttf.btn_SHELL, "SERVER: OPEN FILE\n...with the default related application");
                toolTip.SetToolTip(ttf.btn_SENDKEYS, "SERVER: SEND KEYS TO THE CURRENT WINDOW\n ...as they would come from the KEYBOARD");
                toolTip.SetToolTip(ttf.btn_PROFILE, "SERVER: LOAD PROFILE");

                toolTip.SetToolTip(ttf.lbl_INFO, "Send SHIFT-ESCAPE to the TAB PANEL\nto reset RichText attributes\n(i.e. ZoomFactor, ...)");
            }
            //}}}

            // TAB NAME - (StartPosition - Manual) {{{
            ttf.Text = Settings.APP_NAME;
            ttf.lbl_tab_name.Text = np.Name;

            // }}}
            // DISPLAY CURRENT TAG COMMAND // {{{
            if (!string.IsNullOrEmpty(tag_old))
            {
                ttf.txt_current.Text = tag_old;
                ttf.txt_input.Text   = tag_old;
            }
            // }}}
            // CLONE NotePane {{{
            ttf.np              = np;
            ttf.np_clone        = NotePane.Clone(ttf.np);
            ttf.np_clone.Parent = ttf;

            x = ttf.btn_ok.Location.X + ttf.btn_ok.ClientSize.Width + 8;
            y = ttf.btn_ok.Location.Y;
            ttf.np_clone_L        = new Point(x, y);
            ttf.np_clone.Location = ttf.np_clone_L;

            w = ttf.btn_SENDKEYS.Location.X
                - ttf.btn_ok.Location.X
                - ttf.btn_ok.ClientSize.Width
                - 24;
            h = ttf.MinimumSize.Height
                - ttf.btn_ok.Location.Y
                - 12;
            ttf.np_clone_S          = new Size(w, h);
            ttf.np_clone.ClientSize = ttf.np_clone_S;

            ttf.np_clone_Z = ttf.np_clone._tb.ZoomFactor;

            ttf.np_clone.KeyUp     += new System.Windows.Forms.KeyEventHandler(ttf.text_KeyUp);
            ttf.np_clone._tb.KeyUp += new System.Windows.Forms.KeyEventHandler(ttf.text_KeyUp);

            ttf.btn_activate.Text = (np.Type != NotePane.TYPE_SHORTCUT) ? "Activate" : "De-Activate";

            // radio_color {{{
            // leave radio buttons unchecked when working with a collection .. (commit changes forced)
            int sel_count = TabsCollection.Get_Sel_Count_but_this_one(np);

            if (sel_count > 0)
            {
                ttf.radio_color01.Checked = false;
                ttf.radio_color02.Checked = false;
                ttf.radio_color03.Checked = false;
                ttf.radio_color04.Checked = false;
                ttf.radio_color05.Checked = false;
                ttf.radio_color06.Checked = false;
                ttf.radio_color07.Checked = false;
                ttf.radio_color08.Checked = false;
                ttf.radio_color09.Checked = false;
                ttf.radio_color10.Checked = false;
                ttf.radio_color11.Checked = false;
                ttf.radio_color00.Checked = false;
                set_radio_color_BackColor(Color.Blue);
            }
            else
            {
                switch (np.color)
                {
                case "01": ttf.radio_color01.Checked = true; break;

                case "02": ttf.radio_color02.Checked = true; break;

                case "03": ttf.radio_color03.Checked = true; break;

                case "04": ttf.radio_color04.Checked = true; break;

                case "05": ttf.radio_color05.Checked = true; break;

                case "06": ttf.radio_color06.Checked = true; break;

                case "07": ttf.radio_color07.Checked = true; break;

                case "08": ttf.radio_color08.Checked = true; break;

                case "09": ttf.radio_color09.Checked = true; break;

                case "10": ttf.radio_color10.Checked = true; break;

                case "11": ttf.radio_color11.Checked = true; break;

                default: ttf.radio_color00.Checked = true; break;
                }
                set_radio_color_BackColor(Settings.MainFormInstance.BackColor);
            }
            //}}}

            // radio_shape {{{
            if (sel_count > 0)
            {
                ttf.radio_shape_tile.Checked   = false;
                ttf.radio_shape_circle.Checked = false;
                ttf.radio_shape_onedge.Checked = false;
                ttf.radio_shape_padd_r.Checked = false;
                ttf.radio_shape_square.Checked = false;
                ttf.radio_shape_auto.Checked   = false;
                set_radio_shape_BackColor(Color.Blue);
            }
            else
            {
                switch (np.shape)
                {
                case   "tile": ttf.radio_shape_tile.Checked = true; break;

                case "circle": ttf.radio_shape_circle.Checked = true; break;

                case "onedge": ttf.radio_shape_onedge.Checked = true; break;

                case "padd_r": ttf.radio_shape_padd_r.Checked = true; break;

                case "square": ttf.radio_shape_square.Checked = true; break;

                default: ttf.radio_shape_auto.Checked = true; break;
                }
                set_radio_shape_BackColor(Settings.MainFormInstance.BackColor);
            }
            //}}}

            //}}}
            // FORM COLOR {{{
            ttf.BackColor = Settings.MainFormInstance.BackColor;

            //}}}
            // FORM SIZE // {{{

/*
 *          w           = ttf.ClientSize.Width; // previous width
 *          int  wm     = ttf.np_clone.Location.X + ttf.np_clone.ClientSize.Width  + 16;
 *          if(w<wm) w  = wm;
 *
 *          h           = ttf.MinimumSize.Height;
 *          int  hm     = ttf.  btn_ok.Location.Y + ttf.np_clone.ClientSize.Height + 16;
 *          if(h<hm) h  = hm;
 *
 *          ttf.ClientSize = new Size(w, h);
 */
            // }}}
            // number of selected tabs to be changed along the current one {{{
            if (sel_count > 0)
            {
                string s = (sel_count > 1) ? "tabs" : "tab";
                ttf.lbl_sel_count.Text    = "...or also change the " + sel_count.ToString() + " other selected " + s;
                ttf.lbl_sel_count.Visible = true;
                ttf.btn_sel_clear.Visible = true;
            }
            else
            {
                ttf.lbl_sel_count.Visible = false;
                ttf.btn_sel_clear.Visible = false;
            }
            //}}}
            // EDIT .. (wait for input] {{{
            ttf.ShowDialog();

            if (ttf.result == DialogResult.OK)
            {
                tag_new = ttf.txt_input.Text;
            }
            else
            {
                tag_new = tag_old;
            }

            //  if(ttf != null) ttf.Dispose();
            //  if(ttf.components != null) ttf.components.Dispose();
            ttf.np_clone.Dispose();
            ttf.np_clone = null;
            ttf.np       = null;

            //}}}

            log("ShowDialog:\n"
                + "DialogResult.OK=[" + DialogResult.OK + "]\n"
                + "     ttf.result [" + ttf.result + "]\n"
                + "        tag_old [" + tag_old + "]"
                + "        tag_new [" + tag_new + "]"
                );
            return(ttf.result);
        }