SuspendLayout() public method

public SuspendLayout ( ) : void
return void
        public static void Main()
        {
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content
            graph.AddEdge("A", "B");
            graph.AddEdge("B", "C");
            graph.AddEdge("A", "C").Attr.Color = Microsoft.Msagl.Drawing.Color.Green;
            graph.FindNode("A").Attr.FillColor = Microsoft.Msagl.Drawing.Color.Magenta;
            graph.FindNode("B").Attr.FillColor = Microsoft.Msagl.Drawing.Color.MistyRose;
            Microsoft.Msagl.Drawing.Node c = graph.FindNode("C");
            c.Attr.FillColor = Microsoft.Msagl.Drawing.Color.PaleGreen;
            c.Attr.Shape     = Microsoft.Msagl.Drawing.Shape.Diamond;
            //bind the graph to the viewer
            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();

            viewer.MouseUp += Viewer_MouseUp;

            //show the form
            form.ShowDialog();
        }
Example #2
0
        /*
         * Popup a webbrowser-window with the Oyatel Connect prompt.
         * */
        public void loginPopup()
        {
            _access_token = "";

            popup = new Form();
            canClosePopup = false;
            WebBrowser webBrowser = new WebBrowser();
            popup.SuspendLayout();

            webBrowser.Location = new System.Drawing.Point(0, 0);
            webBrowser.MinimumSize = new System.Drawing.Size(20, 20);
            webBrowser.Name = "webBrowser";
            webBrowser.Size = new System.Drawing.Size(880, 550);

            popup.Width = 900;
            popup.Height = 570;
            popup.Text = "Oyatel Connect";
            popup.Visible = true;

            popup.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            popup.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            popup.ClientSize = new System.Drawing.Size(880, 550);
            popup.Controls.Add(webBrowser);
            popup.Name = "Oyatel.Connect";
            popup.Text = "Oyatel Connect";
            popup.ResumeLayout(false);
            popup.PerformLayout();

            webBrowser.Visible = true;
            webBrowser.Navigated += new WebBrowserNavigatedEventHandler(navigated_event);
            webBrowser.ProgressChanged += new WebBrowserProgressChangedEventHandler(ProgressChanged);
            webBrowser.Navigate("https://oauth.oyatel.com/oauth/authorize?client_id="
                + client_id + "&response_type=token&redirect_uri=" + redirect_uri, false);
        }
Example #3
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 private void InitializeComponent(ref System.Windows.Forms.Form winform)
 {
     this.tintColorDialog  = new System.Windows.Forms.ColorDialog();
     this.tintChangeButton = new System.Windows.Forms.Button();
     winform.SuspendLayout();
     //
     // tintChangeButton
     //
     this.tintChangeButton.Location = new System.Drawing.Point(13, 63);
     this.tintChangeButton.Name     = "tintChangeButton";
     this.tintChangeButton.Size     = new System.Drawing.Size(75, 23);
     this.tintChangeButton.TabIndex = 0;
     this.tintChangeButton.Text     = "Change Tint";
     this.tintChangeButton.Click   += new EventHandler(tintChangeButton_Click);
     this.tintChangeButton.UseVisualStyleBackColor = true;
     //
     // Form1
     //
     winform.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     winform.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     winform.ClientSize          = new System.Drawing.Size(736, 496);
     winform.Controls.Add(this.tintChangeButton);
     winform.Name = "Sprite Previewer";
     winform.Text = "Sprite Previewer";
     winform.ResumeLayout(false);
 }
		/// <summary>
		/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
		/// le contenu de cette méthode avec l'éditeur de code.
		/// </summary>
		protected void InitializeComponent()
		{
			this._elementHost1 = new System.Windows.Forms.Integration.ElementHost();
			this._spatialViewerControl = new SpatialViewer_GDIHost();
			_form = new System.Windows.Forms.Form();
			_form.SuspendLayout();
			// 
			// elementHost1
			// 
			this._elementHost1.Dock = System.Windows.Forms.DockStyle.Fill;
			this._elementHost1.Location = new System.Drawing.Point(0, 0);
			this._elementHost1.Name = "elementHost1";
			this._elementHost1.Size = new System.Drawing.Size(824, 581);
			this._elementHost1.TabIndex = 0;
			this._elementHost1.Text = "elementHost1";
			this._elementHost1.Child = (UIElement)this._spatialViewerControl;
			// 
			// Form1
			// 
			_form.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F);
			_form.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
			_form.ClientSize = new System.Drawing.Size(824, 581);
			_form.Controls.Add(this._elementHost1);
			_form.Name = "Spatial Toolkit";
			_form.Text = "Spatial Toolkit";
			_form.ResumeLayout(false);

		}
        /// <summary>
        /// Returns a SharePoint on-premises / SharePoint Online ClientContext object. Requires claims based authentication with FedAuth cookie.
        /// </summary>
        /// <param name="siteUrl">Site for which the ClientContext object will be instantiated</param>
        /// <param name="icon">Optional icon to use for the popup form</param>
        /// <returns>ClientContext to be used by CSOM code</returns>
        public ClientContext GetWebLoginClientContext(string siteUrl, System.Drawing.Icon icon = null)
        {
            var cookies = new CookieContainer();
            var siteUri = new Uri(siteUrl);

            var thread = new Thread(() =>
            {
                var form = new System.Windows.Forms.Form();
                if (icon != null)
                {
                    form.Icon = icon;
                }
                var browser = new System.Windows.Forms.WebBrowser
                {
                    ScriptErrorsSuppressed = true,
                    Dock = DockStyle.Fill
                };


                form.SuspendLayout();
                form.Width  = 900;
                form.Height = 500;
                form.Text   = string.Format("Log in to {0}", siteUrl);
                form.Controls.Add(browser);
                form.ResumeLayout(false);

                browser.Navigate(siteUri);

                browser.Navigated += (sender, args) =>
                {
                    if (siteUri.Host.Equals(args.Url.Host))
                    {
                        var cookieString = CookieReader.GetCookie(siteUrl).Replace("; ", ",").Replace(";", ",");
                        if (Regex.IsMatch(cookieString, "FedAuth", RegexOptions.IgnoreCase))
                        {
                            var _cookies = cookieString.Split(',').Where(c => c.StartsWith("FedAuth", StringComparison.InvariantCultureIgnoreCase) || c.StartsWith("rtFa", StringComparison.InvariantCultureIgnoreCase));
                            cookies.SetCookies(siteUri, string.Join(",", _cookies));
                            form.Close();
                        }
                    }
                };

                form.Focus();
                form.ShowDialog();
                browser.Dispose();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();

            if (cookies.Count > 0)
            {
                var ctx = new ClientContext(siteUrl);
                ctx.ExecutingWebRequest += (sender, e) => e.WebRequestExecutor.WebRequest.CookieContainer = cookies;
                return(ctx);
            }

            return(null);
        }
        /// <summary>
        /// Визуализация графа
        /// </summary>
        private void CreateGraph()
        {
            if (vertex > 0)
            {
                System.Windows.Forms.Form form = new System.Windows.Forms.Form();
                Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
                Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");


                for (int i = 0; i < vertex; i++)                                                                        //циклы для прохода по массиву
                {
                    for (int j = 0; j < vertex; j++)
                    {
                        if (matrix[i, j] > 0)
                        {
                            graph.AddEdge(Convert.ToString(i), Convert.ToString(j)).Attr.Color =                        //добавление ребра и смена цвета
                                                                                                 Microsoft.Msagl.Drawing.Color.ForestGreen;
                            graph.FindNode(Convert.ToString(i)).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Teal;    //смена цвета вершины
                        }
                    }
                }
                viewer.Graph = graph;                                   //отображение выбранного графа
                form.SuspendLayout();                                   //приостанавливаем логику макета для добавления панели управления
                viewer.Dock = System.Windows.Forms.DockStyle.Fill;      //возвращает границы элемента управления
                form.Controls.Add(viewer);                              //добавляем панель управления
                form.ResumeLayout();                                    //возобновляем логику макета
                form.ShowDialog();                                      //показать форму
            }
            else
            {
                MessageBox.Show("Задайте количество вершин");
            }
        }
Example #7
0
        static public void CreateGraph(ref CourseNode[] nodes)
        {
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");
            List <string> node_name = new List <string>();

            foreach (CourseNode Course in nodes)
            {
                node_name.Add(Course.name);
            }
            foreach (string course in node_name)
            {
                graph.AddNode(course).Attr.Color = Microsoft.Msagl.Drawing.Color.Aqua;
            }
            foreach (CourseNode Course in nodes)
            {
                foreach (string child in Course.children)
                {
                    graph.AddEdge(Course.name, child);
                }
            }
            viewer.Graph = graph;
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            form.ShowDialog();
        }
Example #8
0
        public void TestControl()
        {
            using (var frm = new System.Windows.Forms.Form())
            {
                frm.SuspendLayout();
                var splitter = new System.Windows.Forms.SplitContainer();
                splitter.Dock = DockStyle.Fill;


                var sp1 = splitter.Panel1;    // = new SplitterPanel(splitter);
                var pg  = new PropertyGrid();
                sp1.Controls.Add(pg);
                pg.Dock = DockStyle.Fill;
                var sp2 = splitter.Panel2;    // SplitterPanel(splitter);
                var lc1 = new LegendControl();
                lc1.Dock = DockStyle.Fill;
                sp2.Controls.Add(lc1);
                pg.SelectedObject = lc1;

                lc1.LegendFactory = new LegendFactory(new LegendSettings());
                lc1.Map           = CreateMap();

                frm.Controls.Add(splitter);

                frm.ResumeLayout();
                frm.ShowDialog();
            }
        }
Example #9
0
        public Task StartAsync()
        {
            //System.Diagnostics.Debugger.Break();

            //create a form
            form      = new System.Windows.Forms.Form();
            form.Size = new System.Drawing.Size(500, 500);

            //create a viewer object
            viewer            = new GViewer();
            viewer.Dock       = System.Windows.Forms.DockStyle.Fill;
            viewer.AutoScroll = false;
            //viewer.CurrentLayoutMethod = LayoutMethod.MDS;

            // control
            var b = CreateCommandButton();

            form.Controls.Add(b);
            b.BringToFront();

            viewer.ObjectUnderMouseCursorChanged += new EventHandler <Microsoft.Msagl.Drawing.ObjectUnderMouseCursorChangedEventArgs>(viewer_ObjectUnderMouseCursorChanged);
            viewer.MouseDown += new MouseEventHandler(viewer_MouseDown);
            viewer.SuspendLayout();

            form.SuspendLayout();
            form.Controls.Add(viewer as Control);

            viewer.ResumeLayout(false);
            form.ResumeLayout(false);

            viewer.Graph = graph;

            return(Task.Run(() => form.ShowDialog()));
        }
Example #10
0
 static public void dfagraph(List <DFAState> list)
 {
     System.Windows.Forms.Form form = new System.Windows.Forms.Form();
     Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
     Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");
     for (int i = 0; i < list.Count; i++)
     {
         for (int j = 0; j < list[i].transitions.Count; j += 2)
         {
             if (list[i].transitions[j].input != "")
             {
                 graph.AddEdge(list[i].name, list[i].transitions[j].input, list[i].transitions[j].nextState.name);
             }
             if (list[i].isFinalState == true)
             {
                 Microsoft.Msagl.Drawing.Node c = graph.FindNode(list[i].name);
                 c.Attr.FillColor = Microsoft.Msagl.Drawing.Color.Red;
             }
         }
     }
     viewer.Graph = graph;
     form.SuspendLayout();
     viewer.Dock = System.Windows.Forms.DockStyle.Fill;
     form.Controls.Add(viewer);
     form.ResumeLayout();
     form.ShowDialog();
 }
        private void stage_1_Entities_Identification_Click(object sender, EventArgs e)
        {
            Form form = new System.Windows.Forms.Form();

            form.Text = "Stage-1 Reverse Engineer : Entities";
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content


            foreach (Relation rel  in _masterListRelations)
            {
                Microsoft.Msagl.Drawing.Node newNode = new Microsoft.Msagl.Drawing.Node(rel.relationName);
                newNode.Attr.Shape = Microsoft.Msagl.Drawing.Shape.Box;

                graph.AddNode(newNode);
            }



            //bind the graph to the viewer
            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.Size = new Size(500, 500);
            form.ResumeLayout();
            //show the form
            form.Show();
        }
Example #12
0
        public void TampilkanGraph(bool autoClose)
        {
            form = new System.Windows.Forms.Form();
            graph.GraphAttr.EdgeAttr.ArrowHeadAtTarget = Microsoft.Glee.Drawing.ArrowStyle.None;
            graph.GraphAttr.Orientation = Microsoft.Glee.Drawing.Orientation.Landscape;

            //contoh input
            //bind the graph to the viewer
            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();

            //show the form
            form.StartPosition = FormStartPosition.CenterParent;
            if (autoClose)
            {
                Task.Delay(TimeSpan.FromSeconds(0.75))
                .ContinueWith((t) => form.Close(), TaskScheduler.FromCurrentSynchronizationContext());
            }
            form.ShowDialog();

            //System.Threading.Thread.Sleep(5000);
            //form.DialogResult = DialogResult.Abort;
            //form.Close();
            //form = new System.Windows.Forms.Form();
            //viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
        }
Example #13
0
        public void DrawResult(Graph _graph)
        {
            timestamps.Reverse();
            List <string> distinct = timestamps.Distinct().ToList();

            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");
            for (int i = 0; i < distinct.Count; i++)
            {
                Console.WriteLine("\nSemester {0} :\n{1}", i + 1, distinct[i]);
            }
            for (int idx = 0; idx < distinct.Count - 1; idx++)
            {
                graph.AddEdge(distinct[idx], distinct[idx + 1]).Attr.Color = Microsoft.Msagl.Drawing.Color.Green;;
                int index = _graph.GetNodesIdx(distinct[idx]);
                for (int j = 0; j < _graph.GetNodes(index).GetPostreqCount(); j++)
                {
                    if (!(distinct[idx + 1].Equals(_graph.GetNodes(index).GetPostreq(j), StringComparison.Ordinal)))
                    {
                        graph.AddEdge(_graph.GetNodes(index).GetVal(), _graph.GetNodes(index).GetPostreq(j));
                    }
                }
            }

            viewer.Graph = graph;
            form.SuspendLayout();
            viewer.Dock      = System.Windows.Forms.DockStyle.Fill;
            form.WindowState = FormWindowState.Maximized;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            form.ShowDialog();
        }
Example #14
0
        public static void Visualisasi()
        {
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");
            //create the graph content

            //for (int i = 0; i < ReadFromFile.nEdge; i++) {
            //    graph.AddEdge(Char.ToString(ReadFromFile.EdgeData[i].Item1), Char.ToString(ReadFromFile.EdgeData[i].Item2));
            //}

            //for (int i = 0; i < ReadFromFile.nNode; i++) {
            //    if (BFS.Map.vertices[vertices.Keys.ElementAt(i)].neighbors.Keys.ElementAt(i)) {
            //        graph.FindNode(BFS.Map.vertices.Keys.ElementAt(i)).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Red;
            //    }
            //}

            //bind the graph to the viewer
            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form
            form.ShowDialog();
        }
Example #15
0
File: UI.cs Project: ming4883/TOB
        public static void Init()
        {
            Settings.FULLSCREEN = !Settings.DevMode;

            var frm = new Form() {
                Text = "Tob Broadcast",
                Size = new Size (480, 320),
                Padding = new Padding (2),
                Font = new Font ("Consolas", 10.0f),
                FormBorderStyle = FormBorderStyle.FixedToolWindow,
                MaximizeBox = false,
            };

            frm.SuspendLayout();

            if (Settings.DevMode)
                InitLocal (frm);

            InitRemote (frm);

            InitGeneral (frm);

            frm.ResumeLayout();
            _frm = frm;

            Application.Run (frm);
        }
Example #16
0
 public static void SetFontAndScaling(Form form)
 {
     form.SuspendLayout();
     form.Font = new Font("Tahoma", 8.25f);
     if (form.Font.Name != "Tahoma") form.Font = new Font("Arial", 8.25f);
     form.AutoScaleMode = AutoScaleMode.Font;
     form.AutoScaleDimensions = new SizeF(6f, 13f);
     form.ResumeLayout(false);
 }
Example #17
0
        public static string AskForPassword()
        {
            Form dialog = new Form();
            dialog.FormBorderStyle = FormBorderStyle.FixedDialog;

            System.Windows.Forms.Label label1;
            MarkJohansen.Forms.MSJTextBox msjTextBox1;
            MarkJohansen.Forms.MSJButton msjButton1;

            label1 = new System.Windows.Forms.Label();
            msjTextBox1 = new MarkJohansen.Forms.MSJTextBox();
            msjButton1 = new MarkJohansen.Forms.MSJButton();
            dialog.SuspendLayout();
            //
            // label1
            //
            label1.AutoSize = true;
            label1.Location = new System.Drawing.Point(2, 8);
            label1.Name = "label1";
            label1.Size = new System.Drawing.Size(160, 13);
            label1.TabIndex = 0;
            label1.Text = "Please enter your DM password.";
            //
            // msjTextBox1
            //
            msjTextBox1.Location = new System.Drawing.Point(5, 25);
            msjTextBox1.Name = "msjTextBox1";
            msjTextBox1.Size = new System.Drawing.Size(285, 20);
            msjTextBox1.TabIndex = 1;
            //
            // msjButton1
            //
            msjButton1.Location = new System.Drawing.Point(5, 51);
            msjButton1.Name = "msjButton1";
            msjButton1.Size = new System.Drawing.Size(285, 28);
            msjButton1.TabIndex = 2;
            msjButton1.Text = "OK";
            msjButton1.Click += (sender, e) => { dialog.Close(); };
            msjButton1.UseVisualStyleBackColor = true;
            //
            // Form1
            //
            dialog.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            dialog.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            dialog.ClientSize = new System.Drawing.Size(292, 84);
            dialog.Controls.Add(msjButton1);
            dialog.Controls.Add(msjTextBox1);
            dialog.Controls.Add(label1);
            dialog.Name = "Form1";
            dialog.Text = "Form1";
            dialog.ResumeLayout(false);
            dialog.PerformLayout();

            dialog.ShowDialog();

            return msjTextBox1.Text;
        }
        private void setLayoutFormCategories()
        {
            formCategories.SuspendLayout();

            createTLPCatMain();
            formCategories.Controls.Add(tLPCatMain);

            formCategories.ResumeLayout();
            formCategories.Refresh();
        }
Example #19
0
        public void Draw()
        {
            UndirectedGraph <Vertex, QuickGraph.Edge <Vertex> > mG
                = new UndirectedGraph <Vertex, QuickGraph.Edge <Vertex> >();

            List <Vertex> .Enumerator etV = mGraph.mVertices.GetEnumerator();
            while (etV.MoveNext())
            {
                mG.AddVertex(etV.Current);
            }

            List <Edge> .Enumerator etE = mGraph.mEdges.GetEnumerator();
            while (etE.MoveNext())
            {
                QuickGraph.Edge <Vertex> e = new Edge <Vertex>(etE.Current.mVertexA, etE.Current.mVertexB);
                mG.AddEdge(e);
            }

            Console.WriteLine("QUICK GRAPH FORMAT:");
            Console.WriteLine(mG.VertexCount);
            Console.WriteLine(mG.EdgeCount);

            /*
             * var graphviz = new GraphvizAlgorithm<Vertex, Edge<Vertex>>(mG);
             * string output = graphviz.Generate(new FileDotEngine(), "graph");
             *
             * Console.WriteLine("OUTPUT");
             * Console.WriteLine(output);
             *
             * // Process drawProcess = new Process();
             * Process.Start("dot","-Tpng graph.dot > graph.png");
             */

            var populator = GleeGraphUtility.Create <Vertex, Edge <Vertex> >(mG);

            populator.Compute();
            Microsoft.Glee.Drawing.Graph gleeG = populator.GleeGraph;

            //create a viewer object
            Microsoft.Glee.GraphViewerGdi.GViewer viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();

            //bind the graph to the viewer
            viewer.Graph = gleeG;

            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();

            //show the form
            form.ShowDialog();
        }
Example #20
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Onload event form one
            button1.Enabled = false;
            button2.Enabled = false;
            button3.Enabled = false;
            button4.Enabled = false;
            button6.Enabled = false;
            form.SuspendLayout();

            viewer.Dock = System.Windows.Forms.DockStyle.Fill;

            form.Controls.Add(viewer);

            form.ResumeLayout();
            form.MdiParent   = this;
            form.WindowState = FormWindowState.Maximized;

            form.Show();
        }
Example #21
0
 public static void ShowDiagram()
 {
     //bind the graph to the viewer
     _viewer.Graph = _graph;
     //associate the viewer with the form
     _form.SuspendLayout();
     _viewer.Dock = System.Windows.Forms.DockStyle.Fill;
     _form.Controls.Add(_viewer);
     _form.ResumeLayout();
     //show the form
     _form.ShowDialog();
 }
Example #22
0
        internal static void OpenConsentFlow(string url, Action <string> messageAction)
        {
            var thread = new Thread(() =>
            {
                var maxRetry   = 5;
                var retryCount = 0;
                var form       = new System.Windows.Forms.Form();
                var browser    = new System.Windows.Forms.WebBrowser
                {
                    ScriptErrorsSuppressed = true,
                    Dock = DockStyle.Fill
                };

                form.SuspendLayout();
                form.Width  = 1024;
                form.Height = 800;
                form.Text   = $"Consent";
                form.Controls.Add(browser);
                form.ResumeLayout(false);

                browser.Navigate(url);

                browser.Navigated += (sender, args) =>
                {
                    if (args.Url.Query.Contains("admin_consent=True"))
                    {
                        form.Close();
                    }
                    if (args.Url.Query.Contains("error="))
                    {
                        var query = HttpUtility.ParseQueryString(args.Url.Query);
                        messageAction?.Invoke(query.Get("error"));
                        retryCount++;

                        if (retryCount < maxRetry)
                        {
                            browser.Navigate(url);
                        }
                    }
                };

                form.Focus();
                form.ShowDialog();
                browser.Dispose();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();
        }
 private void createGraph(ScoreNode root)
 {
     System.Windows.Forms.Form form = new System.Windows.Forms.Form();
     Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
     Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph(this.name);
     graph           = treeToGraph(root, graph);
     viewer.Graph    = graph;
     viewer.AutoSize = true;
     viewer.FitGraphBoundingBox();
     form.SuspendLayout();
     form.Controls.Add(viewer);
     form.ResumeLayout();
     form.ShowDialog();
 }
Example #24
0
        public void drawGraph()
        {
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");

            for (int i = 0; i < nodes.Count; i++)
            {
                Console.WriteLine("i:" + i);
                Console.WriteLine("children count: " + nodes[i].children.Count);
                for (int j = 0; j < nodes[i].children.Count; j++)
                {
                    Console.WriteLine("j:" + j);
                    Console.WriteLine("Parent node: " + nodes[i].getNodeName());
                    Console.WriteLine("node name: " + nodes[i].children[j].getNodeName());
                    int flow    = nodes[i].edges[j][0];
                    var newEdge = graph.AddEdge(nodes[i].getNodeName(), nodes[i].children[j].getNodeName());
                    Microsoft.Msagl.Drawing.Node childNode = graph.FindNode(nodes[i].getNodeName());
                    string cap = nodes[i].edges[j][0].ToString() + "/" + nodes[i].edges[j][1].ToString();
                    newEdge.LabelText        = cap;
                    childNode.Attr.Shape     = Microsoft.Msagl.Drawing.Shape.Circle;
                    childNode.Attr.FillColor = Microsoft.Msagl.Drawing.Color.White;
                    if (flow > 0)
                    {
                        string tempStringg = nodes[i].getNodeName() + nodes[i].children[j].getNodeName();
                        if (nameofnodes.Contains(tempStringg))
                        {
                            newEdge.Attr.Color = Microsoft.Msagl.Drawing.Color.Red;
                        }
                        else
                        {
                            newEdge.Attr.Color = Microsoft.Msagl.Drawing.Color.Orange;
                        }
                    }
                    else
                    {
                        newEdge.Attr.Color = Microsoft.Msagl.Drawing.Color.Black;
                    }
                }
            }

            viewer.Graph = graph;
            form.SuspendLayout();
            viewer.CurrentLayoutMethod = LayoutMethod.MDS;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form
            form.ShowDialog();
        }
Example #25
0
        public static void AddFlash(zeus.HelperClass.zBanner banner, System.Windows.Forms.Form f, EventHandler tar)
        {
            Point  location = new Point();
            Size   size     = new Size();
            string src      = banner.src;

            location.X  = int.Parse(banner.location.Split(';')[0]);
            location.Y  = int.Parse(banner.location.Split(';')[1]);
            size.Width  = int.Parse(banner.size.Split(';')[0]);
            size.Height = int.Parse(banner.size.Split(';')[1]);

            try
            {
                AxShockwaveFlashObjects.AxShockwaveFlash       Flash     = new AxShockwaveFlashObjects.AxShockwaveFlash();
                System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(main_menu));
                ((System.ComponentModel.ISupportInitialize)(Flash)).BeginInit();
                f.SuspendLayout();
                //
                // Flash
                //
                Flash.Enabled  = true;
                Flash.Location = location;
                Flash.Name     = "Flash";
                Flash.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("Flash.OcxState")));
                Flash.Size     = new Size(size.Width, size.Height);
                //Flash.SetZoomRect(0, 0, 1280, 184);
                Flash.TabIndex = 0;
                f.Controls.Add(Flash);
                ((System.ComponentModel.ISupportInitialize)(Flash)).EndInit();
                f.ResumeLayout(false);

                Flash.LoadMovie(0, System.IO.Directory.GetCurrentDirectory() +
                                System.IO.Path.DirectorySeparatorChar + src);
                Flash.Play();
                //Flash.ClientRectangle = new Rectangle(0, 0, 1280, 184);
                //Flash.ClientSize = size;
                //Flash.Dock = DockStyle.None;
                Flash.ScaleMode = 1;

                Flash.Size = new Size(size.Width, size.Height);
                //Flash.Pan(100, 100, 0);
                //Flash.Zoom(50);
                lFlash.Add(Flash);
                Ipaybox.Option["can-flash-initialize"] = "true";
            }
            catch
            {
                Ipaybox.Option["can-flash-initialize"] = "false";
            }
        }
