Dispose() public method

public Dispose ( ) : void
return void
Ejemplo n.º 1
0
 void UpdateStyle()
 {
     if (layout != null)
     {
         layout.Dispose();
     }
     layout          = new TextLayout(this);
     layout.Trimming = TextTrimming.Word;
 }
Ejemplo n.º 2
0
		internal protected override void OptionsChanged ()
		{
			var layout = new TextLayout (Editor);
			layout.Font = Editor.Options.Font;
			layout.Text = string.Format ("0{0:X}", Data.Length) + "_";
//			int height;
			width = layout.GetSize ().Width;
			layout.Dispose ();
		}
Ejemplo n.º 3
0
		internal protected override void OptionsChanged ()
		{
			var layout = new TextLayout (Editor);
			layout.Font = Editor.Options.Font;
			layout.Text = ".";
//			int height;
			charWidth = layout.GetSize ().Width;
			layout.Dispose ();
		}
Ejemplo n.º 4
0
		internal protected override void OptionsChanged ()
		{
			var layout = new TextLayout (Editor);
			layout.Font = Editor.Options.Font;
			layout.Text = "!";
//			int tmp;
			this.marginWidth = layout.GetSize ().Height;
			marginWidth *= 12;
			marginWidth /= 10;
			layout.Dispose ();
		}
Ejemplo n.º 5
0
		internal protected override void OptionsChanged ()
		{
			var layout = new TextLayout (Editor);
			layout.Font = Editor.Options.Font;
			string groupString = new string ('0', Editor.Options.GroupBytes * 2);
			layout.Text = groupString + " ";
			double lineHeight;
			var sz = layout.GetSize ();
			groupWidth = sz.Width;
			lineHeight = sz.Height;
			 
			Data.LineHeight = lineHeight;
			
			layout.Text = "00";
			byteWidth = layout.GetSize ().Width;

			layout.Dispose ();
			
//			tabArray = new Pango.TabArray (1, true);
//			tabArray.SetTab (0, Pango.TabAlign.Left, groupWidth);
		}
