Ejemplo n.º 1
0
        protected virtual void Compose()
        {
            StyleSheetCombo = new ComboBox {
                Width       = 100,
                ToolTipText = "Stylesheets",
            };

            var styleSheetComboHost = new ToolbarItemHost {
                Child = StyleSheetCombo
            };

            StyleSheetCombo.SelectionChanged += (s, e) => {
                var selectedItem = StyleSheetCombo.SelectedItem;
                if (selectedItem != null)
                {
                    StyleSheetChange(selectedItem.ToString());
                }
            };

            Registry.Pooled <StyleSheets> ().Keys.ForEach(s => StyleSheetCombo.Items.Add(s));

            var size = new Xwt.Size(60, 15);

            ShapeCombo = new ComboBox {
                Width       = 100,
                ToolTipText = "Shapes",
            };

            var shapeComboHost = new ToolbarItemHost {
                Child = ShapeCombo
            };

            var shapes = ShapeFactory.Shapes().ToArray();

            shapes.ForEach(shape => {
                var img =
                    XwtDrawingExtensions.AsImage(
                        XwtDrawingExtensions.Render(shape, size, UiState.None, CurrentStyleSheet),
                        size);
                ShapeCombo.Items.Add(img);
            });

            ShapeCombo.SelectionChanged += (s, e) => {
                if (ShapeCombo.SelectedIndex == -1)
                {
                    return;
                }
                var shape = shapes[ShapeCombo.SelectedIndex];
                ShapeChange(shape);
            };

            this.AddItems(styleSheetComboHost, shapeComboHost, new ToolbarSeparator());
        }
Ejemplo n.º 2
0
        protected void ComposeWindow(Xwt.Window xwtWindow)
        {
            var windowBackend = xwtWindow.GetBackend() as Xwt.GtkBackend.WindowBackend;

            // set minimum size:
            var minSize = Registry.Pooled <Limaki.Drawing.IDrawingUtils> ().GetTextDimension("File Edit Style", null);

            windowBackend.Window.SizeRequested += (s, e) => {
                var req  = e.Requisition;
                var size = new Xwt.Size(e.Requisition.Width, e.Requisition.Height);
                Trace.WriteLine($"{nameof (windowBackend)}.{nameof (windowBackend.Window.SizeRequested)}:\t{size}");
                req.Width     = (int)minSize.Width;
                e.Requisition = req;
            };
        }
Ejemplo n.º 3
0
        public override IType[] Run(Dictionary<RequestType, object> requestedData, BaseOption[] options, IType[] inputArgs)
        {
            int blockWidth = (int) options[0].Value;
            int blockHeight = (int) options[1].Value;
            Xwt.Size blockSize = new Xwt.Size(blockWidth, blockHeight);

            TScan scan = inputArgs[0] as TScan;

            int width = (int) scan.Size.Width;
            int height = (int) scan.Size.Height;

            float[] inputData = scan.Data;
            for (int y = 0; y < height-blockHeight; y += blockHeight) {
                for (int x = 0; x < width-blockWidth; x+= blockWidth) {
                    float[] data = new float[blockWidth*blockHeight];

                    bool empty = true;
                    for (int i = 0; i < blockWidth; i++) {
                        for (int j = 0; j < blockHeight; j++) {
                            float value = inputData[x + i + ((y + j) * width)];
                            data[i + (j * blockWidth)] = value;

                            if (value > 0.0) {
                                empty = false;
                            }
                        }
                    }

                    if (!empty) {
                        TScan block = new TScan(data, blockSize, scan.IsMultipleAccessModeOn);
                        Yield(new IType[] { block }, null);
                    }
                }
            }

            return null;
        }