Example #26
0
        public static string InputBox(string Prompt = "", string Title = "", string DefaultResponse = "")
        {
            var textBox = new TextBox();
            textBox.Location = new Point(12, 84);
            textBox.Size = new Size(329, 19);
            textBox.Text = DefaultResponse;

            var okButton = new Button();
            okButton.DialogResult = DialogResult.OK;
            okButton.Location = new Point(266, 9);
            okButton.Size = new Size(75, 23);
            okButton.Text = "OK";
            okButton.UseVisualStyleBackColor = true;

            var cancelButton = new Button();
            cancelButton.DialogResult = DialogResult.Cancel;
            cancelButton.Location = new Point(266, 38);
            cancelButton.Size = new Size(75, 23);
            cancelButton.Text = "キャンセル";
            cancelButton.UseVisualStyleBackColor = true;

            var label = new Label();
            label.AutoSize = true;
            label.Location = new Point(12, 9);
            label.Size = new Size(0, 12);
            label.Text = Prompt;

            var form = new Form();
            form.SuspendLayout();
            form.AcceptButton = okButton;
            form.CancelButton = cancelButton;
            form.AutoScaleDimensions = new SizeF(6F, 12F);
            form.AutoScaleMode = AutoScaleMode.Font;
            form.ClientSize = new Size(353, 120);
            form.ControlBox = false;
            form.Controls.Add(textBox);
            form.Controls.Add(okButton);
            form.Controls.Add(cancelButton);
            form.Controls.Add(label);
            form.FormBorderStyle = FormBorderStyle.FixedDialog;
            form.ShowInTaskbar = false;
            form.StartPosition = FormStartPosition.CenterParent;
            form.ResumeLayout(false);
            form.PerformLayout();
            form.Text = Title;

            if (form.ShowDialog() == DialogResult.OK) return textBox.Text;
            else return null;
        }
Example #27
0
        /// <summary>
        /// Init title all the control in form
        /// </summary>
        /// <param name="frm"></param>
        /// <remarks>
        /// Author:			PhatLT. FPTSS.
        /// Created date:	14/02/2011
        /// </remarks>
        public static void InitTitle(Form frm)
        {
            if(frm == null)
                return;

            frm.SuspendLayout();

            frm.Text = clsResources.GetTitle(frm.Name + ".Title");
            foreach(Control control in frm.Controls)
            {
                InitTitle(frm, control);
            }

            frm.ResumeLayout(false);
        }
Example #28
0
        /// <summary>
        ///     Changes the language of the form.
        /// </summary>
        /// <param name="form">
        ///     <c>Form</c> object to apply changes to.
        /// </param>
        private void ChangeFormLanguage(System.Windows.Forms.Form form)
        {
            form.SuspendLayout();
            Cursor.Current = Cursors.WaitCursor;
            System.Resources.ResourceManager resources = new System.Resources.ResourceManager(form.GetType());
            // change main form resources
            form.Text = (string)(GetSafeValue(resources, "$this.Text", form.Text));
            ReloadControlCommonProperties(form, resources);
            ToolTip toolTip = GetToolTip(form);

            // change text of all containing controls
            RecurControls(form, resources, toolTip);
            // change the text of menus
            ScanNonControls(form, resources);
            form.ResumeLayout();
        }
Example #29
0
        public void Draw(Graph _graph)
        {
            DrawBox("DFS - Depth First Search");
            int i = 0;

            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            Microsoft.Msagl.Drawing.Graph          graph  = new Microsoft.Msagl.Drawing.Graph("graph");

            for (int idx = 0; idx < _graph.GetNodesCount(); idx++)
            {
                if (_graph.GetNodes(idx).GetPostreqCount() == 0)
                {
                    graph.AddNode(_graph.GetNodes(idx).GetVal());
                }
                else
                {
                    for (int j = 0; j < _graph.GetNodes(idx).GetPostreqCount(); j++)
                    {
                        graph.AddEdge(_graph.GetNodes(idx).GetVal(), _graph.GetNodes(idx).GetPostreq(j));
                    }
                }
            }

            viewer.Graph = graph;
            form.SuspendLayout();
            form.Controls.Add(viewer);
            form.ResumeLayout();
            viewer.Dock      = System.Windows.Forms.DockStyle.Fill;
            form.WindowState = FormWindowState.Maximized;

            while (i < timestamps.Count)
            {
                if (i != 0)
                {
                    graph.FindNode(timestamps[i - 1]).Attr.FillColor = Microsoft.Msagl.Drawing.Color.White;
                    graph.FindNode(timestamps[i - 1]).LabelText      = timestamps[i - 1];
                }
                graph.FindNode(timestamps[i]).Attr.FillColor = Microsoft.Msagl.Drawing.Color.Green;
                graph.FindNode(timestamps[i]).LabelText      = (i + 1).ToString();
                form.ShowDialog();
                i++;
            }
        }