Ejemplo n.º 6
0
		internal void Draw (DrawingPathBackendHandler targetHandler, object ctx, VectorImageData cm)
		{
			int di = 0;
			int ci = 0;
			int ii = 0;
			int ri = 0;
			int oi = 0;
			int imi = 0;
			int ti = 0;

			ContextBackendHandler handler = targetHandler as ContextBackendHandler;
			DrawingPathBackendHandler pathHandler = targetHandler;

			for (int n=0; n<cm.Commands.Length; n++)
			{
				switch (cm.Commands [n]) {
				case DrawingCommand.AppendPath:
					var p = cm.Objects [oi++];
					if (p is VectorImageData)
						Draw (targetHandler, ctx, (VectorImageData)p);
					else
						pathHandler.AppendPath (ctx, p);
					break;
				case DrawingCommand.Arc:
					pathHandler.Arc (ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.ArcNegative:
					pathHandler.ArcNegative (ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.Clip:
					handler.Clip (ctx);
					break;
				case DrawingCommand.ClipPreserve:
					handler.ClipPreserve (ctx);
					break;
				case DrawingCommand.ClosePath:
					pathHandler.ClosePath (ctx);
					break;
				case DrawingCommand.CurveTo:
					pathHandler.CurveTo (ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.DrawImage2:
					handler.DrawImage (ctx, cm.Images [imi++], cm.Rectangles [ri++], cm.Rectangles [ri++]);
					break;
				case DrawingCommand.DrawImage:
					handler.DrawImage (ctx, cm.Images [imi++], cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.DrawTextLayout:
					var lad = (TextLayoutData)cm.TextLayouts [ti++];
					var la = new TextLayout (toolkit);
					lad.InitLayout (la);
					handler.DrawTextLayout (ctx, la, cm.Doubles [di++], cm.Doubles [di++]);
					la.Dispose();
					break;
				case DrawingCommand.Fill:
					handler.Fill (ctx);
					break;
				case DrawingCommand.FillPreserve:
					handler.FillPreserve (ctx);
					break;
				case DrawingCommand.LineTo:
					pathHandler.LineTo (ctx, cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.MoveTo:
					pathHandler.MoveTo (ctx, cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.NewPath:
					handler.NewPath (ctx);
					break;
				case DrawingCommand.Rectangle:
					pathHandler.Rectangle (ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.RelCurveTo:
					pathHandler.RelCurveTo (ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.RelLineTo:
					pathHandler.RelLineTo (ctx, cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.RelMoveTo:
					pathHandler.RelMoveTo (ctx, cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.Restore:
					handler.Restore (ctx);
					break;
				case DrawingCommand.Rotate:
					handler.Rotate (ctx, cm.Doubles [di++]);
					break;
				case DrawingCommand.Save:
					handler.Save (ctx);
					break;
				case DrawingCommand.Scale:
					handler.Scale (ctx, cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.SetColor:
					handler.SetColor (ctx, cm.Colors [ci++]);
					break;
				case DrawingCommand.SetGlobalAlpha:
					handler.SetGlobalAlpha (ctx, cm.Doubles [di++]);
					break;
				case DrawingCommand.SetLineDash:
					var off = cm.Doubles [di++];
					var ds = new double [cm.Ints [ii++]];
					for (int i = 0; i < ds.Length; i++)
						ds [i] = cm.Doubles [di++];
					handler.SetLineDash (ctx, off, ds);
					break;
				case DrawingCommand.SetLineWidth:
					handler.SetLineWidth (ctx, cm.Doubles [di++]);
					break;
				case DrawingCommand.SetPattern:
					handler.SetPattern (ctx, cm.Objects [oi++]);
					break;
				case DrawingCommand.Stroke:
					handler.Stroke (ctx);
					break;
				case DrawingCommand.StrokePreserve:
					handler.StrokePreserve (ctx);
					break;
				case DrawingCommand.Translate:
					handler.Translate (ctx, cm.Doubles [di++], cm.Doubles [di++]);
					break;
				case DrawingCommand.SetStyles:
					handler.SetStyles (ctx, (StyleSet)cm.Objects [oi++]);
					break;
				}
			}
		}
Ejemplo n.º 7
0
        /// <summary>
        /// Refresh the specified scan.
        /// </summary>
        /// <param name="scan">Scan.</param>
        /// <param name="changedFiberType">Set to true, if the fibertype of the given scan has changed</param>
        void Refresh(BaseScan scan, bool changedFiberType = false)
        {
            Image thumbnail = store.GetNavigatorAt(scan.position).GetValue(thumbnailCol);
            TreePosition currentNode = scan.position;

            if (changedFiberType) {
                TreePosition parentNodePosition;
                if (fiberTypeNodes.ContainsKey(scan.FiberType)) {
                    parentNodePosition = fiberTypeNodes[scan.FiberType];
                } else {

                    TextLayout text = new TextLayout();
                    text.Text = scan.FiberType;
                    ImageBuilder ib = new ImageBuilder(text.GetSize().Width, text.GetSize().Height);
                    ib.Context.DrawTextLayout(text, Point.Zero);

                    parentNodePosition = store.AddNode(null).SetValue(thumbnailCol, ib.ToBitmap()).CurrentPosition;
                    fiberTypeNodes[scan.FiberType] = parentNodePosition;

                    text.Dispose();
                    ib.Dispose();

                }
                store.GetNavigatorAt(currentNode).Remove();
                scan.position = currentNode = store.AddNode(parentNodePosition).CurrentPosition;

                ExpandToRow(scan.position);
                ScrollToRow(scan.position);
                SelectRow(scan.position);

                scan.parentPosition = parentNodePosition;
            }

            store.GetNavigatorAt(currentNode)
                .SetValue(nameCol, scan.ToString())
                .SetValue(thumbnailCol, thumbnail)
                .SetValue(finishCol, scan.IsFinish() ? tick : cross)
                .SetValue(saveStateCol, scan.HasUnsaved() ? "*" : "");

            if (DataSource.GetChildrenCount(scan.parentPosition) <= 0) {
                store.GetNavigatorAt(scan.parentPosition).Remove();
            }

            // update filtered store
            if (!string.IsNullOrEmpty(filterText)) {
                storeFilter.GetNavigatorAt(scan.positionFiltered)
                    .SetValue(nameColFilter, scan.ToString())
                    .SetValue(thumbnailColFilter, thumbnail)
                    .SetValue(finishColFiltered, scan.IsFinish() ? tick : cross)
                    .SetValue(saveStateColFilter, scan.HasUnsaved() ? "*" : "");

                if (changedFiberType) {
                    Filter(filterText);
                }
            }
        }
Ejemplo n.º 8
0
        protected override void OnKeyPressed(KeyEventArgs args)
        {
            base.OnKeyPressed(args);
            switch (args.Key) {
            case Key.Delete:
                TreeStore currentStore = DataSource as TreeStore;

                if (currentStore != null) {
                    TreeNavigator selected = currentStore.GetNavigatorAt(SelectedRow);

                    if (selected != null) {
                        Dialog d = new Dialog();
                        d.Title = "Remove this scan";

                        VBox nameList = new VBox();
                        ScrollView nameListScroll = new ScrollView(nameList);

                        foreach (TreePosition selectPos in SelectedRows) {
                            nameList.PackStart(
                                new Label(currentStore.GetNavigatorAt(selectPos)
                                .GetValue(isFiltered ? nameColFilter : nameCol))
                            );
                        }
                        TextLayout text = new TextLayout();
                        text.Text = "M";
                        double textHeight = text.GetSize().Height;
                        text.Dispose();

                        nameListScroll.MinHeight = Math.Min(10, SelectedRows.Length) * textHeight;
                        d.Content = nameListScroll;
                        d.Buttons.Add(new DialogButton(Command.Delete));
                        d.Buttons.Add(new DialogButton(Command.Cancel));

                        Command r = d.Run();
                        if (r != null && r.Id == Command.Delete.Id) {
                            foreach (TreePosition selectPos in SelectedRows) {
                                string name = currentStore.GetNavigatorAt(selectPos)
                                    .GetValue(isFiltered ? nameColFilter : nameCol);
                                if (!string.IsNullOrEmpty(name)) {
                                    currentStore.GetNavigatorAt(selectPos).Remove();

                                    scanCollection.RemoveAll(scan => scan.Name == name);
                                }
                            }
                        }
                        d.Dispose();
                    }
                }
                break;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Reloads file tree information.
        /// </summary>
        /// <param name="scans">Collection of loaded scans</param>
        /// <param name="currentScan">Current focused scan</param>
        /// <param name="save">Update scan collection</param>
        public void Reload(ScanCollection scans, BaseScan currentScan = null, bool save = true)
        {
            if (scans.Count > 0) {
                scans.Sort(scans[0]);
            }

            if (save) {
                scanCollection = scans;
            }

            DataSource = store;
            store.Clear();

            TreePosition pos = null;
            fiberTypeNodes = new Dictionary<string, TreePosition>();
            foreach (BaseScan scan in scans) {
                TreePosition currentNode;
                if (fiberTypeNodes.ContainsKey(scan.FiberType)) {
                    currentNode = fiberTypeNodes[scan.FiberType];
                } else {
                    TextLayout text = new TextLayout();
                    text.Text = scan.FiberType;
                    ImageBuilder ib = new ImageBuilder(text.GetSize().Width, text.GetSize().Height);
                    ib.Context.DrawTextLayout(text, Point.Zero);

                    currentNode = store.AddNode(null).SetValue(thumbnailCol, ib.ToVectorImage()).CurrentPosition;
                    fiberTypeNodes[scan.FiberType] = currentNode;

                    text.Dispose();
                    ib.Dispose();
                }

                var v = store.AddNode(currentNode)
                    .SetValue(nameCol, scan.ToString())
                    .SetValue(finishCol, scan.IsFinish() ? tick : cross)
                    .SetValue(saveStateCol, scan.HasUnsaved() ? "*" : "")
                    .CurrentPosition;
                scan.position = v;
                scan.parentPosition = currentNode;
                if (currentScan != null) {
                    if (currentScan == scan) {
                        pos = v;
                    }
                } else {
                    if (pos == null) {
                        pos = v;
                    }
                }

                scan.ScanDataChanged += OnScanDataChanged;
            }

            if (scans.Count > 0) {
                ExpandToRow(pos);
                SelectRow(pos);
            }

            LoadPreviewsAsync(scans);
        }
Ejemplo n.º 10
0
        protected override void OnSelectionChanged(EventArgs e)
        {
            if (SelectedRow == null)
                return;

            object value = store.GetNavigatorAt(SelectedRow).GetValue(nameCol);
            if (value is BaseAlgorithm) {

                TextLayout text = new TextLayout();
                text.Text = value.ToString();

                Size textSize = text.GetSize();
                var ib = new ImageBuilder(textSize.Width, textSize.Height);
                ib.Context.DrawTextLayout(text, 0, 0);

                var d = CreateDragOperation();
                d.Data.AddValue(value.GetType().AssemblyQualifiedName);
                d.SetDragImage(ib.ToVectorImage(), -6, -4);
                d.AllowedActions = DragDropAction.Link;
                d.Start();

                d.Finished += (object sender, DragFinishedEventArgs e2) => this.UnselectAll();

                text.Dispose();
                ib.Dispose();
            } else {
                this.UnselectRow(SelectedRow);
            }
        }