Ejemplo n.º 4
0
        public static PopupWindow Show(Widget reference, Xwt.Rectangle positionRect, Widget child)
        {
            var popup    = new PopupWindow(child);
            var topLevel = (Window)reference.Toplevel;

            popup.DestroyWithParent = true;

            popup.BorderWidth = topLevel.BorderWidth;

            // bounds of reference widget in screen coordinates
            var referenceBounds = Xwt.Rectangle.Zero;

            // position of popup
            Func <Xwt.Point> calcPosition = () => {
                referenceBounds = new Xwt.Rectangle(
                    GtkBackendHelper.ConvertToScreenCoordinates(reference, Xwt.Point.Zero),
                    new Xwt.Size(reference.Allocation.Width, reference.Allocation.Height));

                if (positionRect == Xwt.Rectangle.Zero)
                {
                    positionRect = new Xwt.Rectangle(Xwt.Point.Zero, referenceBounds.Size);
                }
                positionRect = positionRect.Offset(referenceBounds.Location);
                return(new Xwt.Point(positionRect.X, positionRect.Bottom));
            };

            var popupPosition = calcPosition();

            if (child == null)
            {
                popup.SetSizeRequest((int)referenceBounds.Width, (int)referenceBounds.Height);
            }
            else
            {
                popup.DefaultWidth = 10;
                child.ShowAll();
            }
            var topLevelPos = GtkBackendHelper.ConvertToScreenCoordinates(topLevel, Xwt.Point.Zero);

            popup.TransientPosition = popupPosition.Offset(-topLevelPos.X, -topLevelPos.Y);
            Gtk.SizeAllocatedHandler sizeAllocated = (o, args) => {
                popup.Move((int)popupPosition.X, (int)popupPosition.Y);
                popup.GrabFocus();
            };
            popup.SizeAllocated += sizeAllocated;

            topLevel.AddEvents((int)Gdk.EventMask.StructureMask);

            topLevel.ConfigureEvent -= popup.TopLevelConfigureEvent;
            topLevel.ConfigureEvent += popup.TopLevelConfigureEvent;

            // if the mouse is moved in toplevel-window:
            Gtk.MotionNotifyEventHandler topLevelMotion = (s, args) => {
                if (topLevel == null)
                {
                    return;
                }

                topLevelPos = GtkBackendHelper.ConvertToScreenCoordinates(topLevel, Xwt.Point.Zero);
                var referencePos = GtkBackendHelper.ConvertToScreenCoordinates(reference, Xwt.Point.Zero);

                // take args in sceen coordinates:
                var motionPos = new Xwt.Point(args.Event.XRoot, args.Event.YRoot);//topLevelPos.Offset (args.Event.X, args.Event.Y);

                var tolerance = popup.Tolerance;
                var popupSize = new Xwt.Size(popup.Allocation.Width, popup.Allocation.Height);

                // var refBounds = new Xwt.Rectangle (refPos, screenBounds.Size);
                var motionBounds = new Xwt.Rectangle(
                    referencePos.X - tolerance.Left,
                    referencePos.Y - tolerance.Top,
                    popupSize.Width + tolerance.HorizontalSpacing,
                    popupSize.Height + tolerance.VerticalSpacing);

                // TODO: hide if other event than move-event occurs outside of popup window
                // TODO: something is wrong with referencepos; maybe ConvertToScreenCoordinates has an error

                if (!motionBounds.Contains(motionPos))
                {
                    popup.HideAll();
                }
            };
            topLevel.MotionNotifyEvent += topLevelMotion;

            //ClientEvent: a message has been received from another application.

            popup.ShowAll();

            popup.Hidden += (o, args) => {
                topLevel.ConfigureEvent    -= popup.TopLevelConfigureEvent;
                topLevel.MotionNotifyEvent -= topLevelMotion;
                popup.ReleaseInnerWidget();
                popup.Destroy();
            };
            return(popup);
        }
Ejemplo n.º 5
0
 public static CoreGraphics.CGSize ToCGSize(this Xwt.Size s)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 6