Example #30
0
        public static void LaunchBrowser(string url, Action <bool> success, System.Drawing.Icon icon = null)
        {
            var thread = new Thread(() =>
            {
                var form = new System.Windows.Forms.Form();
                if (icon != null)
                {
                    form.Icon = icon;
                }
                var browser = new System.Windows.Forms.WebBrowser
                {
                    ScriptErrorsSuppressed = true,
                    Dock = DockStyle.Fill
                };

                form.SuspendLayout();
                form.Width  = 568;
                form.Height = 1012;
                form.Text   = $"Authenticate";
                form.Controls.Add(browser);
                form.ResumeLayout(false);
                form.FormClosed += (sender, args) =>
                {
                    success(false);
                };
                browser.Navigated += (sender, args) =>
                {
                    if (browser.Url.AbsoluteUri.Equals("https://login.microsoftonline.com/common/login", StringComparison.InvariantCultureIgnoreCase) || browser.Url.AbsoluteUri.StartsWith("https://login.microsoftonline.com/common/reprocess", StringComparison.InvariantCultureIgnoreCase))
                    {
                        form.Close();
                        success(true);
                    }
                };
                browser.Navigate(url);

                form.Focus();
                form.ShowDialog();
                browser.Dispose();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();
        }
        public static void main()
        {
            //create a form
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            form.BackColor = System.Drawing.Color.Black;
            form.Size      = new System.Drawing.Size(1000, 600);

            //create a viewer object
            Microsoft.Glee.GraphViewerGdi.GViewer viewer = new Microsoft.Glee.GraphViewerGdi.GViewer();

            //create a graph object
            Microsoft.Glee.Drawing.Graph graph = new Microsoft.Glee.Drawing.Graph("graph");
            graph.GraphAttr.Backgroundcolor = Microsoft.Glee.Drawing.Color.LavenderBlush;

            //create the graph content
            CoursePlan coursePlan = new CoursePlan(filename);

            coursePlan.Print();

            foreach (KeyValuePair <string, Subject> entry in coursePlan.subjects)
            {
                Subject subject = entry.Value;
                foreach (string element in subject.preq_of)
                {
                    graph.AddEdge(subject.name, element);
                }
            }

            //bind the graph to the viewer
            viewer.Graph = graph;

            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();

            //show the form
            form.ShowDialog();

            // print to console
            //DFS resultDFS = new DFS(coursePlan.subjects);
            //resultDFS.Print();
        }
Example #32
0
        public static void OpenBrowser(string url, Action <bool> success, System.Drawing.Icon icon = null)
        {
            var thread = new Thread(() =>
            {
                var form = new System.Windows.Forms.Form();
                if (icon != null)
                {
                    form.Icon = icon;
                }
                var browser = new System.Windows.Forms.WebBrowser
                {
                    ScriptErrorsSuppressed = true,
                    Dock = DockStyle.Fill
                };

                form.SuspendLayout();
                form.Width  = 568;
                form.Height = 1012;
                form.Text   = $"Authenticate";
                form.Controls.Add(browser);
                form.ResumeLayout(false);
                form.FormClosed += (sender, args) =>
                {
                    success(false);
                };
                browser.Navigated += (sender, args) =>
                {
                    if (browser.DocumentText.Contains("You have signed in to the PnP Office 365 Management Shell application on your device. You may now close this window."))
                    {
                        form.Close();
                        success(true);
                    }
                };
                browser.Navigate(url);

                form.Focus();
                form.ShowDialog();
                browser.Dispose();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            thread.Join();
        }
Example #33
0
        private void Button_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Enter)
            {
                ProcessInput(textBox.Text);

                if (form.IsHandleCreated)
                {
                    lock (graph)
                    {
                        form.SuspendLayout();
                        form.Invoke(new RefreshDelegate(Refresh));
                        form.ResumeLayout();
                    }
                }

                textBox.Text = "";
            }
        }
Example #34
0
        // FUNCTION TO DO LOAD GRAPH AND RUN DFS:
        public static void runDFS(Form1 f1)
        {
            defaultG = new Graph("graph");
            if (graphForm.IsDisposed)
            {
                Console.WriteLine(graphForm == null);
                graphForm = new Form();
                viewer    = new Microsoft.Glee.GraphViewerGdi.GViewer();
            }
            StreamReader sr    = new StreamReader(@f1.getFileURL());
            string       Rumah = sr.ReadLine();

            jmlRumah = Int32.Parse(Rumah);

            buildTree(ref sr, jmlRumah);

            // DFS
            arrive  = new long[jmlRumah + 1];
            leave   = new long[jmlRumah + 1];
            visited = new bool[jmlRumah + 1];

            DFS(1, ref tree);

            // COLOR THE ROOT (1) WITH SEAGREEN COLOR
            Microsoft.Glee.Drawing.Node n1 = defaultG.FindNode("1");
            n1.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.SeaGreen;
            // Make Root a double-circled vertex just for emphasis, hehe:
            n1.Attr.Shape = Microsoft.Glee.Drawing.Shape.DoubleCircle;

            // SHOWING THE GRAPH:
            // Bind the graph to the viewer
            viewer.Graph = defaultG;

            // Associate the viewer with the created form
            graphForm.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            graphForm.Controls.Add(viewer);
            graphForm.ResumeLayout();
            graphForm.Refresh();

            // Show the form as a new window, BUT not locked there!
            graphForm.Show();
        }
Example #35
0
        public VisualiseDataForm(ref ObservableCollection Collection)
        {
            InitializeComponent();

            //create a form
            System.Windows.Forms.Form form = this;
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();
            //create a graph object
            Microsoft.Msagl.Drawing.Graph graph = new Microsoft.Msagl.Drawing.Graph("graph");

            //Add all the nodes
            foreach (ObservableObject o in Collection.Observables)
            {
                graph.AddNode(o.DisplayTitle);
            }

            //create the links
            foreach (ObservableRelationship r in Collection.Relationships)
            {
                Microsoft.Msagl.Drawing.Edge ed = graph.AddEdge(Collection.Observables.Find(x => x.ID == r.From).DisplayTitle, Enum.GetName(typeof(ObservableRelationshipType), r.RelationshipType), Collection.Observables.Find(x => x.ID == r.To).DisplayTitle);

                //Set the link text to grey
                Microsoft.Msagl.Drawing.Label l = ed.Label;
                l.FontColor = Microsoft.Msagl.Drawing.Color.DarkGray;
            }

            //Get rid of GUI controls we dont want the user to have access to
            viewer.LayoutAlgorithmSettingsButtonVisible = false;
            viewer.EdgeInsertButtonVisible = false;
            viewer.SaveAsMsaglEnabled      = false; //This disables save and load of the actual graph data.

            //Give some extra space
            graph.LayoutAlgorithmSettings.NodeSeparation = 10;

            //bind the graph to the viewer
            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
        }
        /// <summary>
        /// Loads the position and size of a form.
        /// Best placed in the Form's constructor.
        /// </summary>
        /// <param name="form">The control to be loaded.</param>
        public static void LoadFromRegistry(
                    Form form)
        {
            if (form == null)
            {
                throw new ArgumentNullException("form");
            }

            // open key
            using (RegistryKey key = Registry.CurrentUser.OpenSubKey(SUBKEY))
            {
                try
                {
                    // check that screen res is the same
                    // if not or can't be found revert to origional.
                    if ((Screen.PrimaryScreen.Bounds.Height != (int)key.GetValue(form.Name + "_screenHeight"))
                        || (Screen.PrimaryScreen.Bounds.Width != (int)key.GetValue(form.Name + "_screenWidth")))
                    {
                        return;
                    }

                    form.SuspendLayout();
                    try
                    {
                        form.WindowState = (FormWindowState)key.GetValue(form.Name + "_windowState");
                        form.StartPosition = FormStartPosition.Manual;
                        form.Top = (int)key.GetValue(form.Name + "_top");
                        form.Left = (int)key.GetValue(form.Name + "_left");
                        form.Width = (int)key.GetValue(form.Name + "_width");
                        form.Height = (int)key.GetValue(form.Name + "_height");
                    }
                    finally
                    {
                        form.ResumeLayout();
                    }
                }
                catch (Exception)
                {
                    // Nothing to do.
                }
            }
        }
Example #37
0
    public void GambarPeta()
    //Method menggabarkan peta penyebaran atribut graf pada form baru
    {
        System.Windows.Forms.Form             peta = new System.Windows.Forms.Form();
        Microsoft.Glee.GraphViewerGdi.GViewer view = new Microsoft.Glee.GraphViewerGdi.GViewer();
        Microsoft.Glee.Drawing.Graph          map  = new Microsoft.Glee.Drawing.Graph("Peta Penyebaran Virus");

        Dictionary <string, Graph> .KeyCollection keys = this.graf.Keys;
        foreach (string node1 in keys)
        {
            if (graf[node1].GetNEdge() == 0)
            {
                map.AddNode(node1);
            }
            else
            {
                foreach (string node2 in graf[node1].GetEdge())
                {
                    map.AddEdge(node1, node2);
                }
                if (graf[node1].GetDayInf() != -1)
                {
                    Microsoft.Glee.Drawing.Node temp = map.FindNode(node1);
                    temp.Attr.Fillcolor = Microsoft.Glee.Drawing.Color.Red;
                }
            }
        }

        //bind the graph to the viewer
        view.Graph = map;

        //associate the viewer with the form
        peta.SuspendLayout();
        view.Dock = System.Windows.Forms.DockStyle.Fill;
        peta.Controls.Add(view);
        peta.ResumeLayout();
        peta.Text          = "Peta Penyebaran Virus";
        peta.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;

        //show the form
        peta.ShowDialog();
    }
Example #38
0
        private void btnFSM_Click(object sender, EventArgs e)
        {
            System.Windows.Forms.Form form = new System.Windows.Forms.Form();
            form.WindowState = FormWindowState.Maximized;
            //create a viewer object
            Microsoft.Msagl.GraphViewerGdi.GViewer viewer = new Microsoft.Msagl.GraphViewerGdi.GViewer();

            //create a graph object
            var graph = new Graph("Finite State Machine");
            //create the graph content

            Dictionary <States.State, Node> dictionary = new Dictionary <States.State, Node>();

            foreach (States.State state in _lrZero.FiniteStateMachine.States)
            {
                Node node = new Node(state.ToStringCompact());
                node.Attr.FillColor = state.ReduceOnly ? Microsoft.Msagl.Drawing.Color.SeaGreen :
                                      (state.ShiftOnly ? Microsoft.Msagl.Drawing.Color.LightGreen : Microsoft.Msagl.Drawing.Color.Orange);

                dictionary.Add(state, node);
                graph.AddNode(node);
            }

            foreach (States.State state in _lrZero.FiniteStateMachine.States)
            {
                foreach (KeyValuePair <ISymbol, States.State> stateNextState in state.NextStates)
                {
                    var edge = new Edge(dictionary[state], dictionary[stateNextState.Value], ConnectionToGraph.Connected);
                    edge.LabelText = stateNextState.Key.ToString();
                    graph.AddPrecalculatedEdge(edge);
                }
            }

            viewer.Graph = graph;
            //associate the viewer with the form
            form.SuspendLayout();
            viewer.Dock = System.Windows.Forms.DockStyle.Fill;
            form.Controls.Add(viewer);
            form.ResumeLayout();
            //show the form
            form.ShowDialog();
        }
 public static Form CreateForm(GViewer gviewer) {
     GViewer=gviewer;
     var form = new Form();
     form.SuspendLayout();
     form.Controls.Add(gviewer);
     gviewer.Dock = DockStyle.Fill;
     gviewer.SendToBack();
     form.StartPosition = FormStartPosition.CenterScreen;
     form.Size = new System.Drawing.Size(Screen.PrimaryScreen.WorkingArea.Width,
                       Screen.PrimaryScreen.WorkingArea.Height);
     var statusStrip = new StatusStrip();
     var toolStribLbl = new ToolStripStatusLabel("test");
     statusStrip.Items.Add(toolStribLbl);
     form.Controls.Add(statusStrip);
     form.MainMenuStrip = GetMainMenuStrip();
     form.Controls.Add(form.MainMenuStrip);
     form.ResumeLayout();
     form.Load += form_Load;
     return form;
 }
Example #40
0
 public LabelManager(Form p, int m)
 {
     maxNumItems = m;
     items = new List<ResultItem>(0);
     labels = new Label[maxNumItems];
     p.SuspendLayout();
     for (int i = 0; i < maxNumItems; i++)
     {
         labels[i] = new Label();
         labels[i].AutoEllipsis = true;
         labels[i].BackColor = Color.White;
         labels[i].Font = new Font("Microsoft Sans Serif", 18F, FontStyle.Regular, GraphicsUnit.Point, 0);
         labels[i].Location = new Point(100, 110 + (i * 50));
         labels[i].Size = new Size(1050, 30);
         labels[i].TextAlign = ContentAlignment.MiddleCenter;
         p.Controls.Add(labels[i]);
     }
     p.ResumeLayout();
     p.PerformLayout();
 }
 /// <summary>
 /// Opens a new modeless dialog box with a grid
 /// </summary>
 /// <param name="node">the node to display</param>
 /// <param name="owner">the parent form to attach to, can be null</param>
 /// <returns>the form containing the grid</returns>
 public static Form Show(NsNode node, Form owner)
 {
     Form f = new Form();
     f.Owner = owner;
     f.SuspendLayout();
     NsNodeGridView flow = new NsNodeGridView();
     flow.Dock = DockStyle.Fill;
     f.Controls.Add(flow);
     f.ResumeLayout();
     flow.Node = node;
     f.StartPosition = FormStartPosition.CenterParent;
     f.FormBorderStyle = FormBorderStyle.SizableToolWindow;
     f.Width = 600;
     f.Height = 300;
     f.Text = node.Label;
     f.Show();
     f.BringToFront();
     flow.ReadNode();
     return f;
 }
        public GenreSelectorDialog(TrackDatabase db)
        {
            mDatabase = db;
            mGenres = mDatabase.GetGenres();
            mSelectedGenres = new string[0];

            mForm = new Form();
            mForm.SuspendLayout();

            mForm.Text = "Genre Selection";
            mForm.MinimizeBox = false;
            mForm.MaximizeBox = false;
            mForm.FormBorderStyle = FormBorderStyle.FixedDialog;
            mForm.StartPosition = FormStartPosition.CenterScreen;
            mForm.Size = new Size(200, 250);

            mGenreCheckList = new CheckedListBox();
            mGenreCheckList.CheckOnClick = true;
            mGenreCheckList.IntegralHeight = false;
            mGenreCheckList.Location = new Point(3, 3);
            mGenreCheckList.Size = new Size(mForm.ClientSize.Width - 6, mForm.ClientSize.Height - 32);
            mGenreCheckList.Anchor = AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;

            foreach (string genre in mGenres)
                mGenreCheckList.Items.Add(String.Format("{0} ({1})", genre, mDatabase.GetGenreTrackCount(genre)), true);

            mForm.Controls.Add(mGenreCheckList);

            mOKButton = new Button();
            //mOKButton.DialogResult = DialogResult.OK;
            mOKButton.Text = "OK";
            mOKButton.Location = new Point(mForm.ClientSize.Width - 78, mForm.ClientSize.Height - 26);
            mOKButton.Size = new Size(75, 23);
            mOKButton.Anchor = AnchorStyles.Right | AnchorStyles.Bottom;
            mOKButton.Click += new EventHandler(mOKButton_Click);
            mForm.Controls.Add(mOKButton);

            mForm.AcceptButton = mOKButton;

            mForm.ResumeLayout();
        }
Example #43
0
        public static Form Show(ILogger log, Form owner)
        {
            Form f = new Form();
            f.Owner = owner;
            f.SuspendLayout();
            LogTextBox box = new LogTextBox();
            box.Dock = DockStyle.Fill;
            box.SetLogText(log);
            box.AttachLog(log);
            f.Controls.Add(box);
            f.ResumeLayout();
            f.StartPosition = FormStartPosition.CenterParent;
            f.FormBorderStyle = FormBorderStyle.SizableToolWindow;
            f.Width = 500;
            f.Height = 300;
            f.Text = "";
            f.Show();
            f.BringToFront();

            return f;
        }
 private void RestorePlacement(Form senderForm, FormPlacement restore)
 {
     senderForm.SuspendLayout();
     if (((restore & FormPlacement.Location) > FormPlacement.None) && (this["Location"] != null))
     {
         Screen screen = Screen.FromPoint(this.Location);
         if ((screen != null) && screen.Bounds.Contains(this.Location))
         {
             senderForm.StartPosition = FormStartPosition.Manual;
             senderForm.Location = this.Location;
         }
     }
     if (((restore & FormPlacement.Size) > FormPlacement.None) && (this["Size"] != null))
     {
         senderForm.Size = this.Size;
     }
     if ((restore & FormPlacement.WindowState) > FormPlacement.None)
     {
         senderForm.WindowState = this.WindowState;
     }
     senderForm.ResumeLayout();
 }
Example #45
0
		public void Bug81843 ()
		{
			Form f = new Form ();
			f.ShowInTaskbar = false;
			
		        TableLayoutPanel tableLayoutPanel1;
			Button button2;
			TextBox textBox1;
			Button button4;

			tableLayoutPanel1 = new TableLayoutPanel ();
			button2 = new Button ();
			button4 = new Button ();
			textBox1 = new TextBox ();
			tableLayoutPanel1.SuspendLayout ();
			f.SuspendLayout ();

			tableLayoutPanel1.AutoSize = true;
			tableLayoutPanel1.ColumnCount = 3;
			tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
			tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
			tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
			tableLayoutPanel1.Controls.Add (button2, 0, 1);
			tableLayoutPanel1.Controls.Add (button4, 2, 1);
			tableLayoutPanel1.Controls.Add (textBox1, 1, 0);
			tableLayoutPanel1.Location = new Point (0, 0);
			tableLayoutPanel1.RowCount = 2;
			tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
			tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Percent, 50F));
			tableLayoutPanel1.Size = new Size (292, 287);

			button2.Size = new Size (75, 23);
			
			button4.Size = new Size (75, 23);

			textBox1.Dock = DockStyle.Fill;
			textBox1.Location = new Point (84, 3);
			textBox1.Multiline = true;
			textBox1.Size = new Size (94, 137);

			f.ClientSize = new Size (292, 312);
			f.Controls.Add (tableLayoutPanel1);
			f.Name = "Form1";
			f.Text = "Form1";
			tableLayoutPanel1.ResumeLayout (false);
			tableLayoutPanel1.PerformLayout ();
			f.ResumeLayout (false);
			f.PerformLayout ();

			f.Show ();

			Assert.AreEqual (new Rectangle (3, 146, 75, 23), button2.Bounds, "A1");
			Assert.AreEqual (new Rectangle (184, 146, 75, 23), button4.Bounds, "A2");
			Assert.AreEqual (new Rectangle (84, 3, 94, 137), textBox1.Bounds, "A3");
			
			f.Dispose ();
		}
