示例#1
0
		public TreeGridNode(TreeGridView owner)
			: this()
		{
			this._grid = owner;
			
			//this.IsExpanded = true;
		}
示例#2
0
		internal TreeGridNode(TreeGridView owner)
			: this()
		{
			this._grid = owner;
			this.IsExpanded = true;
            
           
		}
示例#3
0
		public TreeGridView RenderTreeGridViewDetails(long id, string classname)
		{
			InitializeImageList();
			treegrid = InitializeTreeGridView();
			bool readOnly=OMEInteraction.GetCurrentConnParams().ConnectionReadOnly;
			ProxyTreeGridRenderer item = AssemblyInspectorObject.DataPopulation.GetTreeGridViewDetails(readOnly,id, classname);
			TreeGridNode rootNode = new TreeGridNode();
			treegrid.Nodes.Add(rootNode);
			PopulateNode(rootNode, item);
			rootNode.Expand();
			rootNode.ImageIndex = 0;
			List<ProxyTreeGridRenderer> proxyList = AssemblyInspectorObject.DataPopulation.TransverseTreeGridViewDetails(readOnly,id,classname);
            foreach (ProxyTreeGridRenderer item1 in proxyList)
			{
				PopulateTreeGridNode(rootNode, item1);
			}

			return treegrid;
		}
示例#4
0
        private void InitializeComponent()
        {
            Title     = "Delete Items";
            Resizable = true;
            Width     = 450;
            Height    = 300;

            layout1 = new DynamicLayout();
            layout1.DefaultSpacing = new Size(2, 2);
            layout1.BeginVertical();

            label1      = new Label();
            label1.Wrap = WrapMode.Word;
            label1.Text = "The following items will be deleted (this action cannot be undone):";
            layout1.Add(label1, true, false);

            treeView1            = new TreeGridView();
            treeView1.ShowHeader = false;
            layout1.Add(treeView1, true, true);

            DefaultButton.Text = "Delete";

            CreateContent(layout1);
        }
示例#5
0
 private MainForm(bool initializeControls)
 {
     XamlReader.Load(this);
     txtRegexPattern      = FindChild <TextArea>("txtRegexPattern");
     txtReplacementString = FindChild <TextArea>("txtReplacementString");
     txtInputText         = FindChild <TextArea>("txtInputText");
     txtMatchValue        = FindChild <TextArea>("txtMatchValue");
     lboPatternHistory    = FindChild <ListBox>("lboPatternHistory");
     lboInputHistory      = FindChild <ListBox>("lboInputHistory");
     chkCompiled          = FindChild <CheckBox>("chkCompiled");
     chkCultureInvariant  = FindChild <CheckBox>("chkCultureInvariant");
     chkEcmaScript        = FindChild <CheckBox>("chkEcmaScript");
     chkExplicitCapture   = FindChild <CheckBox>("chkExplicitCapture");
     chkIgnoreWhite       = FindChild <CheckBox>("chkIgnoreWhite");
     chkIgnoreCase        = FindChild <CheckBox>("chkIgnoreCase");
     chkMultiline         = FindChild <CheckBox>("chkMultiline");
     chkRightToLeft       = FindChild <CheckBox>("chkRightToLeft");
     chkSingleLine        = FindChild <CheckBox>("chkSingleLine");
     nudTimeout           = FindChild <NumericStepper>("nudTimeout");
     splResultExplorer    = FindChild <Splitter>("splResultExplorer");
     tvwResultExplorer    = FindChild <TreeGridView>("tvwResultExplorer");
     lblStatusMessage     = FindChild <Label>("lblStatusMessage");
     lblPosition          = FindChild <Label>("lblPosition");
 }
示例#6
0
        private void BindProcessFileTreeData(TreeGridView tgv, DataType.FileType fileType)
        {
            //this.tvFileList.Nodes.Clear();
            tgv.Nodes.Clear();
            IDocFileListService service = ServiceContainer.GetService<IDocFileListService>();
            dtDocFile = service.GetDocFileDataTableByDCID(Document.DOCID, fileType.ToString());

            //  Font boldFont = new Font(tvFileList.DefaultCellStyle.Font, FontStyle.Bold);
            Font boldFont = new Font(tgv.DefaultCellStyle.Font, FontStyle.Bold);
            //    DataView dv = new DataView(dt);
            node = new TreeGridNode();
            // dv.RowFilter = "[PARENT]=" + parentId;
            //foreach (DataRowView dr in dv)
            //{
            //    if (parentId == "0")
            //    {
            // node = tvFileList.Nodes.Add(Document.DOCNO, "", "", "", "", "", "", "");
            node = tgv.Nodes.Add(Document.DOCNO, "", "", "", "", "", "", "");
            node.DefaultCellStyle.Font = boldFont;

            // BindChildNode(node, (string)dr["PHYSICALID"]);
            HYDocumentMS.IFileHelper file = new FileHelper();
            foreach (DataRow dr in dtDocFile.Rows)
            {
                node.Nodes.Add(dr["DFL_FILE_NAME"].ToString(), file.getDocumentAllPathByPathID(dr["DFL_FILE_CHILD_PATH"].ToString()),
                      dr["DFL_VER_LATEST"].ToString(),
                                          dr["CHECKINFLG"].ToString(), dr["CHECKINDATE"].ToString(), dr["CHECKOUTFLG"].ToString(),
                                          dr["CHECKOUTDATE"].ToString(), dr["DFL_ID"].ToString());
                node.Expand();
            }
        }
        private void CreateTreeView(databases.baseDS.portfolioDetailDataTable dataTbl, TreeGridView treeGV)
        {
            if (this.myPorfolioCode == null || this.myStockCode == null)
            {
                return;
            }

            DataView dataView = new DataView(dataTbl);

            dataView.Sort      = dataTbl.subCodeColumn.ColumnName;
            dataView.RowFilter = dataTbl.portfolioColumn + "='" + this.myPorfolioCode + "' AND " +
                                 dataTbl.codeColumn + "='" + this.myStockCode + "'";
            databases.baseDS.portfolioDetailRow dataRow;
            Font   boldFont     = new Font(treeGV.DefaultCellStyle.Font, FontStyle.Bold);
            string lastStrategy = "";
            TreeGridNodeCollection strategyNodes = null;

            for (int idx = 0; idx < dataView.Count; idx++)
            {
                dataRow = (databases.baseDS.portfolioDetailRow)dataView[idx].Row;
                if (lastStrategy != dataRow.subCode.Trim())
                {
                    strategyNodes = AddNode(treeGV.Nodes, dataRow.subCode, GetStrategyDescription(dataRow.subCode), boldFont).Nodes;
                    lastStrategy  = dataRow.subCode.Trim();
                }
                AddNodes((strategyNodes == null ? treeGV.Nodes : strategyNodes), dataRow, null);
            }
        }
示例#8
0
 /// <summary>
 /// Required method for Designer support - do not modify
 /// the contents of this method with the code editor.
 /// </summary>
 public void InitializeComponent()
 {
     this.components = new System.ComponentModel.Container();
     AdvancedDataGridView.TreeGridNode treeGridNode1          = new AdvancedDataGridView.TreeGridNode();
     System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
     this.toolStrip1          = new System.Windows.Forms.ToolStrip();
     this.toolStripButton1    = new System.Windows.Forms.ToolStripButton();
     this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
     this.toolStripButton2    = new System.Windows.Forms.ToolStripButton();
     this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
     this.toolStripButton3    = new System.Windows.Forms.ToolStripButton();
     this.toolStripButton4    = new System.Windows.Forms.ToolStripButton();
     this.treeGridView1       = new AdvancedDataGridView.TreeGridView();
     this.ColPCName           = new AdvancedDataGridView.TreeGridColumn();
     this.ColPCIP             = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColPCMac            = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColDownload         = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColUpload           = new System.Windows.Forms.DataGridViewTextBoxColumn();
     this.ColDownCap          = new DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn();
     this.ColUploadCap        = new DataGridViewNumericUpDownElements.DataGridViewNumericUpDownColumn();
     this.ColBlock            = new System.Windows.Forms.DataGridViewCheckBoxColumn();
     this.ColSpoof            = new System.Windows.Forms.DataGridViewCheckBoxColumn();
     this.ContextMenuViews    = new System.Windows.Forms.ContextMenuStrip(this.components);
     this.ViewMenuIP          = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuMAC         = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuDownload    = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuUpload      = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuDownloadCap = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuUploadCap   = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuBlock       = new System.Windows.Forms.ToolStripMenuItem();
     this.ViewMenuSpoof       = new System.Windows.Forms.ToolStripMenuItem();
     this.imageList1          = new System.Windows.Forms.ImageList(this.components);
     this.timer1             = new System.Windows.Forms.Timer(this.components);
     this.timer2             = new System.Windows.Forms.Timer(this.components);
     this.timerSpoof         = new System.Windows.Forms.Timer(this.components);
     this.SelfishNetTrayIcon = new System.Windows.Forms.NotifyIcon(this.components);
     this.timerDiscovery     = new System.Windows.Forms.Timer(this.components);
     this.toolStrip1.SuspendLayout();
     ((System.ComponentModel.ISupportInitialize)(this.treeGridView1)).BeginInit();
     this.ContextMenuViews.SuspendLayout();
     this.SuspendLayout();
     //
     // toolStrip1
     //
     this.toolStrip1.ImageScalingSize = new System.Drawing.Size(32, 32);
     this.toolStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.toolStripButton1,
         this.toolStripSeparator1,
         this.toolStripButton2,
         this.toolStripSeparator2,
         this.toolStripButton3,
         this.toolStripButton4
     });
     this.toolStrip1.Location = new System.Drawing.Point(0, 0);
     this.toolStrip1.Name     = "toolStrip1";
     this.toolStrip1.Size     = new System.Drawing.Size(703, 39);
     this.toolStrip1.TabIndex = 0;
     this.toolStrip1.Text     = "toolStrip1";
     //
     // toolStripButton1
     //
     this.toolStripButton1.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton1.Image                 = global::Properties.Resources.search;
     this.toolStripButton1.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton1.Name   = "toolStripButton1";
     this.toolStripButton1.Size   = new System.Drawing.Size(36, 36);
     this.toolStripButton1.Text   = "Network Discovery";
     this.toolStripButton1.Click += new System.EventHandler(this.toolStripButton1_Click);
     //
     // toolStripSeparator1
     //
     this.toolStripSeparator1.Name = "toolStripSeparator1";
     this.toolStripSeparator1.Size = new System.Drawing.Size(6, 39);
     //
     // toolStripButton2
     //
     this.toolStripButton2.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton2.Image                 = global::Properties.Resources.play;
     this.toolStripButton2.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton2.Name   = "toolStripButton2";
     this.toolStripButton2.Size   = new System.Drawing.Size(36, 36);
     this.toolStripButton2.Text   = "Start redirecting-spoofing";
     this.toolStripButton2.Click += new System.EventHandler(this.toolStripButton2_Click);
     //
     // toolStripSeparator2
     //
     this.toolStripSeparator2.Name = "toolStripSeparator2";
     this.toolStripSeparator2.Size = new System.Drawing.Size(6, 39);
     //
     // toolStripButton3
     //
     this.toolStripButton3.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton3.Image                 = global::Properties.Resources.pause;
     this.toolStripButton3.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton3.Name   = "toolStripButton3";
     this.toolStripButton3.Size   = new System.Drawing.Size(36, 36);
     this.toolStripButton3.Text   = "stop redirecting- spoofing";
     this.toolStripButton3.Click += new System.EventHandler(this.toolStripButton3_Click);
     //
     // toolStripButton4
     //
     this.toolStripButton4.Alignment             = System.Windows.Forms.ToolStripItemAlignment.Right;
     this.toolStripButton4.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.toolStripButton4.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.toolStripButton4.Name   = "toolStripButton4";
     this.toolStripButton4.Size   = new System.Drawing.Size(23, 36);
     this.toolStripButton4.Text   = "Help";
     this.toolStripButton4.Click += new System.EventHandler(this.toolStripButton4_Click);
     //
     // treeGridView1
     //
     this.treeGridView1.AllowUserToAddRows       = false;
     this.treeGridView1.AllowUserToDeleteRows    = false;
     this.treeGridView1.AllowUserToOrderColumns  = true;
     this.treeGridView1.AllowUserToResizeRows    = false;
     this.treeGridView1.AutoSizeColumnsMode      = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
     this.treeGridView1.AutoSizeRowsMode         = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
     this.treeGridView1.BorderStyle              = System.Windows.Forms.BorderStyle.Fixed3D;
     this.treeGridView1.CellBorderStyle          = System.Windows.Forms.DataGridViewCellBorderStyle.RaisedHorizontal;
     this.treeGridView1.ColumnHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.Single;
     this.treeGridView1.ColumnHeadersHeight      = 35;
     this.treeGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
         this.ColPCName,
         this.ColPCIP,
         this.ColPCMac,
         this.ColDownload,
         this.ColUpload,
         this.ColDownCap,
         this.ColUploadCap,
         this.ColBlock,
         this.ColSpoof
     });
     this.treeGridView1.ContextMenuStrip = this.ContextMenuViews;
     this.treeGridView1.Dock             = System.Windows.Forms.DockStyle.Fill;
     this.treeGridView1.EditMode         = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
     this.treeGridView1.ImageList        = this.imageList1;
     this.treeGridView1.Location         = new System.Drawing.Point(0, 39);
     this.treeGridView1.Name             = "treeGridView1";
     treeGridNode1.Height     = 20;
     treeGridNode1.ImageIndex = 1;
     this.treeGridView1.Nodes.Add(treeGridNode1);
     this.treeGridView1.RowHeadersVisible = false;
     this.treeGridView1.ShowCellErrors    = false;
     this.treeGridView1.ShowCellToolTips  = false;
     this.treeGridView1.ShowEditingIcon   = false;
     this.treeGridView1.ShowRowErrors     = false;
     this.treeGridView1.Size                          = new System.Drawing.Size(703, 363);
     this.treeGridView1.TabIndex                      = 1;
     this.treeGridView1.CellPainting                 += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.treeGridView1_CellPainting);
     this.treeGridView1.CellValueChanged             += new System.Windows.Forms.DataGridViewCellEventHandler(this.treeGridView1_CellValueChanged);
     this.treeGridView1.CurrentCellDirtyStateChanged += new System.EventHandler(this.treeGridView1_CurrentCellDirtyStateChanged);
     //
     // ColPCName
     //
     this.ColPCName.AutoSizeMode     = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColPCName.DefaultNodeImage = null;
     this.ColPCName.FillWeight       = 180.4366F;
     this.ColPCName.HeaderText       = "PC Name";
     this.ColPCName.MinimumWidth     = 40;
     this.ColPCName.Name             = "ColPCName";
     this.ColPCName.ReadOnly         = true;
     this.ColPCName.SortMode         = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColPCIP
     //
     this.ColPCIP.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColPCIP.FillWeight   = 119.7174F;
     this.ColPCIP.HeaderText   = "IP";
     this.ColPCIP.MinimumWidth = 35;
     this.ColPCIP.Name         = "ColPCIP";
     this.ColPCIP.ReadOnly     = true;
     this.ColPCIP.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColPCMac
     //
     this.ColPCMac.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColPCMac.FillWeight   = 106.599F;
     this.ColPCMac.HeaderText   = "MAC";
     this.ColPCMac.MinimumWidth = 35;
     this.ColPCMac.Name         = "ColPCMac";
     this.ColPCMac.ReadOnly     = true;
     this.ColPCMac.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColDownload
     //
     this.ColDownload.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColDownload.FillWeight   = 74.57431F;
     this.ColDownload.HeaderText   = "Download KB/s";
     this.ColDownload.MinimumWidth = 20;
     this.ColDownload.Name         = "ColDownload";
     this.ColDownload.ReadOnly     = true;
     this.ColDownload.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColUpload
     //
     this.ColUpload.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColUpload.FillWeight   = 70.42757F;
     this.ColUpload.HeaderText   = "Upload KB/s";
     this.ColUpload.MinimumWidth = 20;
     this.ColUpload.Name         = "ColUpload";
     this.ColUpload.ReadOnly     = true;
     this.ColUpload.SortMode     = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
     //
     // ColDownCap
     //
     this.ColDownCap.HeaderText = "Download Cap";
     this.ColDownCap.Maximum    = new decimal(new int[] {
         10000,
         0,
         0,
         0
     });
     this.ColDownCap.Name = "ColDownCap";
     this.ColDownCap.ThousandsSeparator = true;
     //
     // ColUploadCap
     //
     this.ColUploadCap.HeaderText = "Upload Cap";
     this.ColUploadCap.Maximum    = new decimal(new int[] {
         10000,
         0,
         0,
         0
     });
     this.ColUploadCap.Name = "ColUploadCap";
     this.ColUploadCap.ThousandsSeparator = true;
     //
     // ColBlock
     //
     this.ColBlock.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColBlock.FalseValue   = "False";
     this.ColBlock.FillWeight   = 48.2451F;
     this.ColBlock.HeaderText   = "Block";
     this.ColBlock.MinimumWidth = 10;
     this.ColBlock.Name         = "ColBlock";
     this.ColBlock.Resizable    = System.Windows.Forms.DataGridViewTriState.True;
     this.ColBlock.TrueValue    = "True";
     //
     // ColSpoof
     //
     this.ColSpoof.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
     this.ColSpoof.FalseValue   = "False";
     this.ColSpoof.HeaderText   = "Spoof";
     this.ColSpoof.MinimumWidth = 10;
     this.ColSpoof.Name         = "ColSpoof";
     this.ColSpoof.Resizable    = System.Windows.Forms.DataGridViewTriState.True;
     this.ColSpoof.TrueValue    = "True";
     this.ColSpoof.Visible      = false;
     //
     // ContextMenuViews
     //
     this.ContextMenuViews.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.ViewMenuIP,
         this.ViewMenuMAC,
         this.ViewMenuDownload,
         this.ViewMenuUpload,
         this.ViewMenuDownloadCap,
         this.ViewMenuUploadCap,
         this.ViewMenuBlock,
         this.ViewMenuSpoof
     });
     this.ContextMenuViews.Name = "ContextMenuViews";
     this.ContextMenuViews.Size = new System.Drawing.Size(153, 180);
     this.ContextMenuViews.Text = "Columns Views";
     //
     // ViewMenuIP
     //
     this.ViewMenuIP.Checked            = true;
     this.ViewMenuIP.CheckOnClick       = true;
     this.ViewMenuIP.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuIP.Name               = "ViewMenuIP";
     this.ViewMenuIP.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuIP.Text               = "IP";
     this.ViewMenuIP.CheckStateChanged += new System.EventHandler(this.ViewMenuIP_CheckStateChanged);
     //
     // ViewMenuMAC
     //
     this.ViewMenuMAC.Checked            = true;
     this.ViewMenuMAC.CheckOnClick       = true;
     this.ViewMenuMAC.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuMAC.Name               = "ViewMenuMAC";
     this.ViewMenuMAC.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuMAC.Text               = "MAC";
     this.ViewMenuMAC.CheckStateChanged += new System.EventHandler(this.ViewMenuMAC_CheckStateChanged);
     //
     // ViewMenuDownload
     //
     this.ViewMenuDownload.Checked            = true;
     this.ViewMenuDownload.CheckOnClick       = true;
     this.ViewMenuDownload.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuDownload.Name               = "ViewMenuDownload";
     this.ViewMenuDownload.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuDownload.Text               = "Download";
     this.ViewMenuDownload.CheckStateChanged += new System.EventHandler(this.ViewMenuDownload_CheckStateChanged);
     //
     // ViewMenuUpload
     //
     this.ViewMenuUpload.Checked            = true;
     this.ViewMenuUpload.CheckOnClick       = true;
     this.ViewMenuUpload.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuUpload.Name               = "ViewMenuUpload";
     this.ViewMenuUpload.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuUpload.Text               = "Upload";
     this.ViewMenuUpload.CheckStateChanged += new System.EventHandler(this.ViewMenuUpload_CheckStateChanged);
     //
     // ViewMenuDownloadCap
     //
     this.ViewMenuDownloadCap.Checked            = true;
     this.ViewMenuDownloadCap.CheckOnClick       = true;
     this.ViewMenuDownloadCap.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuDownloadCap.Name               = "ViewMenuDownloadCap";
     this.ViewMenuDownloadCap.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuDownloadCap.Text               = "Download Cap";
     this.ViewMenuDownloadCap.CheckStateChanged += new System.EventHandler(this.DownloadCapToolStripMenuItem_CheckStateChanged);
     this.ViewMenuDownloadCap.Click             += new System.EventHandler(this.DownloadCapToolStripMenuItem_Click);
     //
     // ViewMenuUploadCap
     //
     this.ViewMenuUploadCap.Checked            = true;
     this.ViewMenuUploadCap.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuUploadCap.Name               = "ViewMenuUploadCap";
     this.ViewMenuUploadCap.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuUploadCap.Text               = "Upload Cap";
     this.ViewMenuUploadCap.CheckStateChanged += new System.EventHandler(this.uploadCapToolStripMenuItem_CheckStateChanged);
     //
     // ViewMenuBlock
     //
     this.ViewMenuBlock.Checked            = true;
     this.ViewMenuBlock.CheckOnClick       = true;
     this.ViewMenuBlock.CheckState         = System.Windows.Forms.CheckState.Checked;
     this.ViewMenuBlock.Name               = "ViewMenuBlock";
     this.ViewMenuBlock.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuBlock.Text               = "Block";
     this.ViewMenuBlock.CheckStateChanged += new System.EventHandler(this.ViewMenuBlock_CheckStateChanged);
     //
     // ViewMenuSpoof
     //
     this.ViewMenuSpoof.CheckOnClick       = true;
     this.ViewMenuSpoof.Name               = "ViewMenuSpoof";
     this.ViewMenuSpoof.Size               = new System.Drawing.Size(152, 22);
     this.ViewMenuSpoof.Text               = "Spoofed";
     this.ViewMenuSpoof.CheckStateChanged += new System.EventHandler(this.ViewMenuSpoof_CheckStateChanged);
     //
     // imageList1
     //
     this.imageList1.ImageStream      = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageList1.ImageStream")));
     this.imageList1.TransparentColor = System.Drawing.Color.White;
     this.imageList1.Images.SetKeyName(0, "circle.png");
     this.imageList1.Images.SetKeyName(1, "router.png");
     //
     // timer1
     //
     this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
     //
     // timer2
     //
     this.timer2.Tick += new System.EventHandler(this.timer2_Tick);
     //
     // timerSpoof
     //
     this.timerSpoof.Tick += new System.EventHandler(this.timerSpoof_Tick);
     //
     // SelfishNetTrayIcon
     //
     this.SelfishNetTrayIcon.BalloonTipIcon    = System.Windows.Forms.ToolTipIcon.Info;
     this.SelfishNetTrayIcon.BalloonTipText    = "SelfishNet is minimized";
     this.SelfishNetTrayIcon.BalloonTipTitle   = "SelfishNet";
     this.SelfishNetTrayIcon.Text              = "SelfishNet";
     this.SelfishNetTrayIcon.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.notifyIcon1_MouseDoubleClick);
     //
     // timerDiscovery
     //
     this.timerDiscovery.Interval = 600000;
     //
     // MainForm
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.ClientSize          = new System.Drawing.Size(703, 402);
     this.Controls.Add(this.treeGridView1);
     this.Controls.Add(this.toolStrip1);
     this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D;
     this.MaximizeBox     = false;
     this.Name            = "MainForm";
     this.Text            = "SelfishNetSabsab v0.1 Beta";
     this.FormClosing    += new System.Windows.Forms.FormClosingEventHandler(this.MainForm_FormClosing);
     this.Load           += new System.EventHandler(this.MainForm_Load);
     this.Resize         += new System.EventHandler(this.MainForm_Resize);
     this.toolStrip1.ResumeLayout(false);
     this.toolStrip1.PerformLayout();
     ((System.ComponentModel.ISupportInitialize)(this.treeGridView1)).EndInit();
     this.ContextMenuViews.ResumeLayout(false);
     this.ResumeLayout(false);
     this.PerformLayout();
 }