0
 public virtual void SetChildSize(Xwt.Size s)
 {
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Loading file from filePath and store all information.
        /// </summary>
        /// <param name="filePath">File path.</param>
        /// <param name="newImport">True when data should be read again from original file</param>
        /// <remarks>Gets recalled on filePath change!</remarks>
        public override void Initialize(string filePath, bool newImport = true)
        {
            base.Initialize(filePath, newImport);

            IniFile ini = new IniFile(filePath);

            // set file pathes
            string path = Path.GetDirectoryName(filePath);
            filenames["Intensity"] = String.Format("{0}/{1}", path, ini.ReadString("buffers", "intensity"));
            filenames["Topography"] = String.Format("{0}/{1}", path, ini.ReadString("buffers", "topography"));
            filenames["Color"] = String.Format("{0}/{1}", path, ini.ReadString("buffers", "color"));

            if (newImport) {
                size = new Xwt.Size(ini.ReadInteger("general", "Width", 0), ini.ReadInteger("general", "Height", 0));
                requestedBitmapSize = new Xwt.Size(size.Width, size.Height);

                List<Tuple<string, string>> generalData = ini.ReadAllStrings("general");
                foreach (Tuple<string, string > datum in generalData) {
                    try {
                        metadata[datum.Item1] =
                            float.Parse(datum.Item2, System.Globalization.CultureInfo.CreateSpecificCulture("en-us"));
                    } catch (Exception e) {
                        Console.WriteLine(e.Message);
                        Console.WriteLine(e.StackTrace);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        protected virtual void Compose()
        {
            var size = new Xwt.Size(36, 36);

            GraphStreamViewCommand = new CommandView {
                Action      = s => ViewMode = SplitView.ViewMode = SplitViewMode.GraphContent,
                Image       = Iconery.GraphContentView,
                Size        = size,
                ToolTipText = "show contents"
            };
            GraphGraphViewCommand = new CommandView {
                Action      = s => ViewMode = SplitView.ViewMode = SplitViewMode.GraphGraph,
                Image       = Iconery.GraphGraphView,
                Size        = size,
                ToolTipText = "show tiled graph"
            };

            ToggleViewCommand = new CommandView {
                Action      = s => SplitView.ToggleView(),
                Image       = Iconery.ToggleView,
                Size        = size,
                ToolTipText = "toogle view"
            };

            OpenNewWindowCommand = new CommandView {
                Action      = s => SplitView.ShowInNewWindow(),
                Image       = Iconery.NewViewVisualNote,
                Size        = size,
                ToolTipText = "open new window"
            };

            Action <bool> goBackOrForward = backOrForward => {
                if (SplitView.CanGoBackOrForward(backOrForward))
                {
                    SplitView.GoBackOrForward(backOrForward);
                    CheckBackForward(SplitView);
                }
            };

            GoBackCommand = new CommandView {
                Action      = s => goBackOrForward(false),
                Image       = Iconery.GoPrevious,
                Size        = size,
                ToolTipText = "navigate back"
            };

            GoForwardCommand = new CommandView {
                Action      = s => goBackOrForward(true),
                Image       = Iconery.GoNext,
                Size        = size,
                ToolTipText = "navigate forward"
            };

            GoHomeCommand = new CommandView {
                Action      = s => SplitView.GoHome(),
                Image       = Iconery.GoHome,
                Size        = size,
                ToolTipText = "go to favorites"
            };

            NewSheetCommand = new CommandView {
                Action      = s => SplitView.NewSheet(),
                Image       = Iconery.NewSheet,
                Size        = size,
                ToolTipText = "new sheet"
            };

            NewNoteCommand = new CommandView {
                Action      = s => SplitView.NewNote(),
                Image       = Iconery.NewNote,
                Size        = size,
                ToolTipText = "new note"
            };

            SaveSheetCommand = new CommandView {
                Action      = s => SplitView.SaveDocument(),
                Image       = Iconery.SaveContent,
                Size        = size,
                ToolTipText = "save content"
            };

            GraphStreamViewButton = new ToolbarButton(GraphStreamViewCommand)
            {
                IsCheckable = true
            };
            GraphGraphViewButton = new ToolbarButton(GraphGraphViewCommand)
            {
                IsCheckable = true
            };
            var toggleViewButton = new ToolbarButton(ToggleViewCommand);
            var newWindowButton  = new ToolbarButton(OpenNewWindowCommand);

            GoBackButton    = new ToolbarButton(GoBackCommand);
            GoForwardButton = new ToolbarButton(GoForwardCommand);
            var goHomeButton    = new ToolbarButton(GoHomeCommand);
            var newSheetButton  = new ToolbarButton(NewSheetCommand);
            var newNoteButton   = new ToolbarButton(NewNoteCommand);
            var saveSheetButton = new ToolbarButton(SaveSheetCommand);

            SheetCombo = new ComboBox {
                Width = 100
            };

            var sheetComboHost = new ToolbarItemHost()
            {
                Child = SheetCombo
            };

            this.AddItems(
                sheetComboHost,
                saveSheetButton,

                new ToolbarSeparator(),
                GraphStreamViewButton,
                GraphGraphViewButton,
                toggleViewButton,

                new ToolbarSeparator(),
                GoBackButton,
                GoForwardButton,
                goHomeButton,
                new ToolbarSeparator(),
                newSheetButton,
                newNoteButton,
                newWindowButton,
                new ToolbarSeparator()
                );
        }
Ejemplo n.º 9
0
 public static void VidgetBackendSize(this FrameworkElement backend, Xwt.Size value)
 {
     backend.Width  = value.Width;
     backend.Height = value.Height;
 }
Ejemplo n.º 10
0
        private void btnNew_Clicked(object sender, EventArgs e)
        {
            this.result = new FileDialogResult();
            FileTypeInfo fileTypeInfo = this.selectedItem.FileTypeInfo;
            double       value        = this.entryHeight.Value;
            double       value2       = this.entryWidth.Value;

            Xwt.Size size = new Xwt.Size(value2, value);
            if (RegexModel.IsHasSystemReserveName(this.entry_FileName.Text))
            {
                MessageBox.Show(LanguageInfo.MessageBox215_WindowsNameLimit, this, null, MessageBoxImage.Info);
                this.entry_FileName.SelectRegion(0, this.entry_FileName.Text.Length);
                this.entry_FileName.HasFocus = true;
                this.result.IsSuccessful     = false;
            }
            else
            {
                string text = this.entry_FileName.Text + fileTypeInfo.Extension;
                if (!Regex.IsMatch(text, "^[A-Za-z0-9,._-]+$") || Regex.IsMatch(text, "[\\*\\\\/:?<>|\"]"))
                {
                    MessageBox.Show(LanguageInfo.MessageBox216_FileNameLimit, this, null, MessageBoxImage.Info);
                    this.entry_FileName.SelectRegion(0, this.entry_FileName.Text.Length);
                    this.entry_FileName.HasFocus = true;
                    this.result.IsSuccessful     = false;
                }
                else if (!FileService.IsValidFileName(text))
                {
                    string info = LanguageInfo.NewFile_WrongName.Replace("<", "&lt;").Replace(">", "&gt;");
                    MessageBox.Show(info, this, null, MessageBoxImage.Info);
                    this.entry_FileName.SelectRegion(0, this.entry_FileName.Text.Length);
                    this.entry_FileName.HasFocus = true;
                    this.result.IsSuccessful     = false;
                }
                else
                {
                    string value3 = text.Substring(0, text.Length - fileTypeInfo.Extension.Length);
                    if (string.IsNullOrWhiteSpace(value3))
                    {
                        MessageBox.Show(LanguageInfo.MessageBox_Content110, this, null, MessageBoxImage.Info);
                        this.entry_FileName.HasFocus = true;
                        this.result.IsSuccessful     = false;
                    }
                    else
                    {
                        this.result.FileName = text;
                        this.result.Size     = size;
                        this.result.FileType = this.selectedItem.FileTypeInfo.FileType;
                        string path = System.IO.Path.Combine(this.parentDir, this.result.FileName);
                        if (File.Exists(path))
                        {
                            MessageBox.Show(LanguageInfo.NewFile_SameName, this, null, MessageBoxImage.Info);
                            this.entry_FileName.SelectRegion(0, this.entry_FileName.Text.Length);
                            this.entry_FileName.HasFocus = true;
                            this.result.IsSuccessful     = false;
                        }
                        else
                        {
                            this.Destroy();
                            this.Dispose();
                        }
                    }
                }
            }
        }