Example #46
0
		public void Bug81936 ()
		{
			Form f = new Form ();
			f.ShowInTaskbar = false;

			TableLayoutPanel tableLayoutPanel1;
			Label button2;
			Label button4;

			tableLayoutPanel1 = new TableLayoutPanel ();
			button2 = new Label ();
			button4 = new Label ();
			button2.Text = "Test1";
			button4.Text = "Test2";
			button2.Anchor = AnchorStyles.Left;
			button4.Anchor = AnchorStyles.Left;
			button2.Height = 14;
			button4.Height = 14;
			tableLayoutPanel1.SuspendLayout ();
			f.SuspendLayout ();

			tableLayoutPanel1.ColumnCount = 1;
			tableLayoutPanel1.ColumnStyles.Add (new ColumnStyle ());
			tableLayoutPanel1.Controls.Add (button2, 0, 0);
			tableLayoutPanel1.Controls.Add (button4, 0, 1);
			tableLayoutPanel1.Location = new Point (0, 0);
			tableLayoutPanel1.RowCount = 2;
			tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Absolute, 28F));
			tableLayoutPanel1.RowStyles.Add (new RowStyle (SizeType.Absolute, 28F));
			tableLayoutPanel1.Size = new Size (292, 56);

			f.ClientSize = new Size (292, 312);
			f.Controls.Add (tableLayoutPanel1);
			f.Name = "Form1";
			f.Text = "Form1";
			tableLayoutPanel1.ResumeLayout (false);
			tableLayoutPanel1.PerformLayout ();
			f.ResumeLayout (false);
			f.PerformLayout ();

			f.Show ();

			Assert.AreEqual (new Rectangle (3, 7, 100, 14), button2.Bounds, "A1");
			Assert.AreEqual (new Rectangle (3, 35, 100, 14), button4.Bounds, "A2");

			f.Dispose ();
		}
        private void btnViewHex_Click(object sender, EventArgs e)
        {
            try
            {
                this.Enabled = false;
                Application.DoEvents();

                IResource resource = s4pi.WrapperDealer.WrapperDealer.CreateNewResource(0, "0x00000000");
                BinaryReader r = owner[field].Value as BinaryReader;
                if (r.BaseStream.CanSeek) r.BaseStream.Position = 0;
                (new BinaryWriter(resource.Stream)).Write(r.ReadBytes((int)r.BaseStream.Length));
                if (resource.Stream.CanSeek) resource.Stream.Position = 0;

                Control c = (new HexControl(resource.Stream)).ValueControl;

                Form f = new Form();
                f.SuspendLayout();
                f.Controls.Add(c);
                c.Dock = DockStyle.Fill;
                f.Icon = ((System.Drawing.Icon)(new System.ComponentModel.ComponentResourceManager(typeof(MainForm)).GetObject("$this.Icon")));
                f.Text = "Hex view";
                f.ClientSize = new Size(this.ClientSize.Width - (this.ClientSize.Width / 5), this.ClientSize.Height - (this.ClientSize.Height / 5));
                f.StartPosition = FormStartPosition.CenterParent;
                f.ResumeLayout();
                f.FormClosed += new FormClosedEventHandler((s, fce) => { if (!(s as Form).IsDisposed) (s as Form).Dispose(); });
                f.Show(this);
            }
            finally { this.Enabled = true; edSvc.CloseDropDown(); }
        }