示例#9
0
		public TreeGridNode(TreeGridView owner, IListItem content):this(owner)
		{
			this.content = content;
		}
示例#10
0
		public static void UpdateNodes(TreeGridView tree, TreeGridNodeCollection collection, IList<IListItem> contents)
        {
        	// Add or overwrite existing items
            for (int i = 0; i < contents.Count; i++)
            {
                if (i < collection.Count)
                {
                    // Overwrite
                    //if (!contents[i].IsLiteral)
                        ((TreeGridNode)collection[i]).Content = contents[i];
                }
                else
                {
                    // Add
                    //if (!contents[i].IsLiteral)
                    {
                    	TreeGridNode tn = new TreeGridNode(tree,contents[i]);
                    	tn.UserRow = false;
                    	tn.Update();
                    	collection.Add(tn);
                    }
                }
            }
            // Delete other nodes
            while (collection.Count > contents.Count)
            {
                collection.RemoveAt(collection.Count - 1);
            }
            //tree.Update();
//            tree.UpdateSelection();
//            tree.FullUpdate();
        }
示例#11
0
        public void Recursion(TreeGridView tgv, TreeGridNode node, string path, string top, Dictionary <string, TreeItem> dic)
        {
            bool isFirst = false;

            if (node == null)
            {
                isFirst = true;
            }
            Font          boldFont = new Font(tgv.DefaultCellStyle.Font, FontStyle.Bold);
            DirectoryInfo dir      = new DirectoryInfo(path);

            if (dir.Exists)
            {
                DirectoryInfo[] dirs = dir.GetDirectories();
                if (dirs.Length > 0)
                {
                    foreach (var each in dirs)
                    {
                        string folderKey = each.FullName.Replace(top, "");
                        if (isFirst)
                        {
                            node                       = tgv.Nodes.Add(null, each.Name, "", each.LastWriteTime, each.FullName);
                            node.ImageIndex            = 0;
                            node.DefaultCellStyle.Font = boldFont;
                            List <int> indexList = new List <int>();
                            indexList.Add(tgv.Nodes.Count - 1);
                            TreeItem item = new TreeItem(null, each.Name, 0, each.LastWriteTime, each.FullName, 0, indexList, node.Level);
                            dic.Add(folderKey, item);
                            Recursion(tgv, node, each.FullName, top, dic);
                        }
                        else
                        {
                            TreeGridNode childNode = node.Nodes.Add(null, each.Name, "", each.LastWriteTime, each.FullName);
                            childNode.ImageIndex            = 0;
                            childNode.DefaultCellStyle.Font = boldFont;
                            string     parentKey = each.Parent.FullName.Replace(top, "");
                            List <int> indexList = new List <int>();
                            indexList.AddRange(dic[parentKey].IndexList);
                            indexList.Add(node.Nodes.Count - 1);
                            TreeItem item = new TreeItem(null, each.Name, 0, each.LastWriteTime, each.FullName, 0, indexList, childNode.Level);
                            dic.Add(folderKey, item);
                            Recursion(tgv, childNode, each.FullName, top, dic);
                        }
                    }
                }
                FileInfo[] files = dir.GetFiles();
                if (files.Length > 0)
                {
                    foreach (var each in files)
                    {
                        string fileKey  = each.FullName.Replace(top, "");
                        double tempSize = (double)each.Length / 1024;
                        long   size     = each.Length / 1024;
                        if (tempSize > size)
                        {
                            size++;
                        }
                        if (isFirst)
                        {
                            node            = tgv.Nodes.Add(null, each.Name, size + "KB", each.LastWriteTime, each.FullName);
                            node.ImageIndex = 1;
                            List <int> indexList = new List <int>();
                            indexList.Add(tgv.Nodes.Count - 1);
                            TreeItem item = new TreeItem(null, each.Name, each.Length, each.LastWriteTime, each.FullName, 1, indexList, node.Level);
                            dic.Add(fileKey, item);
                        }
                        else
                        {
                            TreeGridNode childNode = node.Nodes.Add(null, each.Name, size + "KB", each.LastWriteTime, each.FullName);
                            childNode.ImageIndex = 1;
                            string     parentKey = each.Directory.FullName.Replace(top, "");
                            List <int> indexList = new List <int>();
                            indexList.AddRange(dic[parentKey].IndexList);
                            indexList.Add(node.Nodes.Count - 1);
                            string   folderName = each.DirectoryName.Replace(top, "");
                            TreeItem item       = new TreeItem(folderName, each.Name, each.Length, each.LastWriteTime, each.FullName, 1, indexList, childNode.Level);
                            dic.Add(fileKey, item);
                        }
                    }
                }
            }
            else
            {
                throw new Exception("Directory is not exists.");
            }
        }
示例#12
0
 static string SelectedItemsString(TreeGridView grid)
 {
     return(string.Join(",", grid.SelectedItems.Cast <ITreeGridItem>().Select(GetDescription).OrderBy(r => r)));
 }
示例#13
0
 public TreeGridDynamicPropertiesProvider(SfTreeGrid treeGrid, TreeGridView view) : base(treeGrid, view)
 {
     this.View          = view;
     this.dynamicHelper = new DynamicHelper();
 }