Example #48
0
        private void treeLog_MouseDown(object sender, MouseEventArgs e)
        {
            if (ModelingForm ==null)
            {
                if (e.Button == MouseButtons.Middle)
                {
                    TreeNode node = treeLog.GetNodeAt(e.X, e.Y);
                    if (node != null && node.Parent == null)
                    {
                        treeLog.SelectedNode = node;
                        CSMEvent tag = (CSMEvent)node.Tag;
                        ModelingForm = new Form();
                        ModelingForm.SuspendLayout();
                        ModelingForm.StartPosition = FormStartPosition.Manual;
                        ModelingForm.Left = Cursor.Position.X + 5;
                        ModelingForm.Top = Cursor.Position.Y + 5;
                        ModelingForm.Width = 0;
                        ModelingForm.Height = 0;
                        ModelingForm.FormBorderStyle = FormBorderStyle.None;
                        ModelingForm.Name = "frmModeling";
                        ModelingForm.BackColor = System.Drawing.Color.LightGray;
                        RichTextBox eee = new RichTextBox();
                        eee.Margin = new System.Windows.Forms.Padding(0);
                        eee.Font = new System.Drawing.Font("Calibri", 10);
                        eee.Multiline = true;
                        eee.ReadOnly = true;
                        eee.Text = tag.eventInfo.Modeling;
                        int globalindex = 0;
                        foreach (string line in eee.Lines)
                        {
                            int index = line.IndexOf(" = ", 0);
                            if (index > -1)
                            {
                                eee.SelectionStart = globalindex + index + 3;
                                eee.SelectionLength = line.Length - index-3;
                                eee.SelectionFont = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                            }
                            globalindex += line.Length+1;
                        }
                        if (tag.eventInfo.SGCID != default(string))
                        {
                            eee.SelectionStart = 0;
                            eee.SelectionLength = 0;
                            eee.SelectionFont = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                            eee.SelectedText = String.Format("SGCID: {0}{1}", tag.eventInfo.SGCID, Environment.NewLine);
                        }
                        if (tag.eventInfo.PGCID != default(string))
                        {
                            eee.SelectionStart = 0;
                            eee.SelectionLength = 0;
                            eee.SelectionFont = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                            eee.SelectedText = String.Format("PGCID: {0}{1}", tag.eventInfo.PGCID, Environment.NewLine);
                        }
                        if (tag.eventInfo.CGCID != default(string))
                        {
                            eee.SelectionStart = 0;
                            eee.SelectionLength = 0;
                            eee.SelectionFont = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                            eee.SelectedText = String.Format("CGCID: {0}{1}", tag.eventInfo.CGCID, Environment.NewLine);
                        }
                        //Monitor
                        eee.SelectionStart = 0;
                        eee.SelectionLength = 0;
                        eee.SelectionFont = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                        eee.SelectedText = String.Format("Monitor: {0}{1}", tag.Monitor, Environment.NewLine);
                        //Event
                        eee.SelectionStart = 0;
                        eee.SelectionLength = 0;
                        eee.SelectionFont = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                        eee.SelectedText = String.Format("Event: {0}{1}", tag.eventInfo.Type, Environment.NewLine);

                        eee.Size = eee.PreferredSize;
                        ModelingForm.Controls.AddRange(new Control[] {eee});
                        ModelingForm.AutoSize = true;
                        ModelingForm.Show(this);
                        ModelingForm.ResumeLayout();
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    TreeNode node = treeLog.GetNodeAt(e.X, e.Y);
                    if (node != null && node.Parent == null)
                    {
                        treeLog.SelectedNode = node;
                        string result = (node.Text + Environment.NewLine).TrimStart();
                        foreach (TreeNode inode in node.Nodes)
                        {
                            result += "    " + inode.Text + Environment.NewLine;
                        }
                        Clipboard.SetText(result);
                    }
                }
            }
            else
            {
                ModelingForm.Close();
                ModelingForm = null;
            }
        }
Example #49
0
        void f_FloatControl(Control c)
        {
            Form f = new Form();
            f.SuspendLayout();
            f.Controls.Add(c);
            c.Dock = DockStyle.Fill;
            f.Icon = this.Icon;

            f.Text = this.Text + ((resourceName != null && resourceName.Length > 0) ? " - " + resourceName : "");

            if (c.GetType().Equals(typeof(RichTextBox)))
            {
                f.ClientSize = new Size(this.ClientSize.Width - (this.ClientSize.Width / 5), this.ClientSize.Height - (this.ClientSize.Height / 5));
            }
            else if (c.GetType().Equals(typeof(PictureBox)))
            {
                f.ClientSize = c.Size;
                f.SizeGripStyle = SizeGripStyle.Hide;
            }

            f.StartPosition = FormStartPosition.CenterParent;
            f.ResumeLayout();
            f.FormClosed += new FormClosedEventHandler(f_FormClosed);
            f.Show(this);
        }
Example #50
0
        private static Form GuiCreateWindow(string name)
        {
            int n;

            if (name == "1")
                name = Keyword_GuiPrefix;
            else if (name.Length < 3 && name.Length > 0 && int.TryParse(name, out n) && n > 0 && n < 99)
                name += Keyword_GuiPrefix;

            var win = new Form
            {
                Name = name,
                Tag = new GuiInfo
                {
                    Delimiter = '|'
                },
                KeyPreview = true
            };
            GuiAssociatedInfo(win).Font = win.Font;

            win.SuspendLayout();

            int x = (int) Math.Round(win.Font.Size * 1.25), y = (int) Math.Round(win.Font.Size * .75);
            win.Margin = new Padding(x, y, x, y);

            win.FormClosed += delegate
            {
                SafeInvoke(win.Name + Keyword_GuiClose);
            };

            win.KeyDown += delegate(object sender, KeyEventArgs e)
            {
                if (e.KeyCode == Keys.Escape)
                {
                    e.Handled = true;
                    SafeInvoke(win.Name + Keyword_GuiEscape);
                }
            };

            win.Resize += delegate
            {
                SafeInvoke(win.Name + Keyword_GuiSize);
            };

            return win;
        }
Example #51
0
        private void InitializeComponents()
        {
            this.theForm = new Form { BackColor = this.BackColor, WindowState = this.fullscreen ? FormWindowState.Maximized : FormWindowState.Normal };
            this.theForm.Text = "Fleux.Net";

            theForm.SuspendLayout();

            if (!this.fullscreen)
            {
                var mainMenu1 = new System.Windows.Forms.MainMenu();
                this.theForm.Menu = mainMenu1;

                // MenuItems
                this.LeftMenu = new MenuHandler { Visible = true, Enabled = true };
                this.RightMenu = new MenuHandler { Visible = true, Enabled = true };
                this.LeftMenu.PropertyChanged += this.MenuPropertyChanged;
                this.RightMenu.PropertyChanged += this.MenuPropertyChanged;
                this.SyncWinFormsMenuItems();
            }

            this.theForm.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
            this.theForm.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
            this.theForm.AutoScroll = false; //!!
            this.theForm.BackColor = System.Drawing.Color.Black;
            #if WindowsCE
            this.theForm.ClientSize = new System.Drawing.Size(800, 600);
            this.theForm.FormBorderStyle = FormBorderStyle.None;
            this.theForm.ControlBox = false;
            #else
            this.theForm.ClientSize = new System.Drawing.Size(240, 268);
            #endif

            // DpiHelper Set
            if (!FleuxApplication.Initialized)
            {
                FleuxApplication.Initialize(this.theForm.CreateGraphics());
            }

            this.theForm.Activated += (s, e) => this.OnActivated();

            theForm.ResumeLayout(false);
        }
        private void UpdateForm(Form form)
        {
            if (form != null)
            {
                form.SuspendLayout();

                ComponentResourceManager rm = new ComponentResourceManager(Parent.GetType());

                foreach (Control ctrl in form.Controls)
                    RefreshControls(ctrl, rm);

                rm.ApplyResources(form, form.Name, _currentLanguage);

                form.ResumeLayout();
            }
        }
Example #53
0
		public void bug_82326 ()
		{
			using (Form f = new Form ()) {
				DataGridView _dataGrid;
				DataGridViewTextBoxColumn _column;

				_dataGrid = new DataGridView ();
				_column = new DataGridViewTextBoxColumn ();
				f.SuspendLayout ();
				((ISupportInitialize)(_dataGrid)).BeginInit ();
				// 
				// _dataGrid
				// 
				_dataGrid.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
				_dataGrid.Columns.Add (_column);
				_dataGrid.RowTemplate.Height = 21;
				_dataGrid.Location = new Point (12, 115);
				_dataGrid.Size = new Size (268, 146);
				_dataGrid.TabIndex = 0;
				// 
				// _column
				// 
				_column.HeaderText = "Column";
				// 
				// MainForm
				// 
				f.ClientSize = new Size (292, 273);
				f.Controls.Add (_dataGrid);
				((ISupportInitialize)(_dataGrid)).EndInit ();
				f.ResumeLayout (false);
				f.Load += delegate (object sender, EventArgs e) { ((Control)sender).FindForm ().Close (); };

				Application.Run (f);
			}
		}
Example #54
0
        private void CreateMenu()
        {
            menuForm = new Form()
            {
                AutoScaleDimensions = new SizeF(6F, 13F),
                AutoScaleMode = AutoScaleMode.Font,
                AutoSize = true,
                AutoSizeMode = AutoSizeMode.GrowAndShrink,
                ClientSize = new Size(759, 509),
                FormBorderStyle = FormBorderStyle.None,
                Location = new Point(200, 200),
                ShowInTaskbar = false,
                StartPosition = FormStartPosition.Manual,
                Text = "RegionCaptureFormMenu"
            };

            menuForm.SuspendLayout();

            tsMain = new ToolStripEx()
            {
                AutoSize = true,
                CanOverflow = false,
                ClickThrough = true,
                Dock = DockStyle.None,
                GripStyle = ToolStripGripStyle.Hidden,
                Location = new Point(0, 0),
                MinimumSize = new Size(300, 30),
                Padding = new Padding(0, 0, 0, 0),
                Renderer = new CustomToolStripProfessionalRenderer(),
                TabIndex = 0
            };

            tsMain.SuspendLayout();

            menuForm.Controls.Add(tsMain);

            ToolStripLabel tslDragLeft = new ToolStripLabel()
            {
                DisplayStyle = ToolStripItemDisplayStyle.Image,
                Image = Resources.ui_radio_button_uncheck,
                Margin = new Padding(0),
                Padding = new Padding(2)
            };

            tslDragLeft.MouseDown += (sender, e) =>
            {
                NativeMethods.ReleaseCapture();
                NativeMethods.DefWindowProc(menuForm.Handle, (uint)WindowsMessages.SYSCOMMAND, (UIntPtr)NativeConstants.MOUSE_MOVE, IntPtr.Zero);
            };

            tsMain.Items.Add(tslDragLeft);

            #region Editor mode

            if (form.Mode == RegionCaptureMode.Editor)
            {
                ToolStripButton tsbCompleteEdit = new ToolStripButton("Run after capture tasks");
                tsbCompleteEdit.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbCompleteEdit.Image = Resources.tick;
                tsbCompleteEdit.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateRunAfterCaptureTasks);
                tsMain.Items.Add(tsbCompleteEdit);

                ToolStripButton tsbSaveImage = new ToolStripButton("Save image");
                tsbSaveImage.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbSaveImage.Enabled = !string.IsNullOrEmpty(form.ImageFilePath);
                tsbSaveImage.Image = Resources.disk_black;
                tsbSaveImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateSaveImage);
                tsMain.Items.Add(tsbSaveImage);

                ToolStripButton tsbSaveImageAs = new ToolStripButton("Save image as...");
                tsbSaveImageAs.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbSaveImageAs.Image = Resources.disks_black;
                tsbSaveImageAs.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateSaveImageAs);
                tsMain.Items.Add(tsbSaveImageAs);

                ToolStripButton tsbCopyImage = new ToolStripButton("Copy image to clipboard");
                tsbCopyImage.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbCopyImage.Image = Resources.clipboard;
                tsbCopyImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateCopyImage);
                tsMain.Items.Add(tsbCopyImage);

                ToolStripButton tsbUploadImage = new ToolStripButton("Upload image");
                tsbUploadImage.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbUploadImage.Image = Resources.drive_globe;
                tsbUploadImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateUploadImage);
                tsMain.Items.Add(tsbUploadImage);

                ToolStripButton tsbPrintImage = new ToolStripButton("Print image...");
                tsbPrintImage.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbPrintImage.Image = Resources.printer;
                tsbPrintImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotatePrintImage);
                tsMain.Items.Add(tsbPrintImage);

                tsMain.Items.Add(new ToolStripSeparator());
            }

            #endregion Editor mode

            #region Tools

            foreach (ShapeType shapeType in Helpers.GetEnums<ShapeType>())
            {
                if (form.Mode == RegionCaptureMode.Editor)
                {
                    if (IsShapeTypeRegion(shapeType))
                    {
                        continue;
                    }
                }
                else if (shapeType == ShapeType.DrawingRectangle)
                {
                    tsMain.Items.Add(new ToolStripSeparator());
                }

                ToolStripButton tsbShapeType = new ToolStripButton(shapeType.GetLocalizedDescription());
                tsbShapeType.DisplayStyle = ToolStripItemDisplayStyle.Image;

                Image img = null;

                switch (shapeType)
                {
                    case ShapeType.RegionRectangle:
                        img = Resources.layer_shape_region;
                        break;
                    case ShapeType.RegionRoundedRectangle:
                        img = Resources.layer_shape_round_region;
                        break;
                    case ShapeType.RegionEllipse:
                        img = Resources.layer_shape_ellipse_region;
                        break;
                    case ShapeType.RegionFreehand:
                        img = Resources.layer_shape_polygon;
                        break;
                    case ShapeType.DrawingRectangle:
                        img = Resources.layer_shape;
                        break;
                    case ShapeType.DrawingRoundedRectangle:
                        img = Resources.layer_shape_round;
                        break;
                    case ShapeType.DrawingEllipse:
                        img = Resources.layer_shape_ellipse;
                        break;
                    case ShapeType.DrawingFreehand:
                        img = Resources.layer_shape_curve;
                        break;
                    case ShapeType.DrawingLine:
                        img = Resources.layer_shape_line;
                        break;
                    case ShapeType.DrawingArrow:
                        img = Resources.layer_shape_arrow;
                        break;
                    case ShapeType.DrawingText:
                        img = Resources.layer_shape_text;
                        break;
                    case ShapeType.DrawingSpeechBalloon:
                        img = Resources.balloon_box_left;
                        break;
                    case ShapeType.DrawingStep:
                        img = Resources.counter_reset;
                        break;
                    case ShapeType.DrawingImage:
                        img = Resources.image;
                        break;
                    case ShapeType.EffectBlur:
                        img = Resources.layer_shade;
                        break;
                    case ShapeType.EffectPixelate:
                        img = Resources.grid;
                        break;
                    case ShapeType.EffectHighlight:
                        img = Resources.highlighter_text;
                        break;
                }

                tsbShapeType.Image = img;
                tsbShapeType.Checked = shapeType == CurrentShapeType;
                tsbShapeType.Tag = shapeType;

                tsbShapeType.MouseDown += (sender, e) =>
                {
                    tsbShapeType.RadioCheck();
                    CurrentShapeType = shapeType;
                };

                tsMain.Items.Add(tsbShapeType);
            }

            #endregion Tools

            #region Selected object

            tsMain.Items.Add(new ToolStripSeparator());

            tsddbShapeOptions = new ToolStripDropDownButton("Shape options");
            tsddbShapeOptions.DisplayStyle = ToolStripItemDisplayStyle.Image;
            tsddbShapeOptions.Image = Resources.layer__pencil;
            tsMain.Items.Add(tsddbShapeOptions);

            tsmiBorderColor = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Border_color___);
            tsmiBorderColor.Click += (sender, e) =>
            {
                PauseForm();

                ShapeType shapeType = CurrentShapeType;

                Color borderColor;

                if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
                {
                    borderColor = AnnotationOptions.TextBorderColor;
                }
                else if (shapeType == ShapeType.DrawingStep)
                {
                    borderColor = AnnotationOptions.StepBorderColor;
                }
                else
                {
                    borderColor = AnnotationOptions.BorderColor;
                }

                using (ColorPickerForm dialogColor = new ColorPickerForm(borderColor))
                {
                    if (dialogColor.ShowDialog() == DialogResult.OK)
                    {
                        if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
                        {
                            AnnotationOptions.TextBorderColor = dialogColor.NewColor;
                        }
                        else if (shapeType == ShapeType.DrawingStep)
                        {
                            AnnotationOptions.StepBorderColor = dialogColor.NewColor;
                        }
                        else
                        {
                            AnnotationOptions.BorderColor = dialogColor.NewColor;
                        }

                        UpdateMenu();
                        UpdateCurrentShape();
                        UpdateCursor();
                    }
                }

                ResumeForm();
            };
            tsddbShapeOptions.DropDownItems.Add(tsmiBorderColor);

            tslnudBorderSize = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Border_size_);
            tslnudBorderSize.Content.Minimum = 0;
            tslnudBorderSize.Content.Maximum = 20;
            tslnudBorderSize.Content.ValueChanged = (sender, e) =>
            {
                ShapeType shapeType = CurrentShapeType;

                int borderSize = (int)tslnudBorderSize.Content.Value;

                if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
                {
                    AnnotationOptions.TextBorderSize = borderSize;
                }
                else if (shapeType == ShapeType.DrawingStep)
                {
                    AnnotationOptions.StepBorderSize = borderSize;
                }
                else
                {
                    AnnotationOptions.BorderSize = borderSize;
                }

                UpdateCurrentShape();
                UpdateCursor();
            };
            tsddbShapeOptions.DropDownItems.Add(tslnudBorderSize);

            tsmiFillColor = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Fill_color___);
            tsmiFillColor.Click += (sender, e) =>
            {
                PauseForm();

                ShapeType shapeType = CurrentShapeType;

                Color fillColor;

                if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
                {
                    fillColor = AnnotationOptions.TextFillColor;
                }
                else if (shapeType == ShapeType.DrawingStep)
                {
                    fillColor = AnnotationOptions.StepFillColor;
                }
                else
                {
                    fillColor = AnnotationOptions.FillColor;
                }

                using (ColorPickerForm dialogColor = new ColorPickerForm(fillColor))
                {
                    if (dialogColor.ShowDialog() == DialogResult.OK)
                    {
                        if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
                        {
                            AnnotationOptions.TextFillColor = dialogColor.NewColor;
                        }
                        else if (shapeType == ShapeType.DrawingStep)
                        {
                            AnnotationOptions.StepFillColor = dialogColor.NewColor;
                        }
                        else
                        {
                            AnnotationOptions.FillColor = dialogColor.NewColor;
                        }

                        UpdateMenu();
                        UpdateCurrentShape();
                    }
                }

                ResumeForm();
            };
            tsddbShapeOptions.DropDownItems.Add(tsmiFillColor);

            tslnudCornerRadius = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Corner_radius_);
            tslnudCornerRadius.Content.Minimum = 0;
            tslnudCornerRadius.Content.Maximum = 150;
            tslnudCornerRadius.Content.Increment = 3;
            tslnudCornerRadius.Content.ValueChanged = (sender, e) =>
            {
                ShapeType shapeType = CurrentShapeType;

                if (shapeType == ShapeType.RegionRoundedRectangle || shapeType == ShapeType.DrawingRoundedRectangle)
                {
                    AnnotationOptions.RoundedRectangleRadius = (int)tslnudCornerRadius.Content.Value;
                }
                else if (shapeType == ShapeType.DrawingText)
                {
                    AnnotationOptions.TextCornerRadius = (int)tslnudCornerRadius.Content.Value;
                }

                UpdateCurrentShape();
            };
            tsddbShapeOptions.DropDownItems.Add(tslnudCornerRadius);

            tslnudBlurRadius = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Blur_radius_);
            tslnudBlurRadius.Content.Minimum = 2;
            tslnudBlurRadius.Content.Maximum = 100;
            tslnudBlurRadius.Content.ValueChanged = (sender, e) =>
            {
                AnnotationOptions.BlurRadius = (int)tslnudBlurRadius.Content.Value;
                UpdateCurrentShape();
            };
            tsddbShapeOptions.DropDownItems.Add(tslnudBlurRadius);

            tslnudPixelateSize = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Pixel_size_);
            tslnudPixelateSize.Content.Minimum = 2;
            tslnudPixelateSize.Content.Maximum = 100;
            tslnudPixelateSize.Content.ValueChanged = (sender, e) =>
            {
                AnnotationOptions.PixelateSize = (int)tslnudPixelateSize.Content.Value;
                UpdateCurrentShape();
            };
            tsddbShapeOptions.DropDownItems.Add(tslnudPixelateSize);

            tsmiHighlightColor = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Highlight_color___);
            tsmiHighlightColor.Click += (sender, e) =>
            {
                PauseForm();

                using (ColorPickerForm dialogColor = new ColorPickerForm(AnnotationOptions.HighlightColor))
                {
                    if (dialogColor.ShowDialog() == DialogResult.OK)
                    {
                        AnnotationOptions.HighlightColor = dialogColor.NewColor;
                        UpdateMenu();
                        UpdateCurrentShape();
                    }
                }

                ResumeForm();
            };
            tsddbShapeOptions.DropDownItems.Add(tsmiHighlightColor);

            tsbDeleteSelected = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Delete_selected_object);
            tsbDeleteSelected.DisplayStyle = ToolStripItemDisplayStyle.Image;
            tsbDeleteSelected.Image = Resources.layer__minus;
            tsbDeleteSelected.MouseDown += (sender, e) => DeleteCurrentShape();
            tsMain.Items.Add(tsbDeleteSelected);

            tsbDeleteAll = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Delete_all_objects);
            tsbDeleteAll.DisplayStyle = ToolStripItemDisplayStyle.Image;
            tsbDeleteAll.Image = Resources.eraser;
            tsbDeleteAll.MouseDown += (sender, e) => DeleteAllShapes();
            tsMain.Items.Add(tsbDeleteAll);

            #endregion Selected object

            #region Capture

            if (form.Mode != RegionCaptureMode.Editor)
            {
                tsMain.Items.Add(new ToolStripSeparator());

                ToolStripButton tsbFullscreenCapture = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Capture_fullscreen);
                tsbFullscreenCapture.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbFullscreenCapture.Image = Resources.layer_fullscreen;
                tsbFullscreenCapture.MouseDown += (sender, e) => form.Close(RegionResult.Fullscreen);
                tsMain.Items.Add(tsbFullscreenCapture);

                ToolStripButton tsbActiveMonitorCapture = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Capture_active_monitor);
                tsbActiveMonitorCapture.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbActiveMonitorCapture.Image = Resources.monitor;
                tsbActiveMonitorCapture.MouseDown += (sender, e) => form.Close(RegionResult.ActiveMonitor);
                tsMain.Items.Add(tsbActiveMonitorCapture);

                ToolStripDropDownButton tsddbMonitorCapture = new ToolStripDropDownButton(Resources.ShapeManager_CreateContextMenu_Capture_monitor);
                tsddbMonitorCapture.HideImageMargin();
                tsddbMonitorCapture.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsddbMonitorCapture.Image = Resources.monitor_window;
                tsMain.Items.Add(tsddbMonitorCapture);

                tsddbMonitorCapture.DropDownItems.Clear();

                Screen[] screens = Screen.AllScreens;

                for (int i = 0; i < screens.Length; i++)
                {
                    Screen screen = screens[i];
                    ToolStripMenuItem tsmi = new ToolStripMenuItem(string.Format("{0}. {1}x{2}", i + 1, screen.Bounds.Width, screen.Bounds.Height));
                    int index = i;
                    tsmi.MouseDown += (sender, e) =>
                    {
                        form.MonitorIndex = index;
                        form.Close(RegionResult.Monitor);
                    };
                    tsddbMonitorCapture.DropDownItems.Add(tsmi);
                }
            }

            #endregion Capture

            #region Options

            if (form.Mode != RegionCaptureMode.Editor)
            {
                tsMain.Items.Add(new ToolStripSeparator());

                ToolStripDropDownButton tsddbOptions = new ToolStripDropDownButton(Resources.ShapeManager_CreateContextMenu_Options);
                tsddbOptions.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsddbOptions.Image = Resources.gear;
                tsMain.Items.Add(tsddbOptions);

                tsmiQuickCrop = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Multi_region_mode);
                tsmiQuickCrop.Checked = !Config.QuickCrop;
                tsmiQuickCrop.CheckOnClick = true;
                tsmiQuickCrop.Click += (sender, e) => Config.QuickCrop = !tsmiQuickCrop.Checked;
                tsddbOptions.DropDownItems.Add(tsmiQuickCrop);

                ToolStripMenuItem tsmiTips = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_tips);
                tsmiTips.Checked = Config.ShowTips;
                tsmiTips.CheckOnClick = true;
                tsmiTips.Click += (sender, e) => Config.ShowTips = tsmiTips.Checked;
                tsddbOptions.DropDownItems.Add(tsmiTips);

                ToolStripMenuItem tsmiShowInfo = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_position_and_size_info);
                tsmiShowInfo.Checked = Config.ShowInfo;
                tsmiShowInfo.CheckOnClick = true;
                tsmiShowInfo.Click += (sender, e) => Config.ShowInfo = tsmiShowInfo.Checked;
                tsddbOptions.DropDownItems.Add(tsmiShowInfo);

                ToolStripMenuItem tsmiShowMagnifier = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_magnifier);
                tsmiShowMagnifier.Checked = Config.ShowMagnifier;
                tsmiShowMagnifier.CheckOnClick = true;
                tsmiShowMagnifier.Click += (sender, e) => Config.ShowMagnifier = tsmiShowMagnifier.Checked;
                tsddbOptions.DropDownItems.Add(tsmiShowMagnifier);

                ToolStripMenuItem tsmiUseSquareMagnifier = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Square_shape_magnifier);
                tsmiUseSquareMagnifier.Checked = Config.UseSquareMagnifier;
                tsmiUseSquareMagnifier.CheckOnClick = true;
                tsmiUseSquareMagnifier.Click += (sender, e) => Config.UseSquareMagnifier = tsmiUseSquareMagnifier.Checked;
                tsddbOptions.DropDownItems.Add(tsmiUseSquareMagnifier);

                ToolStripLabeledNumericUpDown tslnudMagnifierPixelCount = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Magnifier_pixel_count_);
                tslnudMagnifierPixelCount.Content.Minimum = RegionCaptureOptions.MagnifierPixelCountMinimum;
                tslnudMagnifierPixelCount.Content.Maximum = RegionCaptureOptions.MagnifierPixelCountMaximum;
                tslnudMagnifierPixelCount.Content.Increment = 2;
                tslnudMagnifierPixelCount.Content.Value = Config.MagnifierPixelCount;
                tslnudMagnifierPixelCount.Content.ValueChanged = (sender, e) => Config.MagnifierPixelCount = (int)tslnudMagnifierPixelCount.Content.Value;
                tsddbOptions.DropDownItems.Add(tslnudMagnifierPixelCount);

                ToolStripLabeledNumericUpDown tslnudMagnifierPixelSize = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Magnifier_pixel_size_);
                tslnudMagnifierPixelSize.Content.Minimum = RegionCaptureOptions.MagnifierPixelSizeMinimum;
                tslnudMagnifierPixelSize.Content.Maximum = RegionCaptureOptions.MagnifierPixelSizeMaximum;
                tslnudMagnifierPixelSize.Content.Value = Config.MagnifierPixelSize;
                tslnudMagnifierPixelSize.Content.ValueChanged = (sender, e) => Config.MagnifierPixelSize = (int)tslnudMagnifierPixelSize.Content.Value;
                tsddbOptions.DropDownItems.Add(tslnudMagnifierPixelSize);

                ToolStripMenuItem tsmiShowCrosshair = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_screen_wide_crosshair);
                tsmiShowCrosshair.Checked = Config.ShowCrosshair;
                tsmiShowCrosshair.CheckOnClick = true;
                tsmiShowCrosshair.Click += (sender, e) => Config.ShowCrosshair = tsmiShowCrosshair.Checked;
                tsddbOptions.DropDownItems.Add(tsmiShowCrosshair);

                ToolStripMenuItem tsmiFixedSize = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Fixed_size_region_mode);
                tsmiFixedSize.Checked = Config.IsFixedSize;
                tsmiFixedSize.CheckOnClick = true;
                tsmiFixedSize.Click += (sender, e) => Config.IsFixedSize = tsmiFixedSize.Checked;
                tsddbOptions.DropDownItems.Add(tsmiFixedSize);

                ToolStripDoubleLabeledNumericUpDown tslnudFixedSize = new ToolStripDoubleLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Width_,
                    Resources.ShapeManager_CreateContextMenu_Height_);
                tslnudFixedSize.Content.Minimum = 10;
                tslnudFixedSize.Content.Maximum = 10000;
                tslnudFixedSize.Content.Increment = 10;
                tslnudFixedSize.Content.Value = Config.FixedSize.Width;
                tslnudFixedSize.Content.Value2 = Config.FixedSize.Height;
                tslnudFixedSize.Content.ValueChanged = (sender, e) => Config.FixedSize = new Size((int)tslnudFixedSize.Content.Value, (int)tslnudFixedSize.Content.Value2);
                tsddbOptions.DropDownItems.Add(tslnudFixedSize);

                ToolStripMenuItem tsmiShowFPS = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_FPS);
                tsmiShowFPS.Checked = Config.ShowFPS;
                tsmiShowFPS.CheckOnClick = true;
                tsmiShowFPS.Click += (sender, e) => Config.ShowFPS = tsmiShowFPS.Checked;
                tsddbOptions.DropDownItems.Add(tsmiShowFPS);
            }

            #endregion Options

            ToolStripLabel tslDragRight = new ToolStripLabel()
            {
                Alignment = ToolStripItemAlignment.Right,
                DisplayStyle = ToolStripItemDisplayStyle.Image,
                Image = Resources.ui_radio_button_uncheck,
                Margin = new Padding(0),
                Padding = new Padding(2)
            };

            tslDragRight.MouseDown += (sender, e) =>
            {
                NativeMethods.ReleaseCapture();
                NativeMethods.DefWindowProc(menuForm.Handle, (uint)WindowsMessages.SYSCOMMAND, (UIntPtr)NativeConstants.MOUSE_MOVE, IntPtr.Zero);
            };

            tsMain.Items.Add(tslDragRight);

            tsMain.ResumeLayout(false);
            tsMain.PerformLayout();
            menuForm.ResumeLayout(false);

            menuForm.Show(form);

            Rectangle rectActiveScreen = CaptureHelpers.GetActiveScreenBounds0Based();

            if (tsMain.Width < rectActiveScreen.Width)
            {
                menuForm.Location = new Point(rectActiveScreen.X + rectActiveScreen.Width / 2 - tsMain.Width / 2, rectActiveScreen.Y + 20);

                menuForm.LocationChanged += (sender, e) =>
                {
                    Rectangle rectMenu = menuForm.Bounds;
                    Rectangle rectScreen = CaptureHelpers.GetScreenBounds();
                    Point pos = rectMenu.Location;

                    if (rectMenu.X < rectScreen.X)
                    {
                        pos.X = rectScreen.X;
                    }
                    else if (rectMenu.Right > rectScreen.Right)
                    {
                        pos.X = rectScreen.Right - rectMenu.Width;
                    }

                    if (rectMenu.Y < rectScreen.Y)
                    {
                        pos.Y = rectScreen.Y;
                    }
                    else if (rectMenu.Bottom > rectScreen.Bottom)
                    {
                        pos.Y = rectScreen.Bottom - rectMenu.Height;
                    }

                    if (pos != rectMenu.Location)
                    {
                        menuForm.Location = pos;
                    }
                };
            }
            else
            {
                menuForm.Location = rectActiveScreen.Location;
            }

            form.Activate();

            UpdateMenu();

            CurrentShapeTypeChanged += shapeType => UpdateMenu();

            CurrentShapeChanged += shape => UpdateMenu();
        }
Example #55
0
        private void CreateToolbar()
        {
            menuForm = new Form()
            {
                AutoScaleDimensions = new SizeF(6F, 13F),
                AutoScaleMode = AutoScaleMode.Font,
                AutoSize = true,
                AutoSizeMode = AutoSizeMode.GrowAndShrink,
                ClientSize = new Size(759, 509),
                FormBorderStyle = FormBorderStyle.None,
                Location = new Point(200, 200),
                ShowInTaskbar = false,
                StartPosition = FormStartPosition.Manual,
                Text = "ShareX - Region capture menu",
                TopMost = true
            };

            menuForm.KeyUp += MenuForm_KeyUp;
            menuForm.LocationChanged += MenuForm_LocationChanged;

            menuForm.SuspendLayout();

            tsMain = new ToolStripEx()
            {
                AutoSize = true,
                CanOverflow = false,
                ClickThrough = true,
                Dock = DockStyle.None,
                GripStyle = ToolStripGripStyle.Hidden,
                Location = new Point(0, 0),
                MinimumSize = new Size(10, 30),
                Padding = new Padding(0, 0, 0, 0),
                Renderer = new CustomToolStripProfessionalRenderer(),
                TabIndex = 0,
                ShowItemToolTips = false
            };

            tsMain.MouseLeave += TsMain_MouseLeave;

            tsMain.SuspendLayout();

            // https://www.medo64.com/2014/01/scaling-toolstrip-with-dpi/
            using (Graphics g = menuForm.CreateGraphics())
            {
                double scale = Math.Max(g.DpiX, g.DpiY) / 96.0;
                double newScale = ((int)Math.Floor(scale * 100) / 25 * 25) / 100.0;
                if (newScale > 1)
                {
                    int newWidth = (int)(tsMain.ImageScalingSize.Width * newScale);
                    int newHeight = (int)(tsMain.ImageScalingSize.Height * newScale);
                    tsMain.ImageScalingSize = new Size(newWidth, newHeight);
                }
            }

            menuForm.Controls.Add(tsMain);

            tslDragLeft = new ToolStripLabel()
            {
                DisplayStyle = ToolStripItemDisplayStyle.Image,
                Image = Resources.ui_radio_button_uncheck,
                Margin = new Padding(2, 0, 2, 0),
                Padding = new Padding(2)
            };

            tsMain.Items.Add(tslDragLeft);

            if (form.Mode == RegionCaptureMode.Editor)
            {
                #region Editor mode

                ToolStripButton tsbCompleteEdit = new ToolStripButton("Run after capture tasks");
                tsbCompleteEdit.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbCompleteEdit.Image = Resources.tick;
                tsbCompleteEdit.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateRunAfterCaptureTasks);
                tsMain.Items.Add(tsbCompleteEdit);

                ToolStripButton tsbSaveImage = new ToolStripButton("Save image");
                tsbSaveImage.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbSaveImage.Enabled = !string.IsNullOrEmpty(form.ImageFilePath);
                tsbSaveImage.Image = Resources.disk_black;
                tsbSaveImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateSaveImage);
                tsMain.Items.Add(tsbSaveImage);

                ToolStripButton tsbSaveImageAs = new ToolStripButton("Save image as...");
                tsbSaveImageAs.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbSaveImageAs.Image = Resources.disks_black;
                tsbSaveImageAs.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateSaveImageAs);
                tsMain.Items.Add(tsbSaveImageAs);

                ToolStripButton tsbCopyImage = new ToolStripButton("Copy image to clipboard");
                tsbCopyImage.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbCopyImage.Image = Resources.clipboard;
                tsbCopyImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateCopyImage);
                tsMain.Items.Add(tsbCopyImage);

                ToolStripButton tsbUploadImage = new ToolStripButton("Upload image");
                tsbUploadImage.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbUploadImage.Image = Resources.drive_globe;
                tsbUploadImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotateUploadImage);
                tsMain.Items.Add(tsbUploadImage);

                ToolStripButton tsbPrintImage = new ToolStripButton("Print image...");
                tsbPrintImage.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsbPrintImage.Image = Resources.printer;
                tsbPrintImage.MouseDown += (sender, e) => form.Close(RegionResult.AnnotatePrintImage);
                tsMain.Items.Add(tsbPrintImage);

                tsMain.Items.Add(new ToolStripSeparator());

                #endregion Editor mode
            }

            #region Tools

            foreach (ShapeType shapeType in Helpers.GetEnums<ShapeType>())
            {
                if (form.Mode == RegionCaptureMode.Editor)
                {
                    if (IsShapeTypeRegion(shapeType))
                    {
                        continue;
                    }
                }
                else if (shapeType == ShapeType.DrawingRectangle)
                {
                    tsMain.Items.Add(new ToolStripSeparator());
                }

                ToolStripButton tsbShapeType = new ToolStripButton(shapeType.GetLocalizedDescription());
                tsbShapeType.DisplayStyle = ToolStripItemDisplayStyle.Image;

                Image img = null;

                switch (shapeType)
                {
                    case ShapeType.RegionRectangle:
                        img = Resources.layer_shape_region;
                        break;
                    case ShapeType.RegionEllipse:
                        img = Resources.layer_shape_ellipse_region;
                        break;
                    case ShapeType.RegionFreehand:
                        img = Resources.layer_shape_polygon;
                        break;
                    case ShapeType.DrawingRectangle:
                        img = Resources.layer_shape;
                        break;
                    case ShapeType.DrawingEllipse:
                        img = Resources.layer_shape_ellipse;
                        break;
                    case ShapeType.DrawingFreehand:
                        img = Resources.layer_shape_curve;
                        break;
                    case ShapeType.DrawingLine:
                        img = Resources.layer_shape_line;
                        break;
                    case ShapeType.DrawingArrow:
                        img = Resources.layer_shape_arrow;
                        break;
                    case ShapeType.DrawingText:
                        img = Resources.layer_shape_text;
                        break;
                    case ShapeType.DrawingSpeechBalloon:
                        img = Resources.balloon_box_left;
                        break;
                    case ShapeType.DrawingStep:
                        img = Resources.counter_reset;
                        break;
                    case ShapeType.DrawingImage:
                        img = Resources.image;
                        break;
                    case ShapeType.EffectBlur:
                        img = Resources.layer_shade;
                        break;
                    case ShapeType.EffectPixelate:
                        img = Resources.grid;
                        break;
                    case ShapeType.EffectHighlight:
                        img = Resources.highlighter_text;
                        break;
                }

                tsbShapeType.Image = img;
                tsbShapeType.Checked = shapeType == CurrentShapeType;
                tsbShapeType.Tag = shapeType;

                tsbShapeType.MouseDown += (sender, e) =>
                {
                    tsbShapeType.RadioCheck();
                    CurrentShapeType = shapeType;
                };

                tsMain.Items.Add(tsbShapeType);
            }

            #endregion Tools

            #region Shape options

            tsMain.Items.Add(new ToolStripSeparator());

            tsbBorderColor = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Border_color___);
            tsbBorderColor.DisplayStyle = ToolStripItemDisplayStyle.Image;
            tsbBorderColor.Click += (sender, e) =>
            {
                PauseForm();

                ShapeType shapeType = CurrentShapeType;

                Color borderColor;

                if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
                {
                    borderColor = AnnotationOptions.TextBorderColor;
                }
                else if (shapeType == ShapeType.DrawingStep)
                {
                    borderColor = AnnotationOptions.StepBorderColor;
                }
                else
                {
                    borderColor = AnnotationOptions.BorderColor;
                }

                using (ColorPickerForm dialogColor = new ColorPickerForm(borderColor))
                {
                    if (dialogColor.ShowDialog() == DialogResult.OK)
                    {
                        if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
                        {
                            AnnotationOptions.TextBorderColor = dialogColor.NewColor;
                        }
                        else if (shapeType == ShapeType.DrawingStep)
                        {
                            AnnotationOptions.StepBorderColor = dialogColor.NewColor;
                        }
                        else
                        {
                            AnnotationOptions.BorderColor = dialogColor.NewColor;
                        }

                        UpdateMenu();
                        UpdateCurrentShape();
                    }
                }

                ResumeForm();
            };
            tsMain.Items.Add(tsbBorderColor);

            tsbFillColor = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Fill_color___);
            tsbFillColor.DisplayStyle = ToolStripItemDisplayStyle.Image;
            tsbFillColor.Click += (sender, e) =>
            {
                PauseForm();

                ShapeType shapeType = CurrentShapeType;

                Color fillColor;

                if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
                {
                    fillColor = AnnotationOptions.TextFillColor;
                }
                else if (shapeType == ShapeType.DrawingStep)
                {
                    fillColor = AnnotationOptions.StepFillColor;
                }
                else
                {
                    fillColor = AnnotationOptions.FillColor;
                }

                using (ColorPickerForm dialogColor = new ColorPickerForm(fillColor))
                {
                    if (dialogColor.ShowDialog() == DialogResult.OK)
                    {
                        if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
                        {
                            AnnotationOptions.TextFillColor = dialogColor.NewColor;
                        }
                        else if (shapeType == ShapeType.DrawingStep)
                        {
                            AnnotationOptions.StepFillColor = dialogColor.NewColor;
                        }
                        else
                        {
                            AnnotationOptions.FillColor = dialogColor.NewColor;
                        }

                        UpdateMenu();
                        UpdateCurrentShape();
                    }
                }

                ResumeForm();
            };
            tsMain.Items.Add(tsbFillColor);

            tsbHighlightColor = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Highlight_color___);
            tsbHighlightColor.DisplayStyle = ToolStripItemDisplayStyle.Image;
            tsbHighlightColor.Click += (sender, e) =>
            {
                PauseForm();

                using (ColorPickerForm dialogColor = new ColorPickerForm(AnnotationOptions.HighlightColor))
                {
                    if (dialogColor.ShowDialog() == DialogResult.OK)
                    {
                        AnnotationOptions.HighlightColor = dialogColor.NewColor;
                        UpdateMenu();
                        UpdateCurrentShape();
                    }
                }

                ResumeForm();
            };
            tsMain.Items.Add(tsbHighlightColor);

            tsddbShapeOptions = new ToolStripDropDownButton("Shape options");
            tsddbShapeOptions.DisplayStyle = ToolStripItemDisplayStyle.Image;
            tsddbShapeOptions.Image = Resources.layer__pencil;
            tsMain.Items.Add(tsddbShapeOptions);

            tslnudBorderSize = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Border_size_);
            tslnudBorderSize.Content.Minimum = 0;
            tslnudBorderSize.Content.Maximum = 20;
            tslnudBorderSize.Content.ValueChanged = (sender, e) =>
            {
                ShapeType shapeType = CurrentShapeType;

                int borderSize = (int)tslnudBorderSize.Content.Value;

                if (shapeType == ShapeType.DrawingText || shapeType == ShapeType.DrawingSpeechBalloon)
                {
                    AnnotationOptions.TextBorderSize = borderSize;
                }
                else if (shapeType == ShapeType.DrawingStep)
                {
                    AnnotationOptions.StepBorderSize = borderSize;
                }
                else
                {
                    AnnotationOptions.BorderSize = borderSize;
                }

                UpdateCurrentShape();
            };
            tsddbShapeOptions.DropDownItems.Add(tslnudBorderSize);

            tslnudCornerRadius = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Corner_radius_);
            tslnudCornerRadius.Content.Minimum = 0;
            tslnudCornerRadius.Content.Maximum = 150;
            tslnudCornerRadius.Content.ValueChanged = (sender, e) =>
            {
                ShapeType shapeType = CurrentShapeType;

                if (shapeType == ShapeType.RegionRectangle)
                {
                    AnnotationOptions.RegionCornerRadius = (int)tslnudCornerRadius.Content.Value;
                }
                else if (shapeType == ShapeType.DrawingRectangle || shapeType == ShapeType.DrawingText)
                {
                    AnnotationOptions.DrawingCornerRadius = (int)tslnudCornerRadius.Content.Value;
                }

                UpdateCurrentShape();
            };
            tsddbShapeOptions.DropDownItems.Add(tslnudCornerRadius);

            tslnudBlurRadius = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Blur_radius_);
            tslnudBlurRadius.Content.Minimum = 3;
            tslnudBlurRadius.Content.Maximum = 199;
            tslnudBlurRadius.Content.Increment = 2;
            tslnudBlurRadius.Content.ValueChanged = (sender, e) =>
            {
                AnnotationOptions.BlurRadius = (int)tslnudBlurRadius.Content.Value;
                UpdateCurrentShape();
            };
            tsddbShapeOptions.DropDownItems.Add(tslnudBlurRadius);

            tslnudPixelateSize = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Pixel_size_);
            tslnudPixelateSize.Content.Minimum = 2;
            tslnudPixelateSize.Content.Maximum = 10000;
            tslnudPixelateSize.Content.ValueChanged = (sender, e) =>
            {
                AnnotationOptions.PixelateSize = (int)tslnudPixelateSize.Content.Value;
                UpdateCurrentShape();
            };
            tsddbShapeOptions.DropDownItems.Add(tslnudPixelateSize);

            tsmiShadow = new ToolStripMenuItem("Drop shadow");
            tsmiShadow.Checked = true;
            tsmiShadow.CheckOnClick = true;
            tsmiShadow.Click += (sender, e) =>
            {
                AnnotationOptions.Shadow = tsmiShadow.Checked;
                UpdateCurrentShape();
            };
            tsddbShapeOptions.DropDownItems.Add(tsmiShadow);

            // In dropdown menu if only last item is visible then menu opens at 0, 0 position on first open, so need to add dummy item to solve this weird bug...
            tsddbShapeOptions.DropDownItems.Add(new ToolStripSeparator() { Visible = false });

            #endregion Shape options

            #region Edit

            ToolStripDropDownButton tsddbEdit = new ToolStripDropDownButton("Edit");
            tsddbEdit.DisplayStyle = ToolStripItemDisplayStyle.Image;
            tsddbEdit.Image = Resources.wrench_screwdriver;
            tsMain.Items.Add(tsddbEdit);

            tsmiUndo = new ToolStripMenuItem("Undo");
            tsmiUndo.Image = Resources.arrow_circle_225_left;
            tsmiUndo.ShortcutKeyDisplayString = "Ctrl+Z";
            tsmiUndo.MouseDown += (sender, e) => UndoShape();
            tsddbEdit.DropDownItems.Add(tsmiUndo);

            tsddbEdit.DropDownItems.Add(new ToolStripSeparator());

            tsmiDelete = new ToolStripMenuItem("Delete");
            tsmiDelete.Image = Resources.layer__minus;
            tsmiDelete.ShortcutKeyDisplayString = "Del";
            tsmiDelete.MouseDown += (sender, e) => DeleteCurrentShape();
            tsddbEdit.DropDownItems.Add(tsmiDelete);

            tsmiDeleteAll = new ToolStripMenuItem("Delete all");
            tsmiDeleteAll.Image = Resources.eraser;
            tsmiDeleteAll.ShortcutKeyDisplayString = "Shift+Del";
            tsmiDeleteAll.MouseDown += (sender, e) => DeleteAllShapes();
            tsddbEdit.DropDownItems.Add(tsmiDeleteAll);

            tsddbEdit.DropDownItems.Add(new ToolStripSeparator());

            tsmiMoveTop = new ToolStripMenuItem("Bring to front");
            tsmiMoveTop.Image = Resources.layers_stack_arrange;
            tsmiMoveTop.ShortcutKeyDisplayString = "Home";
            tsmiMoveTop.MouseDown += (sender, e) => MoveCurrentShapeTop();
            tsddbEdit.DropDownItems.Add(tsmiMoveTop);

            tsmiMoveUp = new ToolStripMenuItem("Bring forward");
            tsmiMoveUp.Image = Resources.layers_arrange;
            tsmiMoveUp.ShortcutKeyDisplayString = "Page up";
            tsmiMoveUp.MouseDown += (sender, e) => MoveCurrentShapeUp();
            tsddbEdit.DropDownItems.Add(tsmiMoveUp);

            tsmiMoveDown = new ToolStripMenuItem("Send backward");
            tsmiMoveDown.Image = Resources.layers_arrange_back;
            tsmiMoveDown.ShortcutKeyDisplayString = "Page down";
            tsmiMoveDown.MouseDown += (sender, e) => MoveCurrentShapeDown();
            tsddbEdit.DropDownItems.Add(tsmiMoveDown);

            tsmiMoveBottom = new ToolStripMenuItem("Send to back");
            tsmiMoveBottom.Image = Resources.layers_stack_arrange_back;
            tsmiMoveBottom.ShortcutKeyDisplayString = "End";
            tsmiMoveBottom.MouseDown += (sender, e) => MoveCurrentShapeBottom();
            tsddbEdit.DropDownItems.Add(tsmiMoveBottom);

            #endregion Edit

            if (form.Mode != RegionCaptureMode.Editor)
            {
                tsMain.Items.Add(new ToolStripSeparator());

                #region Capture

                ToolStripDropDownButton tsddbCapture = new ToolStripDropDownButton("Capture");
                tsddbCapture.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsddbCapture.Image = Resources.camera;
                tsMain.Items.Add(tsddbCapture);

                tsmiRegionCapture = new ToolStripMenuItem("Capture regions");
                tsmiRegionCapture.Image = Resources.layer;
                tsmiRegionCapture.ShortcutKeyDisplayString = "Enter";
                tsmiRegionCapture.MouseDown += (sender, e) =>
                {
                    form.UpdateRegionPath();
                    form.Close(RegionResult.Region);
                };
                tsddbCapture.DropDownItems.Add(tsmiRegionCapture);

                if (RegionCaptureForm.LastRegionFillPath != null)
                {
                    ToolStripMenuItem tsmiLastRegionCapture = new ToolStripMenuItem("Capture last region");
                    tsmiLastRegionCapture.Image = Resources.layers;
                    tsmiLastRegionCapture.MouseDown += (sender, e) => form.Close(RegionResult.LastRegion);
                    tsddbCapture.DropDownItems.Add(tsmiLastRegionCapture);
                }

                ToolStripMenuItem tsmiFullscreenCapture = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Capture_fullscreen);
                tsmiFullscreenCapture.Image = Resources.layer_fullscreen;
                tsmiFullscreenCapture.ShortcutKeyDisplayString = "Space";
                tsmiFullscreenCapture.MouseDown += (sender, e) => form.Close(RegionResult.Fullscreen);
                tsddbCapture.DropDownItems.Add(tsmiFullscreenCapture);

                ToolStripMenuItem tsmiActiveMonitorCapture = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Capture_active_monitor);
                tsmiActiveMonitorCapture.Image = Resources.monitor;
                tsmiActiveMonitorCapture.ShortcutKeyDisplayString = "~";
                tsmiActiveMonitorCapture.MouseDown += (sender, e) => form.Close(RegionResult.ActiveMonitor);
                tsddbCapture.DropDownItems.Add(tsmiActiveMonitorCapture);

                ToolStripMenuItem tsmiMonitorCapture = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Capture_monitor);
                tsmiMonitorCapture.HideImageMargin();
                tsmiMonitorCapture.Image = Resources.monitor_window;
                tsddbCapture.DropDownItems.Add(tsmiMonitorCapture);

                Screen[] screens = Screen.AllScreens;

                for (int i = 0; i < screens.Length; i++)
                {
                    Screen screen = screens[i];
                    ToolStripMenuItem tsmi = new ToolStripMenuItem($"{screen.Bounds.Width}x{screen.Bounds.Height}");
                    tsmi.ShortcutKeyDisplayString = (i + 1).ToString();
                    int index = i;
                    tsmi.MouseDown += (sender, e) =>
                    {
                        form.MonitorIndex = index;
                        form.Close(RegionResult.Monitor);
                    };
                    tsmiMonitorCapture.DropDownItems.Add(tsmi);
                }

                #endregion Capture

                #region Options

                ToolStripDropDownButton tsddbOptions = new ToolStripDropDownButton(Resources.ShapeManager_CreateContextMenu_Options);
                tsddbOptions.DisplayStyle = ToolStripItemDisplayStyle.Image;
                tsddbOptions.Image = Resources.gear;
                tsMain.Items.Add(tsddbOptions);

                tsmiQuickCrop = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Multi_region_mode);
                tsmiQuickCrop.Checked = !Config.QuickCrop;
                tsmiQuickCrop.CheckOnClick = true;
                tsmiQuickCrop.ShortcutKeyDisplayString = "Q";
                tsmiQuickCrop.Click += (sender, e) => Config.QuickCrop = !tsmiQuickCrop.Checked;
                tsddbOptions.DropDownItems.Add(tsmiQuickCrop);

                tsmiTips = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_tips);
                tsmiTips.Checked = Config.ShowHotkeys;
                tsmiTips.CheckOnClick = true;
                tsmiTips.ShortcutKeyDisplayString = "F1";
                tsmiTips.Click += (sender, e) => Config.ShowHotkeys = tsmiTips.Checked;
                tsddbOptions.DropDownItems.Add(tsmiTips);

                ToolStripMenuItem tsmiShowInfo = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_position_and_size_info);
                tsmiShowInfo.Checked = Config.ShowInfo;
                tsmiShowInfo.CheckOnClick = true;
                tsmiShowInfo.Click += (sender, e) => Config.ShowInfo = tsmiShowInfo.Checked;
                tsddbOptions.DropDownItems.Add(tsmiShowInfo);

                ToolStripMenuItem tsmiShowMagnifier = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_magnifier);
                tsmiShowMagnifier.Checked = Config.ShowMagnifier;
                tsmiShowMagnifier.CheckOnClick = true;
                tsmiShowMagnifier.Click += (sender, e) => Config.ShowMagnifier = tsmiShowMagnifier.Checked;
                tsddbOptions.DropDownItems.Add(tsmiShowMagnifier);

                ToolStripMenuItem tsmiUseSquareMagnifier = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Square_shape_magnifier);
                tsmiUseSquareMagnifier.Checked = Config.UseSquareMagnifier;
                tsmiUseSquareMagnifier.CheckOnClick = true;
                tsmiUseSquareMagnifier.Click += (sender, e) => Config.UseSquareMagnifier = tsmiUseSquareMagnifier.Checked;
                tsddbOptions.DropDownItems.Add(tsmiUseSquareMagnifier);

                ToolStripLabeledNumericUpDown tslnudMagnifierPixelCount = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Magnifier_pixel_count_);
                tslnudMagnifierPixelCount.Content.Minimum = RegionCaptureOptions.MagnifierPixelCountMinimum;
                tslnudMagnifierPixelCount.Content.Maximum = RegionCaptureOptions.MagnifierPixelCountMaximum;
                tslnudMagnifierPixelCount.Content.Increment = 2;
                tslnudMagnifierPixelCount.Content.Value = Config.MagnifierPixelCount;
                tslnudMagnifierPixelCount.Content.ValueChanged = (sender, e) => Config.MagnifierPixelCount = (int)tslnudMagnifierPixelCount.Content.Value;
                tsddbOptions.DropDownItems.Add(tslnudMagnifierPixelCount);

                ToolStripLabeledNumericUpDown tslnudMagnifierPixelSize = new ToolStripLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Magnifier_pixel_size_);
                tslnudMagnifierPixelSize.Content.Minimum = RegionCaptureOptions.MagnifierPixelSizeMinimum;
                tslnudMagnifierPixelSize.Content.Maximum = RegionCaptureOptions.MagnifierPixelSizeMaximum;
                tslnudMagnifierPixelSize.Content.Value = Config.MagnifierPixelSize;
                tslnudMagnifierPixelSize.Content.ValueChanged = (sender, e) => Config.MagnifierPixelSize = (int)tslnudMagnifierPixelSize.Content.Value;
                tsddbOptions.DropDownItems.Add(tslnudMagnifierPixelSize);

                ToolStripMenuItem tsmiShowCrosshair = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_screen_wide_crosshair);
                tsmiShowCrosshair.Checked = Config.ShowCrosshair;
                tsmiShowCrosshair.CheckOnClick = true;
                tsmiShowCrosshair.Click += (sender, e) => Config.ShowCrosshair = tsmiShowCrosshair.Checked;
                tsddbOptions.DropDownItems.Add(tsmiShowCrosshair);

                ToolStripMenuItem tsmiFixedSize = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Fixed_size_region_mode);
                tsmiFixedSize.Checked = Config.IsFixedSize;
                tsmiFixedSize.CheckOnClick = true;
                tsmiFixedSize.Click += (sender, e) => Config.IsFixedSize = tsmiFixedSize.Checked;
                tsddbOptions.DropDownItems.Add(tsmiFixedSize);

                ToolStripDoubleLabeledNumericUpDown tslnudFixedSize = new ToolStripDoubleLabeledNumericUpDown(Resources.ShapeManager_CreateContextMenu_Width_,
                    Resources.ShapeManager_CreateContextMenu_Height_);
                tslnudFixedSize.Content.Minimum = 10;
                tslnudFixedSize.Content.Maximum = 10000;
                tslnudFixedSize.Content.Increment = 10;
                tslnudFixedSize.Content.Value = Config.FixedSize.Width;
                tslnudFixedSize.Content.Value2 = Config.FixedSize.Height;
                tslnudFixedSize.Content.ValueChanged = (sender, e) => Config.FixedSize = new Size((int)tslnudFixedSize.Content.Value, (int)tslnudFixedSize.Content.Value2);
                tsddbOptions.DropDownItems.Add(tslnudFixedSize);

                ToolStripMenuItem tsmiShowFPS = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Show_FPS);
                tsmiShowFPS.Checked = Config.ShowFPS;
                tsmiShowFPS.CheckOnClick = true;
                tsmiShowFPS.Click += (sender, e) => Config.ShowFPS = tsmiShowFPS.Checked;
                tsddbOptions.DropDownItems.Add(tsmiShowFPS);

                ToolStripMenuItem tsmiRememberMenuState = new ToolStripMenuItem("Remember menu state");
                tsmiRememberMenuState.Checked = Config.RememberMenuState;
                tsmiRememberMenuState.CheckOnClick = true;
                tsmiRememberMenuState.Click += (sender, e) => Config.RememberMenuState = tsmiRememberMenuState.Checked;
                tsddbOptions.DropDownItems.Add(tsmiRememberMenuState);

                #endregion Options
            }

            ToolStripLabel tslDragRight = new ToolStripLabel()
            {
                Alignment = ToolStripItemAlignment.Right,
                DisplayStyle = ToolStripItemDisplayStyle.Image,
                Image = Resources.ui_radio_button_uncheck,
                Margin = new Padding(0, 0, 2, 0),
                Padding = new Padding(2)
            };

            tsMain.Items.Add(tslDragRight);

            tslDragLeft.MouseDown += TslDrag_MouseDown;
            tslDragRight.MouseDown += TslDrag_MouseDown;
            tslDragLeft.MouseEnter += TslDrag_MouseEnter;
            tslDragRight.MouseEnter += TslDrag_MouseEnter;
            tslDragLeft.MouseLeave += TslDrag_MouseLeave;
            tslDragRight.MouseLeave += TslDrag_MouseLeave;

            tsMain.ResumeLayout(false);
            tsMain.PerformLayout();
            menuForm.ResumeLayout(false);

            menuForm.Show(form);

            foreach (ToolStripItem tsi in tsMain.Items.OfType<ToolStripItem>())
            {
                if (!string.IsNullOrEmpty(tsi.Text))
                {
                    tsi.MouseEnter += (sender, e) =>
                    {
                        Point pos = CaptureHelpers.ScreenToClient(menuForm.PointToScreen(tsi.Bounds.Location));
                        pos.Y += tsi.Height + 8;
                        MenuTextAnimation.Position = pos;
                        MenuTextAnimation.Start(tsi.Text);
                    };

                    tsi.MouseLeave += TsMain_MouseLeave;
                }
            }

            UpdateMenu();

            CurrentShapeChanged += shape => UpdateMenu();
            CurrentShapeTypeChanged += shapeType => UpdateMenu();
            ShapeCreated += shape => UpdateMenu();

            ConfigureMenuState();

            form.Activate();
        }
 private static void InitializeComponent()
 {
     // Create a new instance of the form.
     InputDialogFrm = new Form();
     PromptLbl = new Label();
     OkCmd = new Button();
     CancelCmd = new Button();
     InputTxt = new TextBox();
     InputDialogFrm.SuspendLayout();
     //
     // lblPrompt
     //
     PromptLbl.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
     PromptLbl.BackColor = SystemColors.Control;
     PromptLbl.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((Byte)(0)));
     PromptLbl.Location = new Point(12, 9);
     PromptLbl.Name = "lblPrompt";
     PromptLbl.Size = new Size(302, 82);
     PromptLbl.TabIndex = 3;
     //
     // btnOK
     //
     OkCmd.DialogResult = DialogResult.OK;
     OkCmd.UseVisualStyleBackColor = true;
     OkCmd.Location = new Point(326, 8);
     OkCmd.Name = "btnOK";
     OkCmd.Size = new Size(64, 24);
     OkCmd.TabIndex = 1;
     OkCmd.Text = "&OK";
     OkCmd.Click += new EventHandler(OkCmd_Click);
     //
     // btnCancel
     //
     CancelCmd.DialogResult = DialogResult.Cancel;
     CancelCmd.UseVisualStyleBackColor = true;
     CancelCmd.Location = new Point(326, 40);
     CancelCmd.Name = "btnCancel";
     CancelCmd.Size = new Size(64, 24);
     CancelCmd.TabIndex = 2;
     CancelCmd.Text = "&Cancel";
     CancelCmd.Click += new EventHandler(CancelCmd_Click);
     //
     // txtInput
     //
     InputTxt.Location = new Point(8, 100);
     InputTxt.Name = "txtInput";
     InputTxt.Size = new Size(379, 20);
     InputTxt.TabIndex = 0;
     InputTxt.Text = "";
     InputTxt.KeyDown += new KeyEventHandler(InputTxt_KeyDown);
     //
     // InputBoxDialog
     //
     InputDialogFrm.AutoScaleBaseSize = new Size(5, 13);
     InputDialogFrm.ClientSize = new Size(398, 128);
     InputDialogFrm.Controls.Add(InputTxt);
     InputDialogFrm.Controls.Add(CancelCmd);
     InputDialogFrm.Controls.Add(OkCmd);
     InputDialogFrm.Controls.Add(PromptLbl);
     InputDialogFrm.FormBorderStyle = FormBorderStyle.FixedDialog;
     InputDialogFrm.MaximizeBox = false;
     InputDialogFrm.MinimizeBox = false;
     InputDialogFrm.Name = "InputBoxDialog";
     InputDialogFrm.ResumeLayout(false);
 }