示例#14
0
        /// <summary>
        /// 检出文件
        /// </summary>
        /// <param name="tgv"></param>
        /// <param name="fileType"></param>
        private void CheckOut(TreeGridView tgv, DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;

            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DataGridViewRow row = tgv.Rows[rowIndex];
            HYDocumentMS.IFileHelper file = new FileHelper();
            Boolean bl = file.isHasAuth(DataType.AuthParmsType.CheckOut, LoginInfo.LoginID, row.Cells["DFL_ID"].Value.ToString());
            if (bl == false)
            {
                MessageBox.Show("你没有权限检出此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            String Id = row.Cells["DFL_ID"].Value.ToString();
            DOC_FILE_LIST docFileEntity = _docFileListService.GetDocFileEntityByDCID(Id);

            // HYPDM.Entities.PDM_PHYSICAL_FILE physicalfile = _physicalService.GetPhysicalFile(Id, "");
            if (docFileEntity == null) return;
            if (docFileEntity.CHECKOUTFLG == "Y")
            {
                MessageBox.Show("当前文档已被检出,不能再次检出,请等待检出人检入!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DetectionForm form = new DetectionForm();
            form.DocFileEntity = docFileEntity;

            if (form.ShowDialog() == DialogResult.OK)
            {
                docFileEntity.CHECKOUTFLG = "Y";
                docFileEntity.CHECKINFLG = "N";
                docFileEntity.CHECKOUTDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                docFileEntity.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                docFileEntity.LASTUPDATEUSER = LoginInfo.LoginID;
                docFileEntity.Save();

                try
                {
                    VersionSave("0", docFileEntity);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                finally
                {
                    MessageBox.Show("文件检出成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
示例#15
0
        private void InitializeComponent()
        {
            #region Initialization

            searchTextBox = new TextBox
            {
                Size = new Size(268, -1)
            };

            #region Commands

            searchClearCommand = new Command {
                MenuText = "Clear"
            };

            cancelCommand = new Command {
                MenuText = "Cancel"
            };

            openCommand = new Command {
                MenuText = "Open"
            };
            openWithCommand = new Command {
                MenuText = "Open with"
            };

            saveCommand = new Command {
                MenuText = "Save", Shortcut = SaveHotKey
            };
            saveAsCommand = new Command {
                MenuText = "Save As", Shortcut = SaveAsHotKey
            };

            extractDirectoryCommand = new Command {
                MenuText = "Extract", Image = MenuExportResource
            };
            replaceDirectoryCommand = new Command {
                MenuText = "Replace", Image = MenuImportResource
            };
            renameDirectoryCommand = new Command {
                MenuText = "Rename", Image = MenuEditResource
            };
            deleteDirectoryCommand = new Command {
                MenuText = "Delete", Image = MenuDeleteResource
            };
            addDirectoryCommand = new Command {
                MenuText = "Add", Image = MenuAddResource
            };

            extractFileCommand = new Command {
                MenuText = "Extract", Image = MenuExportResource
            };
            replaceFileCommand = new Command {
                MenuText = "Replace", Image = MenuImportResource
            };
            renameFileCommand = new Command {
                MenuText = "Rename", Image = MenuEditResource
            };
            deleteFileCommand = new Command {
                MenuText = "Delete", Image = MenuDeleteResource
            };

            #endregion

            #region Folders

            var folderContext = new ContextMenu
            {
                Items =
                {
                    extractDirectoryCommand,
                    replaceDirectoryCommand,
                    renameDirectoryCommand,
                    addDirectoryCommand,
                    deleteDirectoryCommand
                }
            };

            folders    = new TreeGridItemCollection();
            folderView = new TreeGridView
            {
                ContextMenu = folderContext,

                DataStore = folders,
                Columns   =
                {
                    new GridColumn
                    {
                        DataCell = new ImageTextCell(0, 1)
                    }
                },
                AllowColumnReordering = false
            };

            #endregion

            #region Files

            openWithMenuItem = new ButtonMenuItem {
                Text = "Open with", Command = openWithCommand
            };
            var fileContext = new ContextMenu
            {
                Items =
                {
                    openCommand,
                    openWithMenuItem,

                    new SeparatorMenuItem(),

                    extractFileCommand,
                    replaceFileCommand,
                    renameFileCommand,
                    deleteFileCommand
                }
            };

            files    = new ObservableCollection <FileElement>();
            fileView = new GridView <FileElement>
            {
                ShowHeader             = true,
                AllowMultipleSelection = true,
                BackgroundColor        = KnownColors.White,

                ContextMenu = fileContext,

                Columns =
                {
                    new GridColumn
                    {
                        DataCell   = new TextBoxCell(nameof(FileElement.Name)),
                        HeaderText = "Name",
                        Sortable   = true,
                        AutoSize   = true
                    },
                    new GridColumn
                    {
                        DataCell   = new TextBoxCell(nameof(FileElement.Size)),
                        HeaderText = "Size",
                        Sortable   = true,
                        AutoSize   = true
                    }
                },

                DataStore = files
            };

            #endregion

            #region Buttons

            searchClearButton = new Button
            {
                Text    = "X",
                Size    = new Size(22, -1),
                Command = searchClearCommand
            };

            cancelButton = new Button
            {
                Text    = "Cancel",
                Command = cancelCommand
            };

            saveButton = new ButtonToolStripItem
            {
                Command = saveCommand,
                Image   = MenuSaveResource
            };

            saveAsButton = new ButtonToolStripItem
            {
                Command = saveAsCommand,
                Image   = MenuSaveAsResource
            };

            extractButton = new ButtonToolStripItem
            {
                Command = extractFileCommand,
                Image   = MenuExportResource
            };

            replaceButton = new ButtonToolStripItem
            {
                Command = replaceFileCommand,
                Image   = MenuImportResource
            };

            renameButton = new ButtonToolStripItem
            {
                Command = renameFileCommand,
                Image   = MenuExportResource
            };

            deleteButton = new ButtonToolStripItem
            {
                Command = deleteFileCommand,
                Image   = MenuDeleteResource
            };

            #endregion

            #endregion

            #region Content

            var archiveToolStrip = new ToolStrip
            {
                BackgroundColor = KnownColors.White,
                Items           =
                {
                    saveButton,
                    saveAsButton
                }
            };

            var mainContent = new TableLayout
            {
                Spacing = new Size(3, 3),
                Rows    =
                {
                    // Searchbar and file toolstrip
                    new TableRow
                    {
                        Cells =
                        {
                            // Searchbar
                            new StackLayout
                            {
                                Spacing     = 3,
                                Orientation = Orientation.Horizontal,
                                Items       =
                                {
                                    searchTextBox,
                                    searchClearButton
                                }
                            },

                            // file toolstrip
                            new ToolStrip
                            {
                                Size            = new SizeF(-1, ToolStripItem.Height + 6),
                                BackgroundColor = KnownColors.White,
                                Items           =
                                {
                                    extractButton,
                                    replaceButton,
                                    renameButton,
                                    deleteButton
                                }
                            },
                        }
                    },

                    // Folder and file view
                    new TableRow
                    {
                        Cells =
                        {
                            folderView,
                            fileView
                        }
                    }
                }
            };

            Content = new TableLayout
            {
                Spacing = new Size(3, 3),
                Rows    =
                {
                    new TableRow(new Panel {
                        Content = archiveToolStrip, Size = new Size(-1, (int)ToolStripItem.Height + 6)
                    }),
                    new TableRow           {
                        Cells =            { new TableCell(mainContent)
                                             {
                                                 ScaleWidth = true
                                             } }, ScaleHeight = true
                    }
                }
            };

            #endregion
        }
示例#16
0
 public TableStrip(TreeGridItemCollection selectionState)
 {
     this.viewForm = GetLayout(selectionState);
 }
示例#17
0
        private TreeGridView GetLayout(TreeGridItemCollection selectableItems)
        {
            var isMacOS = Eto.Platform.Detect.IsMac;

            var featureSelect = new TreeGridView()
            {
                GridLines             = GridLines.Horizontal,
                AllowColumnReordering = true,
                RowHeight             = 30,
            };

            featureSelect.CellDoubleClick   += this.CellDoubleClickHandler;
            featureSelect.CellClick         += this.CellClickHandler;
            featureSelect.ColumnHeaderClick += this.HeaderClickHandler;
            featureSelect.CellFormatting    += _OnFormatCell;

            var titleColumn = new GridColumn()
            {
                HeaderText = TagTypeLabel,
                DataCell   = new TextBoxCell(0),
                Resizable  = false,
                Sortable   = false,
                AutoSize   = false,
                Width      = 220, // Don't autosize; hides the arrow buttons on macOS
            };

            featureSelect.Columns.Add(titleColumn);

            var checkColumn = new GridColumn()
            {
                HeaderText = SelectTagLabel,
                DataCell   = new CheckBoxCell(1),
                Width      = isMacOS ? 53 : 44, // 53 minimum macOS without ellipses
                Resizable  = false,
                Sortable   = false,
            };

            featureSelect.Columns.Add(checkColumn);

            var nodeColumn = new GridColumn()
            {
                HeaderText = "Nodes Count",
                DataCell   = new TextBoxCell(2),
                Resizable  = false,
                Sortable   = false,
                Width      = isMacOS ? 98 : 88,
            };

            featureSelect.Columns.Add(nodeColumn);

            var wayColumn = new GridColumn()
            {
                HeaderText = "Ways Count",
                DataCell   = new TextBoxCell(3),
                Resizable  = false,
                Sortable   = false,
                Width      = isMacOS ? 98 : 88,
            };

            featureSelect.Columns.Add(wayColumn);

            var keyValueColumn = new GridColumn()
            {
                HeaderText = TagKVLabel,
                DataCell   = new TextBoxCell(4),
                Resizable  = false,
                Sortable   = false,
                AutoSize   = false,
                Width      = isMacOS ? 130 : 130,
            };

            featureSelect.Columns.Add(keyValueColumn);

            var linkColumn = new GridColumn()
            {
                HeaderText = TagWikiLabel,
                DataCell   = new TextBoxCell(5),
                Resizable  = false,
                Sortable   = false,
                Width      = isMacOS ? 67 : 62, // 67 minimum macOS without ellipses
            };

            featureSelect.Columns.Add(linkColumn);

            var descriptionColumn = new GridColumn()
            {
                HeaderText = "Description",
                DataCell   = new TextBoxCell(6),
                Resizable  = false,
                Sortable   = false,
            };

            featureSelect.Columns.Add(descriptionColumn);

            featureSelect.DataStore = selectableItems;
            return(featureSelect);
        }
示例#18
0
        public Editor(Application application, string baseDirectory, string codeFilename)
        {
            systemPath  = baseDirectory + "/System.txt";
            programPath = baseDirectory + "/Program.txt";
            WindowState = WindowState.Maximized;
            Title       = TitleText;
            Menu        = new MenuBar {
                IncludeSystemItems = MenuBarSystemItems.Quit
            };
            runCommand      = new Command(OnRun);
            continueCommand = new Command(OnContinue);
            stepCommand     = new Command(OnStep)
            {
                Shortcut = Keys.F10
            };
            Button runButton = new Button {
                Command = runCommand, Text = RunText
            };
            Button continueButton = new Button {
                Command = continueCommand, Text = ContinueText
            };
            Button stepButton = new Button {
                Command = stepCommand, Text = StepText
            };

            systemEdit = new RichTextArea()
            {
                TextReplacements = TextReplacements.None
            };
            systemEdit.Text = File.ReadAllText(systemPath);
            programEdit     = new RichTextArea()
            {
                TextReplacements = TextReplacements.None
            };
            programEdit.Text = File.ReadAllText(programPath);
            codeTree         = new TreeGridView()
            {
                ShowHeader = false
            };
            codeTree.Border = BorderType.Line;
            codeTree.Columns.Add(new GridColumn {
                Editable = false, DataCell = new TextBoxCell(0), Resizable = false
            });
            codeTree.Columns.Add(new GridColumn {
                Editable = false, DataCell = new TextBoxCell(1), Resizable = false
            });
            codeTree.SelectedItemChanged += OnCodeTreeViewSelectedItemChanged;
            frameStack = new ListBox {
                Style = "ListNative"
            };
            frameStack.SelectedIndexChanged += OnCallStackListBoxSelectedIndexChanged;
            valueStack = new ListBox {
                Style = "ListNative"
            };
            outputArea        = new RichTextArea();
            documentationView = new WebView();
            Scrollable documentationwindow = new Scrollable();

            documentationwindow.Content = documentationView;
            TableLayout  buttons    = TableLayout.Horizontal(runButton, continueButton, stepButton, new Panel());
            DocumentPage systemPage = new DocumentPage(systemEdit)
            {
                Closable = false, Text = "System"
            };
            DocumentPage programPage = new DocumentPage(programEdit)
            {
                Closable = false, Text = "Program"
            };
            DocumentControl editsDocument = new DocumentControl()
            {
                AllowReordering = false
            };

            editsDocument.Pages.Add(systemPage);
            editsDocument.Pages.Add(programPage);
            TableLayout outputControls = TableLayout.HorizontalScaled(outputArea, documentationwindow);

            outputControls.Height = StandardDimensionHeight;
            TableLayout codeOutputControls = new TableLayout(editsDocument, outputControls);

            codeOutputControls.SetRowScale(0);
            TableLayout stacks = new TableLayout(codeTree, frameStack, valueStack);

            stacks.SetRowScale(0);
            stacks.SetRowScale(1);
            stacks.SetRowScale(2);
            stacks.Width = StandardDimensionWidth;
            TableLayout codeControls = TableLayout.Horizontal(codeOutputControls, stacks);

            codeControls.SetColumnScale(0);
            Content = codeControls;
            TableLayout mainControls = new TableLayout(buttons, codeControls);

            mainControls.SetRowScale(1);
            Content              = mainControls;
            runtime              = new Mira(application, baseDirectory);
            runtime.Breaking    += UpdateUI;
            runtime.Outputting  += OnOutputting;
            runtime.Stepping    += UpdateUI;
            runtime.Terminating += OnTerminating;
            runtime.Code         = codeFilename;
            timer.Interval       = 0.33;
            timer.Elapsed       += OnElapsed;
            timer.Start();
            LoadComplete += OnLoadComplete;
        }
示例#19
0
        /// <summary>
        /// 删除文件
        /// </summary>
        private void delFile(TreeGridView tgv,DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;

            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            HYDocumentMS.IFileHelper file = new FileHelper();
            Boolean bl = file.isHasAuth(DataType.AuthParmsType.Delete, LoginInfo.LoginID, tgv.CurrentRow.Cells["DFL_ID"].Value.ToString());
            if (bl == false)
            {
                MessageBox.Show("你没有权限删除此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (MessageBox.Show("所选择的文件将被删除,是否确定?", "提示信息", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                DataGridViewRow row = tgv.Rows[rowIndex];
                string dflID = row.Cells["DFL_ID"].Value.ToString();
                //var file = _physicalService.GetPhysicalFile(Id, "");
                // IDocFileListService serv = new DocFileListService();
                if (_docFileListService.delDocFileByDFLID(dflID))
                {
                    MessageBox.Show("删除成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                }
                else
                {
                    MessageBox.Show("删除失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                }
                this.BindTreeData();
                //serv.
                //file.Delete();
                //  MessageBox.Show("所选择的文件已被删除!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#20
0
 private void InitializeComponent()
 {
     this.m_grid = new pr.gui.TreeGridView();
     this.m_ts   = new System.Windows.Forms.ToolStrip();
     this.m_btn_active_trades      = new System.Windows.Forms.ToolStripButton();
     this.m_btn_pending_orders     = new System.Windows.Forms.ToolStripButton();
     this.m_btn_visualising_orders = new System.Windows.Forms.ToolStripButton();
     this.m_btn_closed_orders      = new System.Windows.Forms.ToolStripButton();
     ((System.ComponentModel.ISupportInitialize)(this.m_grid)).BeginInit();
     this.m_ts.SuspendLayout();
     this.SuspendLayout();
     //
     // m_grid
     //
     this.m_grid.AllowUserToAddRows          = false;
     this.m_grid.AllowUserToDeleteRows       = false;
     this.m_grid.AllowUserToOrderColumns     = true;
     this.m_grid.AllowUserToResizeRows       = false;
     this.m_grid.AutoSizeColumnsMode         = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
     this.m_grid.AutoSizeRowsMode            = System.Windows.Forms.DataGridViewAutoSizeRowsMode.AllCells;
     this.m_grid.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
     this.m_grid.Dock              = System.Windows.Forms.DockStyle.Fill;
     this.m_grid.EditMode          = System.Windows.Forms.DataGridViewEditMode.EditProgrammatically;
     this.m_grid.ImageList         = null;
     this.m_grid.Location          = new System.Drawing.Point(0, 31);
     this.m_grid.MultiSelect       = false;
     this.m_grid.Name              = "m_grid";
     this.m_grid.NodeCount         = 0;
     this.m_grid.ReadOnly          = true;
     this.m_grid.RowHeadersVisible = false;
     this.m_grid.SelectionMode     = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
     this.m_grid.ShowLines         = true;
     this.m_grid.Size              = new System.Drawing.Size(659, 207);
     this.m_grid.TabIndex          = 0;
     this.m_grid.VirtualNodes      = false;
     //
     // m_ts
     //
     this.m_ts.ImageScalingSize = new System.Drawing.Size(24, 24);
     this.m_ts.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
         this.m_btn_active_trades,
         this.m_btn_pending_orders,
         this.m_btn_visualising_orders,
         this.m_btn_closed_orders
     });
     this.m_ts.Location = new System.Drawing.Point(0, 0);
     this.m_ts.Name     = "m_ts";
     this.m_ts.Size     = new System.Drawing.Size(659, 31);
     this.m_ts.Stretch  = true;
     this.m_ts.TabIndex = 1;
     this.m_ts.Text     = "toolStrip1";
     //
     // m_btn_active_trades
     //
     this.m_btn_active_trades.CheckOnClick          = true;
     this.m_btn_active_trades.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.m_btn_active_trades.Image                 = global::Tradee.Properties.Resources.active_orders;
     this.m_btn_active_trades.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.m_btn_active_trades.Name = "m_btn_active_trades";
     this.m_btn_active_trades.Size = new System.Drawing.Size(28, 28);
     this.m_btn_active_trades.Text = "toolStripButton1";
     //
     // m_btn_pending_orders
     //
     this.m_btn_pending_orders.CheckOnClick          = true;
     this.m_btn_pending_orders.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.m_btn_pending_orders.Image                 = global::Tradee.Properties.Resources.pending_orders;
     this.m_btn_pending_orders.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.m_btn_pending_orders.Name = "m_btn_pending_orders";
     this.m_btn_pending_orders.Size = new System.Drawing.Size(28, 28);
     this.m_btn_pending_orders.Text = "toolStripButton1";
     //
     // m_btn_visualising_orders
     //
     this.m_btn_visualising_orders.CheckOnClick          = true;
     this.m_btn_visualising_orders.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.m_btn_visualising_orders.Image                 = global::Tradee.Properties.Resources.visualising_orders;
     this.m_btn_visualising_orders.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.m_btn_visualising_orders.Name = "m_btn_visualising_orders";
     this.m_btn_visualising_orders.Size = new System.Drawing.Size(28, 28);
     this.m_btn_visualising_orders.Text = "toolStripButton1";
     //
     // m_btn_closed_orders
     //
     this.m_btn_closed_orders.CheckOnClick          = true;
     this.m_btn_closed_orders.DisplayStyle          = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
     this.m_btn_closed_orders.Image                 = global::Tradee.Properties.Resources.closed_orders;
     this.m_btn_closed_orders.ImageTransparentColor = System.Drawing.Color.Magenta;
     this.m_btn_closed_orders.Name = "m_btn_closed_orders";
     this.m_btn_closed_orders.Size = new System.Drawing.Size(28, 28);
     this.m_btn_closed_orders.Text = "toolStripButton1";
     //
     // TradesUI
     //
     this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     this.AutoScaleMode       = System.Windows.Forms.AutoScaleMode.Font;
     this.Controls.Add(this.m_grid);
     this.Controls.Add(this.m_ts);
     this.Name = "TradesUI";
     this.Size = new System.Drawing.Size(659, 238);
     ((System.ComponentModel.ISupportInitialize)(this.m_grid)).EndInit();
     this.m_ts.ResumeLayout(false);
     this.m_ts.PerformLayout();
     this.ResumeLayout(false);
     this.PerformLayout();
 }
示例#21
0
 private void SetDataStore(TreeGridView control)
 {
     control.DataStore = CreateComplexTreeItem(0, "", Image);
 }
示例#22
0
        protected override Control OnDefineLayout()
        {
            _container = new TableLayout(1, 2);

            var header = new Label
            {
                Text = "Visual Tree"
            };

            var actionBar = new TableLayout(5, 1)
            {
                Spacing = new Size(5, 0),
                Padding = new Padding(0, 0, 0, 5)
            };

            var refreshBtn = new ImageButton
            {
                ToolTip = "Refresh",
                Image   = AppImages.Refresh,
                Width   = 18,
                Height  = 18
            };

            var addBtn = new ImageButton
            {
                ToolTip = "Register New View",
                Image   = AppImages.AddView,
                Width   = 18,
                Height  = 18
            };

            var editBtn = new ButtonMenuList
            {
                ToolTip = "Edit View",
                Image   = AppImages.Edit,
                Width   = 18,
                Height  = 18
            };

            if (_editMenuItems != null)
            {
                editBtn.AddRange(_editMenuItems);
            }

            // visual tree
            _tree = new TreeGridView
            {
                ShowHeader  = false,
                ContextMenu = _contextMenu
            };

            _tree.Columns.Add(new GridColumn {
                DataCell = new VisualTreeCell(), HeaderText = "Image and Text", AutoSize = true, Resizable = true, Editable = false
            });

            _tree.SelectionChanged += (s, e) =>
            {
                // An item has been selected
                var ti = _tree.SelectedItem as TreeGridItem;

                if (ti?.Tag != null)
                {
                    // does this visual tree node have the data we need?
                    var node = (VisualTreeNode)ti.Tag;

                    if (_tree.SelectedRows.Any())
                    {
                        _lastSelected = _tree.SelectedRows.First();

                        // notify outside views
                        var evt = new VisualTreeNodeSelected(node);
                        ToolboxApp.Bus.Notify(evt);
                    }
                }
                else
                {
                    ToolboxApp.Log.Error("The selected node did not have an attached widget.");
                }
            };

            // layout
            actionBar.Add(header, 0, 0, true, false);
            actionBar.Add(addBtn, 1, 0, false, false);
            actionBar.Add(editBtn, 2, 0, false, false);
            actionBar.Add(refreshBtn, 3, 0, false, false);
            actionBar.Add(null, 4, 0, false, false);

            _container.Add(actionBar, 0, 0, false, false);
            _container.Add(_tree, 0, 1, false, true);

            addBtn.Click += OnAddViewClicked;

            refreshBtn.Click += (s, e) =>
            {
                ToolboxApp.Bus.Notify(new ForceVisualTreeRefresh());
                ToolboxApp.Bus.Notify(new ShowStatusMessage("Visual Tree refresh requested"));
            };

            return(_container);
        }
示例#23
0
		internal static void PaintBlack(TreeGridView treeobj)
		{
			try
			{
				TreeGridNode node = treeobj.Nodes[0];
				CheckColor(node);
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
			}
		}
示例#24
0
        /// <summary>
        /// 检出文件
        /// </summary>
        /// <param name="tgv"></param>
        /// <param name="fileType"></param>
        private void CheckOut(TreeGridView tgv, DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;


            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }


            DataGridViewRow row = tgv.Rows[rowIndex];

            HYDocumentMS.IFileHelper file = new FileHelper();
            Boolean bl = file.isHasAuth(DataType.AuthParmsType.CheckOut, LoginInfo.LoginID, row.Cells["DFL_ID"].Value.ToString());

            if (bl == false)
            {
                MessageBox.Show("你没有权限检出此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            String        Id            = row.Cells["DFL_ID"].Value.ToString();
            DOC_FILE_LIST docFileEntity = _docFileListService.GetDocFileEntityByDCID(Id);

            // HYPDM.Entities.PDM_PHYSICAL_FILE physicalfile = _physicalService.GetPhysicalFile(Id, "");
            if (docFileEntity == null)
            {
                return;
            }
            if (docFileEntity.CHECKOUTFLG == "Y")
            {
                MessageBox.Show("当前文档已被检出,不能再次检出,请等待检出人检入!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            HYPDM.WinUI.Document.DetectionForm form = new HYPDM.WinUI.Document.DetectionForm();
            form.DocFileEntity = docFileEntity;

            if (form.ShowDialog() == DialogResult.OK)
            {
                if (form.FileServerAckResult)
                {
                    docFileEntity.CHECKOUTFLG    = "Y";
                    docFileEntity.CHECKINFLG     = "N";
                    docFileEntity.CHECKOUTDATE   = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    docFileEntity.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    docFileEntity.LASTUPDATEUSER = LoginInfo.LoginID;
                    docFileEntity.Save();
                }
                else
                {
                    MessageBox.Show("文件检出失败", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                try
                {
                    VersionSave("0", docFileEntity);
                    MessageBox.Show("文件检出成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message.ToString());
                }
                finally
                {
                    // MessageBox.Show("文件检出成功!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
示例#25
0
        private void CreateTreeView(data.baseDS.portfolioDetailDataTable dataTbl, TreeGridView treeGV)
        {
            if (this.myPorfolioCode == null || this.myStockCode == null) return;

            DataView dataView = new DataView(dataTbl);
            dataView.Sort = dataTbl.subCodeColumn.ColumnName;
            dataView.RowFilter = dataTbl.portfolioColumn + "='" + this.myPorfolioCode + "' AND " +
                                 dataTbl.codeColumn + "='" + this.myStockCode + "'";
            data.baseDS.portfolioDetailRow dataRow;
            Font boldFont = new Font(treeGV.DefaultCellStyle.Font, FontStyle.Bold);
            string lastStrategy = "";
            TreeGridNodeCollection strategyNodes = null;
            for (int idx = 0; idx < dataView.Count; idx++)
            {
                dataRow = (data.baseDS.portfolioDetailRow)dataView[idx].Row;
                if (lastStrategy != dataRow.subCode.Trim())
                {
                    strategyNodes = AddNode(treeGV.Nodes, dataRow.subCode, GetStrategyDescription(dataRow.subCode), boldFont).Nodes;
                    lastStrategy = dataRow.subCode.Trim();
                }
                AddNodes((strategyNodes == null ? treeGV.Nodes : strategyNodes), dataRow,null);
            }
        }
示例#26
0
        //private void btnFileDown_Click(object sender, EventArgs e)
        //{
        //    ///工艺文件下载
        //    downLoadFile(this.tvFileList, DataType.FileType.ProcessFile);
        //}

        /// <summary>
        /// 文件下载
        /// </summary>
        private void downLoadFile(TreeGridView tgv, DataType.FileType fileType)
        {
            TreeGridNode node       = null;//当前选择的节点
            String       serverpath = "";

            node = new TreeGridNode();
            //node = this.tvFileList.CurrentNode;
            node = tgv.CurrentNode;
            int index = node.RowIndex;

            if (index <= 0)
            {
                MessageBox.Show("请选择需要下载的文件" + "(" + index + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (tgv.CurrentRow == null)
            {
                MessageBox.Show("请选择需要下载的文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                HYDocumentMS.IFileHelper file = new FileHelper();

                Boolean bl = file.isHasAuth(DataType.AuthParmsType.DownLoad, LoginInfo.LoginID, tgv.CurrentRow.Cells["DFL_ID"].Value.ToString());
                if (bl == false)
                {
                    MessageBox.Show("你没有权限下载此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.FileName = node.Cells[0].Value.ToString();
                saveDialog.Filter   = @"Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                DialogResult res = saveDialog.ShowDialog();
                if (DialogResult.OK == res)
                {
                    string clientSaveFileAndPath = saveDialog.FileName.ToString();
                    //MessageBox.Show(clientSavepath);


                    // MessageBox.Show(index.ToString());
                    if (index > 0) //取消第一行
                    {
                        serverpath = node.Cells[1].Value.ToString() + node.Cells[0].Value.ToString();
                        //  MessageBox.Show(serverpath);

                        //FileSockClient.DownLoadFileSocketClient downSocket = new FileSockClient.DownLoadFileSocketClient(serverpath, @"C:\\" + node.Cells[0].Value.ToString());
                        FileSockClient.DownLoadFileSocketClient downSocket = new FileSockClient.DownLoadFileSocketClient(serverpath, clientSaveFileAndPath);
                        if (!downSocket.AckStatus)
                        {
                            return;
                        }
                        else
                        {
                            MessageBox.Show("下载成功,保存路径:" + "\n" + clientSaveFileAndPath, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择需要下载的文件" + "(" + index + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            //  this.tvFileList.CurrentRow
        }
示例#27
0
        public CreateSchemaObjectDialog()
        {
            model       = new CSOViewModel();
            DataContext = model;

            Title     = "Create an Object by Schema";
            Padding   = 5;
            Resizable = true;

            types         = ListAvailableTypes();
            typesFiltered = types;

            search = new SearchBox
            {
                PlaceholderText = "Search for a schema class"
            };
            search.Focus();
            search.TextChanged += Search_TextChanged;


            //list = new ListBox
            //{
            //  Size = new Size(200, 200),
            //  ItemTextBinding = Binding.Property<Type, string>(x => x.Name),
            //  DataStore = typesFiltered,
            //  SelectedIndex = 0
            //};
            //list.SelectedIndexBinding.BindDataContext((CSOViewModel m) => m.SelectedIndex, DualBindingMode.OneWayToSource);
            //list.SelectedValueBinding.BindDataContext((CSOViewModel m) => m.SelectedType, DualBindingMode.OneWayToSource);


            tree = new TreeGridView {
                Size = new Size(300, 200)
            };
            tree.Columns.Add(new GridColumn {
                DataCell = new TextBoxCell(0)
            });
            tree.DataStore = GenerateTree();
            tree.BindDataContext(x => x.SelectedItem, (CSOViewModel m) => m.SelectedItem, DualBindingMode.OneWayToSource);

            description = new TextArea
            {
                ReadOnly = true,
                Size     = new Size(400, 200)
            };

            description.TextBinding.BindDataContext(Binding.Property((CSOViewModel m) => m.SelectedItem).
                                                    Convert(x => GetDescription(x)), DualBindingMode.OneWay);

            Content = new TableLayout
            {
                Spacing = new Size(5, 5),
                Padding = new Padding(10),
                Rows    =
                {
                    new TableRow(search),
                    new TableRow(tree,   description),
                }
            };

            // buttons
            DefaultButton = new Button {
                Text = "Create"
            };
            DefaultButton.BindDataContext(x => x.Enabled, Binding.Property((CSOViewModel m) => m.SelectedItem)
                                          .Convert(x => x != null && x.Tag != null), DualBindingMode.OneWay);

            DefaultButton.Click += (sender, e) =>
            {
                HasResult = true;
                Close();
            };
            PositiveButtons.Add(DefaultButton);

            AbortButton = new Button {
                Text = "C&ancel"
            };
            AbortButton.Click += (sender, e) => Close();
            NegativeButtons.Add(AbortButton);
        }
示例#28
0
        public void NullDataStoreShouldNotCrash()
        {
            var control = new TreeGridView();

            control.DataStore = null;             // when binding, this will be done so it should not crash!
        }
示例#29
0
        public HiSumDisplay()
        {
            // sets the client (inner) size of the window for your content
            ClientSize = new Eto.Drawing.Size(600, 400);

            Title = "HiSum";
            TreeGridView view = new TreeGridView()
            {
                Height = 500
            };

            view.Columns.Add(new GridColumn()
            {
                HeaderText = "Summary", DataCell = new TextBoxCell(0), AutoSize = true, Resizable = true, Editable = false
            });
            var textbox = new TextBox()
            {
                Width = 1000
            };
            var button = new Button()
            {
                Text = "Go", Width = 15
            };
            var label = new Label()
            {
                Width = 100
            };
            var tbResult = new TextArea()
            {
                Width = 1000
            };

            button.Click += (sender, e) =>
            {
                Reader           reader      = new Reader();
                List <int>       top100      = reader.GetTop100();
                List <FullStory> fullStories = new List <FullStory>();
                foreach (int storyID in top100.Take(30))
                {
                    FullStory fullStory = reader.GetStoryFull(storyID);
                    fullStories.Add(fullStory);
                }
                TreeGridItemCollection data = GetTree(fullStories);
                view.DataStore = data;
            };
            Content = new TableLayout
            {
                Spacing = new Size(5, 5),              // space between each cell
                Padding = new Padding(10, 10, 10, 10), // space around the table's sides
                Rows    =
                {
                    new TableRow(
                        new Label {
                        Text = "Input URL from Hacker News: ", Width = 200
                    },
                        textbox,
                        button,
                        label
                        ),
                    new TableRow(
                        null,
                        tbResult,
                        null,
                        null
                        ),
                    new TableRow(
                        new Label(),
                        view
                        ),

                    // by default, the last row & column will get scaled. This adds a row at the end to take the extra space of the form.
                    // otherwise, the above row will get scaled and stretch the TextBox/ComboBox/CheckBox to fill the remaining height.
                    new TableRow  {
                        ScaleHeight = true
                    }
                }
            };
        }
示例#30
0
        void InitializeComponent()
        {
            //exception handling

            var sf = s.UIScalingFactor;

            width = (int)(width * sf);

            height = (int)(height * sf);

            Application.Instance.UnhandledException += (sender, e) =>
            {
                new DWSIM.UI.Desktop.Editors.UnhandledExceptionView((Exception)e.ExceptionObject).ShowModalAsync();
            };

            Title = "DWSIMLauncher".Localize();

            ClientSize = new Size((int)(width * sf), (int)(height * sf));

            Icon = Eto.Drawing.Icon.FromResource(imgprefix + "DWSIM_ico.ico");

            if (Application.Instance.Platform.IsGtk)
            {
                BackgroundColor = Colors.White;
            }

            var abslayout = new PixelLayout();

            var background = new ImageView {
                Size = ClientSize, Image = new Bitmap(Bitmap.FromResource("DWSIM.UI.Forms.Resources.Bitmaps.background_welcome.png"))
            };

            abslayout.Add(background, 0, 0);

            int dx = (int)(15 * sf), dy = (int)(15 * sf), dx2 = (int)(10 * sf), dy2 = (int)(10 * sf);

            float fsize1, fsize2;

            if (GlobalSettings.Settings.RunningPlatform() == s.Platform.Mac)
            {
                fsize1 = 12.0f;
                fsize2 = 10.0f;
            }
            else
            {
                fsize1 = 11.0f;
                fsize2 = 9.0f;
            }

            var boldfont    = new Font(SystemFont.Bold, fsize1, FontDecoration.None);
            var regularfont = new Font(SystemFont.Default, fsize2, FontDecoration.None);
            var boldfont2   = new Font(SystemFont.Bold, fsize2, FontDecoration.None);
            var bfh         = (int)boldfont.LineHeight;
            var rfh         = (int)regularfont.LineHeight;

            var psize  = new Size((int)(100 * sf), (int)(100 * sf));
            var psize2 = new Size((int)(80 * sf), (int)(80 * sf));
            var lsize  = new Size((int)(350 * sf), (int)(50 * sf));

            abslayout.Add(new Label {
                Text = "Welcome to DWSIM!", Width = (int)(200 * sf), Font = boldfont
            }, dx, dy);
            abslayout.Add(new Label {
                Text = "Quick Access", Width = (int)(200 * sf), Font = boldfont
            }, dx * 2 + (int)(500 * sf), dy);

            PixelLayout pfile, pccreator, pdocs, pabout, ppatreon;

            pfile = new PixelLayout {
                BackgroundColor = Colors.White, Width = (int)(500 * sf), Height = (int)(100 * sf)
            };
            pfile.Add(new Label {
                Text = "Process Modeling", Width = (int)(200 * sf), Font = boldfont
            }, dx2, dy2);
            pfile.Add(new Label {
                Size = lsize, Font = regularfont, Wrap = WrapMode.Word, Text = "Create or load chemical steady-state or dynamic process models."
            }, dx2, dy2 * 2 + bfh);
            var img1 = new ImageView {
                Size = psize, Image = new Bitmap(Bitmap.FromResource(imgprefix + "icons8-chemical_plant.png"))
            };

            pfile.Add(img1, (int)(400 * sf), 0);
            var link1 = new LinkButton {
                Text = "Create New", Width = (int)(140 * sf), Font = boldfont2
            };

            pfile.Add(link1, dx2, (int)(100 * sf - rfh - dy));
            var link2 = new LinkButton {
                Text = "Open Existing", Width = (int)(200 * sf), Font = boldfont2
            };

            pfile.Add(link2, dx2 + (int)(150 * sf), (int)(100 * sf - rfh - dy));

            link2.Click += (sender, e) =>
            {
                var dialog = new OpenFileDialog();
                dialog.Title = "Open File".Localize();
                dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" }));
                dialog.Filters.Add(new FileFilter("Mobile XML Simulation File (Android/iOS)", new[] { ".xml" }));
                dialog.MultiSelect        = false;
                dialog.CurrentFilterIndex = 0;
                if (dialog.ShowDialog(this) == DialogResult.Ok)
                {
                    LoadSimulation(dialog.FileName);
                }
            };

            link1.Click += (sender, e) =>
            {
                var form = new Forms.Flowsheet();
                AddUserCompounds(form.FlowsheetObject);
                OpenForms   += 1;
                form.Closed += (sender2, e2) =>
                {
                    OpenForms -= 1;
                };
                form.newsim = true;
                form.Show();
            };

            abslayout.Add(pfile, dx, dy * 2 + bfh);

            pccreator = new PixelLayout {
                BackgroundColor = Colors.White, Width = (int)(500 * sf), Height = (int)(100 * sf)
            };
            pccreator.Add(new Label {
                Text = "Compound Creator", Width = (int)(200 * sf), Font = boldfont
            }, dx2, dy2);
            pccreator.Add(new Label {
                Size = lsize, Font = regularfont, Wrap = WrapMode.Word, Text = "Use this tool to create new compounds and load them in your models."
            }, dx2, dy2 * 2 + bfh);
            var img2 = new ImageView {
                Size = psize2, Image = new Bitmap(Bitmap.FromResource(imgprefix + "icons8-test_tube.png"))
            };

            pccreator.Add(img2, (int)(410 * sf), (int)(10 * sf));
            var link3 = new LinkButton {
                Text = "Create New", Width = (int)(140 * sf), Font = boldfont2
            };

            pccreator.Add(link3, dx2, (int)(100 * sf - rfh - dy));

            link3.Click += (sender, e) => {
                var form = new Desktop.Editors.CompoundCreatorWizard(null);
                form.SetupAndDisplayPage(1);
            };

            abslayout.Add(pccreator, dx, dy * 3 + bfh + (int)(100 * sf));

            ppatreon = new PixelLayout {
                BackgroundColor = Colors.White, Width = (int)(500 * sf), Height = (int)(100 * sf)
            };
            ppatreon.Add(new Label {
                Text = "Become a Patron", Width = (int)(200 * sf), Font = boldfont
            }, dx2, dy2);
            ppatreon.Add(new Label {
                Size = lsize, Font = regularfont, Wrap = WrapMode.Word, Text = "Become a Patron and get access to exclusive Unit Operations, Property Packages and Plugins/Add-Ins!"
            }, dx2, dy2 * 2 + bfh);
            var img4 = new ImageView {
                Size = psize, Image = new Bitmap(Bitmap.FromResource(imgprefix + "Patreon_Navy.jpg"))
            };

            ppatreon.Add(img4, (int)(400 * sf), 0);
            var link4 = new LinkButton {
                Text = "Support the Project", Width = (int)(140 * sf), Font = boldfont2
            };

            ppatreon.Add(link4, dx2, (int)(100 * sf - rfh - dy));
            var bwidth = 70;

            if (Application.Instance.Platform.IsGtk)
            {
                bwidth = 140;
            }
            var link4a = new LinkButton {
                Text = "Get Benefits", Width = bwidth, Font = boldfont2, BackgroundColor = Colors.DodgerBlue, TextColor = Colors.White
            };

            ppatreon.Add(link4a, dx2 + (int)(150 * sf), (int)(100 * sf - rfh - dy));

            link4.Click  += (sender, e) => "https://patreon.com/dwsim".OpenURL();
            link4a.Click += (sender, e) => "https://www.patreon.com/join/dwsim?".OpenURL();

            abslayout.Add(ppatreon, dx, dy * 4 + bfh + 2 * (int)(100 * sf));

            pdocs = new PixelLayout {
                BackgroundColor = Colors.White, Width = (int)(500 * sf), Height = (int)(100 * sf)
            };
            pdocs.Add(new Label {
                Text = "Documentation", Width = (int)(200 * sf), Font = boldfont
            }, dx2, dy2);
            pdocs.Add(new Label {
                Size = lsize, Font = regularfont, Wrap = WrapMode.Word, Text = "View DWSIM's User Guide in PDF format."
            }, dx2, dy2 * 2 + bfh);
            var img5 = new ImageView {
                Size = psize, Image = new Bitmap(Bitmap.FromResource(imgprefix + "icons8-books.png"))
            };

            pdocs.Add(img5, (int)(400 * sf), 0);
            var link5 = new LinkButton {
                Text = "User Guide", Width = (int)(140 * sf), Font = boldfont2
            };

            pdocs.Add(link5, dx2, (int)(100 * sf - rfh - dy));
            var link6 = new LinkButton {
                Text = "Learning Resources", Width = (int)(140 * sf), Font = boldfont2
            };

            pdocs.Add(link6, dx2 + (int)(150 * sf), (int)(100 * sf - rfh - dy));

            link6.Click += (sender, e) => "http://dwsim.inforside.com.br/wiki/index.php?title=Tutorials".OpenURL();

            link5.Click += (sender, e) =>
            {
                var basepath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                try
                {
                    Process.Start(basepath + Path.DirectorySeparatorChar + "docs" + Path.DirectorySeparatorChar + "user_guide.pdf");
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message, "Error opening User Guide", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK);
                }
            };

            abslayout.Add(pdocs, dx, dy * 5 + bfh + 3 * (int)(100 * sf));

            pabout = new PixelLayout {
                BackgroundColor = Colors.White, Width = (int)(500 * sf), Height = (int)(100 * sf)
            };
            pabout.Add(new Label {
                Text = "About DWSIM", Width = (int)(200 * sf), Font = boldfont
            }, dx2, dy2);
            pabout.Add(new Label {
                Size = lsize, Font = regularfont, Wrap = WrapMode.Word, Text = "Adjust Global Settings and view DWSIM licensing and version information."
            }, dx2, dy2 * 2 + bfh);
            var img6 = new ImageView {
                Size = psize, Image = new Bitmap(Bitmap.FromResource(imgprefix + "DWSIM_ico.png"))
            };

            pabout.Add(img6, (int)(400 * sf), 0);
            var link7 = new LinkButton {
                Text = "Global Settings", Width = (int)(140 * sf), Font = boldfont2
            };

            pabout.Add(link7, dx2, (int)(100 * sf - rfh - dy));
            var link8 = new LinkButton {
                Text = "About DWSIM", Width = (int)(140 * sf), Font = boldfont2
            };

            pabout.Add(link8, dx2 + (int)(150 * sf), (int)(100 * sf - rfh - dy));

            link7.Click += (sender, e) =>
            {
                new Forms.Forms.GeneralSettings().GetForm().Show();
            };

            link8.Click += (sender, e) => new AboutBox().Show();

            abslayout.Add(pabout, dx, dy * 6 + bfh + 4 * (int)(100 * sf));

            MostRecentList = new TreeGridView();
            SampleList     = new ListBox();
            FoldersList    = new ListBox();
            FOSSEEList     = new ListBox();

            MostRecentList.AllowMultipleSelection = false;
            MostRecentList.ShowHeader             = true;
            MostRecentList.Columns.Clear();
            MostRecentList.Columns.Add(new GridColumn {
                DataCell = new ImageViewCell(0)
                {
                    ImageInterpolation = ImageInterpolation.High
                }
            });
            MostRecentList.Columns.Add(new GridColumn {
                DataCell = new TextBoxCell(1), HeaderText = "Name", Sortable = true
            });
            MostRecentList.Columns.Add(new GridColumn {
                DataCell = new TextBoxCell(2), HeaderText = "Date", Sortable = true
            });
            MostRecentList.Columns.Add(new GridColumn {
                DataCell = new TextBoxCell(3), HeaderText = "DWSIM Version", Sortable = true
            });
            MostRecentList.Columns.Add(new GridColumn {
                DataCell = new TextBoxCell(4), HeaderText = "Operating System", Sortable = true
            });

            var invertedlist = new List <string>(GlobalSettings.Settings.MostRecentFiles);

            invertedlist.Reverse();

            var tgc = new TreeGridItemCollection();

            foreach (var item in invertedlist)
            {
                if (File.Exists(item))
                {
                    try
                    {
                        var li   = new TreeGridItem();
                        var data = new Dictionary <string, string>();
                        if (Path.GetExtension(item).ToLower() == ".dwxmz")
                        {
                            data = SharedClasses.Utility.GetSimulationFileDetails(FlowsheetBase.FlowsheetBase.LoadZippedXMLDoc(item));
                        }
                        else
                        {
                            data = SharedClasses.Utility.GetSimulationFileDetails(XDocument.Load(item));
                        }
                        li.Tag = data;
                        data.Add("Path", item);
                        DateTime dt;
                        if (data.ContainsKey("SavedOn"))
                        {
                            dt = DateTime.Parse(data["SavedOn"]);
                        }
                        else
                        {
                            dt = File.GetLastWriteTime(item);
                        }
                        string dwsimver, osver;
                        if (data.ContainsKey("DWSIMVersion"))
                        {
                            dwsimver = data["DWSIMVersion"];
                        }
                        else
                        {
                            dwsimver = "N/A";
                        }
                        if (data.ContainsKey("OSInfo"))
                        {
                            osver = data["OSInfo"];
                        }
                        else
                        {
                            osver = "N/A";
                        }
                        li.Values = new object[] { new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-workflow.png")).WithSize(16, 16),
                                                   System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Path.GetFileNameWithoutExtension(item)),
                                                   dt, dwsimver, osver };
                        tgc.Add(li);
                    }
                    catch { }
                }
            }

            tgc = new TreeGridItemCollection(tgc.OrderByDescending(x => ((DateTime)((TreeGridItem)x).Values[2]).Ticks));

            MostRecentList.DataStore = tgc;

            IEnumerable <string> samplist = new List <string>();

            try
            {
                samplist = Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "samples"), "*.dwxm*");
            }
            catch
            { }

            foreach (var item in samplist.OrderBy((x) => Path.GetFileNameWithoutExtension(x)))
            {
                if (File.Exists(item))
                {
                    SampleList.Items.Add(new ListItem {
                        Text = Path.GetFileNameWithoutExtension(item), Key = item
                    });
                }
            }

            foreach (String f in invertedlist)
            {
                if (Path.GetExtension(f).ToLower() != ".dwbcs")
                {
                    if (FoldersList.Items.Where((x) => x.Text == Path.GetDirectoryName(f)).Count() == 0)
                    {
                        if (Directory.Exists(Path.GetDirectoryName(f)))
                        {
                            FoldersList.Items.Add(new ListItem {
                                Text = Path.GetDirectoryName(f), Key = Path.GetDirectoryName(f)
                            });
                        }
                    }
                }
            }

            FOSSEEList.Items.Add(new ListItem {
                Text = "Downloading flowsheet list, please wait...", Key = ""
            });

            Dictionary <string, SharedClasses.FOSSEEFlowsheet> fslist = new Dictionary <string, SharedClasses.FOSSEEFlowsheet>();

            Task.Factory.StartNew(() =>
            {
                return(SharedClasses.FOSSEEFlowsheets.GetFOSSEEFlowsheets());
            }).ContinueWith((t) =>
            {
                Application.Instance.Invoke(() =>
                {
                    FOSSEEList.Items.Clear();
                    if (t.Exception != null)
                    {
                        FOSSEEList.Items.Add(new ListItem {
                            Text = "Error loading flowsheet list. Check your internet connection.", Key = ""
                        });
                    }
                    else
                    {
                        foreach (var item in t.Result)
                        {
                            fslist.Add(item.DownloadLink, item);
                            FOSSEEList.Items.Add(new ListItem {
                                Text = item.DisplayName, Key = item.DownloadLink
                            });
                        }
                    }
                });
            });

            FoldersList.SelectedIndexChanged += (sender, e) =>
            {
                if (FoldersList.SelectedIndex >= 0)
                {
                    var dialog = new OpenFileDialog();
                    dialog.Title     = "Open File".Localize();
                    dialog.Directory = new Uri(FoldersList.SelectedKey);
                    dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" }));
                    dialog.MultiSelect        = false;
                    dialog.CurrentFilterIndex = 0;
                    if (dialog.ShowDialog(this) == DialogResult.Ok)
                    {
                        LoadSimulation(dialog.FileName);
                    }
                }
            };

            MostRecentList.SelectedItemChanged += (sender, e) =>
            {
                if (MostRecentList.SelectedItem != null)
                {
                    var si   = (TreeGridItem)MostRecentList.SelectedItem;
                    var data = (Dictionary <string, string>)si.Tag;
                    LoadSimulation(data["Path"]);
                    MostRecentList.UnselectAll();
                }
                ;
            };

            SampleList.SelectedIndexChanged += (sender, e) =>
            {
                if (SampleList.SelectedIndex >= 0)
                {
                    LoadSimulation(SampleList.SelectedKey);
                    SampleList.SelectedValue = null;
                }
                ;
            };

            FOSSEEList.SelectedIndexChanged += (sender, e) =>
            {
                if (FOSSEEList.SelectedIndex >= 0 && FOSSEEList.SelectedKey != "")
                {
                    var item = fslist[FOSSEEList.SelectedKey];
                    var sb   = new StringBuilder();
                    sb.AppendLine("Title: " + item.Title);
                    sb.AppendLine("Author: " + item.ProposerName);
                    sb.AppendLine("Institution: " + item.Institution);
                    sb.AppendLine();
                    sb.AppendLine("Click 'Yes' to download and open this flowsheet.");

                    if (MessageBox.Show(sb.ToString(), "Open FOSSEE Flowsheet", MessageBoxButtons.YesNo, MessageBoxType.Information, MessageBoxDefaultButton.Yes) == DialogResult.Yes)
                    {
                        var loadingdialog = new LoadingData();
                        loadingdialog.loadingtext.Text = "Please wait, downloading file...\n(" + FOSSEEList.SelectedKey + ")";
                        loadingdialog.Show();
                        var address = FOSSEEList.SelectedKey;
                        Task.Factory.StartNew(() =>
                        {
                            return(SharedClasses.FOSSEEFlowsheets.DownloadFlowsheet(address, (p) =>
                            {
                                Application.Instance.Invoke(() => loadingdialog.loadingtext.Text = "Please wait, downloading file... (" + p + "%)\n(" + address + ")");
                            }));
                        }).ContinueWith((t) =>
                        {
                            Application.Instance.Invoke(() => loadingdialog.Close());
                            if (t.Exception != null)
                            {
                                MessageBox.Show(t.Exception.Message, "Error downloading file", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK);
                            }
                            else
                            {
                                Application.Instance.Invoke(() => LoadSimulation(SharedClasses.FOSSEEFlowsheets.LoadFlowsheet(t.Result)));
                            }
                        });
                        FOSSEEList.SelectedIndex = -1;
                    }
                }
                ;
            };

            var fosseecontainer = c.GetDefaultContainer();
            var l1  = c.CreateAndAddLabelRow3(fosseecontainer, "About the Project");
            var l2  = c.CreateAndAddDescriptionRow(fosseecontainer, "FOSSEE, IIT Bombay, invites chemical engineering students, faculty and practitioners to the flowsheeting project using DWSIM. We want you to convert existing flowsheets into DWSIM and get honoraria and certificates.");
            var bu1 = c.CreateAndAddButtonRow(fosseecontainer, "Submit a Flowsheet", null, (b1, e1) => Process.Start("https://dwsim.fossee.in/flowsheeting-project"));
            var bu2 = c.CreateAndAddButtonRow(fosseecontainer, "About FOSSEE", null, (b2, e2) => Process.Start("https://fossee.in/"));
            var l3  = c.CreateAndAddLabelRow3(fosseecontainer, "Completed Flowsheets");

            fosseecontainer.Add(FOSSEEList);
            fosseecontainer.EndVertical();

            var tabview = new TabControl();
            var tab1    = new TabPage(MostRecentList)
            {
                Text = "Recent Files"
            };;
            var tab2 = new TabPage(SampleList)
            {
                Text = "Samples"
            };;
            var tab2a = new TabPage(fosseecontainer)
            {
                Text = "FOSSEE Flowsheets"
            };;
            var tab3 = new TabPage(FoldersList)
            {
                Text = "Recent Folders"
            };;

            tabview.Pages.Add(tab1);
            tabview.Pages.Add(tab2);
            tabview.Pages.Add(tab2a);
            tabview.Pages.Add(tab3);

            if (Application.Instance.Platform.IsGtk)
            {
                tabview.Size = new Size((int)(480 * sf), (int)(636 - dy * 4 - bfh));
            }
            else
            {
                tabview.Size = new Size((int)(480 * sf), (int)(ClientSize.Height - dy * 4 - bfh));
            }

            abslayout.Add(tabview, dx * 2 + (int)(500 * sf), dy * 2 + bfh);

            Content = abslayout;

            var quitCommand = new Command {
                MenuText = "Quit".Localize(), Shortcut = Application.Instance.CommonModifier | Keys.Q
            };

            quitCommand.Executed += (sender, e) =>
            {
                try
                {
                    DWSIM.GlobalSettings.Settings.SaveSettings("dwsim_newui.ini");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, "Error Saving Settings to File", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK);
                }
                if (MessageBox.Show(this, "ConfirmAppExit".Localize(), "AppExit".Localize(), MessageBoxButtons.YesNo, MessageBoxType.Information, MessageBoxDefaultButton.No) == DialogResult.Yes)
                {
                    Application.Instance.Quit();
                }
            };

            var aboutCommand = new Command {
                MenuText = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "information.png"))
            };

            aboutCommand.Executed += (sender, e) => new AboutBox().Show();

            var aitem1 = new ButtonMenuItem {
                Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-sorting_options.png"))
            };

            aitem1.Click += (sender, e) =>
            {
                new Forms.Forms.GeneralSettings().GetForm().Show();
            };

            var hitem1 = new ButtonMenuItem {
                Text = "User Guide".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png"))
            };

            hitem1.Click += (sender, e) =>
            {
                var basepath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                Process.Start(basepath + Path.DirectorySeparatorChar + "docs" + Path.DirectorySeparatorChar + "user_guide.pdf");
            };

            var hitem2 = new ButtonMenuItem {
                Text = "Support".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png"))
            };

            hitem2.Click += (sender, e) =>
            {
                "http://dwsim.inforside.com.br/wiki/index.php?title=Support".OpenURL();
            };

            var hitem3 = new ButtonMenuItem {
                Text = "Report a Bug".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png"))
            };

            hitem3.Click += (sender, e) =>
            {
                "https://sourceforge.net/p/dwsim/tickets/".OpenURL();
            };

            var hitem4 = new ButtonMenuItem {
                Text = "Go to DWSIM's Website".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png"))
            };

            hitem4.Click += (sender, e) =>
            {
                "http://dwsim.inforside.com.br".OpenURL();
            };

            // create menu
            Menu = new MenuBar
            {
                ApplicationItems = { aitem1 },
                QuitItem         = quitCommand,
                HelpItems        = { hitem1, hitem4, hitem2, hitem3 },
                AboutItem        = aboutCommand
            };

            Shown += MainForm_Shown;

            Closing += MainForm_Closing;

            //Plugins

            LoadPlugins();
        }
示例#31
0
        /// <summary>
        /// Set up the <see cref="Form"/> with visual styling.
        /// </summary>
        void InitializeComponent()
        {
            Icon       = Iconography.MainIcon;
            Title      = Versioning.ProgramTitle;
            ClientSize = new Size(680, 420);
            Padding    = 5;

            Content = new Splitter
            {
                FixedPanel = SplitterFixedPanel.Panel1,
                Panel1     = _nodeTree = new TreeGridView(),
                Panel2     = new Splitter
                {
                    Orientation = Orientation.Vertical,
                    FixedPanel  = SplitterFixedPanel.None,
                    Panel1      = _propertyGrid = new PropertyGrid {
                        Size = new Size(100, 100)
                    },
                    Panel2 = _previewPanel = new Panel {
                        Size = new Size(100, 100)
                    },
                    Position = 255
                },
                Position = 235
            };

            // create a few commands that can be used for the menu and toolbar
            var openFile = new Command {
                MenuText = "&Open...", ToolBarText = "Open a file", Shortcut = Application.Instance.CommonModifier | Keys.O
            };

            openFile.Executed += OpenFile;

            var quitCommand = new Command {
                MenuText = "Quit", ToolBarText = "Quit the program"
            };

            quitCommand.Executed += (sender, e) => Application.Instance.Quit();

            var aboutCommand = new Command {
                MenuText = "About...", ToolBarText = "Learn more about the program"
            };

            aboutCommand.Executed += (sender, e) => new AboutDialog().ShowDialog(this);

            // create menu
            Menu = new MenuBar
            {
                Items =
                {
                    // File submenu
                    new ButtonMenuItem {
                        Text = "&File", Items ={ openFile          }
                    },
                    new ButtonMenuItem {
                        Text = "&Edit", Items ={ new Command {
                                             MenuText = "Coming Soon™"
                                         } }
                    }
                },
                ApplicationItems =
                {
                    // application (OS X) or file menu (others)
                    new ButtonMenuItem {
                        Text = "&Preferences..."
                    }
                },
                // Placed in Application Menu for OSX, File Menu for Windows/Linux
                QuitItem = quitCommand,
                // Placed in Application Menu for OSX, Help Menu for Windows/Linux
                AboutItem = aboutCommand
            };
        }
示例#32
0
        public DragDropSection()
        {
            // drag data object

            showDragOverEvents = new CheckBox {
                Text = "Show DragOver Events"
            };
            var includeImageCheck = new CheckBox {
                Text = "Include Image"
            };
            var textBox = new TextBox {
                Text = "Some text"
            };
            var allowedEffectDropDown = new EnumDropDown <DragEffects> {
                SelectedValue = DragEffects.All
            };

            dragOverEffect = new EnumDropDown <DragEffects> {
                SelectedValue = DragEffects.Copy
            };

            var htmlTextArea      = new TextArea();
            var selectFilesButton = new Button {
                Text = "Select Files"
            };

            Uri[] uris = null;
            selectFilesButton.Click += (sender, e) =>
            {
                var ofd = new OpenFileDialog();
                ofd.MultiSelect = true;
                ofd.ShowDialog(this);
                uris = ofd.Filenames.Select(r => new Uri(r)).ToArray();
                if (uris.Length == 0)
                {
                    uris = null;
                }
            };

            Func <DataObject> createDataObject = () =>
            {
                var data = new DataObject();
                if (!string.IsNullOrEmpty(textBox.Text))
                {
                    data.Text = textBox.Text;
                }
                if (uris != null)
                {
                    data.Uris = uris;
                }
                if (!string.IsNullOrEmpty(htmlTextArea.Text))
                {
                    data.Html = htmlTextArea.Text;
                }
                if (includeImageCheck.Checked == true)
                {
                    data.Image = TestIcons.Logo;
                }
                return(data);
            };

            // sources

            var buttonSource = new Button {
                Text = "Source"
            };

            buttonSource.MouseDown += (sender, e) =>
            {
                buttonSource.DoDragDrop(createDataObject(), allowedEffectDropDown.SelectedValue);
                e.Handled = true;
            };

            var panelSource = new Panel {
                BackgroundColor = Colors.Red, Size = new Size(50, 50)
            };

            panelSource.MouseDown += (sender, e) =>
            {
                panelSource.DoDragDrop(createDataObject(), allowedEffectDropDown.SelectedValue);
                e.Handled = true;
            };

            var treeSource = new TreeGridView {
                Size = new Size(200, 200)
            };

            treeSource.DataStore = CreateTreeData();
            SetupTreeColumns(treeSource);
            treeSource.MouseMove += (sender, e) =>
            {
                if (e.Buttons == MouseButtons.Primary)
                {
                    var cell = treeSource.GetCellAt(e.Location);
                    if (cell.Item == null || cell.ColumnIndex == -1)
                    {
                        return;
                    }
                    var data     = createDataObject();
                    var selected = treeSource.SelectedItems.OfType <TreeGridItem>().Select(r => (string)r.Values[0]);
                    data.SetString(string.Join(";", selected), "my-tree-data");

                    treeSource.DoDragDrop(data, allowedEffectDropDown.SelectedValue);
                    e.Handled = true;
                }
            };

            var gridSource = new GridView {
            };

            SetupGridColumns(gridSource);
            gridSource.DataStore  = CreateGridData();
            gridSource.MouseMove += (sender, e) =>
            {
                if (e.Buttons == MouseButtons.Primary)
                {
                    var data     = createDataObject();
                    var selected = gridSource.SelectedItems.OfType <GridItem>().Select(r => (string)r.Values[0]);
                    data.SetString(string.Join(";", selected), "my-grid-data");

                    gridSource.DoDragDrop(data, allowedEffectDropDown.SelectedValue);
                    e.Handled = true;
                }
            };


            // destinations

            var buttonDestination = new Button {
                Text = "Drop here!", AllowDrop = true
            };

            buttonDestination.DragEnter += (sender, e) => buttonDestination.Text = "Now, drop it!";
            buttonDestination.DragLeave += (sender, e) => buttonDestination.Text = "Drop here!";
            LogEvents(buttonDestination);

            var drawableDest = new Drawable {
                BackgroundColor = Colors.Blue, AllowDrop = true, Size = new Size(50, 50)
            };

            LogEvents(drawableDest);
            drawableDest.DragEnter += (sender, e) =>
            {
                if (e.Effects != DragEffects.None)
                {
                    drawableDest.BackgroundColor = Colors.Green;
                }
            };
            drawableDest.DragLeave += (sender, e) =>
            {
                if (e.Effects != DragEffects.None)
                {
                    drawableDest.BackgroundColor = Colors.Blue;
                }
            };
            drawableDest.DragDrop += (sender, e) =>
            {
                if (e.Effects != DragEffects.None)
                {
                    drawableDest.BackgroundColor = Colors.Blue;
                }
            };

            var dragMode = new RadioButtonList
            {
                Orientation = Orientation.Vertical,
                Items       =
                {
                    new ListItem {
                        Text = "No Restriction", Key = ""
                    },
                    new ListItem {
                        Text = "RestrictToOver", Key = "over"
                    },
                    new ListItem {
                        Text = "RestrictToInsert", Key = "insert"
                    },
                    new ListItem {
                        Text = "RestrictToNode", Key = "node"
                    },
                    new ListItem {
                        Text = "No Node", Key = "none"
                    }
                },
                SelectedIndex = 0
            };
            var treeDest = new TreeGridView {
                AllowDrop = true, Size = new Size(200, 200)
            };
            var treeDestData = CreateTreeData();

            treeDest.DataStore = treeDestData;
            treeDest.DragOver += (sender, e) =>
            {
                var info = treeDest.GetDragInfo(e);
                if (info == null)
                {
                    return;                     // not supported
                }
                switch (dragMode.SelectedKey)
                {
                case "over":
                    info.RestrictToOver();
                    break;

                case "insert":
                    info.RestrictToInsert();
                    break;

                case "node":
                    info.RestrictToNode(treeDestData[2]);
                    break;

                case "none":
                    info.Item = info.Parent = null;
                    break;
                }
            };
            SetupTreeColumns(treeDest);
            LogEvents(treeDest);

            var gridDest = new GridView {
                AllowDrop = true
            };
            var gridDestData = CreateGridData();

            gridDest.DataStore = gridDestData;
            gridDest.DragOver += (sender, e) =>
            {
                var info = gridDest.GetDragInfo(e);
                if (info == null)
                {
                    return;                     // not supported
                }
                switch (dragMode.SelectedKey)
                {
                case "over":
                    info.RestrictToOver();
                    break;

                case "insert":
                    info.RestrictToInsert();
                    break;

                case "node":
                    info.Index    = 2;
                    info.Position = GridDragPosition.Over;
                    break;

                case "none":
                    info.Index = -1;
                    break;
                }
            };
            SetupGridColumns(gridDest);
            LogEvents(gridDest);



            // layout

            var layout = new DynamicLayout {
                Padding = 10, DefaultSpacing = new Size(4, 4)
            };

            layout.BeginHorizontal();

            layout.BeginCentered();

            layout.AddSeparateRow(showDragOverEvents);
            layout.AddSeparateRow("AllowedEffect", allowedEffectDropDown, null);
            layout.AddSeparateRow("DragOver Effect", dragOverEffect, null);

            layout.BeginGroup("DataObject", 10);
            layout.AddRow("Text", textBox);
            layout.AddRow("Html", htmlTextArea);
            layout.BeginHorizontal();
            layout.AddSpace();
            layout.BeginVertical();
            layout.AddCentered(includeImageCheck);
            layout.AddCentered(selectFilesButton);
            layout.EndVertical();
            layout.EndGroup();
            layout.Add(dragMode);
            layout.AddSpace();

            layout.EndCentered();

            layout.BeginVertical(xscale: true);
            layout.AddRange("Drag sources:", buttonSource, panelSource);
            layout.Add(treeSource, yscale: true);
            layout.Add(gridSource, yscale: true);
            layout.EndVertical();

            layout.BeginVertical(xscale: true);
            layout.AddRange("Drag destinations:", buttonDestination, drawableDest);
            layout.Add(treeDest, yscale: true);
            layout.Add(gridDest, yscale: true);
            layout.EndVertical();

            layout.EndHorizontal();

            Content = layout;
        }
示例#33
0
        /// <summary>
        /// 查看文件
        /// </summary>
        /// <param name="tgv"></param>
        /// <param name="fileType"></param>
        private void ViewFile(TreeGridView tgv, DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;

            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            else
            {

                //  dr["DFL_FILE_NAME"].ToString()
                DataGridViewRow row = tgv.Rows[rowIndex];
                //   string ff = row.Cells[0].Value.ToString();

                HYDocumentMS.IFileHelper file = new FileHelper();
                Boolean bl = file.isHasAuth(DataType.AuthParmsType.View, LoginInfo.LoginID, row.Cells["DFL_ID"].Value.ToString());
                if (bl == false)
                {
                    MessageBox.Show("你没有权限查看此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                String fileName = Path.ChangeExtension(row.Cells["DFL_FILE_NAME"].Value.ToString(), "swf");
                string viewPath = System.Configuration.ConfigurationManager.AppSettings["viewFilePath"].ToString();
                ViewFileFrm fileView = new ViewFileFrm();
                fileView.FileName = fileName;
                //fileView.ViewFilePathAndName = @"D:\swf\Java网络编程精解.swf";
                fileView.ViewFilePath = viewPath;
                fileView.ShowDialog();
            }
        }
示例#34
0
		private TreeGridView InitializeTreeGridView()
		{
			try
			{
				//TreeGridView Initialization
				TreeGridView treeGridView = new TreeGridView();
				treeGridView.Size = new Size(530, 442);
				treeGridView.Location = new Point(2, 2);
				treeGridView.Name = BusinessConstants.DB4OBJECTS_TREEGRIDVIEW;
				treeGridView.RowHeadersVisible = false;
				treeGridView.ShowLines = true;
				treeGridView.Dock = DockStyle.Fill;
				treeGridView.Visible = true;
				treeGridView.AllowDrop = true;

				//Column Intialization

				//Field Column
				TreeGridColumn m_fieldColumn = new TreeGridColumn();
				m_fieldColumn.DefaultNodeImage = null;
				m_fieldColumn.FillWeight = 386.9562F;
				m_fieldColumn.HeaderText = BusinessConstants.DB4OBJECTS_FIELD;
				m_fieldColumn.Name = BusinessConstants.DB4OBJECTS_FIELDCOLOUMN;
				m_fieldColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
				m_fieldColumn.ReadOnly = true;
				m_fieldColumn.Width = 170;

				//Value Column
				TreeGridViewDateTimePickerColumn m_valueColumn = new TreeGridViewDateTimePickerColumn();
				m_valueColumn.FillWeight = 50F;
				m_valueColumn.HeaderText = BusinessConstants.DB4OBJECTS_VALUEFORGRID;
				m_valueColumn.Name = BusinessConstants.DB4OBJECTS_VALUECOLUMN;
				m_valueColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
				m_valueColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
				m_valueColumn.ReadOnly = checkReadonlyStatus();

				//Type Column
				DataGridViewTextBoxColumn m_typeColumn = new DataGridViewTextBoxColumn();
				m_typeColumn.FillWeight = 50F;
				m_typeColumn.HeaderText = BusinessConstants.DB4OBJECTS_TYPE;
				m_typeColumn.Name = BusinessConstants.DB4OBJECTS_TYPECOLUMN;
				m_typeColumn.SortMode = DataGridViewColumnSortMode.NotSortable;
				m_typeColumn.ReadOnly = true;
				m_typeColumn.Width = 150;

				treeGridView.Columns.AddRange(new DataGridViewColumn[] { m_fieldColumn, m_valueColumn, m_typeColumn });

				treeGridView.ImageList = m_imageListTreeGrid;
				treeGridView.ScrollBars = ScrollBars.Both;

				return treeGridView;
			}
			catch (Exception oEx)
			{
				LoggingHelper.HandleException(oEx);
			}

			return null;
		}
示例#35
0
        /// <summary>
        /// checkin文件
        /// </summary>
        /// <param name="tgv"></param>
        /// <param name="fileType"></param>
        private void CheckInFile(TreeGridView tgv, DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;

            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            DataGridViewRow row = tgv.Rows[rowIndex];
            String Id = row.Cells["DFL_ID"].Value.ToString();
            DOC_FILE_LIST docFileEntity = _docFileListService.GetDocFileEntityByDCID(Id);
            // HYPDM.Entities.PDM_PHYSICAL_FILE physicalfile = _physicalService.GetPhysicalFile(Id, "");
            HYDocumentMS.IFileHelper file = new FileHelper();
            Boolean bl = file.isHasAuth(DataType.AuthParmsType.CheckIn, LoginInfo.LoginID, row.Cells["DFL_ID"].Value.ToString());
            if (bl == false)
            {
                MessageBox.Show("你没有权限检入此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (docFileEntity == null) return;
            if (docFileEntity.CHECKOUTFLG == "N")
            {
                MessageBox.Show("文件名【" + docFileEntity.DFL_FILE_NAME + "】" + "\n" + "不为检出状态,不能进行检入操作!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                CheckInForm form = new CheckInForm();
                form.DocFileEntity = docFileEntity;

                if (form.ShowDialog() == DialogResult.OK)
                {
                    docFileEntity.CHECKINFLG = "Y";
                    docFileEntity.CHECKINDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    docFileEntity.CHECKOUTFLG = "N";
                    docFileEntity.DFL_VER_LATEST = "V" + DateTime.Now.ToString("yyyyMMddHHmmss");
                    docFileEntity.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    docFileEntity.LASTUPDATEUSER = LoginInfo.LoginID;
                    docFileEntity.Save();

                    VersionSave("1", docFileEntity);
                }
            }
        }
示例#36
0
        private void InitializeComponent()
        {
            #region Initialization

            searchTextBox = new SearchBox
            {
                Size = new Size(268, -1)
            };

            #region Commands

            searchClearCommand = new Command {
                MenuText = "Clear", Image = ImageResources.Actions.Delete
            };

            cancelCommand = new Command {
                MenuText = "Cancel"
            };

            openCommand = new Command {
                MenuText = "Open", Image = ImageResources.Actions.Open
            };
            openWithCommand = new Command {
                MenuText = "Open with", Image = ImageResources.Actions.OpenWith
            };

            saveCommand = new Command {
                MenuText = "Save", Shortcut = SaveHotKey, Image = ImageResources.Actions.Save
            };
            saveAsCommand = new Command {
                MenuText = "Save As", Shortcut = SaveAsHotKey, Image = ImageResources.Actions.SaveAs
            };

            extractDirectoryCommand = new Command {
                MenuText = "Extract", Image = ImageResources.Actions.FolderExport
            };
            replaceDirectoryCommand = new Command {
                MenuText = "Replace", Image = ImageResources.Actions.FolderImport
            };
            renameDirectoryCommand = new Command {
                MenuText = "Rename", Image = ImageResources.Actions.Rename
            };
            deleteDirectoryCommand = new Command {
                MenuText = "Delete", Image = ImageResources.Actions.Delete
            };
            addDirectoryCommand = new Command {
                MenuText = "Add", Image = ImageResources.Actions.Add
            };

            extractFileCommand = new Command {
                MenuText = "Extract", Image = ImageResources.Actions.FileExport
            };
            replaceFileCommand = new Command {
                MenuText = "Replace", Image = ImageResources.Actions.FileImport
            };
            renameFileCommand = new Command {
                MenuText = "Rename", Image = ImageResources.Actions.Rename
            };
            deleteFileCommand = new Command {
                MenuText = "Delete", Image = ImageResources.Actions.Delete
            };

            #endregion

            #region Folders

            var folderContext = new ContextMenu
            {
                Items =
                {
                    extractDirectoryCommand,
                    replaceDirectoryCommand,
                    renameDirectoryCommand,
                    addDirectoryCommand,
                    deleteDirectoryCommand
                }
            };

            folders    = new TreeGridItemCollection();
            folderView = new TreeGridView
            {
                ContextMenu = folderContext,

                DataStore = folders,
                Columns   =
                {
                    new GridColumn
                    {
                        DataCell = new ImageTextCell(0, 1)
                    }
                },
                AllowColumnReordering = false
            };

            #endregion

            #region Files

            //NOTE Image has to be set explicitly, I think the Command is not used anymore as soon as sub-items are added
            openWithMenuItem = new ButtonMenuItem {
                Text = "Open with", Command = openWithCommand, Image = openWithCommand.Image
            };
            var fileContext = new ContextMenu
            {
                Items =
                {
                    openCommand,
                    openWithMenuItem,

                    new SeparatorMenuItem(),

                    extractFileCommand,
                    replaceFileCommand,
                    renameFileCommand,
                    deleteFileCommand
                }
            };

            files    = new ObservableCollection <FileElement>();
            fileView = new GridView <FileElement>
            {
                ShowHeader             = true,
                AllowMultipleSelection = true,
                BackgroundColor        = KnownColors.White,

                ContextMenu = fileContext,

                Columns =
                {
                    new GridColumn
                    {
                        DataCell   = new TextBoxCell(nameof(FileElement.Name)),
                        HeaderText = "Name",
                        Sortable   = true,
                        AutoSize   = true
                    },
                    new GridColumn
                    {
                        DataCell   = new TextBoxCell(nameof(FileElement.Size)),
                        HeaderText = "Size",
                        Sortable   = true,
                        AutoSize   = true
                    }
                },

                DataStore = files
            };

            #endregion

            #region Buttons

            searchClearButton = new Button
            {
                Image   = ImageResources.Actions.Clear,
                ToolTip = "Reset search",
                Command = searchClearCommand,
                Size    = new Size(22, -1)
            };

            cancelButton = new Button
            {
                Text    = "Cancel",
                Command = cancelCommand
            };

            saveButton = new ButtonToolStripItem
            {
                ToolTip = "Save",
                Command = saveCommand,
            };

            saveAsButton = new ButtonToolStripItem
            {
                ToolTip = "Save As",
                Command = saveAsCommand,
            };

            extractButton = new ButtonToolStripItem
            {
                ToolTip = "Extract file(s)",
                Command = extractFileCommand,
            };

            replaceButton = new ButtonToolStripItem
            {
                ToolTip = "Replace file(s)",
                Command = replaceFileCommand,
            };

            renameButton = new ButtonToolStripItem
            {
                ToolTip = "Rename file",
                Command = renameFileCommand,
            };

            deleteButton = new ButtonToolStripItem
            {
                ToolTip = "Delete file",
                Command = deleteFileCommand,
            };

            #endregion

            #endregion

            #region Content

            var archiveToolStrip = new ToolStrip
            {
                Padding = 3,
                Items   =
                {
                    saveButton,
                    saveAsButton
                }
            };

            var mainContent = new TableLayout
            {
                Spacing = new Size(3, 3),
                Rows    =
                {
                    // Searchbar and file toolstrip
                    new TableRow
                    {
                        Cells =
                        {
                            // Searchbar
                            new StackLayout
                            {
                                Spacing     = 3,
                                Orientation = Orientation.Horizontal,
                                Items       =
                                {
                                    searchTextBox,
                                    searchClearButton
                                }
                            },

                            // file toolstrip
                            new ToolStrip
                            {
                                Items =
                                {
                                    extractButton,
                                    replaceButton,
                                    renameButton,
                                    deleteButton
                                }
                            },
                        }
                    },

                    // Folder and file view
                    new TableRow
                    {
                        Cells =
                        {
                            folderView,
                            fileView
                        }
                    }
                }
            };

            Content = new TableLayout
            {
                Spacing = new Size(3, 3),
                Rows    =
                {
                    new TableRow(archiveToolStrip),
                    new TableRow {
                        Cells = { new TableCell(mainContent)
                                  {
                                      ScaleWidth = true
                                  } },             ScaleHeight= true
                    }
                }
            };

            #endregion
        }
示例#37
0
        /// <summary>
        /// 取消检出
        /// </summary>
        /// <param name="tgv"></param>
        /// <param name="fileType"></param>
        private void CheckOutCancel(TreeGridView tgv, DataType.FileType fileType)
        {
            int rowIndex = tgv.CurrentCell.RowIndex;

            if (rowIndex <= 0)
            {
                MessageBox.Show("请选择文件", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            DataGridViewRow row = tgv.Rows[rowIndex];
            String Id = row.Cells["DFL_ID"].Value.ToString();
            DOC_FILE_LIST docFileEntity = _docFileListService.GetDocFileEntityByDCID(Id);
            if (docFileEntity.CREATEUSER.ToString() != LoginInfo.LoginID.ToString())
            {
                MessageBox.Show("当前不为文件的检出用户,不能进行取消动作!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
                return;
            }

            if (docFileEntity == null) return;

            docFileEntity.CHECKOUTFLG = "N";
            docFileEntity.CHECKINFLG = "Y";
            docFileEntity.LASTUPDATEUSER = LoginInfo.LoginID;
            docFileEntity.LASTUPDATEDATE = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            try
            {
                docFileEntity.Save();
                VersionSave("qx", docFileEntity);
                MessageBox.Show("文件检出取消成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
                return;
            }
            finally
            {

            }
        }
示例#38
0
        private Dialog_Error(HoneybeeSchema.ValidationReport report)
        {
            this.Title = $"Validation Report - {DialogHelper.PluginName}";
            this.Width = 800;
            this.Icon  = DialogHelper.HoneybeeIcon;

            _vm = new ErrorViewModel(report, this);

            _grid = GenGridView();
            var nextBtn = new Button()
            {
                Text = ">>"
            };
            var currentErrorIndex = new Label();
            var preBtn            = new Button()
            {
                Text = "<<"
            };
            var showBtn = new Button()
            {
                Text = "Show"
            };
            var showParentBtn = new Button()
            {
                Text = "Show Parent"
            };
            var moreInfoBtn = new Button()
            {
                Text = "More Info"
            };

            var message = new TextArea()
            {
                Height = 84
            };


            message.TextBinding.Bind(_vm, _ => _.CurrentErrorMessage);
            currentErrorIndex.TextBinding.Bind(_vm, _ => _.CurrentErrorIndex);
            nextBtn.Bind(_ => _.Enabled, _vm, _ => _.NextBtnEnabled);
            preBtn.Bind(_ => _.Enabled, _vm, _ => _.PreBtnEnabled);
            moreInfoBtn.Bind(_ => _.Enabled, _vm, _ => _.MoreBtnEnabled);

            showBtn.Bind(_ => _.Enabled, _vm, _ => _.ShowBtnEnabled);
            showParentBtn.Bind(_ => _.Enabled, _vm, _ => _.ShowParentBtnEnabled);

            nextBtn.Command       = _vm.NextBtnCommand;
            preBtn.Command        = _vm.PreBtnCommand;
            moreInfoBtn.Command   = _vm.ErrorLinkCommand;
            showBtn.Command       = _vm.ShowCommand;
            showParentBtn.Command = _vm.ShowParentCommand;
            //errorLink.Command = _vm.ErrorLinkCommand;


            var group = new GroupBox();

            group.Bind(_ => _.Text, _vm, _ => _.TotalErrorMessage);

            group.Size = new Eto.Drawing.Size(-1, -1);
            var groupLayout = new DynamicLayout();

            groupLayout.DefaultSpacing = new Eto.Drawing.Size(5, 5);
            groupLayout.DefaultPadding = new Eto.Drawing.Padding(5);
            groupLayout.AddSeparateRow(_grid);
            groupLayout.AddSeparateRow(preBtn, currentErrorIndex, nextBtn, null, showBtn, showParentBtn, moreInfoBtn);
            groupLayout.AddSeparateRow(message);
            group.Content = groupLayout;

            var validateBtn = new Eto.Forms.Button()
            {
                Text = "Re-Validate"
            };

            validateBtn.Bind(_ => _.Visible, _vm, _ => _.ValidateBtnEnabled);
            validateBtn.Command = _vm.ValidateCommand;

            var abortButton = new Eto.Forms.Button()
            {
                Text = "Close", Height = 24
            };

            abortButton.Click += (s, e) => { this.Close(); };

            var layout = new Eto.Forms.DynamicLayout();

            layout.DefaultSpacing = new Eto.Drawing.Size(5, 2);
            layout.DefaultPadding = new Eto.Drawing.Padding(4);
            layout.AddSeparateRow(controls: new[] { group }, xscale: true, yscale: true);
            layout.AddSeparateRow(null, validateBtn, abortButton);
            this.Content = layout;

            _vm.UILoaded();
        }
示例#39
0
        /// <summary>
        /// 文件下载
        /// </summary>
        private void downLoadFile(TreeGridView tgv, DataType.FileType fileType)
        {
            TreeGridNode node = null;//当前选择的节点
            String serverpath = "";
            node = new TreeGridNode();
            //node = this.tvFileList.CurrentNode;
            node = tgv.CurrentNode;
            int index = node.RowIndex;

            if (index <= 0)
            {
                MessageBox.Show("请选择需要下载的文件" + "(" + index + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            if (tgv.CurrentRow == null)
            {
                MessageBox.Show("请选择需要下载的文件", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {

                HYDocumentMS.IFileHelper file = new FileHelper();
                Boolean bl = file.isHasAuth(DataType.AuthParmsType.DownLoad, LoginInfo.LoginID, tgv.CurrentRow.Cells["DFL_ID"].Value.ToString());
                if (bl == false)
                {
                    MessageBox.Show("你没有权限下载此文件!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }

                SaveFileDialog saveDialog = new SaveFileDialog();
                saveDialog.FileName = node.Cells[0].Value.ToString();
                //saveDialog.Filter = @"Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                string suffix = node.Cells[0].Value.ToString().Substring(node.Cells[0].Value.ToString().LastIndexOf(@".") + 1);
                saveDialog.Filter = @"文件 (*." + suffix + ")|*." + suffix;
                DialogResult res = saveDialog.ShowDialog();

                //SaveFileDialog saveDialog = new SaveFileDialog();
                //saveDialog.FileName = node.Cells[0].Value.ToString();
                //saveDialog.Filter = @"Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
                //DialogResult res = saveDialog.ShowDialog();
                if (DialogResult.OK == res)
                {
                    string clientSaveFileAndPath = saveDialog.FileName.ToString();
                    //MessageBox.Show(clientSavepath);

                    // MessageBox.Show(index.ToString());
                    if (index > 0) //取消第一行
                    {
                        serverpath = node.Cells[1].Value.ToString() + node.Cells[0].Value.ToString();
                        //  MessageBox.Show(serverpath);

                        //FileSockClient.DownLoadFileSocketClient downSocket = new FileSockClient.DownLoadFileSocketClient(serverpath, @"C:\\" + node.Cells[0].Value.ToString());
                        FileSockClient.DownLoadFileSocketClient downSocket = new FileSockClient.DownLoadFileSocketClient(serverpath, clientSaveFileAndPath);
                        if (!downSocket.AckStatus)
                        {
                            return;
                        }
                    }
                    else
                    {
                        MessageBox.Show("请选择需要下载的文件" + "(" + index + ")", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            //  this.tvFileList.CurrentRow
        }
示例#40
0
        public TreeGridNode CloneNode(TreeGridView grid)
        {
            // clone and copy value
            TreeGridNode nodeclone = (TreeGridNode) Clone();
            for (int i = 0; i < ((Cells.Count < nodeclone.Cells.Count) ? Cells.Count : nodeclone.Cells.Count); i++)
                nodeclone.Cells[i].Value = Cells[i].Value;

            // clone child
            nodeclone._grid = grid;
            if (HasChildren)
                foreach (TreeGridNode ChildNode in Nodes)
                    nodeclone.Nodes.Add(ChildNode.CloneNode(grid));

            // return
            return nodeclone;
        }
示例#41
0
        public UnitTestSection()
        {
            startButton = new Button {
                Text = "Start Tests", Size = new Size(200, 80)
            };
            useTestPlatform = new CheckBox {
                Text = "Use Test Platform"
            };
            includeManualTests = new CheckBox {
                Text = "Manual Tests", Checked = true
            };
            var buttons = new StackLayout
            {
                Padding = new Padding(10),
                Spacing = 5,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Items =
                {
                    startButton,
                    TableLayout.Horizontal(useTestPlatform, includeManualTests)
                }
            };

            if (Platform.Supports <TreeGridView>())
            {
                search = new SearchBox();
                search.Focus();
                search.KeyDown += (sender, e) =>
                {
                    if (e.KeyData == Keys.Enter)
                    {
                        startButton.PerformClick();
                        e.Handled = true;
                    }
                };

                var timer = new UITimer();
                timer.Interval = 0.5;
                timer.Elapsed += (sender, e) =>
                {
                    timer.Stop();
                    var searchText = search.Text;
                    Task.Factory.StartNew(() => PopulateTree(searchText));
                };
                search.TextChanged += (sender, e) => {
                    if (timer.Started)
                    {
                        timer.Stop();
                    }
                    timer.Start();
                };

                tree = new TreeGridView {
                    ShowHeader = false
                };
                tree.Columns.Add(new GridColumn
                {
                    DataCell = new TextBoxCell {
                        Binding = Binding.Property((UnitTestItem m) => m.Text)
                    }
                });

                tree.Activated += (sender, e) =>
                {
                    var item = (TreeGridItem)tree.SelectedItem;
                    if (item != null)
                    {
                        RunTests(item.Tag as CategoryFilter);
                    }
                };

                Content = new StackLayout
                {
                    Spacing = 5,
                    HorizontalContentAlignment = HorizontalAlignment.Stretch,
                    Items = { buttons, search, new StackLayoutItem(tree, expand: true) }
                };
            }
            else
            {
                Content = buttons;
            }

            startButton.Click += (s, e) => RunTests();
        }
示例#42
0
 internal TreeGridNode(TreeGridView owner)
     : this()
 {
     this._grid = owner;
     this.IsExpanded = true;
     _nodeEditMode = NodeEditMode.Unchanged;
     objNodeHash = new Hashtable();
 }
示例#43
0
 static string SelectedRowsString(TreeGridView grid)
 {
     return(string.Join(",", grid.SelectedRows.Select(r => r.ToString()).OrderBy(r => r)));
 }
示例#44
0
        void InitializeComponent()
        {
            //exception handling

            var sf = s.UIScalingFactor;

            Application.Instance.UnhandledException += (sender, e) =>
            {
                new DWSIM.UI.Desktop.Editors.UnhandledExceptionView((Exception)e.ExceptionObject).ShowModalAsync();
            };

            Title = "DWSIMLauncher".Localize();

            switch (GlobalSettings.Settings.RunningPlatform())
            {
            case GlobalSettings.Settings.Platform.Windows:
                ClientSize = new Size((int)(690 * sf), (int)(420 * sf));
                break;

            case GlobalSettings.Settings.Platform.Linux:
                ClientSize = new Size((int)(690 * sf), (int)(370 * sf));
                break;

            case GlobalSettings.Settings.Platform.Mac:
                ClientSize = new Size((int)(690 * sf), (int)(350 * sf));
                break;
            }

            Icon = Eto.Drawing.Icon.FromResource(imgprefix + "DWSIM_ico.ico");

            var bgcolor = new Color(0.051f, 0.447f, 0.651f);

            if (s.DarkMode)
            {
                bgcolor = SystemColors.ControlBackground;
            }

            Eto.Style.Add <Button>("main", button =>
            {
                button.BackgroundColor = bgcolor;
                button.Font            = new Font(FontFamilies.Sans, 12f, FontStyle.None);
                button.TextColor       = Colors.White;
                button.ImagePosition   = ButtonImagePosition.Left;
                button.Width           = (int)(sf * 250);
                button.Height          = (int)(sf * 50);
            });

            Eto.Style.Add <Button>("donate", button =>
            {
                button.BackgroundColor = !s.DarkMode ? Colors.LightYellow : SystemColors.ControlBackground;
                button.Font            = new Font(FontFamilies.Sans, 12f, FontStyle.None);
                button.TextColor       = !s.DarkMode ? bgcolor : Colors.White;
                button.ImagePosition   = ButtonImagePosition.Left;
                button.Width           = (int)(sf * 250);
                button.Height          = (int)(sf * 50);
            });

            var btn1 = new Button()
            {
                Style = "main", Text = "OpenSavedFile".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "OpenFolder_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default)
            };
            var btn2 = new Button()
            {
                Style = "main", Text = "NewSimulation".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-workflow.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default)
            };
            var btn3 = new Button()
            {
                Style = "main", Text = "NewCompound".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Peptide_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default)
            };
            var btn4 = new Button()
            {
                Style = "main", Text = "NewDataRegression".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "AreaChart_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default)
            };
            var btn6 = new Button()
            {
                Style = "main", Text = "User Guide".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Help_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default)
            };
            var btn7 = new Button()
            {
                Style = "main", Text = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "Info_100px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default)
            };
            var btn8 = new Button()
            {
                Style = "donate", Text = "Become a Patron", Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-patreon.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default)
            };
            var btn9 = new Button()
            {
                Style = "main", Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "ReportCard_96px.png"), (int)(sf * 40), (int)(sf * 40), ImageInterpolation.Default)
            };

            btn9.Click += (sender, e) =>
            {
                new Forms.Forms.GeneralSettings().GetForm().Show();
            };

            btn6.Click += (sender, e) =>
            {
                var basepath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                Process.Start(basepath + Path.DirectorySeparatorChar + "docs" + Path.DirectorySeparatorChar + "user_guide.pdf");
            };

            btn1.Click += (sender, e) =>
            {
                var dialog = new OpenFileDialog();
                dialog.Title = "Open File".Localize();
                dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" }));
                dialog.Filters.Add(new FileFilter("Mobile XML Simulation File (Android/iOS)", new[] { ".xml" }));
                dialog.MultiSelect        = false;
                dialog.CurrentFilterIndex = 0;
                if (dialog.ShowDialog(this) == DialogResult.Ok)
                {
                    LoadSimulation(dialog.FileName);
                }
            };

            btn2.Click += (sender, e) =>
            {
                var form = new Forms.Flowsheet();
                AddUserCompounds(form.FlowsheetObject);
                OpenForms   += 1;
                form.Closed += (sender2, e2) =>
                {
                    OpenForms -= 1;
                };
                form.newsim = true;
                form.Show();
            };

            btn7.Click += (sender, e) => new AboutBox().Show();
            btn8.Click += (sender, e) => Process.Start("https://patreon.com/dwsim");

            var stack = new StackLayout {
                Orientation = Orientation.Vertical, Spacing = 5
            };

            stack.Items.Add(btn1);
            stack.Items.Add(btn2);
            stack.Items.Add(btn9);
            stack.Items.Add(btn6);
            stack.Items.Add(btn7);
            stack.Items.Add(btn8);

            var tableright = new TableLayout();

            tableright.Padding = new Padding(5, 5, 5, 5);
            tableright.Spacing = new Size(10, 10);

            MostRecentList = new TreeGridView {
                Height = (int)(sf * 330)
            };
            SampleList = new ListBox {
                BackgroundColor = bgcolor, Height = (int)(sf * 330)
            };
            FoldersList = new ListBox {
                BackgroundColor = bgcolor, Height = (int)(sf * 330)
            };
            FOSSEEList = new ListBox {
                BackgroundColor = bgcolor, Height = (int)(sf * 330)
            };

            if (Application.Instance.Platform.IsGtk &&
                GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac)
            {
                SampleList.TextColor  = bgcolor;
                FoldersList.TextColor = bgcolor;
                FOSSEEList.TextColor  = bgcolor;
            }
            else if (GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac)
            {
                SampleList.BackgroundColor  = SystemColors.ControlBackground;
                FoldersList.BackgroundColor = SystemColors.ControlBackground;
                FOSSEEList.BackgroundColor  = SystemColors.ControlBackground;
                SampleList.TextColor        = SystemColors.ControlText;
                FoldersList.TextColor       = SystemColors.ControlText;
                FOSSEEList.TextColor        = SystemColors.ControlText;
            }
            else
            {
                SampleList.TextColor  = Colors.White;
                FoldersList.TextColor = Colors.White;
                FOSSEEList.TextColor  = Colors.White;
            }

            MostRecentList.AllowMultipleSelection = false;
            MostRecentList.ShowHeader             = true;
            MostRecentList.Columns.Clear();
            MostRecentList.Columns.Add(new GridColumn {
                DataCell = new ImageViewCell(0)
                {
                    ImageInterpolation = ImageInterpolation.High
                }
            });
            MostRecentList.Columns.Add(new GridColumn {
                DataCell = new TextBoxCell(1), HeaderText = "Name", Sortable = true
            });
            MostRecentList.Columns.Add(new GridColumn {
                DataCell = new TextBoxCell(2), HeaderText = "Date", Sortable = true
            });
            MostRecentList.Columns.Add(new GridColumn {
                DataCell = new TextBoxCell(3), HeaderText = "DWSIM Version", Sortable = true
            });
            MostRecentList.Columns.Add(new GridColumn {
                DataCell = new TextBoxCell(4), HeaderText = "Operating System", Sortable = true
            });

            var invertedlist = new List <string>(GlobalSettings.Settings.MostRecentFiles);

            invertedlist.Reverse();

            var tgc = new TreeGridItemCollection();

            foreach (var item in invertedlist)
            {
                if (File.Exists(item))
                {
                    var li   = new TreeGridItem();
                    var data = new Dictionary <string, string>();
                    if (Path.GetExtension(item).ToLower() == ".dwxmz")
                    {
                        data = SharedClasses.Utility.GetSimulationFileDetails(FlowsheetBase.FlowsheetBase.LoadZippedXMLDoc(item));
                    }
                    else
                    {
                        data = SharedClasses.Utility.GetSimulationFileDetails(XDocument.Load(item));
                    }
                    li.Tag = data;
                    data.Add("Path", item);
                    DateTime dt;
                    if (data.ContainsKey("SavedOn"))
                    {
                        dt = DateTime.Parse(data["SavedOn"]);
                    }
                    else
                    {
                        dt = File.GetLastWriteTime(item);
                    }
                    string dwsimver, osver;
                    if (data.ContainsKey("DWSIMVersion"))
                    {
                        dwsimver = data["DWSIMVersion"];
                    }
                    else
                    {
                        dwsimver = "N/A";
                    }
                    if (data.ContainsKey("OSInfo"))
                    {
                        osver = data["OSInfo"];
                    }
                    else
                    {
                        osver = "N/A";
                    }
                    li.Values = new object[] { new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-workflow.png")).WithSize(16, 16),
                                               System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Path.GetFileNameWithoutExtension(item)),
                                               dt, dwsimver, osver };
                    tgc.Add(li);
                }
            }

            tgc = new TreeGridItemCollection(tgc.OrderByDescending(x => ((DateTime)((TreeGridItem)x).Values[2]).Ticks));

            MostRecentList.DataStore = tgc;

            var samplist = Directory.EnumerateFiles(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "samples"), "*.dwxm*");

            foreach (var item in samplist)
            {
                if (File.Exists(item))
                {
                    SampleList.Items.Add(new ListItem {
                        Text = Path.GetFileNameWithoutExtension(item), Key = item
                    });
                }
            }

            foreach (String f in invertedlist)
            {
                if (Path.GetExtension(f).ToLower() != ".dwbcs")
                {
                    if (FoldersList.Items.Where((x) => x.Text == Path.GetDirectoryName(f)).Count() == 0)
                    {
                        if (Directory.Exists(Path.GetDirectoryName(f)))
                        {
                            FoldersList.Items.Add(new ListItem {
                                Text = Path.GetDirectoryName(f), Key = Path.GetDirectoryName(f)
                            });
                        }
                    }
                }
            }

            FOSSEEList.Items.Add(new ListItem {
                Text = "Downloading flowsheet list, please wait...", Key = ""
            });

            Dictionary <string, SharedClasses.FOSSEEFlowsheet> fslist = new Dictionary <string, SharedClasses.FOSSEEFlowsheet>();

            Task.Factory.StartNew(() =>
            {
                return(SharedClasses.FOSSEEFlowsheets.GetFOSSEEFlowsheets());
            }).ContinueWith((t) =>
            {
                Application.Instance.Invoke(() =>
                {
                    FOSSEEList.Items.Clear();
                    if (t.Exception != null)
                    {
                        FOSSEEList.Items.Add(new ListItem {
                            Text = "Error loading flowsheet list. Check your internet connection.", Key = ""
                        });
                    }
                    else
                    {
                        foreach (var item in t.Result)
                        {
                            fslist.Add(item.DownloadLink, item);
                            FOSSEEList.Items.Add(new ListItem {
                                Text = item.DisplayName, Key = item.DownloadLink
                            });
                        }
                    }
                });
            });

            FoldersList.SelectedIndexChanged += (sender, e) =>
            {
                if (FoldersList.SelectedIndex >= 0)
                {
                    var dialog = new OpenFileDialog();
                    dialog.Title     = "Open File".Localize();
                    dialog.Directory = new Uri(FoldersList.SelectedKey);
                    dialog.Filters.Add(new FileFilter("XML Simulation File".Localize(), new[] { ".dwxml", ".dwxmz" }));
                    dialog.MultiSelect        = false;
                    dialog.CurrentFilterIndex = 0;
                    if (dialog.ShowDialog(this) == DialogResult.Ok)
                    {
                        LoadSimulation(dialog.FileName);
                    }
                }
            };

            MostRecentList.SelectedItemChanged += (sender, e) =>
            {
                if (MostRecentList.SelectedItem != null)
                {
                    var si   = (TreeGridItem)MostRecentList.SelectedItem;
                    var data = (Dictionary <string, string>)si.Tag;
                    LoadSimulation(data["Path"]);
                    //MostRecentList.SelectedIndex = -1;
                }
                ;
            };

            SampleList.SelectedIndexChanged += (sender, e) =>
            {
                if (SampleList.SelectedIndex >= 0)
                {
                    LoadSimulation(SampleList.SelectedKey);
                    //MostRecentList.SelectedIndex = -1;
                }
                ;
            };

            FOSSEEList.SelectedIndexChanged += (sender, e) =>
            {
                if (FOSSEEList.SelectedIndex >= 0 && FOSSEEList.SelectedKey != "")
                {
                    var item = fslist[FOSSEEList.SelectedKey];
                    var sb   = new StringBuilder();
                    sb.AppendLine("Title: " + item.Title);
                    sb.AppendLine("Author: " + item.ProposerName);
                    sb.AppendLine("Institution: " + item.Institution);
                    sb.AppendLine();
                    sb.AppendLine("Click 'Yes' to download and open this flowsheet.");

                    if (MessageBox.Show(sb.ToString(), "Open FOSSEE Flowsheet", MessageBoxButtons.YesNo, MessageBoxType.Information, MessageBoxDefaultButton.Yes) == DialogResult.Yes)
                    {
                        var loadingdialog = new LoadingData();
                        loadingdialog.loadingtext.Text = "Please wait, downloading file...\n(" + FOSSEEList.SelectedKey + ")";
                        loadingdialog.Show();
                        var address = FOSSEEList.SelectedKey;
                        Task.Factory.StartNew(() =>
                        {
                            return(SharedClasses.FOSSEEFlowsheets.DownloadFlowsheet(address, (p) =>
                            {
                                Application.Instance.Invoke(() => loadingdialog.loadingtext.Text = "Please wait, downloading file... (" + p + "%)\n(" + address + ")");
                            }));
                        }).ContinueWith((t) =>
                        {
                            Application.Instance.Invoke(() => loadingdialog.Close());
                            if (t.Exception != null)
                            {
                                MessageBox.Show(t.Exception.Message, "Error downloading file", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK);
                            }
                            else
                            {
                                Application.Instance.Invoke(() => LoadSimulation(SharedClasses.FOSSEEFlowsheets.LoadFlowsheet(t.Result)));
                            }
                        });
                        FOSSEEList.SelectedIndex = -1;
                    }
                }
                ;
            };

            var fosseecontainer = c.GetDefaultContainer();
            var l1  = c.CreateAndAddLabelRow3(fosseecontainer, "About the Project");
            var l2  = c.CreateAndAddDescriptionRow(fosseecontainer, "FOSSEE, IIT Bombay, invites chemical engineering students, faculty and practitioners to the flowsheeting project using DWSIM. We want you to convert existing flowsheets into DWSIM and get honoraria and certificates.");
            var bu1 = c.CreateAndAddButtonRow(fosseecontainer, "Submit a Flowsheet", null, (b1, e1) => Process.Start("https://dwsim.fossee.in/flowsheeting-project"));
            var bu2 = c.CreateAndAddButtonRow(fosseecontainer, "About FOSSEE", null, (b2, e2) => Process.Start("https://fossee.in/"));
            var l3  = c.CreateAndAddLabelRow3(fosseecontainer, "Completed Flowsheets");

            if (GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac)
            {
                fosseecontainer.BackgroundColor = SystemColors.ControlBackground;
            }
            else
            {
                fosseecontainer.BackgroundColor = bgcolor;
                l1.TextColor        = Colors.White;
                l2.TextColor        = Colors.White;
                l3.TextColor        = Colors.White;
                bu1.TextColor       = Colors.White;
                bu2.TextColor       = Colors.White;
                bu1.BackgroundColor = bgcolor;
                bu2.BackgroundColor = bgcolor;
            }
            fosseecontainer.Add(FOSSEEList);
            fosseecontainer.EndVertical();

            var tabview = new TabControl();
            var tab1    = new TabPage(MostRecentList)
            {
                Text = "Recent Files"
            };;
            var tab2 = new TabPage(SampleList)
            {
                Text = "Samples"
            };;
            var tab2a = new TabPage(fosseecontainer)
            {
                Text = "FOSSEE Flowsheets"
            };;
            var tab3 = new TabPage(FoldersList)
            {
                Text = "Recent Folders"
            };;

            tabview.Pages.Add(tab1);
            tabview.Pages.Add(tab2);
            tabview.Pages.Add(tab2a);
            tabview.Pages.Add(tab3);

            tableright.Rows.Add(new TableRow(tabview));

            var tl = new DynamicLayout();

            tl.Add(new TableRow(stack, tableright));

            TableContainer = new TableLayout
            {
                Padding = 10,
                Spacing = new Size(5, 5),
                Rows    = { new TableRow(tl) }
            };

            if (GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac)
            {
                TableContainer.BackgroundColor = SystemColors.ControlBackground;
            }
            else
            {
                TableContainer.BackgroundColor = bgcolor;
            }


            Content = TableContainer;

            var quitCommand = new Command {
                MenuText = "Quit".Localize(), Shortcut = Application.Instance.CommonModifier | Keys.Q
            };

            quitCommand.Executed += (sender, e) =>
            {
                try
                {
                    DWSIM.GlobalSettings.Settings.SaveSettings("dwsim_newui.ini");
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, "Error Saving Settings to File", MessageBoxButtons.OK, MessageBoxType.Error, MessageBoxDefaultButton.OK);
                }
                if (MessageBox.Show(this, "ConfirmAppExit".Localize(), "AppExit".Localize(), MessageBoxButtons.YesNo, MessageBoxType.Information, MessageBoxDefaultButton.No) == DialogResult.Yes)
                {
                    Application.Instance.Quit();
                }
            };

            var aboutCommand = new Command {
                MenuText = "About".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "information.png"))
            };

            aboutCommand.Executed += (sender, e) => new AboutBox().Show();

            var aitem1 = new ButtonMenuItem {
                Text = "Preferences".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "icons8-sorting_options.png"))
            };

            aitem1.Click += (sender, e) =>
            {
                new Forms.Forms.GeneralSettings().GetForm().Show();
            };

            var hitem1 = new ButtonMenuItem {
                Text = "User Guide".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png"))
            };

            hitem1.Click += (sender, e) =>
            {
                var basepath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
                Process.Start(basepath + Path.DirectorySeparatorChar + "docs" + Path.DirectorySeparatorChar + "user_guide.pdf");
            };

            var hitem2 = new ButtonMenuItem {
                Text = "Support".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png"))
            };

            hitem2.Click += (sender, e) =>
            {
                Process.Start("http://dwsim.inforside.com.br/wiki/index.php?title=Support");
            };

            var hitem3 = new ButtonMenuItem {
                Text = "Report a Bug".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png"))
            };

            hitem3.Click += (sender, e) =>
            {
                Process.Start("https://sourceforge.net/p/dwsim/tickets/");
            };

            var hitem4 = new ButtonMenuItem {
                Text = "Go to DWSIM's Website".Localize(), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "help_browser.png"))
            };

            hitem4.Click += (sender, e) =>
            {
                Process.Start("http://dwsim.inforside.com.br");
            };

            // create menu
            Menu = new MenuBar
            {
                ApplicationItems = { aitem1 },
                QuitItem         = quitCommand,
                HelpItems        = { hitem1, hitem4, hitem2, hitem3 },
                AboutItem        = aboutCommand
            };

            Shown += MainForm_Shown;

            Closing += MainForm_Closing;

            //Plugins

            LoadPlugins();
        }
示例#45
0
        void LogEvents(TreeGridView control)
        {
            control.Activated += (sender, e) =>
            {
                Log.Write(control, "Activated, Item: {0}", GetDescription(e.Item));
            };
            control.SelectionChanged += delegate
            {
                Log.Write(control, "SelectionChanged, Rows: {0}", string.Join(", ", control.SelectedRows.Select(r => r.ToString())));
                Log.Write(control, "\t Items: {0}", string.Join(", ", control.SelectedItems.OfType <TreeGridItem>().Select(r => GetDescription(r))));
            };
            control.SelectedItemChanged += delegate
            {
                Log.Write(control, "SelectedItemChanged, Item: {0}", control.SelectedItem != null ? GetDescription(control.SelectedItem) : "<none selected>");
            };

            control.Expanding += (sender, e) =>
            {
                Log.Write(control, "Expanding, Item: {0}", GetDescription(e.Item));
                e.Cancel = !(allowExpanding.Checked ?? true);
            };
            control.Expanded += (sender, e) =>
            {
                Log.Write(control, "Expanded, Item: {0}", GetDescription(e.Item));
            };
            control.Collapsing += (sender, e) =>
            {
                Log.Write(control, "Collapsing, Item: {0}", GetDescription(e.Item));
                e.Cancel = !(allowCollapsing.Checked ?? true);
            };
            control.Collapsed += (sender, e) =>
            {
                Log.Write(control, "Collapsed, Item: {0}", GetDescription(e.Item));
            };
            control.ColumnHeaderClick += delegate(object sender, GridColumnEventArgs e)
            {
                Log.Write(control, "ColumnHeaderClick: {0}", e.Column);
            };

            control.CellClick += (sender, e) =>
            {
                Log.Write(control, "CellClick, Row: {0}, Column: {1}, Item: {2}, ColInfo: {3}", e.Row, e.Column, e.Item, e.GridColumn);
            };

            control.CellDoubleClick += (sender, e) =>
            {
                Log.Write(control, "CellDoubleClick, Row: {0}, Column: {1}, Item: {2}, ColInfo: {3}", e.Row, e.Column, e.Item, e.GridColumn);
            };

            control.MouseDown += (sender, e) =>
            {
                var cell = control.GetCellAt(e.Location);
                Log.Write(control, $"MouseDown, Cell Column: {cell.Column?.HeaderText}, Item: {GetDescription(cell.Item as ITreeGridItem)}");
            };

            control.MouseUp += (sender, e) =>
            {
                var cell = control.GetCellAt(e.Location);
                Log.Write(control, $"MouseUp, Cell Column: {cell.Column?.HeaderText}, Item: {GetDescription(cell.Item as ITreeGridItem)}");
            };

            control.MouseDoubleClick += (sender, e) =>
            {
                var cell = control.GetCellAt(e.Location);
                Log.Write(control, $"MouseDoubleClick, Cell Column: {cell.Column?.HeaderText}, Item: {GetDescription(cell.Item as ITreeGridItem)}");
            };
        }
示例#46
0
        public DragDropSection()
        {
            // drag data object

            showDragOverEvents = new CheckBox {
                Text = "Show DragOver Events"
            };
            var includeImageCheck = new CheckBox {
                Text = "Include Image"
            };

            descriptionTextBox = new TextBox {
                PlaceholderText = "Format", ToolTip = "Add {0} to insert inner text into the description, e.g. 'Move to {0}'"
            };
            innerTextBox = new TextBox {
                PlaceholderText = "Inner", ToolTip = "Highlighted text to insert into description"
            };
            var textBox = new TextBox {
                Text = "Some text"
            };

            allowedEffectDropDown = new EnumDropDown <DragEffects> {
                SelectedValue = DragEffects.All
            };
            dragEnterEffect = new EnumDropDown <DragEffects?> {
                SelectedValue = DragEffects.Copy
            };
            dragOverEffect = new EnumDropDown <DragEffects?> {
                SelectedValue = null
            };
            writeDataCheckBox = new CheckBox {
                Text = "Write data to log"
            };
            useDragImage = new CheckBox {
                Text = "Use custom drag image"
            };
            imageOffset = new PointEntry {
                Value = new Point(80, 80)
            };
            imageOffset.Bind(c => c.Enabled, useDragImage, c => c.Checked);

            var htmlTextArea = new TextArea {
                Height = 24
            };
            var selectFilesButton = new Button {
                Text = "Select Files"
            };

            Uri[] fileUris = null;
            selectFilesButton.Click += (sender, e) =>
            {
                var ofd = new OpenFileDialog();
                ofd.MultiSelect = true;
                ofd.ShowDialog(this);
                fileUris = ofd.Filenames.Select(r => new Uri(r)).ToArray();
                if (fileUris.Length == 0)
                {
                    fileUris = null;
                }
            };

            var urlTextBox = new TextBox();

            DataObject CreateDataObject()
            {
                var data = new DataObject();

                if (!string.IsNullOrEmpty(textBox.Text))
                {
                    data.Text = textBox.Text;
                }
                var uris = new List <Uri>();

                if (fileUris != null)
                {
                    uris.AddRange(fileUris);
                }
                if (Uri.TryCreate(urlTextBox.Text, UriKind.Absolute, out var uri))
                {
                    uris.Add(uri);
                }
                if (uris.Count > 0)
                {
                    data.Uris = uris.ToArray();
                }
                if (!string.IsNullOrEmpty(htmlTextArea.Text))
                {
                    data.Html = htmlTextArea.Text;
                }
                if (includeImageCheck.Checked == true)
                {
                    data.Image = TestIcons.Logo;
                }

                return(data);
            }

            // sources

            var buttonSource = new Button {
                Text = "Source"
            };

            buttonSource.MouseDown += (sender, e) =>
            {
                if (e.Buttons != MouseButtons.None)
                {
                    DoDragDrop(buttonSource, CreateDataObject());
                    e.Handled = true;
                }
            };

            var panelSource = new Panel {
                BackgroundColor = Colors.Red, Size = new Size(50, 50)
            };

            panelSource.MouseMove += (sender, e) =>
            {
                if (e.Buttons != MouseButtons.None)
                {
                    DoDragDrop(panelSource, CreateDataObject());
                    e.Handled = true;
                }
            };

            var treeSource = new TreeGridView {
                Size = new Size(200, 200)
            };

            treeSource.SelectedItemsChanged += (sender, e) => Log.Write(treeSource, $"TreeGridView.SelectedItemsChanged (source) Rows: {string.Join(", ", treeSource.SelectedRows.Select(r => r.ToString()))}");
            treeSource.DataStore             = CreateTreeData();
            SetupTreeColumns(treeSource);
            treeSource.MouseMove += (sender, e) =>
            {
                if (e.Buttons == MouseButtons.Primary && !treeSource.IsEditing)
                {
                    var cell = treeSource.GetCellAt(e.Location);
                    if (cell.Item == null || cell.ColumnIndex == -1)
                    {
                        return;
                    }
                    var data     = CreateDataObject();
                    var selected = treeSource.SelectedItems.OfType <TreeGridItem>().Select(r => (string)r.Values[0]);
                    data.SetString(string.Join(";", selected), "my.tree.data");

                    DoDragDrop(treeSource, data);
                    e.Handled = true;
                }
            };

            var gridSource = new GridView {
            };

            gridSource.SelectedRowsChanged += (sender, e) => Log.Write(gridSource, $"GridView.SelectedItemsChanged (source): {string.Join(", ", gridSource.SelectedRows.Select(r => r.ToString()))}");
            SetupGridColumns(gridSource);
            gridSource.DataStore  = CreateGridData();
            gridSource.MouseMove += (sender, e) =>
            {
                if (e.Buttons == MouseButtons.Primary && !gridSource.IsEditing)
                {
                    var cell = gridSource.GetCellAt(e.Location);
                    if (cell.RowIndex == -1 || cell.ColumnIndex == -1)
                    {
                        return;
                    }
                    var data     = CreateDataObject();
                    var selected = gridSource.SelectedItems.OfType <GridItem>().Select(r => (string)r.Values[0]);
                    data.SetString(string.Join(";", selected), "my.grid.data");

                    DoDragDrop(gridSource, data);
                    e.Handled = true;
                }
            };


            // destinations

            var buttonDestination = new Button {
                Text = "Drop here!", AllowDrop = true
            };

            buttonDestination.DragEnter += (sender, e) => buttonDestination.Text = "Now, drop it!";
            buttonDestination.DragLeave += (sender, e) => buttonDestination.Text = "Drop here!";
            LogEvents(buttonDestination);

            var drawableDest = new Drawable {
                BackgroundColor = Colors.Blue, AllowDrop = true, Size = new Size(50, 50)
            };

            LogEvents(drawableDest);
            drawableDest.DragEnter += (sender, e) =>
            {
                if (e.Effects != DragEffects.None)
                {
                    drawableDest.BackgroundColor = Colors.Green;
                }
            };
            drawableDest.DragLeave += (sender, e) =>
            {
                if (e.Effects != DragEffects.None)
                {
                    drawableDest.BackgroundColor = Colors.Blue;
                }
            };
            drawableDest.DragDrop += (sender, e) =>
            {
                if (e.Effects != DragEffects.None)
                {
                    drawableDest.BackgroundColor = Colors.Blue;
                }
            };

            var dragMode = new RadioButtonList
            {
                Orientation = Orientation.Vertical,
                Items       =
                {
                    new ListItem {
                        Text = "No Restriction", Key = ""
                    },
                    new ListItem {
                        Text = "RestrictToOver", Key = "over"
                    },
                    new ListItem {
                        Text = "RestrictToInsert", Key = "insert"
                    },
                    new ListItem {
                        Text = "RestrictToNode", Key = "node"
                    },
                    new ListItem {
                        Text = "No Node", Key = "none"
                    }
                },
                SelectedIndex = 0
            };
            var treeDest = new TreeGridView {
                AllowDrop = true, Size = new Size(200, 200)
            };
            var treeDestData = CreateTreeData();

            treeDest.DataStore = treeDestData;
            treeDest.DragOver += (sender, e) =>
            {
                var info = treeDest.GetDragInfo(e);
                if (info == null)
                {
                    return;                     // not supported
                }
                switch (dragMode.SelectedKey)
                {
                case "over":
                    info.RestrictToOver();
                    break;

                case "insert":
                    info.RestrictToInsert();
                    break;

                case "node":
                    info.RestrictToNode(treeDestData[2]);
                    break;

                case "none":
                    info.Item = info.Parent = null;
                    break;
                }
            };
            SetupTreeColumns(treeDest);
            LogEvents(treeDest);

            var gridDest = new GridView {
                AllowDrop = true
            };
            var gridDestData = CreateGridData();

            gridDest.DataStore = gridDestData;
            gridDest.DragOver += (sender, e) =>
            {
                var info = gridDest.GetDragInfo(e);
                if (info == null)
                {
                    return;                     // not supported
                }
                switch (dragMode.SelectedKey)
                {
                case "over":
                    info.RestrictToOver();
                    break;

                case "insert":
                    info.RestrictToInsert();
                    break;

                case "node":
                    info.Index    = 2;
                    info.Position = GridDragPosition.Over;
                    break;

                case "none":
                    info.Index = -1;
                    break;
                }
            };
            SetupGridColumns(gridDest);
            LogEvents(gridDest);



            // layout

            var layout = new DynamicLayout {
                Padding = 10, DefaultSpacing = new Size(4, 4)
            };

            layout.BeginHorizontal();

            layout.BeginScrollable(BorderType.None);
            layout.BeginCentered();

            layout.AddSeparateRow(showDragOverEvents);
            layout.AddSeparateRow("AllowedEffect", allowedEffectDropDown, null);
            layout.BeginVertical();
            layout.AddRow("DropDescription", descriptionTextBox);
            layout.AddRow(new Panel(), innerTextBox);
            layout.EndVertical();
            layout.AddSeparateRow("DragEnter Effect", dragEnterEffect, null);
            layout.AddSeparateRow("DragOver Effect", dragOverEffect, null);
            layout.AddSeparateRow(useDragImage);
            layout.AddSeparateRow("Image offset:", imageOffset);
            layout.AddSeparateRow(writeDataCheckBox);

            layout.BeginGroup("DataObject", 10);
            layout.AddRow("Text", textBox);
            layout.AddRow("Html", htmlTextArea);
            layout.AddRow("Url", urlTextBox);
            layout.BeginHorizontal();
            layout.AddSpace();
            layout.BeginVertical();
            layout.AddCentered(includeImageCheck);
            layout.AddCentered(selectFilesButton);
            layout.EndVertical();
            layout.EndGroup();
            layout.Add(dragMode);
            layout.AddSpace();

            layout.EndCentered();
            layout.EndScrollable();

            layout.BeginVertical(xscale: true);
            layout.AddRange("Drag sources:", buttonSource, panelSource);
            layout.Add(treeSource, yscale: true);
            layout.Add(gridSource, yscale: true);
            layout.EndVertical();

            layout.BeginVertical(xscale: true);
            layout.AddRange("Drag destinations:", buttonDestination, drawableDest);
            layout.Add(treeDest, yscale: true);
            layout.Add(gridDest, yscale: true);
            layout.EndVertical();

            layout.EndHorizontal();

            Content = layout;
        }
示例#47
0
		private void RegisterTreeviewEvents(TreeGridView treeview)
		{
			treeview.NodeExpanded += treeview_NodeExpanded;
			treeview.CellBeginEdit += treeview_CellBeginEdit;
			treeview.CellEndEdit += treeview_CellEndEdit;
			treeview.OnContextMenuItemClicked += treeview_OnContextMenuItemClicked;
			treeview.OnContextMenuOpening += treeview_OnContextMenuOpening;
			treeview.Click += treeview_Click;
			treeview.Columns[0].Width = (treeview.Width - 2)/3;
			treeview.Columns[1].Width = (treeview.Width - 2)/3;
			treeview.Columns[2].Width = (treeview.Width - 2)/3;
		}
示例#48
-7
        /// <summary>获取优先级的数据列
        ///
        /// </summary>
        /// <param name="tgv"></param>
        /// <returns></returns>
        public static Dictionary <int, List <TreeGridNode> > GetFirstLevelNodes(TreeGridView tgv)
        {
            Dictionary <int, List <TreeGridNode> > dic = new Dictionary <int, List <TreeGridNode> >();
            int indexKey = 0;

            foreach (DataGridViewRow row in tgv.Rows)
            {
                TreeGridNode node = tgv.GetNodeForRow(row);
                if (node != null)
                {
                    if (node.Cells[0].Value.ToString().Trim().Contains("优先"))
                    {
                        indexKey = indexKey + 1;

                        var nodes = new List <TreeGridNode> {
                            node
                        };
                        nodes.AddRange(node.Nodes);
                        dic.Add(indexKey, nodes);
                    }
                }
            }
            return(dic);
        }