Example #57
0
 private static void InitializeComponent()
 {
     // Create a new instance of the form.
     frmInputDialog = new Form();
     lblPrompt = new Label();
     btnOK = new Button();
     btnCancel = new Button();
     txtInput = new TextBox();
     frmInputDialog.SuspendLayout();
     //
     // lblPrompt
     //
     lblPrompt.Anchor = ((AnchorStyles)((((AnchorStyles.Top | AnchorStyles.Bottom) | AnchorStyles.Left) | AnchorStyles.Right)));
     lblPrompt.BackColor = SystemColors.Control;
     lblPrompt.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((Byte)(0)));
     lblPrompt.Location = new Point(12, 9);
     lblPrompt.Name = "lblPrompt";
     lblPrompt.Size = new Size(302, 82);
     lblPrompt.TabIndex = 3;
     //
     // btnOK
     //
     btnOK.DialogResult = DialogResult.OK;
     btnOK.Location = new Point(315, 8);
     btnOK.Name = "btnOK";
     btnOK.Size = new Size(75, 24);
     btnOK.TabIndex = 1;
     btnOK.Text = "&OK";
     btnOK.Click += new EventHandler(btnOK_Click);
     //
     // btnCancel
     //
     btnCancel.DialogResult = DialogResult.Cancel;
     btnCancel.Location = new Point(315, 40);
     btnCancel.Name = "btnCancel";
     btnCancel.Size = new Size(75, 24);
     btnCancel.TabIndex = 2;
     btnCancel.Text = "&Cancel";
     btnCancel.Click += new EventHandler(btnCancel_Click);
     //
     // txtInput
     //
     txtInput.Location = new Point(8, 70);
     txtInput.Name = "txtInput";
     txtInput.Size = new Size(380, 20);
     txtInput.TabIndex = 0;
     txtInput.Text = "";
     //
     // InputBoxDialog
     //
     frmInputDialog.AutoScaleBaseSize = new Size(5, 13);
     frmInputDialog.ClientSize = new Size(398, 98);
     frmInputDialog.Controls.Add(txtInput);
     frmInputDialog.Controls.Add(btnCancel);
     frmInputDialog.Controls.Add(btnOK);
     frmInputDialog.Controls.Add(lblPrompt);
     frmInputDialog.FormBorderStyle = FormBorderStyle.FixedToolWindow;
     frmInputDialog.MaximizeBox = false;
     frmInputDialog.MinimizeBox = false;
     frmInputDialog.ShowInTaskbar = false;
     frmInputDialog.Name = "InputBoxDialog";
     frmInputDialog.KeyPreview = true;
     frmInputDialog.KeyUp += new KeyEventHandler(frmInputDialog_KeyUp);
     frmInputDialog.ResumeLayout(false);
 }
Example #58
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (ModelingForm == null)
     {
         ModelingForm = new Form();
         ModelingForm.StartPosition = FormStartPosition.Manual;
         ModelingForm.Left = Cursor.Position.X + 5;
         ModelingForm.Top = Cursor.Position.Y + 5;
         ModelingForm.FormBorderStyle = FormBorderStyle.Sizable;
         ModelingForm.Name = "frmModeling";
         ModelingForm.BackColor = System.Drawing.Color.LightGray;
         RichTextBox eee = new RichTextBox();
         eee.Margin = new System.Windows.Forms.Padding(0);
         eee.Font = new System.Drawing.Font("Calibri", 10);
         eee.Multiline = true;
         eee.ReadOnly = true;
         TabControl tbc = new TabControl();
         SplitContainer sc = new SplitContainer();
         TableLayoutPanel tbl = new TableLayoutPanel();
         Button b = new Button();
         b.Text = "Hello";
         b.Dock = DockStyle.Fill;
         tbl.Controls.Add(b, 0, 0);
         tbl.Controls.Add(new Button(), 0, 1);
         tbl.Controls.Add(new Button(), 0, 2);
         tbl.Controls.Add(new Button(), 0, 3);
         tbl.AutoSize = true;
         TableLayoutPanel tbl2 = new TableLayoutPanel();
         b = new Button();
         b.Text = "Hello";
         tbl2.Controls.Add(b, 0, 0);
         tbl2.Controls.Add(new Button(), 0, 1);
         tbl2.Controls.Add(new Button(), 0, 2);
         tbl2.Controls.Add(new Button(), 0, 3);
         tbl2.AutoSize = true;
         tbl2.SuspendLayout();
         tbl.SuspendLayout();
         sc.Panel2.Controls.Add(tbl2);
         sc.Panel1.Controls.Add(tbl);
         sc.Panel1.AutoSize = true;
         sc.AutoSize = true;
         tbl2.ResumeLayout();
         tbl.ResumeLayout();
         sc.BorderStyle = BorderStyle.Fixed3D;
         sc.AutoSize = true;
         string aaa = @"
     ================================================================
     MainCallEndByExtension - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
      byCallType = INTERNAL
      sDeviceExtension = 3312
      sDeviceDistantOptional =
      sDeviceExtLst =
      bIncludeDistConnectnsFromToDevIfInternal = True
      bSearchConnctnsForwards = False
      bOnlyConsiderNonAnsweredGroupCalls = False
      ppMainCallIDsDeleted =
     ================================================================
     DevCallConnctnDelete - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
      sDevice = [CONF]
      sCallIDTelSys = 9D1CE0BF47B8039EDB48
      sDeviceDistantEnd = 3312
      bUseDistantEndAlsoIfUsingCallID = True
      bCallInInfoOverride = False
      sCallInInfoGrp =
      sCallInInfoDDIDigits =
      bIgnoreNonCallConnections = True
      bSearchForwards = False
      bSearchAllCallConnections = True
      bClearByDevFirstRung = False
      bClearDistantEndConnectionIfFlagsMatch = False
      iClearDistantEndConnectionIfFlagsMatch = 0
      bDoNotAttemptOnHookCalculation = False
     ================================================================
     DevCallConnctnDelete - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
      sDevice = 3312
      sCallIDTelSys = 9D1CE0BF47B8039EDB48
      sDeviceDistantEnd =
      bUseDistantEndAlsoIfUsingCallID = False
      bCallInInfoOverride = False
      sCallInInfoGrp =
      sCallInInfoDDIDigits =
      bIgnoreNonCallConnections = True
      bSearchForwards = False
      bSearchAllCallConnections = True
      bClearByDevFirstRung = False
      bClearDistantEndConnectionIfFlagsMatch = False
      iClearDistantEndConnectionIfFlagsMatch = 0
      bDoNotAttemptOnHookCalculation = False
     ================================================================
     MainCallEndByExtension - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
      byCallType = INTERNAL
      sDeviceExtension = 3321
      sDeviceDistantOptional =
      sDeviceExtLst =
      bIncludeDistConnectnsFromToDevIfInternal = True
      bSearchConnctnsForwards = False
      bOnlyConsiderNonAnsweredGroupCalls = False
      ppMainCallIDsDeleted =
     ================================================================
     DevCallConnctnDelete - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
      sDevice = [CONF]
      sCallIDTelSys = 9D1CE0BF47B8039EDB48
      sDeviceDistantEnd = 3321
      bUseDistantEndAlsoIfUsingCallID = True
      bCallInInfoOverride = False
      sCallInInfoGrp =
      sCallInInfoDDIDigits =
      bIgnoreNonCallConnections = True
      bSearchForwards = False
      bSearchAllCallConnections = True
      bClearByDevFirstRung = False
      bClearDistantEndConnectionIfFlagsMatch = False
      iClearDistantEndConnectionIfFlagsMatch = 0
      bDoNotAttemptOnHookCalculation = False
     ================================================================
     DevCallConnctnDelete - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
      sDevice = 3321
      sCallIDTelSys = 9D1CE0BF47B8039EDB48
      sDeviceDistantEnd =
      bUseDistantEndAlsoIfUsingCallID = False
      bCallInInfoOverride = False
      sCallInInfoGrp =
      sCallInInfoDDIDigits =
      bIgnoreNonCallConnections = True
      bSearchForwards = False
      bSearchAllCallConnections = True
      bClearByDevFirstRung = False
      bClearDistantEndConnectionIfFlagsMatch = False
      iClearDistantEndConnectionIfFlagsMatch = 0
      bDoNotAttemptOnHookCalculation = False
     ================================================================
     DevCallConnctnDelete - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
      sDevice = [CONF]
      sCallIDTelSys = 9D1CE0BF47B8039EDB48
      sDeviceDistantEnd =
      bUseDistantEndAlsoIfUsingCallID = False
      bCallInInfoOverride = False
      sCallInInfoGrp =
      sCallInInfoDDIDigits =
      bIgnoreNonCallConnections = True
      bSearchForwards = False
      bSearchAllCallConnections = True
      bClearByDevFirstRung = False
      bClearDistantEndConnectionIfFlagsMatch = False
      iClearDistantEndConnectionIfFlagsMatch = 0
      bDoNotAttemptOnHookCalculation = False
     ================================================================
     DevCallAnswer - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
      sDeviceLocal = 3311, LegID =
      sDeviceDistant = 3321, LegID =
      sDeviceGroup = , LegID =
      bAlwaysUseDevGrpToCalcGrpDistrib = False
      iCallModellingFlags = 15
      sCallIDTelSys = 9D1CE0BF47B8039EDB48
      bCalcMainCallIDFromConnectns = True
      bMarkAnsweredIn = True
      bMarkAnsweredOut = True
      bMarkUnHeldIn = True
      bMarkUnHeldOut = True
      bDeleteCallConnectnsElsewhere = False
      bUseCallAnswerFlagForCallConnectns = False
      bDegenerateCallConference = True
      bSegAlgrthmRun = True
      iSegAlgrthmFlags = 257
     ================================================================
     MainCallEnd - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
      sCallIDTelSys = 9D1CE0BF47B8039EDB48
      pSDeviceDistant = [CONF], LegID =
      pSDeviceLocal = 3311, LegID =
      sDeviceExtLst =
     ";
         string[] bbb = System.Text.RegularExpressions.Regex.Split(aaa, String.Format("{1}+{0}{1}+", @"={2,}\s*", Environment.NewLine));//, System.Text.RegularExpressions.RegexOptions.Multiline);
         int counter = 1;
         foreach (string item in bbb)
         {
             eee.Text += item;
             if (!String.IsNullOrWhiteSpace(item))
             {
                 string []info = item.Split(new string[]{" - "}, StringSplitOptions.RemoveEmptyEntries);
                 if (info.Length == 2)
                 {
                     TabPage tb = new TabPage(counter.ToString());
                     RichTextBox tbText = new RichTextBox();
                     tbText.Text = info[0] + Environment.NewLine;
                     tbText.Text += "     " + info[1];
                     tbText.Size = tbText.PreferredSize;
                     tb.Controls.Add(tbText);
                     tbc.TabPages.Add(tb);
                     tb.Dock = DockStyle.Fill;
                     counter++;
                 }
             }
         }
         //tbc.Size = tbc.GetPreferredSize(tbc.Size);
         tbc.Dock = DockStyle.Fill;
         //tbc.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
         //int globalindex = 0;
         //foreach (string line in eee.Lines)
         //{
         //    int index = line.IndexOf(" = ", 0);
         //    if (index > -1)
         //    {
         //        eee.SelectionStart = globalindex + index + 3;
         //        eee.SelectionLength = line.Length - index - 3;
         //        eee.SelectionFont = new System.Drawing.Font(eee.Font, FontStyle.Bold);
         //    }
         //    globalindex += line.Length + 1;
         //}
         eee.Size = eee.PreferredSize;
         ModelingForm.SuspendLayout();
         sc.Size = sc.PreferredSize;
         sc.SuspendLayout();
         //ModelingForm.Controls.AddRange(new Control[] { eee, tbc });
         //ModelingForm.Controls.AddRange(new Control[] { tbc });
         ModelingForm.Controls.AddRange(new Control[] { sc });
         ModelingForm.Show(this);
         sc.ResumeLayout();
         ModelingForm.ResumeLayout();
     }
     else
     {
         ModelingForm.Close();
         ModelingForm = null;
     }
 }
        /// <summary>
        /// Opens a Windows Forms Web Browser control to authenticate the user against an CLAIM site.
        /// </summary>
        /// <param name="popUpWidth"></param>
        /// <param name="popUpHeight"></param>
        public CookieCollection Show()
        {
            if (string.IsNullOrEmpty(this.LoginPageUrl)) throw new ApplicationException(Constants.MSG_NOT_CLAIM_SITE);

              // navigate to the login page url.
              this.webBrowser.Navigate(this.LoginPageUrl);

              DisplayLoginForm = new Form();
              DisplayLoginForm.SuspendLayout();

              // size the login form
              int dialogWidth = Constants.DEFAULT_POP_UP_WIDTH;
              int dialogHeight = Constants.DEFAULT_POP_UP_HEIGHT;

              if (PopUpHeight != 0 && PopUpWidth != 0)
              {
            dialogWidth = Convert.ToInt32(PopUpWidth);
            dialogHeight = Convert.ToInt32(PopUpHeight);
              }

              DisplayLoginForm.Width = dialogWidth;
              DisplayLoginForm.Height = dialogHeight;
              DisplayLoginForm.Text = this.fldTargetSiteUrl;

              DisplayLoginForm.Controls.Add(this.webBrowser);
              DisplayLoginForm.ResumeLayout(false);

              Application.Run(DisplayLoginForm);

              // see ClaimsWebBrowser_Navigated event
              return this.fldCookies;
        }
Example #60
0
 /// <summary>
 /// Opens a new modeless dialog box with a tree
 /// </summary>
 /// <param name="node">the node to display</param>
 /// <param name="owner">the parent form to attach to, can be null</param>
 /// <returns>the form containing the tree</returns>
 public static Form Show(NsNode node, Form owner)
 {
     Form f = new Form();
     f.Owner = owner;
     f.SuspendLayout();
     NsNodeTree flow = new NsNodeTree();
     flow.Dock = DockStyle.Fill;
     f.Controls.Add(flow);
     f.ResumeLayout();
     flow.AddRootNode(node);
     f.StartPosition = FormStartPosition.CenterParent;
     f.FormBorderStyle = FormBorderStyle.SizableToolWindow;
     f.Width = 150;
     f.Height = 300;
     f.Text = "";
     flow.SelectionChanged += delegate(object s, NodeEventArgs ne)
     {
         if (ne.Node == null)
             f.Close();
     };
     f.FormClosed += delegate(object s, FormClosedEventArgs e)
     {
         if (flow.SelectedRoot != null)
             flow.SelectedRoot.Detach(flow);
     };
     f.Show();
     f.BringToFront();
     return f;
 }